using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Treatment.Entity; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; namespace Core.StlMes.Client.Mcp.Treatment.HeatTreatment { public partial class FrmControlShift : FrmBase { public FrmControlShift() { InitializeComponent(); } private string[] plineCode = null; private string fileName = "";//路径 private void FrmControlShift_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); plineCode = Core.StlMes.Client.Mcp.Treatment.HeatTreatment.comm.GetPlineCode(ValidDataPurviewIds, CustomInfo, ob); comm.InitDropPlinePower(CustomInfo, txtPline, this.ValidDataPurviewIds, this.ob); } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "DoQuery": QuerySinglePlan(); break; case "DoSave": doSave(); break; case "DoUpdate": doUpdate(); break; case "CancelSignature": cancelSignature(); break; case "Close": this.Close(); break; } } private void QuerySinglePlan() { List listSource = EntityHelper.GetData( "com.steering.mes.mcp.heatTreatment.HttControlShift.doQuery", new object[] { plineCode }, this.ob); HttControlShiftEntitybindingSource1.DataSource = listSource; GridHelper.RefreshAndAutoSize(this.ultraGrid1); foreach (UltraGridRow ugr in ultraGrid1.Rows) { ugr.Cells["PlineCode"].Appearance.BackColor = Color.Transparent; ugr.Cells["PlineCode"].Appearance.BackHatchStyle = BackHatchStyle.Default; ugr.Cells["PlineCode"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly; ugr.Cells["proBc"].Appearance.BackColor = Color.Transparent; ugr.Cells["proBc"].Appearance.BackHatchStyle = BackHatchStyle.Default; ugr.Cells["proBc"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly; } } /// /// 新增 /// private void doSave() { this.ultraGrid1.UpdateData(); ArrayList list = new ArrayList(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkRows.Count() == 0) { MessageUtil.ShowTips("请勾选要新增的信息"); return; } foreach (UltraGridRow row in checkRows) { HttControlShiftEntity hsEntity = (HttControlShiftEntity)row.ListObject; if (hsEntity.PlineCode.Equals("")) { MessageUtil.ShowTips("产线不能为空"); return; } if (hsEntity.ProBc.Equals("")) { MessageUtil.ShowTips("班次不能为空"); return; } //else if (hsEntity.ProBc.Equals("早")) //{ // hsEntity.ProBc = "1"; //} //else if (hsEntity.ProBc.Equals("中")) //{ // hsEntity.ProBc = "2"; //} //else if (hsEntity.ProBc.Equals("晚")) //{ // hsEntity.ProBc = "3"; //} if (hsEntity.LastBc.Equals("")) { MessageUtil.ShowTips("上一班次不能为空"); return; } //else if (hsEntity.LastBc.Equals("早")) //{ // hsEntity.LastBc = "1"; //} //else if (hsEntity.LastBc.Equals("中")) //{ // hsEntity.LastBc = "2"; //} //else if (hsEntity.LastBc.Equals("晚")) //{ // hsEntity.LastBc = "3"; //} string httEntity = JSONFormat.Format(hsEntity); list.Add(httEntity); DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttControlShift.getSameData", new object[] { hsEntity.PlineCode, hsEntity.ProBc}, ob); if (dt.Rows.Count > 0) { MessageUtil.ShowTips("已存在数据,不能进行此操作!"); return; } } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttControlShift"; ccp.MethodName = "doSave"; ccp.ServerParams = new object[] { list }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("新增成功!")) { QuerySinglePlan(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 修改 /// private void doUpdate() { this.ultraGrid1.UpdateData(); ArrayList list = new ArrayList(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkRows.Count() == 0) { MessageUtil.ShowTips("请勾选要修改的信息"); return; } foreach (UltraGridRow row in checkRows) { HttControlShiftEntity hsEntity = (HttControlShiftEntity)row.ListObject; if (hsEntity.PlineCode.Equals("")) { MessageUtil.ShowTips("产线不能为空"); return; } if (hsEntity.ProBc.Equals("")) { MessageUtil.ShowTips("班次不能为空"); return; } //else if (hsEntity.ProBc.Equals("早")) //{ // hsEntity.ProBc = "1"; //} //else if (hsEntity.ProBc.Equals("中")) //{ // hsEntity.ProBc = "2"; //} //else if (hsEntity.ProBc.Equals("晚")) //{ // hsEntity.ProBc = "3"; //} if (hsEntity.LastBc.Equals("")) { MessageUtil.ShowTips("上一班次不能为空"); return; } //else if (hsEntity.LastBc.Equals("早")) //{ // hsEntity.LastBc = "1"; //} //else if (hsEntity.LastBc.Equals("中")) //{ // hsEntity.LastBc = "2"; //} //else if (hsEntity.LastBc.Equals("晚")) //{ // hsEntity.LastBc = "3"; //} string httEntity = JSONFormat.Format(hsEntity); list.Add(httEntity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttControlShift"; ccp.MethodName = "doUpdate"; ccp.ServerParams = new object[] { list }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("修改成功!")) { QuerySinglePlan(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 删除 /// private void cancelSignature() { this.ultraGrid1.UpdateData(); ArrayList list = new ArrayList(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkRows.Count() == 0) { MessageUtil.ShowTips("请勾选要删除的信息"); return; } foreach (UltraGridRow row in checkRows) { HttControlShiftEntity hsEntity = (HttControlShiftEntity)row.ListObject; if (hsEntity.PlineCode.Equals("")) { MessageUtil.ShowTips("产线不能为空"); return; } if (hsEntity.ProBc.Equals("")) { MessageUtil.ShowTips("班次不能为空"); return; } else if (hsEntity.ProBc.Equals("早")) { hsEntity.ProBc = "1"; } else if (hsEntity.ProBc.Equals("中")) { hsEntity.ProBc = "2"; } else if (hsEntity.ProBc.Equals("晚")) { hsEntity.ProBc = "3"; } if (hsEntity.LastBc.Equals("")) { MessageUtil.ShowTips("上一班次不能为空"); return; } else if (hsEntity.LastBc.Equals("早")) { hsEntity.LastBc = "1"; } else if (hsEntity.LastBc.Equals("中")) { hsEntity.LastBc = "2"; } else if (hsEntity.LastBc.Equals("晚")) { hsEntity.LastBc = "3"; } string httEntity = JSONFormat.Format(hsEntity); list.Add(httEntity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttControlShift"; ccp.MethodName = "doDelete"; ccp.ServerParams = new object[] { list }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("删除成功!")) { QuerySinglePlan(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { if (e.Cell.Column.Key == "PlineCode") { e.Cell.Row.Cells["PlineName"].Value = e.Cell.Text; } } } }