using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using Core.Mes.Client.Comm.Control; using com.steering.mes.mcp.entity; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Tool; using Core.Mes.Client.Comm.Server; using Core.StlMes.Client.Mcp.Control.Entity; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinEditors; namespace Core.StlMes.Client.Mcp.Control { public partial class DetectResultControl : UserControl { public DetectResultControl() { InitializeComponent(); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); ScrappedList = new DataSourceList(); ScrappedLenList = new DataSourceList(); SuspiciousList = new DataSourceList(); } public OpeBase Ob { get; set; } public void SetFont(Font f1) { ultraGrid1.Font = f1; foreach (UltraGridColumn UltraGridColumn in ultraGrid1.DisplayLayout.Bands[0].Columns) { UltraGridColumn.Header.Appearance.FontData.Bold = f1.Bold ? DefaultableBoolean.True : DefaultableBoolean.False; UltraGridColumn.Header.Appearance.FontData.Name = f1.Name; UltraGridColumn.Header.Appearance.FontData.SizeInPoints = f1.SizeInPoints; } } public string gx { get; set; } /// /// 废品 /// public List ScrappedList { get; set; } /// /// 废品总米长 /// public List ScrappedLenList { get; set; } /// /// 可疑 /// public List SuspiciousList { get; set; } public HttCrackDetectionEtEntity Value { get { var list = httCrackDetectionEtEntityBindingSource.DataSource as List; return (list == null) || !list.Any() ? new HttCrackDetectionEtEntity() : list.FirstOrDefault(); } set { if (value == null) { httCrackDetectionEtEntityBindingSource.DataSource = new List { new HttCrackDetectionEtEntity() }; ScrappedList = new List(); ScrappedLenList = new List(); SuspiciousList = new List(); } else { httCrackDetectionEtEntityBindingSource.DataSource = new List { value}; if ((Ob == null) || (Ob.MainUrl == "")) return; var dt1 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMcpLoading.getPerson", new object[] {ultraGrid1.Rows[0].Cells["ColGroup"].Text, Value.PlineName}, Ob); //如果是“”里面添加的是条件 name.DataSource = dt1; name.DisplayMember = "NAME"; //name.ValueMember = "ID"; YdmBaseClass.SetComboItemHeight(name); if (!string.IsNullOrEmpty(value.ResultNo) && value.EwasteNum > 0 && value.EwasteNum != ScrappedList.Count) { ScrappedList = EntityHelper.GetData( "com.steering.mes.mcp.heatTreatment.FrmHttBugD.doQueryScrapNum", new object[] { "", value.ResultNo }, Ob); } if (!string.IsNullOrEmpty(value.ResultNo) && value.DubiousNum > 0 && value.DubiousNum != SuspiciousList.Count) { SuspiciousList = EntityHelper.GetData( "com.steering.mes.mcp.heatTreatment.FrmHttBugD.doQueryAlarmNum", new object[] { "", value.ResultNo }, Ob); } decimal TotalLen; decimal.TryParse(value.EwasteReason, out TotalLen); if (!string.IsNullOrEmpty(value.ResultNo) && TotalLen > 0 && TotalLen != ScrappedLenList.Sum(p => p.TotalLen ?? 0)) { ScrappedLenList = EntityHelper.GetData( "com.steering.mes.mcp.heatTreatment.FrmHttBugD.doQueryScrapLen", new object[] { "", value.ResultNo }, Ob); } if (value.EwasteNum == null || value.EwasteNum == 0) { ScrappedList = new List(); } if (value.DubiousNum == null || value.DubiousNum == 0) { SuspiciousList = new List(); } if (value.EwasteReason == "" || !value.EwasteReason.TryParseDouble()) { ScrappedLenList = new List(); } if (value.PlineCode != "C015" && value.PlineCode != "C074") { ultraGrid1.DisplayLayout.Bands[0].Columns["MachineNo"].Hidden = true; } else { ultraGrid1.DisplayLayout.Bands[0].Columns["MachineNo"].Hidden = false; } } ultraGrid1.Refresh(); } } public void DisableFiltering() { ultraGrid1.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False; foreach (var ugc in ultraGrid1.DisplayLayout.Bands[0].Columns) ugc.SortIndicator = SortIndicator.Disabled; } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { ultraGrid1.UpdateData(); /* if (e.Cell.Column.Key.Equals("ColGroup")) { var dt1 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMcpLoading.getPerson", new object[] { e.Cell.Row.Cells["ColGroup"].Text, Value.PlineName }, Ob); //如果是“”里面添加的是条件 name.DataSource = dt1; name.DisplayMember = "NAME"; //name.ValueMember = "ID"; YdmBaseClass.SetComboItemHeight(name); } ultraGrid1.Refresh();*/ } private void craftImg_EditorButtonClick(object sender, EditorButtonEventArgs e) { if (Value.HeatPlanNo == null) return; if (Value.PlineCode == null) return; var matfrm = new FrmScrapHttNew(Ob, new List(), ScrappedList, false, Value.HeatPlanNo, int.Parse(Value.ProcessSeq.ToString3()),"600405",Value.BatchNo); matfrm.ShowDialog(); if (matfrm.DialogResult == DialogResult.OK) { ScrappedList = matfrm.ScrappedList; Value.EwasteNum = ScrappedList.Sum(p => p.DefFillNum); // SuspiciousList = matfrm.SuspiciousList; // Value.DubiousNum = SuspiciousList.Sum(p => p.DefFillNum); Value.EwasteWt = ScrappedList.Sum(p => p.DefFillWt); Value.EwasteReason = ScrappedList.Any() ? ScrappedList.Select(p => p.DefFillName).Distinct().Aggregate((a, b) => (string.IsNullOrEmpty(a) ? "" : (a + ",")) + b) : "/"; } Value.EwasteNum = Value.EwasteNum ?? 0; Value.EpassNum = Value.TestingNum - Value.EwasteNum; // Value.DubiousNum = Value.DubiousNum ?? 0; ultraGrid1.PerformAction(UltraGridAction.ExitEditMode); ultraGrid1.UpdateData(); } private void ultraTextEditor1_EditorButtonClick(object sender, EditorButtonEventArgs e) { if (Value.HeatPlanNo == null) return; if (Value.PlineCode == null) return; var matfrm = new FrmHttScrapLen(Ob, ScrappedLenList, Value.HeatPlanNo, int.Parse(Value.ProcessSeq.ToString3()), Value.BatchNo); matfrm.ShowDialog(); if (matfrm.DialogResult == DialogResult.OK) { ScrappedLenList = matfrm.ScrappedLenList; Value.TotalFailLen = (ScrappedLenList.Any() ? ScrappedLenList.Sum(p => p.TotalLen ?? 0) : 0); } ultraGrid1.PerformAction(UltraGridAction.ExitEditMode); ultraGrid1.UpdateData(); } private void ultraTextEditor2_EditorButtonClick(object sender, EditorButtonEventArgs e) { if (Value.HeatPlanNo == null) return; if (Value.PlineCode == null) return; var matfrm = new FrmScrapHttNew(Ob, SuspiciousList, new List(), true, Value.HeatPlanNo, int.Parse(Value.ProcessSeq.ToString3()), "600405", Value.BatchNo); matfrm.ShowDialog(); if (matfrm.DialogResult == DialogResult.OK) { // ScrappedList = matfrm.ScrappedList; // Value.EwasteNum = ScrappedList.Sum(p => p.DefFillNum); SuspiciousList = matfrm.SuspiciousList; Value.DubiousNum = SuspiciousList.Sum(p => p.DefFillNum); Value.FtestingReason = SuspiciousList.Any() ? SuspiciousList.Select(p => p.DefFillName).Distinct().Aggregate((a, b) => (string.IsNullOrEmpty(a)?"":(a + ",")) + b) : "/"; } // Value.EwasteNum = Value.EwasteNum ?? 0; Value.DubiousNum = Value.DubiousNum ?? 0; Value.FtestingNum = Value.DubiousNum; ultraGrid1.PerformAction(UltraGridAction.ExitEditMode); ultraGrid1.UpdateData(); } } }