using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using com.steering.mes.mcp.entity; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Control; using Core.StlMes.Client.Mcp.Control.Common; using Core.StlMes.Client.Mcp.Control.Entity; using Core.StlMes.Client.Mcp.Mch.MchResult; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.Mcp.Mch { public partial class FrmThreadingResult : FrmMchBase { public FrmThreadingResult() { InitializeComponent(); mchControlBase1 = new ThreadingMachiningControl() { Dock = DockStyle.Fill }; plnEdit.Controls.Add(mchControlBase1); mchControlBase1.ultraGrid1.CellChange+= (sender, args) => { if (args.Cell.Column.Key == "MachineNo") { ChangeData(Value as MchThreaderResultEntity); } } ; } protected override UltraGridRow ActitveResultRow { get { return CrackDetectGrid.ActiveRow; } } protected override object Value { get { return (mchControlBase1 as ThreadingMachiningControl).Value; } } protected override void OnLoad(EventArgs e) { base.OnLoad(e); EntityHelper.ShowGridCaption(CrackDetectGrid.DisplayLayout.Bands[0]); base.ultraGrid1.DisplayLayout.Bands[0].Columns["ActCount"].Hidden = true; base.ultraGrid1.DisplayLayout.Bands[0].Columns["ActWeight"].Hidden = true; base.ultraGrid1.DisplayLayout.Bands[0].Columns["BatchGroudNo"].Hidden = true; CrackDetectGrid.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False; CrackDetectGrid.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default; ultraOptionSet2.Visible = false; } protected override void DoAdd() { if (ActiveRow != null) { if (MessageUtil.ShowYesNoAndQuestion("是否增加实绩?") == DialogResult.No) return; var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.Mch.FrmThreadingResult"; ccp.MethodName = "DoAdd"; ccp.ServerParams = new object[] { JSONFormat.Format(Value), Gx, mchControlBase1.ScrappedList.Select(JSONFormat.Format).ToList(), mchControlBase1.SuspiciousList.Select(JSONFormat.Format).ToList() }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("新增成功!")) { Query(); } } } } protected override void DoDelete() { { if (ActiveRow != null && ActitveResultRow != null) { if (MessageUtil.ShowYesNoAndQuestion("是否删除实绩?") == DialogResult.No) return; var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.Mch.FrmThreadingResult"; ccp.MethodName = "DoDelete"; ccp.ServerParams = new object[] { JSONFormat.Format(ActitveResultRow.ListObject), Gx }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("删除成功!")) Query(); } } } } protected override void GetResultData() { base.GetResultData(); mchThreaderResultEntityBindingSource.DataSource = EntityHelper.GetData( "com.steering.mes.mcp.Mch.FrmThreadingResult.getQueryExpandResult", new object[] { ActiveRow.HeatPlanNo, ActiveRow.BatchNo }, ob); commHelper.RefreshAndAutoSize(CrackDetectGrid); if (ActiveRow == null) return; var result = new MchThreaderResultEntity { HeatPlanNo = ActiveRow.HeatPlanNo, JudgeStoveNo = ActiveRow.JudgeStoveNo, BatchNo = ActiveRow.BatchNo, PlineCode = ActiveRow.PlineCode, PlineName = ActiveRow.PlineName, FailNum = 0, FailWt = 0, ProShift = UserInfo.GetUserOrder(), ProGroup = UserInfo.GetUserGroup(), ProUser = UserInfo.GetUserName(), ProTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), MachineNo = 1 }; ChangeData(result); } private void ChangeData(MchThreaderResultEntity data) { if (ActiveRow == null) return; //需要经过探伤的支数 int NeedTest = mchControlBase1.OkPort.Count; List ProductionList = mchThreaderResultEntityBindingSource.DataSource as List; //已经录过当前探伤种类的支数 int TestedNum = (int)ProductionList.Where(p =>p.MachineNo == data.MachineNo).Sum(p => p.ProNum); /* //不属于该种类的废品( 该种类的废品已经包含在TestedNum) int WasteNum = (int) ProductionList.Sum(p => (p.FailNum ?? 0));*/ data.ProNum = NeedTest - TestedNum; if (data.ProNum <= 0) { //返线到前工序的 int OffNum = GetReturnNum(); data.ProNum = data.ProNum + OffNum; if (data.ProNum < 0) { data.ProNum = 0; } } var ThreadingMachiningControl = mchControlBase1 as ThreadingMachiningControl; if (ThreadingMachiningControl == null) return; ThreadingMachiningControl.Value = data; } } }