using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Linq; using System.Windows.Forms; using com.steering.mes.mcp.entity; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Control.Common; using Core.StlMes.Client.Mcp.Control.Entity; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.Mcp.Treatment.HeatTreatment { public partial class FrmReportDefault : FrmBase { public FrmReportDefault() { InitializeComponent(); uceMachineNo.SelectedIndex = 0; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); string[] plineCodes = comm.InitDropPlinePower(CustomInfo, ucePlinCode, ValidDataPurviewIds, ob); if (plineCodes.Length <= 0) { MessageBox.Show("无数据权限"); this.Close(); } commonCrackDetection1.Init(ob,null); ucePlinCode.SelectedIndex = 0; ucReportNo.SelectedIndex = 0; EntityHelper.ShowGridCaption(ugDefault.DisplayLayout.Bands[0]); DataTable dt1 = ServerHelper.GetData( "com.steering.mes.mcp.heatTreatment.FrmReportDefault.getReportColumns", new object[] { }, ob); var dt = ServerHelper.GetData( "com.steering.mes.mcp.collarMaterial.ComBaseInfo.getBaseInfo", new object[] { "4097" }, ob); if (dt != null && dt.Rows.Count > 0 && dt1!=null) { foreach (DataRow row in dt.Rows) { DataRow datarow = dt1.NewRow(); datarow[0] = "PROBE_QTY_" + row["BASECODE"]; datarow[1] = "[" + row["BASENAME"] + "]探头个数"; dt1.Rows.Add(datarow); DataRow datarow1 = dt1.NewRow(); datarow1[0] = "PROBE_PARAMETERS_" + row["BASECODE"]; datarow1[1] = "[" + row["BASENAME"] + "]探头参数"; dt1.Rows.Add(datarow1); } } cmbReportColumn.DataSource = dt1; cmbReportColumn.DisplayMember = "COMMENTS"; cmbReportColumn.ValueMember = "COLUMN_NAME"; } public override void ToolBar_Click(object sender, string ToolbarKey) { //base.ToolBar_Click(sender, ToolbarKey); switch (ToolbarKey) { case "DoQuery": Query(); break; case "DoSave": DoSave(); break; case "DoDelete": DoReturn(); break; case "DoUpdate": DoUpdate(); break; case "DoClose": Close(); break; case "Copy": Copy(); break; } } private void Copy() { var matfrm = new FrmReportDefaultCopy(ob, ucePlinCode.SelectedItem.DataValue.ToString(), ucReportNo.SelectedItem.DataValue.ToString2(), uceMachineNo.SelectedItem.DataValue.ToString2()); matfrm.ShowDialog(); if (matfrm.DialogResult == DialogResult.OK) { Query(); } } private void DoUpdate() { List list = httReportDefaultEntityBindingSource.DataSource as List; if (list == null || !list.Any()) return; list = list.Where(p => p.Chk && !p.isNew).ToList(); if (!list.Any()) { MessageBox.Show("请选择需要修改的行"); return; } var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.FrmReportDefault"; ccp.MethodName = "UpdateDefault"; ccp.ServerParams = new object[] { list.Select(JSONFormat.Format).ToList() }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("修改成功!")) { Query(); } } } private void DoReturn() { List list = httReportDefaultEntityBindingSource.DataSource as List; if (list == null || !list.Any()) return; list = list.Where(p => p.Chk && !p.isNew).ToList(); if (!list.Any()) { MessageBox.Show("请选择需要删除的行"); return; } var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.FrmReportDefault"; ccp.MethodName = "DeleteDefault"; ccp.ServerParams = new object[] { list.Select(JSONFormat.Format).ToList() }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("删除成功!")) { Query(); } } } private void DoSave() { List list = httReportDefaultEntityBindingSource.DataSource as List; if (list == null || !list.Any()) return; list = list.Where(p => p.Chk && p.isNew).ToList(); if (!list.Any()) { MessageBox.Show("请选择需要新增的行"); return; } var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.FrmReportDefault"; ccp.MethodName = "AddDefault"; ccp.ServerParams = new object[] { list.Select(JSONFormat.Format).ToList() }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("新增成功!")) { Query(); } } } private void Query() { List list = EntityHelper.GetData( "com.steering.mes.mcp.heatTreatment.FrmReportDefault.Query", new object[] { ucePlinCode.SelectedItem.DataValue.ToString(), ucReportNo.SelectedItem.DataValue.ToString2(), uceMachineNo.SelectedItem.DataValue.ToString2()}, ob); httReportDefaultEntityBindingSource.DataSource = list; commonCrackDetection1.SettingModeValue(list, ucePlinCode.SelectedItem.DataValue.ToString()); commHelper.RefreshAndAutoSize(ugDefault); } private void ugDefault_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { try { ugDefault.UpdateData(); HttReportDefaultEntity HttReportDefaultEntity = e.Cell.Row.ListObject as HttReportDefaultEntity; commonCrackDetection1.SetValue(HttReportDefaultEntity.ReportNo, HttReportDefaultEntity,e.Cell.Column.Key); if (e.Cell.Column.Key != "Chk") HttReportDefaultEntity.Chk = true; } catch (Exception) { } } private void utProbe_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { TextEdit TextEdit = new TextEdit() {data = ugDefault.ActiveCell.Text}; TextEdit.ShowDialog(); if (TextEdit.DialogResult == DialogResult.OK) { ugDefault.ActiveCell.Value = TextEdit.data; ugDefault_CellChange(null, new CellEventArgs(ugDefault.ActiveCell)); } } private void egbView_ExpandedStateChanged(object sender, EventArgs e) { } private void utUsed_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { HttReportDefaultEntity HttReportDefaultEntity = ugDefault.ActiveRow.ListObject as HttReportDefaultEntity; if(HttReportDefaultEntity==null) return; SelectEdit SelectEdit = new SelectEdit(ob, HttReportDefaultEntity.ReportColumn == "PROBE_NAME" || HttReportDefaultEntity.ReportColumn == "STANDARD_NAME", HttReportDefaultEntity.ReportColumn == "PROBE_NAME"?"4097": HttReportDefaultEntity.ReportColumn == "STANDARD_NAME"? "4021":HttReportDefaultEntity.DroplistDefult, HttReportDefaultEntity.DroplistUsed.Split(';').ToList()); SelectEdit.ShowDialog(); if (SelectEdit.DialogResult == DialogResult.OK) { ugDefault.ActiveCell.Value = SelectEdit.Codes; ugDefault_CellChange(null, new CellEventArgs(ugDefault.ActiveCell)); } } private void ugDefault_AfterRowInsert(object sender, RowEventArgs e) { e.Row.Cells["isNew"].Value = true; e.Row.Appearance.BackColor = Color.LightGreen; e.Row.Cells["PlineCode"].Value = ucePlinCode.SelectedItem.DataValue; e.Row.Cells["ReportNo"].Value = ucReportNo.SelectedItem.DataValue.ToString2(); e.Row.Cells["ReportNo"].Activation = Activation.AllowEdit; e.Row.Cells["ReportNo"].IgnoreRowColActivation = true; e.Row.Cells["ReportColumn"].Activation = Activation.AllowEdit; e.Row.Cells["ReportColumn"].IgnoreRowColActivation = true; e.Row.Cells["MachineNo"].Value = uceMachineNo.SelectedItem.DataValue.ToString(); } } }