| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102 |
- 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 Infragistics.Win;
- using System.Text.RegularExpressions;
- using System.IO;
- namespace Core.StlMes.Client.YdmBcPipeManage
- {
- public class BaseMethod
- {
- /// <summary>
- /// 初始化下拉框
- /// </summary>
- /// <param name="uce">下拉框</param>
- /// <param name="methodId">请求的服务</param>
- /// <param name="valueMember">值成员</param>
- /// <param name="ob">ob对象</param>
- /// <param name="isEmpty">是否有空行</param>
- public static void InitComboEditor(UltraComboEditor uce, string methodId, string valueMember, OpeBase ob, bool isEmpty)
- {
- DataTable dt = ServerHelper.GetData(methodId, null, ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- if (isEmpty)
- {
- Object[] obj = new Object[] { "", "" };
- DataRow dr = dt.NewRow();
- dr.ItemArray = obj;
- dt.Rows.InsertAt(dr, 0);
- }
- uce.DataSource = dt;
- uce.ValueMember = valueMember;
- SetComboItemHeight(uce);
- }
- }
- /// <summary>
- /// 将下拉框绑定到GRID列
- /// </summary>
- /// <param name="uce">下拉框(已经初始化完成)</param>
- /// <param name="ColumnName">列名</param>
- /// <param name="con">空间集合(每次只需填入this.Controls)</param>
- /// <param name="ug">GRID</param>
- /// <param name="i">GRID的第几层结构</param>
- public static void BindColumn(UltraComboEditor uce, string ColumnName, System.Windows.Forms.Control.ControlCollection con, UltraGrid ug, int i)
- {
- con.Add(uce);
- uce.Visible = false;
- ug.DisplayLayout.Bands[i].Columns[ColumnName].EditorComponent = uce;
- ug.DisplayLayout.Bands[i].Columns[ColumnName].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- SetComboItemHeight(uce);
- }
- /// <summary>
- /// 初始化下拉框 --带参数的
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="methodId"></param>
- /// <param name="valueMember"></param>
- /// <param name="ob"></param>
- /// <param name="isEmpty"></param>
- /// <param name="obj"></param>
- public static void InitComboEditorWithParmArr(UltraComboEditor uce, string methodId, string valueMember, OpeBase ob, bool isEmpty, params object[] parm)
- {
- DataTable dt = ServerHelper.GetData(methodId, parm, ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- if (isEmpty)
- {
- Object[] obj = new Object[] { "", "" };
- DataRow dr = dt.NewRow();
- dr.ItemArray = obj;
- dt.Rows.InsertAt(dr, 0);
- }
- uce.DataSource = dt;
- uce.ValueMember = valueMember;
- uce.SelectedIndex = -1;
- SetComboItemHeight(uce);
- }
- }
- /// <summary>
- /// 设置UltraComboEditor中的中文和非中文统一高度。
- /// </summary>
- /// <param name="cmb"></param>
- public static void SetComboItemHeight(UltraComboEditor cmb)
- {
- foreach (ValueListItem item in cmb.Items)
- {
- if (Regex.IsMatch(item.DisplayText, @"[\u4e00-\u9fa5]+"))
- {
- item.Appearance.FontData.SizeInPoints = 9.0F;
- }
- else
- {
- item.Appearance.FontData.SizeInPoints = 10.5F;
- }
- }
- }
- /// <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.mes.mcp.common.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[] WarehousePermissionsStore1(String[] validDataPurviewIds,string tt , OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.mes.SendRecive.FrmFilpOutStorage.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="customInfo">页面配制信息(自定义参数)</param>
- /// <param name="validDataPurviewIds">用户数据权限</param>
- /// <returns>可查看仓库组成的字符串</returns>
- public static string[] WarehousePermissionsStore1(String[] validDataPurviewIds, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.mes.SendRecive.FrmFilpOutStorage.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="customInfo">页面配制信息(自定义参数)</param>
- /// <param name="validDataPurviewIds">用户数据权限</param>
- /// <returns>可查看仓库组成的字符串</returns>
- public static string[] WarehousePermissionsStore(String[] validDataPurviewIds, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.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="customInfo">页面配制信息(自定义参数)</param>
- /// <param name="validDataPurviewIds">用户数据权限</param>
- /// <returns>可查看仓库组成的字符串</returns>
- public static string[] WarehousePermissionsDepart(String[] validDataPurviewIds, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getWarehousePermissionsDepart", 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]["PID"].ToString();
- }
- return storages;
- }
- 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 InitGpStorage(UltraComboEditor uce, OpeBase ob)
- //{
- // DataTable dtMapStatus = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.doQueryStorage", new object[] { }, ob);
- // BaseMethod.InitComboEditor(uce, dtMapStatus, "BASENAME", "BASECODE");
- //}
- /// <summary>
- /// 初始化下拉框材料类别
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- //public static void InitProducFlagCom(UltraComboEditor uce, OpeBase ob)
- //{
- // DataTable dtProducFlag = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.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("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.queryMaterialStatus", new object[] { flag }, ob);
- // BaseMethod.InitComboEditor(uce, dtMapStatus, "BASENAME", "BASECODE");
- //}
- ///// <summary>
- ///// 初始化下拉框管坯物料码
- ///// </summary>
- ///// <param name="uce"></param>
- ///// <param name="ob"></param>
- //public static void InitMaterialCom(UltraComboEditor uce, OpeBase ob)
- //{
- // DataTable dtMapStatus = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.doQueryMaterial", new object[] { }, 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="ob"></param>
- public static void InitStorageNoGp(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dtStorageNo = ServerHelper.GetData("com.steering.ydm.bc.FrmDeleteMatBcM.getStorageNoGp", new object[] { }, ob);
- BaseMethod.InitComboEditor(uce, dtStorageNo, "STORAGE_NAME", "STORAGE_NO");
- }
- /// <summary>
- /// 初始化下拉框仓库名称
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitStorageNo(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dtStorageNo = ServerHelper.GetData("com.steering.ydm.bc.FrmDeleteMatBcM.getStorageNo", new object[] { }, ob);
- BaseMethod.InitComboEditor(uce, dtStorageNo, "STORAGE_NAME", "STORAGE_NO");
- }
- /// <summary>
- /// 初始化下拉框装卸点
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitUnLoad(UltraComboEditor uce, OpeBase ob,string plineCode)
- {
- DataTable dtStorageNo = ServerHelper.GetData("com.steering.Demand.sever.FrmBcM.getUnLoad", new object[] { plineCode }, ob);
- BaseMethod.InitComboEditor(uce, dtStorageNo, "UNLOADING_DESC", "UNLOADING_CODE");
- }
- /// <summary>
- /// 初始化下拉框需求单位
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitDemandUser(UltraComboEditor uce, OpeBase ob,string[] plineCode)
- {
- DataTable dtStorageNo = ServerHelper.GetData("com.steering.Demand.sever.FrmBcM.getDemandUser", new object[] { plineCode }, ob);
- BaseMethod.InitComboEditor(uce, dtStorageNo, "PLINE_NAME", "PLINE_CODE");
- }
- /// <summary>
- /// 初始化下拉框工序判定结果
- /// </summary>
- /// <param name="uce"></param>
- /// <param name="ob"></param>
- public static void InitJudgeResult(UltraComboEditor uce, OpeBase ob)
- {
- DataTable dtStorageNo = ServerHelper.GetData("com.steering.ydm.bc.FrmApplyCode.getJudgeResult", new object[] { }, ob);
- BaseMethod.InitComboEditor(uce, dtStorageNo, "BASENAME", "BASECODE");
- }
-
- /// <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.pss.ydm.base.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,string processNo, OpeBase ob)
- //{
- // string[] arr = null;
- // DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Common.ComLgValidDataPurviewIds.getLgPermissions", new object[] { validDataPurviewIds, processNo }, 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="validDataPurviewIds">数据权限</param>
- /// <param name="ob"></param>
- /// <returns>字符串数组</returns>
- public static string[] getPCodePline(string[] arr1,OpeBase _ob)
- {
- string[] arr = null;
- DataTable dt = ServerHelper.GetData("com.steering.ydm.bc.FrmFilpOutStorage.getPCode", 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] { "" };
- }
- }
- public static string[] InitDropPlineCodePower(UltraComboEditor ugc, string[] validDataPurviewIds, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.ydm.bc.FrmFilpOutStorage.getPCode", new object[] { validDataPurviewIds }, ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- ugc.DataSource = dt;
- ugc.ValueMember = "PLINE_CODE";
- ugc.DisplayMember = "PLINE_NAME";
- string[] plineArr = new string[dt.Rows.Count];
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- plineArr[i] = dt.Rows[i]["PLINE_CODE"].ToString();
- }
- return plineArr;
- }
- else
- {
- return null;
- }
- }
- public static string[] InitDropPlineCodePower(List<UltraComboEditor> ugc, string[] validDataPurviewIds, OpeBase ob)
- {
- DataTable dt = ServerHelper.GetData("com.steering.ydm.bc.FrmFilpOutStorage.getPCode", new object[] { validDataPurviewIds }, ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- ugc.ForEach(p =>
- {
- p.DataSource = dt;
- p.ValueMember = "PLINE_CODE";
- p.DisplayMember = "PLINE_NAME";
- });
-
- string[] plineArr = new string[dt.Rows.Count];
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- plineArr[i] = dt.Rows[i]["PLINE_CODE"].ToString();
- }
- return plineArr;
- }
- else
- {
- return null;
- }
- }
- /// <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>
- /// 键盘按下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 { }
- }
- }
- }
|