using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using com.steering.mes.mcp.entity; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Control.Entity; using Core.StlMes.Client.Mcp.Control.Machining; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.Mcp.Control { public partial class ChamferingControl : MchControlBase { public ChamferingControl() { InitializeComponent(); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); gx = "701309"; Value = null; } protected override string ScrapCode { get { return "701509"; } } public List Detail { get; set; } public MchChamferingResultEntity Value { get { var list = mchChamferingResultEntityBindingSource.DataSource as List; return (list == null) || !list.Any() ? new MchChamferingResultEntity() : list.FirstOrDefault(); } set { if (value == null) { mchChamferingResultEntityBindingSource.DataSource = new List { new MchChamferingResultEntity() }; ScrappedList = new List(); Detail = new List(); } else { value.ProWt = comm.GetWeight(PortHttBatchSampleResultEntitys, gx, (int)(value.ProNum ?? 0), (int)(PlnZyJgxCEntity.ProCount ?? 0)); value.QualifiedWt = comm.GetWeight(PortHttBatchSampleResultEntitys, gx, (int)(value.QualifiedNum ?? 0), (int)(PlnZyJgxCEntity.ProCount ?? 0)); mchChamferingResultEntityBindingSource.DataSource = new List { value.Clone() }; if (_plineCode != Value.PlineCode) { Names = EntityHelper.GetData( "com.steering.mes.mcp.heatTreatment.FrmHttCrackDetectResult.getHttSign", new object[] { Value.PlineCode, "8" }, Ob); name.DisplayMember = "UserName"; name.ValueMember = "UserName"; YdmBaseClass.SetComboItemHeight(name); _plineCode = Value.PlineCode; } name.DataSource = Names.Where(p => p.ColGroup == value.ProGroup).ToList(); if (value.TestRecord == null || value.TestRecord == 0) Detail = new List(); if (value.FailNum == 0) ScrappedList = new List(); //ultraGrid1.DisplayLayout.Bands[0].Columns["ProNum"].MaxValue = value.ProNum; } } } protected override void EditScrapped() { Value.FailNum = ScrappedList.Sum(p => p.FailNum); Value.FailWt = ScrappedList.Sum(p => p.FailWt); ultraGrid1.Refresh(); } private void TestRecord_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { if (PlnZyJgxCEntity == null) return; if (PlnZyJgxCEntity.HeatPlanNo == null) return; if (PlnZyJgxCEntity.PlineCode == null) return; var matfrm = new ChamferTestRecord(Detail); matfrm.ShowDialog(); if (matfrm.DialogResult == DialogResult.OK) { Detail = matfrm.Detail; Value.TestRecord = Detail.Count; } ultraGrid1.PerformAction(UltraGridAction.ExitEditMode); ultraGrid1.UpdateData(); } } }