| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using CoreFS.CA06;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.ZGMil.Entity;
- using Core.Mes.Client.Comm.Server;
- using System.Windows.Documents;
- using Infragistics.Win.UltraWinEditors;
- using Infragistics.Win.UltraWinGrid;
- using Infragistics.Win;
- using System.Text.RegularExpressions;
- using System.Collections;
- using Core.Mes.Client.Comm.Format;
- namespace Core.StlMes.Client.ZGMil.Signature
- {
- public partial class FrmTubTechnological : FrmBase
- {
- public FrmTubTechnological()
- {
- InitializeComponent();
- }
- private void FrmTubTechnological_Load(object sender, EventArgs e)
- {
- EntityHelper.ShowGridCaption<MilCraftworkSetEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<MilCraftworkSetEntity>(ultraGrid2.DisplayLayout.Bands[0]);
-
- InitBase();
- }
- UltraComboEditor plineCode = new UltraComboEditor();
- UltraComboEditor station = new UltraComboEditor();
- UltraComboEditor factoryId = new UltraComboEditor();
- UltraNumericEditor numEditor = new UltraNumericEditor();
- UltraDateTimeEditor dateEditor = new UltraDateTimeEditor();
- /// <summary>
- /// 加载基础信息
- /// </summary>
- private void InitBase()
- {
- string[] arr = null;
- NativeMethodNew na = new NativeMethodNew(this.ob);
- arr = na.GetPCodePline(this.ValidDataPurviewIds);
- InitComboEditor1(plineCode, "com.steering.mes.signature.FrmTubTechnological.doQueryPline", "PLINE_CODE", this.ob, false,arr);
- BindColumn(plineCode, "PlineName", this.Controls, this.ultraGrid1, 0);
- InitComboEditor(station, "com.steering.mes.signature.FrmTubTechnological.doQueryStation", "STATION_CODE",this.ob, false);
- BindColumn(station, "StationDesc", this.Controls, this.ultraGrid1, 0);
-
- }
- /// <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.ValueMember = valueMember;
- uce.DataSource = dt;
-
- SetComboItemHeight(uce);
- }
- }
- public static void InitComboEditor2(UltraComboEditor uce, string methodId, string valueMember, OpeBase ob, string value,bool isEmpty)
- {
- DataTable dt = ServerHelper.GetData(methodId, new object[] { value }, 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.ValueMember = valueMember;
- uce.DataSource = dt;
- SetComboItemHeight(uce);
- }
- }
- public static void InitComboEditor1(UltraComboEditor uce, string methodId, string valueMember, OpeBase ob, bool isEmpty,string[] arr)
- {
- DataTable dt = ServerHelper.GetData(methodId, new object[]{arr}, 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.ValueMember = valueMember;
-
- uce.DataSource = dt;
- 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>
- /// 设置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>
- /// 重写基类方法
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- doQueryData();
- break;
- case "Add":
- doAdd();
- break;
- case"Update":
- doUpdate();
- break;
- case"Delete":
- doDelete();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 删除工艺项
- /// </summary>
- private void doDelete()
- {
- UltraGridRow urg = ultraGrid2.ActiveRow;
- if (urg == null) { MessageUtil.ShowTips("无数据!"); return; }
- this.ultraGrid2.UpdateData();
- IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
- if (checkMagRows.Count() == 0)
- {
- if (MessageUtil.ShowYesNoAndQuestion("是否作废该项所有工艺项?") == DialogResult.No)
- {
- MessageUtil.ShowTips("请选择需要作废的的工艺项!");
- return;
- }
- else
- {
- foreach (UltraGridRow row1 in ultraGrid2.Rows)
- {
- row1.Cells["CHK"].Value = true;
- }
- }
- }
- IQueryable<UltraGridRow> checkMagRows1 = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
- ArrayList parm = new ArrayList();
- foreach (UltraGridRow row in checkMagRows1)
- {
- MilCraftworkSetEntity _milCraftEntity = EntityHelper.CopyEntity<MilCraftworkSetEntity>(row.ListObject);
- string _milCraftTity = JSONFormat.Format(_milCraftEntity);
- parm.Add(_milCraftTity);
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认作废工艺项?") == DialogResult.No)
- {
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.signature.FrmTubTechnological";
- ccp.MethodName = "doDeleteData";
- ccp.ServerParams = new object[] { parm };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("作废成功!"))
- {
- doQueryData();
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- /// <summary>
- /// 修改工艺项
- /// </summary>
- private void doUpdate()
- {
- this.ultraGrid2.UpdateData();
- IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
- if (checkMagRows.Count() == 0)
- {
- MessageUtil.ShowTips("请选择需要修改的的工艺项!");
- return;
- }
- ArrayList parm = new ArrayList();
- foreach (UltraGridRow row in checkMagRows)
- {
- if (row.Cells["FactorName"].Text.ToString() == "" || row.Cells["FactorVal"].Text.ToString() == "")
- {
- MessageUtil.ShowTips("工艺项/工艺参数都不能为空!");
- return;
- }
- MilCraftworkSetEntity _milCraftEntity = EntityHelper.CopyEntity<MilCraftworkSetEntity>(row.ListObject);
- _milCraftEntity.FactorId = row.Cells["FactorName"].Value.ToString();
- _milCraftEntity.FactorName = row.Cells["FactorName"].Text.Trim();
- _milCraftEntity.UpdateName = this.UserInfo.GetUserName();
- string _milCraftTity = JSONFormat.Format(_milCraftEntity);
- parm.Add(_milCraftTity);
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否修改工艺项?") == DialogResult.No)
- {
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.signature.FrmTubTechnological";
- ccp.MethodName = "doUpdateData";
- ccp.ServerParams = new object[] {parm};
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("修改成功!"))
- {
- doQueryData();
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- /// <summary>
- /// 查询已维护的工艺参数
- /// </summary>
- private void doQueryData()
- {
- string[] arr = null;
- NativeMethodNew na = new NativeMethodNew(this.ob);
- arr = na.GetPCodePline(this.ValidDataPurviewIds);
- List<MilCraftworkSetEntity> listSource = EntityHelper.GetData<MilCraftworkSetEntity>("com.steering.mes.signature.FrmTubTechnological.doQueryData", new object[] { arr }, ob);
- MilCraftworkSetEntitybindingSource.DataSource = listSource;
- }
- /// <summary>
- /// 维护工艺参数
- /// </summary>
- private void doAdd()
- {
- this.ultraGrid1.UpdateData();
- this.ultraGrid2.UpdateData();
-
- UltraGridRow uRow = this.ultraGrid1.ActiveRow;
- if (!(uRow.Cells["PlineName"].Text.ToString() != "" && uRow.Cells["StationDesc"].Text.ToString() != "" && uRow.Cells["ClassName"].Text.Trim() != ""))
- {
- MessageUtil.ShowTips("机组/工序点/版本号都不允许为空!");
- return;
- }
- List<string> ss = new List<string>();
- ArrayList list = new ArrayList();
- MilCraftworkSetEntity milCraftEntity = EntityHelper.CopyEntity<MilCraftworkSetEntity>(uRow.ListObject);
- if (milCraftEntity.PlineCode.Equals(""))
- {
- milCraftEntity.PlineCode = uRow.Cells["PlineName"].Value.ToString();
- milCraftEntity.PlineName = uRow.Cells["PlineName"].Text.Trim();
- milCraftEntity.StationCode = uRow.Cells["StationDesc"].Value.ToString();
- milCraftEntity.StationDesc = uRow.Cells["StationDesc"].Text.Trim();
- milCraftEntity.CreateName = this.UserInfo.GetUserName();
- }
- else
- {
- milCraftEntity.CreateName = this.UserInfo.GetUserName();
- }
- string milCraftTity = JSONFormat.Format(milCraftEntity);
- list.Add(milCraftTity);
- IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
- if (checkMagRows.Count() == 0)
- {
- MessageUtil.ShowTips("请选择需要维护的工艺项!");
- return;
- }
- ArrayList parm = new ArrayList();
- foreach(UltraGridRow row in checkMagRows)
- {
- if (row.Cells["FactorName"].Text.ToString() == "" || row.Cells["FactorVal"].Text.ToString() == "")
- {
- MessageUtil.ShowTips("工艺项/工艺参数都不能为空!");
- return;
- }
- MilCraftworkSetEntity _milCraftEntity = EntityHelper.CopyEntity <MilCraftworkSetEntity>(row.ListObject);
- _milCraftEntity.FactorId = row.Cells["FactorName"].Value.ToString();
- _milCraftEntity.FactorName = row.Cells["FactorName"].Text.Trim();
- string _milCraftTity = JSONFormat.Format(_milCraftEntity);
- parm.Add(_milCraftTity);
- if (ss.Contains(_milCraftEntity.FactorName.ToString()))
- {
- MessageUtil.ShowTips("已选择相同工艺项,不允许重复!");
- return;
- }
- else
- {
- ss.Add(_milCraftEntity.FactorName.ToString());
- }
- }
- if (!getCraftSet(uRow.Cells["PlineName"].Value.ToString2(), uRow.Cells["StationDesc"].Value.ToString2(), uRow.Cells["ClassName"].Text.Trim()))
- {
- MessageUtil.ShowTips("已存在该版本名称,不允许重复!");
- return;
- }
-
- if (MessageUtil.ShowYesNoAndQuestion("是否维护工艺参数?") == DialogResult.No)
- {
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.signature.FrmTubTechnological";
- ccp.MethodName = "doAdd";
- ccp.ServerParams = new object[] {list,parm };
- ccp = ob.ExecuteNonQuery(ccp,CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("维护成功!"))
- {
- doQueryData();
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- /// <summary>
- /// 判断是否已有相同产线版本
- /// </summary>
- /// <returns></returns>
- private bool getCraftSet(string plineCode,string stationId,string className)
- {
- DataTable ds = ServerHelper.GetData("com.steering.mes.signature.FrmTubTechnological.getCraftSet", new object[] { plineCode, stationId, className }, ob);
- if (ds.Rows.Count > 0)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
-
-
- private void doQueryData(string className,string stationCode,string plineCode)
- {
- List<MilCraftworkSetEntity> listSource = EntityHelper.GetData<MilCraftworkSetEntity>("com.steering.mes.signature.FrmTubTechnological.doQuery", new object[] { className, stationCode, plineCode }, ob);
- MilCraftworkSetEntity1bindingSource.DataSource = listSource;
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- doQueryData(this.ultraGrid1.ActiveRow.Cells["ClassName"].Value.ToString(), this.ultraGrid1.ActiveRow.Cells["stationCode"].Value.ToString(), this.ultraGrid1.ActiveRow.Cells["PlineCode"].Value.ToString());
- }
- private void ultraGrid2_CellChange(object sender, CellEventArgs e)
- {
- ultraGrid2.UpdateData();
- UltraGridRow ugr = this.ultraGrid2.ActiveRow;
- string factorId = "";
- if (e.Cell.Column.Key.Equals("FactorName"))
- {
- factorId = this.ultraGrid2.ActiveRow.Cells["FactorName"].Value.ToString();
- DataTable ds = ServerHelper.GetData("com.steering.mes.signature.FrmTubTechnological.doQueryType", new object[] { factorId }, ob);
- if (ds.Rows.Count > 0)
- {
- if (ds.Rows[0]["COLUMN_TYPE"].ToString() == "D")
- {
- this.ultraGrid2.ActiveRow.Cells["FactorVal"].Value = "";
- ugr.Cells["FactorVal"].EditorComponent = numEditor;
- numEditor.NumericType = NumericType.Decimal;
- numEditor.MaskInput = "nnnnn.nnn";
- }
- else if (ds.Rows[0]["COLUMN_TYPE"].ToString() == "T")
- {
- this.ultraGrid2.ActiveRow.Cells["FactorVal"].Value = "";
- ugr.Cells["FactorVal"].EditorComponent = dateEditor;
- dateEditor.FormatString = "yyyy-MM-dd HH:mm:ss";
- }
- else
- {
- this.ultraGrid2.ActiveRow.Cells["FactorVal"].Value = "";
- ugr.Cells["FactorVal"].EditorComponent = null;
- }
- }
- }
- }
- private void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- this.ultraGrid1.UpdateData();
- if (e.Cell.Column.Key == "StationDesc")
- {
- InitComboEditor2(factoryId, "com.steering.mes.signature.FrmTubTechnological.doQueryFactor", "FACTOR_ID",this.ob, this.ultraGrid1.ActiveRow.Cells["StationDesc"].Value.ToString2(), false);
- BindColumn(factoryId, "FactorName", this.Controls, this.ultraGrid2, 0);
- }
- }
- }
- }
|