| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Infragistics.Win.UltraWinGrid;
- using System.Drawing;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinEditors;
- using System.Data;
- using System.Windows.Forms;
- using Core.Mes.Client.Comm.Server;
- using Infragistics.Win.UltraWinMaskedEdit;
- using System.Collections;
- using System.Text.RegularExpressions;
- using System.IO;
- namespace Core.StlMes.Client.ZGMil.Common
- {
- class BaseMethod
- {
- /// <summary>
- /// UltraGrid可读
- /// </summary>
- /// <param name="ugr">UltraGrid</param>
- /// <param name="keys">可编辑列</param>
- public static void setOtherColumnReadOnly(UltraGrid ugr, string[] keys)
- {
- keys.ToArray();
- foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
- {
- if (!keys.Contains(ugc.Key))
- {
- ugc.CellActivation = Activation.ActivateOnly;
- }
- }
- }
- /// <summary>
- /// UltraGrid激活某行
- /// </summary>
- /// <param name="ug">UltraGrid</param>
- /// <param name="keys">列名</param>
- /// <param name="values">对应的值</param>
- public static void UltraGridLocation(UltraGrid ug, String[] keys, String[] values)
- {
- if (ug.Rows.Count == 0)
- {
- return;
- }
- if (keys.Length == 0 || values.Length == 0 || values.Length != keys.Length)
- {
- return;
- }
- foreach (UltraGridRow ugr in ug.Rows)
- {
- Boolean flag = true;
- for (int i = 0; i < keys.Length; i++)
- {
- if (!ugr.Cells[keys[i]].ToString().Equals(values[i]))
- {
- flag = false;
- }
- }
- if (flag == true)
- {
- ugr.Activate();
- return;
- }
- }
- }
- /// <summary>
- /// 设置列字段显示位置在右
- /// </summary>
- /// <param name="ug">UltraGrid</param>
- /// <param name="columnsKeys">要设置的列</param>
- public static void InitCellPosition(UltraGrid ug, string[] columnsKeys)
- {
- 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 InitCellPosition(UltraGrid ug, string[] columnsKeys,int dex)
- {
- columnsKeys.ToArray();
- foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[dex].Columns)
- {
- if (columnsKeys.Contains(ugc.Key.ToString()))
- {
- ugc.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
- }
- }
- }
- /// <summary>
- /// 列求和
- /// </summary>
- /// <param name="ug">UltraGrid</param>
- /// <param name="columnKeys">列数组</param>
- public static void GridColumnSum(UltraGrid ug, string[] columnKeys)
- {
- if (columnKeys.Length == 0)
- {
- return;
- }
- for (int i = 0; i < columnKeys.Length; i++)
- {
- ug.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum, ug.DisplayLayout.Bands[0].Columns[columnKeys[i]], SummaryPosition.UseSummaryPositionColumn);
- }
- }
- /// <summary>
- /// 设置UltraGrid行颜色
- /// </summary>
- /// <param name="ug">UltraGrid</param>
- /// <param name="columnKeys">列</param>
- /// <param name="values">值</param>
- /// <param name="color">颜色</param>
- public static void SetUltraGridRowColor(UltraGrid ug, string[] columnKeys, string[] values, Color color)
- {
- if (ug.Rows.Count == 0 || columnKeys.Length == 0 || values.Length == 0 || color == null || values.Length != columnKeys.Length)
- {
- return;
- }
- foreach (UltraGridRow ugr in ug.Rows)
- {
- Boolean flag = true;
- for (int i = 0; i < columnKeys.Length; i++)
- {
- if (!ugr.Cells[columnKeys[i]].Value.ToString().Equals(values[i]))
- {
- flag = false;
- }
- }
- if (flag)
- {
- ugr.Appearance.BackColor = color;
- }
- }
- }
- /// <summary>
- /// 合并单元格
- /// </summary>
- /// <param name="ug"></param>
- /// <param name="columnKeys"></param>
- public static void MergedCell(UltraGrid ug, string[] columnKeys)
- {
- if (columnKeys.Length == 0)
- {
- return;
- }
- ug.DisplayLayout.Override.MergedCellStyle = MergedCellStyle.Never;
- for (int i = 0; i < columnKeys.Length; i++)
- {
- ug.DisplayLayout.Bands[0].Columns[columnKeys[i]].MergedCellStyle = MergedCellStyle.Always;
- }
- }
- /// <summary>
- /// 仓库数据权限
- /// </summary>
- /// <param name="customInfo">页面配制信息(自定义参数)</param>
- /// <param name="validDataPurviewIds">用户数据权限</param>
- /// <returns>可查看仓库组成的字符串</returns>
- public static string[] WarehousePermissions(String customInfo, String[] validDataPurviewIds, OpeBase ob)
- {
- string storageType = "";//仓库类别
- string storageAttr = "";//仓库类型
- if (customInfo.Length >= 0 && customInfo.Contains(","))
- {
- string[] strflg = customInfo.ToString().Split(new char[] { ',' });
- storageType = strflg[0];
- storageAttr = strflg[1];
- }
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getWarehousePermissions", new object[] { storageType, storageAttr, validDataPurviewIds }, ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- string[] storages = new string[dt.Rows.Count];
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- storages[i] = dt.Rows[i]["STORAGE_NO"].ToString();
- }
- return storages;
- }
- else
- {
- return new string[1] { "" };
- }
- }
- /// <summary>
- /// 仓库数据权限(用于报表)
- /// </summary>
- /// <param name="customInfo">页面配制信息(自定义参数)</param>
- /// <param name="validDataPurviewIds">用户数据权限</param>
- /// <returns>可查看仓库组成的字符串</returns>
- public static string[] WarehousePermissionsStore(String[] validDataPurviewIds, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.mes.signature.WarehousePermissions.getWarehousePermissionsStore", new object[] { validDataPurviewIds }, ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- string[] storages = new string[dt.Rows.Count];
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- storages[i] = dt.Rows[i]["STORAGE_NO"].ToString();
- }
- return storages;
- }
- else
- {
- return new string[1] { "" };
- }
- }
- /// <summary>
- /// 获取产线
- /// </summary>
- /// <param name="arr1"></param>
- /// <returns></returns>
- public static string[] GetPlineCode(string[] arr1, OpeBase ob)
- {
- string[] arr = null;
- DataTable dt = ServerHelper.GetData("com.steering.mes.signature.WarehousePermissions.getPlineCode", new Object[] { arr1 }, ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- arr = new string[dt.Rows.Count];
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- arr[i] = dt.Rows[i][0].ToString();
- }
- return arr;
- }
- else
- {
- return new string[1] { "" };
- }
- }
- /// <summary>
- /// 初始化仓库号下拉框
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="customInfo"></param>
- /// <param name="validDataPurviewIds"></param>
- /// <param name="ob"></param>
- public static void InitStorage(UltraComboEditor uce, String customInfo, String[] validDataPurviewIds, OpeBase ob)
- {
- string storageType = "";//仓库类别
- string storageAttr = "";//仓库类型
- if (customInfo.Length >= 0 && customInfo.Contains(","))
- {
- string[] strflg = customInfo.ToString().Split(new char[] { ',' });
- storageType = strflg[0];
- storageAttr = strflg[1];
- }
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getWarehousePermissions", new object[] { storageType, storageAttr, validDataPurviewIds }, ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- uce.DataSource = dt;
- uce.DisplayMember = "STORAGE_NAME";
- uce.ValueMember = "STORAGE_NO";
- uce.SelectedIndex = 0;
- }
- else
- {
- uce.DataSource = null;
- }
- }
- /// <summary>
- /// 初始化下拉框材料类别
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitProducFlagCom(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dtProducFlag = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeMagement.queryMaterialSTyle", new object[] { }, ob);
- BaseMethod.InitComboEditor(uce, dtProducFlag, "BASENAME", "BASECODE");
- }
- /// <summary>
- /// 初始化下拉框材料状态
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitMapStatusCom(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dtMapStatus = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeMagement.queryMaterialStatus", new object[] { }, ob);
- BaseMethod.InitComboEditor(uce, dtMapStatus, "BASENAME", "BASECODE");
- }
- /// <summary>
- /// 初始化下拉框材料状态
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitMapStatusCom(UltraComboEditor uce, OpeBase ob, string flag)
- {
- DataTable dtMapStatus = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeMagement.queryMaterialStatus", new object[] { flag }, ob);
- BaseMethod.InitComboEditor(uce, dtMapStatus, "BASENAME", "BASECODE");
- }
- /// <summary>
- /// 初始下拉框
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="dt"></param>
- /// <param name="showName"></param>
- /// <param name="hideValue"></param>
- public static void InitComboEditor(UltraComboEditor uce, DataTable dt, String showName, String hideValue)
- {
- uce.DataSource = dt;
- uce.DisplayMember = showName;
- uce.ValueMember = hideValue;
- }
- /// <summary>
- /// 初始下拉框
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="dt"></param>
- /// <param name="showName"></param>
- /// <param name="hideValue"></param>
- public static void InitComboEditor1(UltraComboEditor uce, DataTable dt, String showName, String hideValue)
- {
- uce.DataSource = dt;
- uce.DisplayMember = showName;
- uce.ValueMember = hideValue;
- uce.SelectedIndex = 1;
- }
- /// <summary>
- /// 初始化下拉框产线
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitPline(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dtPline = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getPline", new object[] { }, ob);
- BaseMethod.InitComboEditor(uce, dtPline, "PLINE_NAME", "PLINE_CODE");
- }
- /// <summary>
- /// 初始化下拉框材料来源
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitSourse(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getSourse", new object[] { "8013" }, ob);
- BaseMethod.InitComboEditor1(uce, dt, "BASENAME", "BASECODE");
- }
- /// <summary>
- /// 初始化下拉框钢种
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitGrade(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeEnter.getGrade", new object[] { }, ob);
- BaseMethod.InitComboEditor(uce, dt, "GRADENAME", "GRADECODE");
- }
- /// <summary>
- /// 获取规格
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitSpec(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeEnter.getSpec", new object[] { }, ob);
- BaseMethod.InitComboEditor(uce, dt, "SPEC_NAME", "SPEC_CODE");
- }
- /// <summary>
- /// 获取扣型
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitModel(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeEnter.getModel", new object[] { }, ob);
- BaseMethod.InitComboEditor(uce, dt, "MODEL_DESC", "MODEL_CODE");
- }
- /// <summary>
- /// 获取品名
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitProcduce(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.BaseOperations.getProcduce", new object[] { }, ob);
- BaseMethod.InitComboEditor(uce, dt, "PRODUC_JX", "PRODUCCODE");
- }
- /// <summary>
- /// 获取钢级
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitSteel(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.BaseOperations.getSteel", new object[] { }, ob);
- BaseMethod.InitComboEditor(uce, dt, "STEELNAME", "STEELCODE");
- }
- /// <summary>
- /// 获取标准类别
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitStdStyle(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.BaseOperations.getStdStyle", new object[] { }, ob);
- BaseMethod.InitComboEditor(uce, dt, "STD_STYLE_DESC", "STD_STYLE");
- }
- /// <summary>
- /// 初始化下拉框原因
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitReason(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getSourse", new object[] { "8012" }, ob);
- BaseMethod.InitComboEditor(uce, dt, "BASENAME", "BASECODE");
- }
- /// <summary>
- /// 初始化下拉框综合判断结果
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitJustResult(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getSourse", new object[] { "407407" }, ob);
- BaseMethod.InitComboEditor(uce, dt, "BASENAME", "BASECODE");
- }
- /// <summary>
- /// 初始化下拉框所属权单位
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitBelongCode(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getBelongCode", new object[] { }, ob);
- BaseMethod.InitComboEditor(uce, dt, "DEPARTNAME", "DEPARTID");
- }
- /// <summary>
- /// 销售组织权限
- /// </summary>
- /// <param name="validDataPurviewIds">数据权限</param>
- /// <param name="ob"></param>
- /// <returns>字符串数组</returns>
- public static string[] InitPermissions(string[] validDataPurviewIds, OpeBase ob)
- {
- string[] arr = null;
- DataTable dt = ServerHelper.GetData("com.steering.common.WarehousePermissions.getSalgPermissions", new object[] { validDataPurviewIds }, ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- arr = new string[dt.Rows.Count];
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- arr[i] = dt.Rows[i][0].ToString();
- }
- }
- return arr;
- }
- /// <summary>
- /// 炼钢权限
- /// </summary>
- /// <param name="validDataPurviewIds">数据权限</param>
- /// <param name="ob"></param>
- /// <returns>字符串数组</returns>
- public static string[] InitLgPermissions(string[] validDataPurviewIds, OpeBase ob)
- {
- string[] arr = null;
- DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Common.ComLgValidDataPurviewIds.getLgPermissions", new object[] { validDataPurviewIds }, ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- arr = new string[dt.Rows.Count];
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- arr[i] = dt.Rows[i][0].ToString();
- }
- }
- return arr;
- }
- /// <summary>
- /// 获取PCode
- /// </summary>
- /// <param name="Department">user_depatment</param>
- /// <returns></returns>
- public static string GetPCode(string Department, OpeBase ob)
- {
- string Pcode = "";
- DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Common.ComLgValidDataPurviewIds.getPCode", new Object[] { Department }, ob);
- if (dt.Rows.Count > 0)
- {
- Pcode = dt.Rows[0]["pline_code"].ToString();
- }
- return Pcode;
- }
- /// <summary>
- /// 设置列显示位数
- /// </summary>
- /// <param name="ug"></param>
- /// <param name="arr"></param>
- public static void setUltraGridColumnMaxInput(UltraGrid ug, string[] arr)
- {
- if (ug == null || arr == null || arr.Length == 0)
- {
- return;
- }
- arr.ToArray();
- foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
- {
- if (arr.Contains(ugc.Key.ToString()))
- {
- ugc.MaskClipMode = MaskMode.IncludeLiterals;
- ugc.MaskInput = "{LOC}nn,nnn,nnn.nnn";
- }
- }
- }
- /// <summary>
- /// 炉号去-后的字符
- /// </summary>
- /// <param name="JudgeStoveNo"></param>
- /// <returns></returns>
- public static string getJudgeStoveNo(string JudgeStoveNo)
- {
- Regex regex = new Regex("-[0-9]*");
- return regex.Replace(JudgeStoveNo, "");
- }
- /// <summary>
- /// 键盘按下Ctrl+D,拷贝活动单元格的数据到所有已勾选的此列的单元格中
- /// </summary>
- /// <param name="ugrid">UltraGrid</param>
- /// <param name="e"></param>
- /// <param name="strs">可以进行列名称</param>
- public static void setGridCopyActColumn(UltraGrid ugrid, KeyEventArgs e, params string[] strs)
- {
- if (e.Control && e.KeyCode == Keys.D)
- {
- if (ugrid != null && ugrid.ActiveRow != null)
- {
- UltraGridRow ugr = ugrid.ActiveRow;
- foreach (string colName in strs)
- {
- if (ugrid.ActiveCell.Column.Key.Equals(colName))
- {
- if (ugr.Cells[colName].Activation != Activation.AllowEdit)
- {
- return;
- }
- ugrid.UpdateData();
- ArrayList list = new ArrayList();
- IQueryable<UltraGridRow> checkRows = ugrid.Rows.AsQueryable().Where("CHK = 'True' ");
- if (checkRows.Count() == 0)
- {
- return;
- }
- foreach (UltraGridRow uRow in checkRows)
- {
- if (uRow != ugr && uRow.Cells[colName].Activation == Activation.AllowEdit)
- {
- uRow.Cells[colName].Value = ugr.Cells[colName].Value;
- }
- }
- }
- }
- }
- }
- }/// <summary>
- /// 初始年份
- /// </summary>
- /// <param name="uce"></param>
- public static void InitYear(UltraComboEditor uce)
- {
- DataTable dtYear = new DataTable();
- dtYear.Columns.Add("YEAR");
- for (int i = 2000; i < 2200; i++)
- {
- DataRow dr = dtYear.NewRow();
- dr["YEAR"] = i.ToString();
- dtYear.Rows.Add(dr);
- }
- uce.DataSource = dtYear;
- uce.DisplayMember = "YEAR";
- uce.ValueMember = "YEAR";
- }
- /// <summary>
- /// 初始月份
- /// </summary>
- /// <param name="uce"></param>
- public static void InitMonth(UltraComboEditor uce)
- {
- DataTable dtMonth = new DataTable();
- dtMonth.Columns.Add("MONTH");
- for (int i = 1; i < 13; i++)
- {
- DataRow dr = dtMonth.NewRow();
- dr["MONTH"] = string.Format("{0:00}", i);
- dtMonth.Rows.Add(dr);
- }
- uce.DataSource = dtMonth;
- uce.DisplayMember = "MONTH";
- uce.ValueMember = "MONTH";
- }
- /// <summary>
- /// 键盘按下Ctrl+D,拷贝活动单元格的数据到所有已勾选的此列的单元格中
- /// </summary>
- /// <param name="ugrid">UltraGrid</param>
- /// <param name="e"></param>
- /// <param name="strs">可以进行列名称</param>
- public static void setGridCopyActColumn1(UltraGrid ugrid, KeyEventArgs e, params string[] strs)
- {
- if (e.Control && e.KeyCode == Keys.D)
- {
- if (ugrid != null && ugrid.ActiveRow != null)
- {
- UltraGridRow ugr = ugrid.ActiveRow;
- foreach (string colName in strs)
- {
- if (ugrid.ActiveCell.Column.Key.Equals(colName))
- {
- if (ugr.Cells[colName].Activation != Activation.AllowEdit)
- {
- return;
- }
- ugrid.UpdateData();
- ArrayList list = new ArrayList();
- IQueryable<UltraGridRow> checkRows = ugrid.Rows.AsQueryable().Where("CHOOSE = 'True' ");
- if (checkRows.Count() == 0)
- {
- return;
- }
- foreach (UltraGridRow uRow in checkRows)
- {
- if (uRow != ugr && uRow.Cells[colName].Activation == Activation.AllowEdit)
- {
- uRow.Cells[colName].Value = ugr.Cells[colName].Value;
- }
- }
- }
- }
- }
- }
- }
- /// <summary>
- /// 获取表格中
- /// </summary>
- /// <typeparam name="T">返回类</typeparam>
- /// <param name="dt">数据表</param>
- /// <param name="t">输入类</param>
- /// <returns></returns>
- public static T GetTableToEntity<T>(DataTable dt, T t)
- {
- String[] strColumns = null;
- DataRow dr = dt.Rows[0];
- try
- {
- if (dt.Columns.Count > 0)
- {
- int columnNum = 0;
- columnNum = dt.Columns.Count;
- strColumns = new string[columnNum];
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- strColumns[i] = dt.Columns[i].ColumnName.Replace("_", "");
- }
- System.Reflection.PropertyInfo[] pro = t.GetType().GetProperties();
- foreach (System.Reflection.PropertyInfo item in pro)
- {
- for (int i = 0; i < strColumns.Length; i++)
- {
- if (string.Compare(item.Name.ToString(), strColumns[i].ToString(), true) == 0)
- {
- if (item.PropertyType == typeof(int?))
- {
- item.SetValue(t, Convert.ToInt32(dr[i].ToString3()), null);
- }
- else if (item.PropertyType == typeof(decimal?))
- {
- item.SetValue(t, Convert.ToDecimal(dr[i].ToString3()), null);
- }
- else
- {
- item.SetValue(t, dr[i].ToString(), null);
- }
- }
- }
- }
- }
- else
- {
- }
- }
- catch (Exception e)
- {
- System.Windows.Forms.MessageBox.Show("出错:", e.ToString());
- }
- return t;
- }
- /// <summary>
- /// 获取数据源中第一行数据赋到类中(grid 带下划线)
- /// </summary>
- /// <typeparam name="T">返回类</typeparam>
- /// <param name="ds">输入带数据的数据源</param>
- /// <param name="t">输入类</param>
- /// <returns></returns>
- public static T GetUltraGridToEntityNEW<T>(UltraGrid _grid, T t)
- {
- String[] strColumns = null;
- String[] strColumnsNew = null;
- UltraGridRow dr = _grid.Rows[0];
- int columnNum = dr.Cells.Count;
- strColumns = new String[columnNum];
- strColumnsNew = new String[columnNum];
- for (int i = 0; i < columnNum; i++)
- {
- strColumns[i] = _grid.DisplayLayout.Bands[0].Columns[i].Key.ToString().Replace("_", "");
- strColumnsNew[i] = _grid.DisplayLayout.Bands[0].Columns[i].Key.ToString();
- }
- System.Reflection.PropertyInfo[] pro = t.GetType().GetProperties();
- foreach (System.Reflection.PropertyInfo item in pro)
- {
- for (int i = 0; i < strColumns.Length; i++)
- {
- if (string.Compare(item.Name.ToString(), strColumns[i].ToString(), true) == 0)
- {
- if (item.PropertyType == typeof(int?))
- {
- item.SetValue(t, Convert.ToInt32(dr.Cells[strColumnsNew[i]].Value.ToString3()), null);
- }
- else if (item.PropertyType == typeof(decimal?))
- {
- item.SetValue(t, Convert.ToDecimal(dr.Cells[strColumnsNew[i]].Value.ToString3()), null);
- }
- else
- {
- item.SetValue(t, Convert.ToString(dr.Cells[strColumnsNew[i]].Value.ToString()), null);
- }
- }
- }
- }
- return t;
- }
- //调用本地程序打开查看服务器文件
- /// <summary>
- /// 调用本地程序打开查看服务器文件
- /// </summary>
- /// <param name="pathName"></param>
- public static void ViewCarft_No(string pathName)
- {
- try
- {
- //删除本地文件
- string tmpPath = Environment.CurrentDirectory + "\\Tmp\\";
- DirectoryInfo di = new DirectoryInfo(tmpPath);
- if (di.Exists == false)
- {
- di.Create();
- return;
- }
- foreach (FileInfo fi in di.GetFiles())
- {
- try
- {
- fi.Delete();
- }
- catch { continue; }
- }
- //下载写入本地Tmp目录
- if (pathName == "" || pathName == null) return;
- List<FileBean> list = Core.Mes.Client.Comm.Server.FileHelper.Download(pathName);
- foreach (FileBean bean in list)
- {
- FileStream fs = new FileStream(tmpPath + bean.getFileName(), FileMode.Create);
- fs.Write(bean.getFile(), 0, bean.getFile().Length);
- fs.Flush();
- fs.Close();
- System.Diagnostics.Process MyProcess = new System.Diagnostics.Process();
- MyProcess.StartInfo.FileName = tmpPath + bean.getFileName();
- MyProcess.StartInfo.Verb = "Open";
- MyProcess.StartInfo.CreateNoWindow = true;
- MyProcess.Start();
- return;
- }
- }
- catch { }
- }
- }
- }
|