| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using CoreFS.CA06;
- using System.Data;
- using Infragistics.Win.UltraWinGrid;
- using Core.Mes.Client.Comm;
- using System.Windows.Forms;
- using Infragistics.Win.UltraWinEditors;
- using System.Collections;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Infragistics.Win;
- using System.Drawing;
- namespace Pur.PublicTools
- {
- /// <summary>
- /// 自定义公共方法类
- /// </summary>
- class PublicPur
- {
- /// <summary>
- /// 筛选符合条件的DataTable
- /// </summary>
- /// <param name="dt"></param>源dt
- /// <returns></returns>
- public static DataTable GetSelectDt(DataTable dtSource, string sql)
- {
- if (dtSource != null)
- {
- DataTable dtReturn = dtSource.Clone();
- DataRow[] arrDrSelect = dtSource.Select(sql);
- if (arrDrSelect != null && arrDrSelect.Length > 0)
- {
- foreach (DataRow row in arrDrSelect)
- {
- dtReturn.Rows.Add(row.ItemArray);
- }
- }
- return dtReturn;
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// 筛选符合条件的DataTable加入排序
- /// </summary>
- /// <param name="dt"></param>源dt
- /// <returns></returns>
- public static DataTable GetSelectDt(DataTable dtSource, string sql, string sort)
- {
- if (dtSource != null)
- {
- DataTable dtReturn = dtSource.Clone();
- DataRow[] arrDrSelect;
- if (sort != "")
- {
- arrDrSelect = dtSource.Select(sql, sort);
- }
- else
- {
- arrDrSelect = dtSource.Select(sql);
- }
- if (arrDrSelect != null && arrDrSelect.Length > 0)
- {
- foreach (DataRow row in arrDrSelect)
- {
- dtReturn.Rows.Add(row.ItemArray);
- }
- }
- return dtReturn;
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// 比较字符串是否含某元素
- /// </summary>
- /// <param name="chemName"></param>元素名称
- /// <returns></returns>
- public static bool IsHaveChemItems(string chemName, string[] arrChems)
- {
- if (chemName == "" || arrChems.Length == 0)
- {
- return false;
- }
- else
- {
- foreach (string row in arrChems)
- {
- if (chemName == row)
- {
- return true;
- }
- }
- }
- return false;
- }
- /// <summary>
- /// 激活当前操作的列
- ///
- /// </summary>
- /// <param name="ultraGrid"></param>
- /// <param name="strPK"></param>主键
- public static void ActiveOperateRow(UltraGrid ultraGrid, string strPK, string strPKText)
- {
- for (int i = 0; i < ultraGrid.Rows.Count; i++)
- {
- if (ultraGrid.Rows[i].Cells[strPK].Text == strPKText)
- {
- ultraGrid.Rows[i].Activated = true;
- }
- }
- }
- /// <summary>
- /// 激活当前操作的列
- ///
- /// </summary>
- /// <param name="ultraGrid"></param>
- /// <param name="strPK"></param>多主键
- public static void ActiveOperateRow(UltraGrid ultraGrid, object[] strPK, object[] strPKText)
- {
- bool isEquals;
- for (int i = 0; i < ultraGrid.Rows.Count; i++)
- {
- isEquals = true;
- for (int j = 0; j < strPK.Length; j++)
- {
- if (ultraGrid.Rows[i].Cells[strPK[j].ToString()].Text != strPKText[j].ToString())
- {
- isEquals = false;
- break;
- }
- }
- if (isEquals == true)
- {
- ultraGrid.Rows[i].Activated = true;
- return;
- }
- }
- }
- //点击Grid编辑区显示基本信息
- public static void ShowBaseInfo(UltraGridRow ur, Panel panel)
- {
- if (ur != null)
- {
- foreach (UltraGridCell uc in ur.Cells)
- {
- if (panel.Controls.ContainsKey("txt" + uc.Column.Key) == true)//判定是否存在text
- {
- ((UltraTextEditor)panel.Controls["txt" + uc.Column.Key]).Text = uc.Text.Trim();
- }
- else if (panel.Controls.ContainsKey("ultra" + uc.Column.Key) == true)//判定是否存在text
- {
- ((UltraComboEditor)panel.Controls["ultra" + uc.Column.Key]).Text = uc.Text.Trim();
- }
- }
- }
- }
- //点击Grid编辑区显示基本信息
- public static void ShowDataTaleInfo(DataTable dt, Panel panel)
- {
- foreach (DataColumn dc in dt.Columns)
- {
- if (panel.Controls.ContainsKey("txt" + dc.ColumnName) == true)//判定是否存在text
- {
- }
- if (panel.Controls.ContainsKey("txt" + dc.ColumnName) == true)//判定是否存在text
- {
- ((UltraTextEditor)panel.Controls["txt" + dc.ColumnName]).Text = dt.Rows[0][dc.ColumnName].ToString();
- }
- else if (panel.Controls.ContainsKey("ultra" + dc.ColumnName) == true)//判定是否存在text
- {
- ((UltraComboEditor)panel.Controls["ultra" + dc.ColumnName]).Text = dt.Rows[0][dc.ColumnName].ToString();
- }
- }
- }
- //点击Grid编辑区显示基本信息
- public static void ClearBaseInfo(Panel panel, string[] cols)
- {
- if (cols != null)
- {
- foreach (string col in cols)
- {
- if (panel.Controls.ContainsKey("txt" + col) == true)//判定是否存在text && panel.Controls.ContainsKey("txt" + col).GetType(). == UltraTextEditor
- {
- ((UltraTextEditor)panel.Controls["txt" + col]).Text = "";
- }
- else if (panel.Controls.ContainsKey("ultra" + col) == true)//判定是否存在text && panel.Controls.ContainsKey("txt" + col).GetType(). == UltraTextEditor
- {
- ((UltraTextEditor)panel.Controls["ultra" + col]).Text = "";
- }
- }
- }
- }
- /// <summary>
- /// 隐藏空列
- /// </summary>
- /// <param name="strHidden"></param>本来就隐藏的列名集合
- /// <param name="ug"></param>需要操作的UltraGrid
- /// <param name="dt"></param>需要操作的dt
- private void HideNullColumn(string strHidden, UltraGrid ultraGrid, DataTable dataTable)
- {
- if (strHidden != "")
- {
- foreach (DataColumn dc in dataTable.Columns)
- {
- if (strHidden.IndexOf(dc.ColumnName) >= 0)
- {
- continue;
- }
- foreach (DataRow dr in dataTable.Rows)
- {
- if (dr[dc].ToString() != "")
- {
- ultraGrid.DisplayLayout.Bands[0].Columns[dc.ColumnName].Hidden = false;
- break;
- }
- else
- {
- ultraGrid.DisplayLayout.Bands[0].Columns[dc.ColumnName].Hidden = true;
- }
- }
- }
- }
- else
- {
- foreach (DataColumn dc in dataTable.Columns)
- {
- foreach (DataRow dr in dataTable.Rows)
- {
- if (dr[dc].ToString() != "")
- {
- ultraGrid.DisplayLayout.Bands[0].Columns[dc.ColumnName].Hidden = false;
- break;
- }
- else
- {
- ultraGrid.DisplayLayout.Bands[0].Columns[dc.ColumnName].Hidden = true;
- }
- }
- }
- }
- }
- /// <summary>
- /// UltraGrid可读
- /// </summary>
- /// <param name="ugr">UltraGrid</param>
- /// <param name="keys">可编辑列</param>
- public static void setOtherColumnReadOnly(UltraGrid ugr, string[] keys)
- {
- if (keys == null || keys.Length == 0)
- {
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
- {
- ugc.CellActivation = Activation.ActivateOnly;
- }
- }
- else
- {
- keys.ToArray();
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
- {
- if (!keys.Contains(ugc.Key))
- {
- ugc.CellActivation = Activation.ActivateOnly;
- }
- //else
- //{
- // ugc.CellActivation = Activation.AllowEdit;
- //}
- }
- }
- if (ugr.DisplayLayout.Bands[0].Columns.Exists("CHK"))
- {
- ugr.DisplayLayout.Bands[0].Columns["CHK"].DefaultCellValue = "False";
- ugr.DisplayLayout.Bands[0].Columns["CHK"].Header.CheckBoxVisibility = Infragistics.Win.UltraWinGrid.HeaderCheckBoxVisibility.Always;
- ugr.DisplayLayout.Bands[0].Columns["CHK"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;
- }
- }
- /// <summary>
- /// UltraGrid可读
- /// </summary>
- /// <param name="ugr">UltraGrid</param>
- /// <param name="keys">可编辑列</param>
- public static void setOtherColumnReadOnly(UltraGrid ugr, string[] keys, int bandNum)
- {
- if (bandNum < 0 || ugr.DisplayLayout.Bands.Count < bandNum + 1)
- {
- return;
- }
- if (keys == null || keys.Length == 0)
- {
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[bandNum].Columns)
- {
- ugc.CellActivation = Activation.ActivateOnly;
- }
- }
- else
- {
- keys.ToArray();
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[bandNum].Columns)
- {
- if (!keys.Contains(ugc.Key))
- {
- ugc.CellActivation = Activation.ActivateOnly;
- }
- }
- }
- if (ugr.DisplayLayout.Bands[bandNum].Columns.Exists("CHK"))
- {
- ugr.DisplayLayout.Bands[bandNum].Columns["CHK"].DefaultCellValue = "False";
- ugr.DisplayLayout.Bands[bandNum].Columns["CHK"].Header.CheckBoxVisibility = Infragistics.Win.UltraWinGrid.HeaderCheckBoxVisibility.Always;
- ugr.DisplayLayout.Bands[bandNum].Columns["CHK"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;
- }
- }
- /// <summary>
- /// UltraGrid列是否隐藏
- /// </summary>isShow 为true则显示其他隐藏,false则隐藏其他显示
- /// <param name="ugr">UltraGrid</param>
- /// <param name="keys">隐藏列</param>
- public static void setColumnShowOrHidden(UltraGrid ugr, string[] keys, bool isShow)
- {
- if (keys == null || keys.Length == 0)
- {
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
- {
- ugc.Hidden = false;
- }
- }
- else
- {
- keys.ToArray();
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
- {
- if (keys.Contains(ugc.Key))
- {
- if (isShow)
- {
- ugc.Hidden = false;
- }
- else
- {
- ugc.Hidden = true;
- }
- }
- else
- {
- if (isShow)
- {
- ugc.Hidden = true;
- }
- }
- }
- }
- }
- /// <summary>
- /// UltraGrid列是否隐藏
- /// </summary>isShow 为true则显示其他隐藏,false则隐藏其他显示
- /// <param name="ugr">UltraGrid</param>
- /// <param name="keys">隐藏列</param>
- public static void setColumnShowOrHidden(UltraGrid ugr, string[] keys, bool isShow, int bandNum)
- {
- if (bandNum < 0 || ugr.DisplayLayout.Bands.Count < bandNum + 1)
- {
- return;
- }
- if (keys == null || keys.Length == 0)
- {
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[bandNum].Columns)
- {
- ugc.Hidden = false;
- }
- }
- else
- {
- keys.ToArray();
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[bandNum].Columns)
- {
- if (keys.Contains(ugc.Key))
- {
- if (isShow)
- {
- ugc.Hidden = false;
- }
- else
- {
- ugc.Hidden = true;
- }
- }
- else
- {
- if (isShow)
- {
- ugc.Hidden = true;
- }
- }
- }
- }
- }
- //初始化列
- public static void InitColumns(string[] arrColumns, string[] arrCaption, DataTable dataTable1)
- {
- if (arrColumns == null || arrColumns.Length == 0 || arrColumns.Length != arrCaption.Length)
- {
- return;
- }
- dataTable1.Columns.Clear();//先清除
- DataColumn dc;
- for (int i = 0; i < arrColumns.Length; i++)
- {
- try
- {
- dc = new DataColumn(arrColumns[i]);
- dc.Caption = arrCaption[i];
- dataTable1.Columns.Add(dc);
- if (dc.ColumnName == "CHK")
- {
- dc.DataType = typeof(bool);
- dc.DefaultValue = "False";
- }
- }
- catch
- {
- continue;
- }
- }
- }
- public static void InitColumns(string[] arrColumns, string[] arrCaption, DataTable dataTable, UltraGrid ultraGrid, string[] show, bool isShow, string[] ope)
- {
- InitColumns(arrColumns, arrCaption, dataTable);
- setColumnShowOrHidden(ultraGrid, show, isShow);
- setOtherColumnReadOnly(ultraGrid, ope);
- }
- public static void InitColumns(string[] arrColumns, string[] arrCaption, DataTable dataTable, UltraGrid ultraGrid, string[] show, bool isShow, string[] ope, int bandNum)
- {
- InitColumns(arrColumns, arrCaption, dataTable);
- setColumnShowOrHidden(ultraGrid, show, isShow, bandNum);
- setOtherColumnReadOnly(ultraGrid, ope, bandNum);
- }
- //建立主从表关系
- public static void CreateConstraints(DataSet dataSet, DataTable dtParent, DataTable dtChild, string[] col)
- {
- Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn = new Infragistics.Win.UltraWinGrid.UltraGridColumn("Relation1");
- dataSet.Relations.AddRange(new System.Data.DataRelation[] {
- new System.Data.DataRelation("Relation1", dtParent.TableName, dtChild.TableName, col, col, false)});
- UniqueConstraint un = new UniqueConstraint("Constraint1", col, false);
- dtParent.Constraints.AddRange(new System.Data.Constraint[] {
- new UniqueConstraint("Constraint1", col, false)});
- dtChild.Constraints.AddRange(new System.Data.Constraint[] {
- new System.Data.ForeignKeyConstraint("Relation1", dtParent.TableName, col, col, System.Data.AcceptRejectRule.None, System.Data.Rule.Cascade, System.Data.Rule.Cascade)});
- }
- //隐藏空列
- /// <summary>
- ///
- ///
- /// </summary>
- /// <param name="strHidden"></param>需要判断的列
- /// <param name="ug"></param>
- public static void HideNullColumn(string strHidden, UltraGrid ug)
- {
- string[] arr = strHidden.Split(',');
- for (int i = 0; i < arr.Length; i++)
- {
- if (!ug.DisplayLayout.Bands[0].Columns.Exists(arr[i]))
- {
- continue;
- }
- foreach (UltraGridRow ur in ug.Rows)
- {
- if (ur.Cells[arr[i]].Text != "")
- {
- ug.DisplayLayout.Bands[0].Columns[arr[i]].Hidden = false;
- break;
- }
- else
- {
- ug.DisplayLayout.Bands[0].Columns[arr[i]].Hidden = true;
- }
- }
- }
- }
- //选择事件
- /// <summary>
- ///
- ///
- /// </summary>
- /// <param name="strHidden"></param>
- /// <param name="ug"></param>
- public static void SelectRow(UltraGrid ultraGrid)
- {
- if (ultraGrid.DisplayLayout.Bands[0].Columns.Exists("CHK"))
- {
- foreach (UltraGridRow uRow in ultraGrid.Selected.Rows)
- {
- if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
- {
- uRow.Cells["CHK"].Value = true;
- }
- }
- }
- }
- public static void ReMoveColumns(DataTable dataTable, int position)
- {
- //从0开始
- int dcNum = dataTable.Columns.Count;
- if (dcNum > position)
- {
- for (int i = 0; i < dcNum - position; i++)
- {
- dataTable.Columns.RemoveAt(position);
- }
- }
- }
- //自适应
- private void RefreshAutoSize(UltraGrid ultraGrid1)
- {
- ultraGrid1.DisplayLayout.Bands[0].Columns[0].Width = 80;
- for (int i = 1; i < ultraGrid1.DisplayLayout.Bands[0].Columns.Count; i++)
- {
- ultraGrid1.DisplayLayout.Bands[0].Columns[i].Width = 60;//设置列宽
- }
- }
- /// <summary>
- /// 设置列宽
- /// </summary>
- /// <param name="dt"></param>需要设置的UltraGrid
- /// <param name="haveNum"></param>不需要清除的列
- /// /// <param name="width"></param>宽度
- public static void ColumnsWidth(UltraGrid ultraGrid, int haveNum, int width)
- {
- int col = ultraGrid.DisplayLayout.Bands[0].Columns.Count;
- for (int i = haveNum; i < col; i++)
- {
- ultraGrid.DisplayLayout.Bands[0].Columns[i].Width = width;//设置列宽
- }
- }
- /// <summary>
- /// 设置列宽
- /// </summary>
- /// <param name="dt"></param>需要设置的UltraGrid
- /// <param name="haveNum"></param>不需要清除的列
- /// /// <param name="width"></param>宽度
- public static void ColumnsWidth(UltraGrid ultraGrid, int haveNum, int width, string[] noSet)
- {
- ArrayList al = new ArrayList();
- for (int i = 0; i < noSet.Length; i++)
- {
- al.Add(noSet[i]);
- }
- int col = ultraGrid.DisplayLayout.Bands[0].Columns.Count;
- for (int i = haveNum; i < col; i++)
- {
- if (!al.Contains(ultraGrid.DisplayLayout.Bands[0].Columns[i].ToString()))
- {
- ultraGrid.DisplayLayout.Bands[0].Columns[i].Width = width;//设置列宽
- }
- }
- }
- /// <summary>
- /// 刷新Grid数据并根据数据调整Grid列宽
- /// </summary>
- /// <param name="ultraGrid">需要处理的Grid</param>
- /// <param name="cols">需要调整的列</param>
- /// <param name="is调整">true则自适应,false则不自适应</param>
- public static void RefreshAndAutoSizeColumns(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid, object[] cols, bool isMove)
- {
- try
- {
- ultraGrid.DataBind();
- foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands)
- {
- foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns)
- {
- if (cols != null && cols.Contains(column.Key))
- {
- if (!isMove)
- {
- continue;
- }
- column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);//AllRowsInBand
- }
- else
- {
- if (!isMove)
- {
- column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
- }
- }
- }
- }
- ultraGrid.Refresh();
- }
- catch { }
- }
- //改变splitContainer1.Panel1
- public static void ChangeSplit(SplitContainer splitContainer, DataTable dtPhyMax)
- {
- if (dtPhyMax != null && dtPhyMax.Rows.Count > 0)
- {
- splitContainer.Panel1Collapsed = false;
- }
- else
- {
- splitContainer.Panel1Collapsed = true; ;
- }
- }
- //解析数据权限
- public static string ValidDataString(string[] arrId)
- {
- string strId = "";
- if (arrId != null)
- {
- foreach (string str in arrId)
- {
- strId += "'" + str + "',";
- }
- }
- strId = strId.Remove(0, 1);
- strId = strId.Remove(strId.Length - 2);
- return strId;
- }
- // 路径组成 Lims + 界面名称 + 文件名 "Lims/data/base/";
- public static string GetFilePath(string strPath)
- {
- return "";
- }
- /// <summary>
- /// 更改文件路径
- /// </summary>
- /// <param name="Department">user_depatment</param>
- /// <returns></returns>
- public static void UpdateFilePosition(string strTableName, string strPath, string strPk, string strPkValue, OpeBase ob)
- {
- try
- {
- string sql = "UPDATE " + strTableName + " SET FILE_POSITION = '" + strPath + "' WHERE " + strPk + " = '" + strPkValue + "'";
- //PublicServer.SetData("com.steering.BaseInfo.UpdateFilePosition", new Object[] { sql }, ob);
- }
- catch
- {
- }
- }
- /// <summary>
- /// 查看文件路径
- /// </summary>
- /// <param name="Department">user_depatment</param>
- /// <returns></returns>
- public static bool ViewFilePosition(OpeBase _ob, string path)
- {
- bool isSucc = true;
- FormFileDown down = new FormFileDown(_ob, path);
- down.ShowDialog();
- if (down.CtrlFileDown1.List.Count == 0)
- {
- isSucc = false;//删除了则更新FILE_POSITION
- }
- return isSucc;
- }
- /// <summary>
- /// 上传文件路径
- /// </summary>
- /// <param name="Department">user_depatment</param>
- /// <returns></returns>
- public static bool UploadFilePosition(OpeBase _ob, string path)
- {
- //var serverFileList = FileHelper.Download(path);
- //if (serverFileList.Count > 0)
- //{
- // MessageUtil.ShowWarning("该记录已存在一份文件,请删除后再重新上传!");
- // return false;
- //}
- List<FileBean> list = new List<FileBean>();
- FileBean bean = new FileBean();
- OpenFileDialog file = new OpenFileDialog();
- file.Multiselect = false;
- DialogResult drStat;
- drStat = file.ShowDialog();
- if (drStat == DialogResult.OK)
- {
- string filePath = file.FileName;
- string fileName = System.IO.Path.GetFileName(filePath);
- bean = new FileBean();
- bean.setFileName(fileName);
- bean.setPathName(path);
- bean.setFile(FileHelper.FileToArray(filePath));
- list.Add(bean);
- bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
- if (isSuccess)
- {
- MessageUtil.ShowTips("上传成功!");
- }
- else
- {
- MessageUtil.ShowTips("上传失败,请重试!");
- }
- return isSuccess;//成功了则更新FILE_POSITION
- }
- return false;
- }
- //勾选激活行
- public static void GridEdite(UltraGridRow row)
- {
- if (row.GetValue("CHK") == "True")
- {
- foreach (UltraGridCell cell in row.Cells)
- {
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.AllowEdit;
- }
- }
- }
- else
- {
- foreach (UltraGridCell cell in row.Cells)
- {
- if (cell.Column.Key == "CHK") continue;
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.ActivateOnly;
- }
- }
- }
- }
- public static void GridEdite(UltraGridRow row, string[] arrStr)
- {
- if (row.GetValue("CHK") == "True")
- {
- foreach (UltraGridCell cell in row.Cells)
- {
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.AllowEdit;
- }
- }
- }
- else
- {
- foreach (UltraGridCell cell in row.Cells)
- {
- if (cell.Column.Key == "CHK") continue;
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.ActivateOnly;
- }
- }
- }
- }
- /// <summary>
- /// 设置列字段显示位置在右
- /// </summary>
- /// <param name="ug">UltraGrid</param>
- /// <param name="columnsKeys">要设置的列</param>
- public static void InitCellPositionRight(UltraGrid ug, string[] columnsKeys)
- {
- if (columnsKeys == null || columnsKeys.Length == 0)
- {
- foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
- {
- ugc.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
- }
- }
- else
- {
- columnsKeys.ToArray();
- foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
- {
- if (columnsKeys.Contains(ugc.Key.ToString()))
- {
- ugc.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
- }
- }
- }
- }
- /// <summary>
- /// 设置列字段显示位置在右
- /// </summary>
- /// <param name="ug">UltraGrid</param>
- /// <param name="columnsKeys">要设置的列</param>
- public static void InitCellPositionRight(UltraGrid[] arrUg, string[] columnsKeys)
- {
- if (arrUg == null || arrUg.Length < 1)
- {
- return;
- }
- foreach (UltraGrid ug in arrUg)
- {
- if (ug.DisplayLayout.Bands.Count < 1)
- {
- continue;
- }
- if (columnsKeys == null || columnsKeys.Length == 0)
- {
- foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
- {
- ugc.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
- }
- }
- else
- {
- columnsKeys.ToArray();
- foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
- {
- if (columnsKeys.Contains(ugc.Key.ToString()))
- {
- ugc.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
- }
- }
- }
- }
- }
- /// <summary>
- /// 设置列字段显示小数位后几位
- /// </summary>
- /// <param name="ug">UltraGrid</param>
- /// band 第几个 num显示位数不足补齐0,isShow 数字是否用逗号隔开
- /// <param name="columnsKeys">要设置的列</param>
- public static void InitColumnShowLength(UltraGrid ug, int band, string[] columnsKeys, int num, bool isShow)
- {
- if (columnsKeys == null || columnsKeys.Length == 0 || band < 0 || num < 0 || ug.DisplayLayout.Bands.Count < band + 1)
- {
- return;
- }
- else
- {
- string strShow = "";//nnnnnnnnnn {LOC}nn,nnn,nnn.nn
- if (isShow)
- {
- strShow += "-n,nnn,nnn,nnn,nnn,nnn";
- }
- else
- {
- strShow += "-nnnnnnnnnnnnnnnn";
- }
- if (num > 0)
- {
- strShow += ".";
- for (int i = 0; i < num; i++)
- {
- strShow += "n";
- }
- }
- columnsKeys.ToArray();
- foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[band].Columns)
- {
- if (columnsKeys.Contains(ugc.Key.ToString()))
- {
- //ug.DisplayLayout.Bands[band].Columns[ugc.Key.ToString()].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Double;
- ug.DisplayLayout.Bands[band].Columns[ugc.Key.ToString()].MaskInput = strShow;
- }
- }
- }
- }
- /// <summary>
- /// 设置列字段显示小数位后几位
- /// </summary>
- /// <param name="ug">UltraGrid</param>
- /// band 第几个 num显示位数不足补齐0,isShow 数字是否用逗号隔开
- /// <param name="columnsKeys">要设置的列</param>
- public static void InitColumnShowLength(UltraGrid[] arrUg, int band, string[] columnsKeys, int num, bool isShow)
- {
- if (columnsKeys == null || columnsKeys.Length == 0 || band < 0 || num < 0 || arrUg == null
- || arrUg.Length < 1)
- {
- return;
- }
- else
- {
- string strShow = "";//nnnnnnnnnn {LOC}nn,nnn,nnn.nn
- if (isShow)
- {
- strShow += "-n,nnn,nnn,nnn,nnn,nnn";
- }
- else
- {
- strShow += "-nnnnnnnnnnnnnnnn";
- }
- if (num > 0)
- {
- strShow += ".";
- for (int i = 0; i < num; i++)
- {
- strShow += "n";
- }
- }
- columnsKeys.ToArray();
- foreach (UltraGrid ug in arrUg)
- {
- if (ug.DisplayLayout.Bands.Count < band + 1)
- {
- continue;
- }
- foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[band].Columns)
- {
- if (columnsKeys.Contains(ugc.Key.ToString()))
- {
- //ug.DisplayLayout.Bands[band].Columns[ugc.Key.ToString()].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Double;
- ug.DisplayLayout.Bands[band].Columns[ugc.Key.ToString()].MaskInput = strShow;
- }
- }
- }
- }
- }
- /// <summary>
- /// 设置Grid统计格式
- ///
- /// </summary>
- /// <param name="Arrsumtype"></param>统计格式集合
- /// <param name="HeadeVale"></param>显示格式
- /// <param name="ColumName"></param>列名
- /// <param name="band"></param>
- /// <param name="areas"></param>位置
- public static void SetupSummaryHeade(string[] Arrsumtype, string[] HeadeVale, string[] ColumName, UltraGridBand band, SummaryDisplayAreas areas)
- {
- if (HeadeVale.Length != Arrsumtype.Length && Arrsumtype.Length != ColumName.Length)
- {
- return;
- }
- SummaryType sumType; ;
- for (int i = 0; i < HeadeVale.Length; i++)
- {
- //SummaryType.Count 统计 Average平均值 Maximum最大值 Minimum 最小值 Sum 求和
- if (Arrsumtype[i] == "Count")
- {
- sumType = SummaryType.Count;
- }
- else if (Arrsumtype[i] == "Maximum")
- {
- sumType = SummaryType.Maximum;
- }
- else if (Arrsumtype[i] == "Minimum")
- {
- sumType = SummaryType.Minimum;
- }
- else
- {
- sumType = SummaryType.Sum;
- }
- if (band.Columns.Exists(ColumName[i]))
- {
- SummarySettings summary = band.Summaries.Add(sumType, band.Columns[ColumName[i]]);
- summary.SummaryDisplayArea = areas;
- summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
- summary.DisplayFormat = HeadeVale[i];
- summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Center;
- summary.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle;
- //summary.Appearance.ForeColor = Color.Black;
- //summary.Appearance.BackColor = Color.FromArgb(248, 253, 180);
- }
- }
- Infragistics.Win.Appearance appearance21 = new Infragistics.Win.Appearance();
- Infragistics.Win.Appearance appearance20 = new Infragistics.Win.Appearance();
- appearance20.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
- band.Override.SummaryFooterAppearance = appearance20;
- appearance21.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
- appearance21.TextHAlignAsString = "Right";
- band.Override.SummaryValueAppearance = appearance21;
- }
- /// <summary>
- /// 可编区域显示(黄色+可编辑)
- /// </summary>
- /// <param name="ug">UltraGrid</param>
- /// <param name="columnsKeys">要设置的列</param>
- public static void InitCellEdit(UltraGrid[] arrUg, string[] columnsKeys)
- {
- if (arrUg == null || arrUg.Length < 1)
- {
- return;
- }
- if (columnsKeys == null || columnsKeys.Length == 0)
- {
- return;
- }
- foreach (UltraGrid ug in arrUg)
- {
- if (ug.DisplayLayout.Bands.Count < 1)
- {
- continue;
- }
- columnsKeys.ToArray();
- foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
- {
- if (columnsKeys.Contains(ugc.Key.ToString()))
- {
- ugc.CellAppearance.BackColor = Color.FromArgb(255, 255, 128);
- ugc.CellActivation = Activation.AllowEdit;
- }
- else
- {
- ugc.CellActivation = Activation.ActivateOnly;
- }
- }
- }
- }
- }
- }
|