| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874 |
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Diagnostics;
- using System.Drawing;
- using System.Drawing.Printing;
- using System.IO;
- using System.Net.NetworkInformation;
- using System.Reflection;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Windows.Forms;
- using Infragistics.Excel;
- using Infragistics.Win;
- using Infragistics.Win.Layout;
- using Infragistics.Win.Misc;
- using Infragistics.Win.UltraWinDataSource;
- using Infragistics.Win.UltraWinEditors;
- using Infragistics.Win.UltraWinGrid;
- using Infragistics.Win.UltraWinGrid.ExcelExport;
- using Infragistics.Win.UltraWinTabControl;
- using Infragistics.Win.UltraWinToolbars;
- using System.Collections.Generic;
- namespace Core.LZMes.Client.QCM
- {
- /// <summary>
- /// 控件设置、属性相关公用
- /// </summary>
- public class ClsControlPack
- {
-
- /// <summary>
- /// 获取子窗体弹出的位置坐标
- /// </summary>
- /// <param name="ChildWindowSize"></param>
- /// <returns></returns>
- public static Point GetChildWindowLocation(Size ChildWindowSize)
- {
- Point point = Cursor.Position;
- Size size = Cursor.Current.Size;
- int width = point.X + ChildWindowSize.Width - Screen.PrimaryScreen.Bounds.Width;
- int height = point.Y + ChildWindowSize.Height - Screen.PrimaryScreen.Bounds.Height;
- width = (width > 0) ? (point.X - width - size.Width) : point.X; // X坐标
- height = (height > 0) ? (point.Y - height - size.Height) : point.Y; // Y坐标
- return new Point(width, height);
- }
- /// <summary>
- /// DataTable数据拷贝
- /// </summary>
- /// <param name="src">源</param>
- /// <param name="dest">目标</param>
- /// <param name="ClearExists">是否清除目标DataTable现有数据</param>
- public static void CopyDataToDatatable(ref DataTable src, ref DataTable dest, bool ClearExists)
- {
- try
- {
- if (src == null || dest == null)
- {
- return;
- }
- if (ClearExists)
- {
- dest.Rows.Clear();
- }
- DataRow CurRow, NewRow;
- for (int i = 0; i < src.Rows.Count; i++)
- {
- CurRow = src.Rows[i];
- NewRow = dest.NewRow();
- for (int j = 0; j < src.Columns.Count; j++)
- {
- try
- {
- if (dest.Columns.Contains(src.Columns[j].ColumnName))
- {
- NewRow[src.Columns[j].ColumnName] = CurRow[j];
- }
- }
- catch { }
- }
- dest.Rows.Add(NewRow);
- }
- dest.AcceptChanges();
- }
- catch { }
- }
- /// <summary>
- /// UltraGrid列宽自适应
- /// </summary>
- /// <param name="ultraGrid"></param>
- public static void RefreshAndAutoSize(UltraGrid ultraGrid)
- {
- try
- {
- ultraGrid.BeginUpdate();
- foreach (UltraGridBand band in ultraGrid.DisplayLayout.Bands)
- {
- foreach (UltraGridColumn column in band.Columns)
- {
- column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand, band.ColHeadersVisible ? true : false);
- }
- }
- }
- catch { }
- ultraGrid.EndUpdate();
- }
- /// <summary>
- /// 设置UltraComboEditor项目集合
- /// </summary>
- /// <param name="cbEdt"></param>
- /// <param name="vlist"></param>
- /// <param name="bNull">是否加入空项</param>
- /// <returns></returns>
- public static bool SetUltraComboEditor(ref UltraComboEditor cbEdt, ref ValueList vlist, bool bNull)
- {
- if (cbEdt == null || vlist == null)
- return false;
- cbEdt.Items.Clear();
- if (bNull)
- cbEdt.Items.Add(null, "");
- for (int i = 0; i < vlist.ValueListItems.Count; i++)
- {
- try
- {
- cbEdt.Items.Add(vlist.ValueListItems[i].DataValue, vlist.ValueListItems[i].DisplayText);
- }
- catch { }
- }
- return true;
- }
- public static void SetUltraComboDataSource(UltraCombo cmb, DataTable table, string ColumnValue, string ColumnDisplay)
- {
- if (table == null || !table.Columns.Contains(ColumnValue) || !table.Columns.Contains(ColumnDisplay)) return;
- try
- {
- if (cmb != null)
- {
- cmb.DataSource = table;
- cmb.DisplayLayout.Override.TipStyleScroll = TipStyle.Hide;
- cmb.DisplayLayout.Override.BorderStyleCell = UIElementBorderStyle.None;
- cmb.DisplayLayout.Override.BorderStyleRow = UIElementBorderStyle.None;
- cmb.DisplayLayout.Override.SelectTypeRow = SelectType.Single;
- cmb.DisplayLayout.Override.HeaderStyle = HeaderStyle.Standard;
- cmb.DisplayLayout.Override.HeaderAppearance.TextHAlign = HAlign.Center;
- cmb.DisplayLayout.Override.RowAppearance.TextVAlign = VAlign.Middle;
- cmb.DisplayLayout.Override.ActiveRowAppearance.BackColor = Color.FromArgb(51, 153, 255);
- cmb.DisplayLayout.Override.ActiveRowAppearance.ForeColor = Color.FromArgb(255, 255, 255);
- cmb.DisplayLayout.Override.SelectedRowAppearance.BackColor = Color.FromArgb(51, 153, 255);
- cmb.DisplayLayout.Override.SelectedRowAppearance.ForeColor = Color.FromArgb(255, 255, 255);
- //cmb.DisplayLayout.Override.ActiveRowAppearance.FontData.Bold = DefaultableBoolean.True;
- foreach (UltraGridBand band in cmb.DisplayLayout.Bands)
- {
- band.ColHeadersVisible = false;
- foreach (UltraGridColumn column in band.Columns)
- {
- if (!column.Key.Equals(ColumnDisplay)) column.Hidden = true;
- column.Width = cmb.Width;
- //column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
- }
- }
- cmb.ValueMember = ColumnValue;
- cmb.DisplayMember = ColumnDisplay;
- cmb.DropDownWidth = -1;
- }
- }
- catch { }
- }
- /// <summary>
- /// 设置ultraGrid的激活单元格
- /// </summary>
- /// <param name="ultraGrid"></param>
- /// <param name="RowIndexNo"></param>
- /// <param name="ColumnName"></param>
- /// <param name="EnterEditMode"></param>
- public static void SetUltraGridActiveCell(ref UltraGrid ultraGrid, int RowIndexNo, string ColumnName, bool EnterEditMode)
- {
- try
- {
- if (ultraGrid != null && RowIndexNo >= 0 && ultraGrid.Rows.Count >= RowIndexNo + 1)
- {
- ultraGrid.ActiveCell = ultraGrid.Rows[RowIndexNo].Cells[ColumnName];
- if (EnterEditMode)
- ultraGrid.PerformAction(UltraGridAction.EnterEditMode);
- }
- }
- catch { }
- }
- /// <summary>
- /// 设置UltraGrid指定列的ValueList
- /// </summary>
- /// <param name="myGrid"></param>
- /// <param name="strColumn"></param>
- /// <param name="vlist"></param>
- public static void SetGridValuelist(ref UltraGrid myGrid, string strColumn, ref ValueList vlist)
- {
- SetGridValuelist(ref myGrid, 0, strColumn, ref vlist);
- }
- /// <summary>
- /// 设置UltraGrid指定列的ValueList,指定Band
- /// </summary>
- /// <param name="myGrid"></param>
- /// <param name="BandIndex"></param>
- /// <param name="strColumn"></param>
- /// <param name="vlist"></param>
- public static void SetGridValuelist(ref UltraGrid myGrid, int BandIndex, string strColumn, ref ValueList vlist)
- {
- bool Contains = GridContainsColumn(myGrid, BandIndex, strColumn);
- try
- {
- if (Contains)
- {
- myGrid.DisplayLayout.Bands[BandIndex].Columns[strColumn].ValueList = vlist;
- //myGrid.DisplayLayout.Bands[BandIndex].Columns[strColumn].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDown;
- }
- }
- catch { }
- }
- /// <summary>
- /// 根据指定DataTable生成ValueList
- /// </summary>
- /// <param name="table"></param>
- /// <param name="strKey">value</param>
- /// <param name="strText">Text</param>
- /// <returns></returns>
- public static ValueList GeneralValuelist(ref DataTable table, string strKey, string strText)
- {
- if (table == null || !table.Columns.Contains(strKey) || !table.Columns.Contains(strText))
- return null;
- ArrayList alist = new ArrayList();
- ValueList vlist = new ValueList();
- for (int i = 0; i < table.Rows.Count; i++)
- {
- try
- {
- if (!alist.Contains(table.Rows[i][strKey]))
- {
- alist.Add(table.Rows[i][strKey]);
- vlist.ValueListItems.Add(table.Rows[i][strKey], Convert.ToString(table.Rows[i][strText]));
- }
- }
- catch { }
- }
- return vlist;
- }
-
-
- /// <summary>
- /// ultraGrid设置Cell只读属性
- /// </summary>
- /// <param name="ultraGrid"></param>
- /// <param name="bReadOnly"></param>
- public static void SetUltraGridCellReadOnly(ref UltraGrid ultraGrid, bool bReadOnly)
- {
- try
- {
- for (int i = 0; i < ultraGrid.DisplayLayout.Bands[0].Columns.Count; i++)
- {
- ultraGrid.DisplayLayout.Bands[0].Columns[i].CellActivation = (bReadOnly ? Activation.ActivateOnly : Activation.AllowEdit);
- ultraGrid.DisplayLayout.Bands[0].Columns[i].CellAppearance.BackColor = (bReadOnly ? Color.LightBlue : Color.White);
- }
- }
- catch { }
- }
- public static bool GridContainsColumn(UltraGrid grid, string strColumn)
- {
- return GridContainsColumn(grid, 0, strColumn);
- }
- public static bool GridContainsColumn(UltraGridBand band, string strColumn)
- {
- for (int i = 0; i < band.Columns.Count; i++)
- {
- if (band.Columns[i].Key.Equals(strColumn))
- return true;
- }
- return false;
- }
- public static bool GridContainsColumn(UltraGrid grid, int BandIndex, string strColumn)
- {
- if (BandIndex <= grid.DisplayLayout.Bands.Count - 1)
- {
- for (int i = 0; i < grid.DisplayLayout.Bands[BandIndex].Columns.Count; i++)
- {
- if (grid.DisplayLayout.Bands[BandIndex].Columns[i].Key.Equals(strColumn))
- return true;
- }
- }
- return false;
- }
- public static void SetGridGroupBy(ref UltraGrid myGrid1, bool bAllowGroupBy)
- {
- try
- {
- if (!bAllowGroupBy)
- {
- for (int i = 0; i < myGrid1.DisplayLayout.Bands[0].Columns.Count; i++)
- {
- try
- {
- if (myGrid1.DisplayLayout.Bands[0].Columns[i].IsGroupByColumn)
- myGrid1.DisplayLayout.Bands[0].Columns[i].ResetIsGroupByColumn();
- }
- catch { }
- }
- }
- myGrid1.DisplayLayout.GroupByBox.Hidden = !bAllowGroupBy;
- }
- catch { }
- }
- public static void SetUltraGridRowFilter(ref UltraGrid myGrid1, bool bAllowFilter)
- {
- try
- {
- if (bAllowFilter)
- {
- if (myGrid1.DisplayLayout.Override.FilterUIType != FilterUIType.Default)
- myGrid1.DisplayLayout.Override.FilterUIType = FilterUIType.Default;
- for (int i = 0; i < myGrid1.DisplayLayout.Bands.Count; i++)
- {
- if (myGrid1.DisplayLayout.Bands[i].CardView) continue;
- for (int j = 0; j < myGrid1.DisplayLayout.Bands[i].Columns.Count; j++)
- {
- try
- {
- if (!myGrid1.DisplayLayout.Bands[i].Columns[j].Hidden &&
- myGrid1.DisplayLayout.Bands[i].Columns[j].RowLayoutColumnInfo.LabelPosition != LabelPosition.LabelOnly)
- myGrid1.DisplayLayout.Bands[i].Columns[j].AllowRowFiltering = Infragistics.Win.DefaultableBoolean.True;
- }
- catch { }
- }
- }
- }
- else
- {
- if (myGrid1.DisplayLayout.Override.FilterUIType != FilterUIType.Default)
- myGrid1.DisplayLayout.Override.FilterUIType = FilterUIType.Default;
- for (int i = 0; i < myGrid1.DisplayLayout.Bands.Count; i++)
- {
- try
- {
- myGrid1.DisplayLayout.Bands[i].ColumnFilters.ClearAllFilters();
- }
- catch { }
- for (int j = 0; j < myGrid1.DisplayLayout.Bands[i].Columns.Count; j++)
- {
- try
- {
- myGrid1.DisplayLayout.Bands[i].Columns[j].AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
- }
- catch { }
- }
- }
- }
- }
- catch { }
- }
- public static void SetGridColumnsReadOnly(ref UltraGrid ultraGrid, ArrayList alistAllowEdit, ArrayList alistActivateOnly, ArrayList alistNoEdit, ArrayList alistDisabled)
- {
- try
- {
- for (int i = 0; i < ultraGrid.Rows.Count; i++)
- {
- if (alistAllowEdit != null && alistAllowEdit.Count > 0)
- {
- for (int j = 0; j < alistAllowEdit.Count; j++)
- {
- try
- {
- if (GridContainsColumn(ultraGrid, alistAllowEdit[j].ToString()))
- {
- ultraGrid.Rows[i].Cells[alistAllowEdit[j].ToString()].Activation = Activation.AllowEdit;
- }
- }
- catch (Exception ex)
- {
- Debug.WriteLine(ex.Message);
- }
- }
- }
- if (alistActivateOnly != null && alistActivateOnly.Count > 0)
- {
- for (int j = 0; j < alistActivateOnly.Count; j++)
- {
- try
- {
- if (GridContainsColumn(ultraGrid, alistActivateOnly[j].ToString()))
- {
- ultraGrid.Rows[i].Cells[alistActivateOnly[j].ToString()].Activation = Activation.ActivateOnly;
- }
- }
- catch (Exception ex)
- {
- Debug.WriteLine(ex.Message);
- }
- }
- }
- if (alistNoEdit != null && alistNoEdit.Count > 0)
- {
- for (int j = 0; j < alistNoEdit.Count; j++)
- {
- try
- {
- if (GridContainsColumn(ultraGrid, alistNoEdit[j].ToString()))
- {
- ultraGrid.Rows[i].Cells[alistNoEdit[j].ToString()].Activation = Activation.NoEdit;
- }
- }
- catch (Exception ex)
- {
- Debug.WriteLine(ex.Message);
- }
- }
- }
- if (alistDisabled != null && alistDisabled.Count > 0)
- {
- for (int j = 0; j < alistDisabled.Count; j++)
- {
- try
- {
- if (GridContainsColumn(ultraGrid, alistDisabled[j].ToString()))
- {
- ultraGrid.Rows[i].Cells[alistDisabled[j].ToString()].Activation = Activation.Disabled;
- }
- }
- catch (Exception ex)
- {
- Debug.WriteLine(ex.Message);
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- Debug.WriteLine(ex.Message);
- }
- }
- public static bool HasCheckedRows(ref UltraGrid ultraGrid, string strColumnCondition, object value, string strOutColumn, out ArrayList alistValue, out string strMsg)
- {
- strMsg = "";
- alistValue = new ArrayList();
- try
- {
- if (ultraGrid == null || ultraGrid.Rows.Count == 0)
- {
- return false;
- }
- if (!string.IsNullOrEmpty(strColumnCondition))
- {
- if (!GridContainsColumn(ultraGrid, 0, strColumnCondition))
- {
- strMsg = "不存在条件字段【" + strColumnCondition + "】!";
- return false;
- }
- }
- if (string.IsNullOrEmpty(strOutColumn))
- {
- strMsg = "未指定输出字段【" + strOutColumn + "】!";
- return false;
- }
- if (!GridContainsColumn(ultraGrid, 0, strOutColumn))
- {
- strMsg = "不存在输出字段【" + strOutColumn + "】!";
- return false;
- }
- for (int i = 0; i < ultraGrid.Rows.Count; i++)
- {
- if (!string.IsNullOrEmpty(strColumnCondition))
- {
- if (ultraGrid.Rows[i].Cells[strColumnCondition].Value.Equals(value))
- {
- if (ultraGrid.Rows[i].Cells["FCFLAG"].Value.ToString() != "校磅")
- alistValue.Add(ultraGrid.Rows[i].Cells[strOutColumn].Value);
- }
- }
- else
- {
- if (ultraGrid.Rows[i].Cells["FCFLAG"].Value.ToString() != "校磅")
- alistValue.Add(ultraGrid.Rows[i].Cells[strOutColumn].Value);
- }
- }
- return true;
- }
- catch (Exception ex)
- {
- strMsg = ex.Message;
- alistValue = null;
- }
- return false;
- }
- private static UltraGridExcelExporter ultraGridExcelExporter1 = new UltraGridExcelExporter();
- /// <summary>
- /// 判断系统是否安装EXCEL组件
- /// </summary>
- /// <returns></returns>
- public static bool ExcelInstalled()
- {
- bool bInstalled = (Type.GetTypeFromProgID("Excel.Application") != null);
- if (!bInstalled)
- {
- MessageBox.Show("系统没有安装EXCEL组件,无法导出数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- return bInstalled;
- }
- public static void ExportDataWithSaveDialog2(ref UltraGrid myGrid1, string strFileName)
- {
- try
- {
- if (myGrid1.Rows.Count == 0) return;
- if (strFileName.Length == 0) strFileName = "未命名";
- SaveFileDialog dlg = new SaveFileDialog();
- dlg.Title = "保存";
- dlg.OverwritePrompt = true;
- dlg.Filter = "Excel文件(*.xls)|*.xls";
- dlg.AddExtension = true;
- dlg.FileName = strFileName;
- if (dlg.ShowDialog() == DialogResult.OK)
- {
- strFileName = dlg.FileName;
- ultraGridExcelExporter1.Export(myGrid1, strFileName);
- if (MessageBox.Show("数据导出成功!\n需要打开所导出文件吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- ProcessStartInfo p = new ProcessStartInfo(strFileName);
- p.WorkingDirectory = Path.GetDirectoryName(strFileName);
- Process.Start(p);
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- public static bool IPCheck(string IP)
- {
- string Segment = @"(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)";
- return Regex.IsMatch(IP, ("^" + Segment + @"\." + Segment + @"\." + Segment + @"\." + Segment + "$"));
- }
- public static bool Pinging(string IP)
- {
- try
- {
- Ping ping = new Ping();
- PingOptions options = new PingOptions();
- options.DontFragment = true;
- byte[] buffer = Encoding.ASCII.GetBytes("TEST PING");
- PingReply reply = ping.Send(IP, 3000, buffer, options);
- if (reply.Status == IPStatus.Success)
- {
- return true;
- }
- }
- catch { }
- return false;
- }
- public static bool PrinterExists(string strPrinterName)
- {
- if (string.IsNullOrEmpty(strPrinterName))
- return false;
- foreach (string printerName in PrinterSettings.InstalledPrinters)
- {
- if (strPrinterName.Equals(printerName))
- return true;
- }
- return false;
- }
- public static bool FontFamilyNameExists(string strFontFamilyName)
- {
- if (string.IsNullOrEmpty(strFontFamilyName))
- return false;
- foreach (FontFamily fontfamily in FontFamily.Families)
- {
- if (strFontFamilyName.Equals(fontfamily.Name))
- return true;
- }
- return false;
- }
- public static void ResetHashtable(ref Hashtable htbl)
- {
- if (htbl == null)
- htbl = new Hashtable();
- else
- htbl.Clear();
- }
- public static void ResetArraylist(ref ArrayList alist)
- {
- if (alist == null)
- alist = new ArrayList();
- else
- alist.Clear();
- }
- public static bool CheckComboBoxSelection(UltraComboEditor cbEdit, string Caption, bool MustSelect, bool ShowError, out string Message)
- {
- Message = "";
- try
- {
- if (cbEdit != null)
- {
- if (MustSelect)
- {
- if (cbEdit.SelectedIndex < 0)
- {
- Message = cbEdit.Text.Trim().Length > 0 ? Caption + "不正确,请从列表中选取!" : "请选择" + Caption + "!";
- if (ShowError)
- MessageBox.Show(Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return false;
- }
- }
- else
- {
- if (cbEdit.SelectedIndex < 0 && cbEdit.Text.Trim().Length > 0)
- {
- Message = Caption + "不正确,请从列表中选取!";
- if (ShowError)
- MessageBox.Show(Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return false;
- }
- }
- }
- return true;
- }
- catch (Exception ex)
- {
- Message = Caption + "验证出错!\n" + ex.Message;
- if (ShowError)
- MessageBox.Show(Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return false;
- }
- }
-
- public static void SetUltraGridColumnColor(ValueList colorList, string columnName, UltraGrid ultraGrid1)
- {
- try
- {
- Infragistics.Win.Appearance apprc;
- OperatorCondition oc;
- ConditionValueAppearance cva = new ConditionValueAppearance();
- for (int i = 0; i < colorList.ValueListItems.Count; i++)
- {
- apprc = new Infragistics.Win.Appearance();
- if (i == 0)
- apprc.BackColor = Color.Cornsilk;
- else if (i == 1)
- apprc.BackColor = Color.Gainsboro;
- else if (i == 2)
- apprc.BackColor = Color.LightSkyBlue;
- else if (i == 3)
- apprc.BackColor = Color.PaleGreen;
- else if (i == 4)
- apprc.BackColor = Color.Lime;
- oc = new OperatorCondition(ConditionOperator.Equals, colorList.ValueListItems[0].DisplayText, false, typeof(string));
- cva.Add((ICondition)oc, apprc);
- }
- ultraGrid1.DisplayLayout.Bands[0].Columns[columnName].ValueBasedAppearance = cva;
- }
- catch { }
- }
-
- public static void SetStaticsInfoCount(ref UltraGrid myGrid1, ArrayList alistColumns, bool clearExists)
- {
- try
- {
- UltraGridBand band = myGrid1.DisplayLayout.Bands[0];
- if (clearExists)
- band.Summaries.Clear();
- band.Override.SummaryFooterCaptionVisible = Infragistics.Win.DefaultableBoolean.False;
- for (int i = 0; i < alistColumns.Count; i++)
- {
- try
- {
- SummarySettings summary = band.Summaries.Add(SummaryType.Count, band.Columns[alistColumns[i].ToString()]);
- summary.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
- summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
- summary.DisplayFormat = "{0}";
- summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Right;
- summary.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle;
- summary.Appearance.FontData.Bold = DefaultableBoolean.True;
- }
- catch { }
- }
- }
- catch { }
- }
- public static void SetStaticsInfoSum(ref UltraGrid myGrid1, ArrayList alistColumns, bool clearExists)
- {
- try
- {
- UltraGridBand band = myGrid1.DisplayLayout.Bands[0];
- if (clearExists)
- band.Summaries.Clear();
- band.Override.SummaryFooterCaptionVisible = Infragistics.Win.DefaultableBoolean.False;
- for (int i = 0; i < alistColumns.Count; i++)
- {
- try
- {
- SummarySettings summary = band.Summaries.Add(SummaryType.Sum, band.Columns[alistColumns[i].ToString()]);
- summary.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
- summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
- summary.DisplayFormat = "{0}";
- summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Right;
- summary.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle;
- summary.Appearance.FontData.Bold = DefaultableBoolean.True;
- }
- catch { }
- }
- }
- catch { }
- }
-
-
-
- public static void ClearUltraGridColumnsSort(UltraGrid ultraGrid)
- {
- if (ultraGrid != null)
- {
- foreach (UltraGridBand band in ultraGrid.DisplayLayout.Bands)
- {
- foreach (UltraGridColumn col in band.Columns)
- {
- if (col.SortIndicator == SortIndicator.Disabled)
- continue;
- col.SortIndicator = SortIndicator.None;
- }
- }
- }
- }
- public static DataTable ConvertToDataTable(IList list)
- {
- DataTable table = new DataTable();
- if ((list != null) && (list.Count > 0))
- {
- Hashtable hashtable2;
- Hashtable hashtable = (Hashtable)list[0];
- foreach (DictionaryEntry entry in hashtable)
- {
- string columnName = entry.Key.ToString();
- if (entry.Value == null)
- {
- table.Columns.Add(columnName, typeof(string));
- }
- else if ((entry.Value != null) && typeof(Hashtable).Equals(entry.Value.GetType()))
- {
- hashtable2 = (Hashtable)entry.Value;
- table.Columns.Add(columnName, hashtable2["value"].GetType());
- }
- else
- {
- table.Columns.Add(columnName, entry.Value.GetType());
- }
- }
- for (int i = 0; i < list.Count; i++)
- {
- hashtable = (Hashtable)list[i];
- ArrayList list2 = new ArrayList();
- foreach (DictionaryEntry entry in hashtable)
- {
- if ((entry.Value != null) && typeof(Hashtable).Equals(entry.Value.GetType()))
- {
- hashtable2 = (Hashtable)entry.Value;
- list2.Add(hashtable2["value"]);
- }
- else
- {
- list2.Add(entry.Value);
- }
- }
- table.LoadDataRow(list2.ToArray(), true);
- }
- }
- return table;
- }
- /// <summary>
- /// 某个空间是否某个特定的类型
- /// </summary>
- /// <param name="ctrl"></param>
- /// <param name="SomeType"></param>
- /// <returns></returns>
- public static bool SpecificType(Control ctrl, Type SomeType)
- {
- if (ctrl == null || SomeType == null) return false;
- Type type = ctrl.GetType();
- while (type != null)
- {
- if (type.Equals(SomeType))
- return true;
- type = type.BaseType;
- }
- return false;
- }
- }
- }
|