using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Control.Entity; using Core.StlMes.Client.Mcp.Control.Machining; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.Mcp.Control { public partial class RemanenceControl : MchControlBase { public RemanenceControl() { InitializeComponent(); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); Detail = new List(); gx = "701314"; Value = null; } public List Detail { get; set; } protected override string ScrapCode { get { return "/"; } } public bool UpdateMode { get { return ultraGrid1.DisplayLayout.Bands[0].Columns["ProNum"].CellActivation == Activation.ActivateOnly; } set { ultraGrid1.DisplayLayout.Bands[0].Columns["ProNum"].CellActivation = value ? Activation.ActivateOnly : Activation.AllowEdit; ultraGrid1.DisplayLayout.Bands[0].Columns["BatchNo"].CellActivation = value ? Activation.ActivateOnly : Activation.AllowEdit; } } public MchRemanenceResultEntity Value { get { var list = mchPathResultEntityBindingSource.DataSource as List; return (list == null) || !list.Any() ? new MchRemanenceResultEntity() : list.FirstOrDefault(); } set { if (value == null) { mchPathResultEntityBindingSource.DataSource = new List { new MchRemanenceResultEntity() }; ScrappedList = new List(); Detail = new List(); } else { if (PortHttBatchSampleResultEntitys!=null) value.ProWt = comm.GetWeight(PortHttBatchSampleResultEntitys, gx, (int) (value.ProNum ?? 0), (int) (PlnZyJgxCEntity.ProCount ?? 0)); mchPathResultEntityBindingSource.DataSource = new List {value.Clone()}; if (_plineCode != Value.PlineCode) { Names = EntityHelper.GetData( "com.steering.mes.mcp.heatTreatment.FrmHttCrackDetectResult.getHttSign", new object[] {Value.PlineCode, "13"}, 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(); ScrappedList = new List(); // ultraGrid1.DisplayLayout.Bands[0].Columns["ProNum"].MaxValue = value.ProNum; } } } private void TestRecord_EditorButtonClick(object sender, EditorButtonEventArgs e) { var matfrm = new RemanenceRecord(Detail); matfrm.ShowDialog(); if (matfrm.DialogResult == DialogResult.OK) { Detail = matfrm.Detail; Value.TestRecord = Detail.Count(); if (Detail.Any()) { var point = Detail.SelectMany(p => { var points = new List(); double a0, a90, a180, a270, b0, b90, b180, b270; if (double.TryParse(p.MeasurementValueA0, out a0)) points.Add(a0); if (double.TryParse(p.MeasurementValueA90, out a90)) points.Add(a90); if (double.TryParse(p.MeasurementValueA180, out a180)) points.Add(a180); if (double.TryParse(p.MeasurementValueA270, out a270)) points.Add(a270); if (double.TryParse(p.MeasurementValueB0, out b0)) points.Add(b0); if (double.TryParse(p.MeasurementValueB90, out b90)) points.Add(b90); if (double.TryParse(p.MeasurementValueB180, out b180)) points.Add(b180); if (double.TryParse(p.MeasurementValueB270, out b270)) points.Add(b270); return points; } ).ToList(); // if (point.Any()) Value.PointMax = decimal.Parse(point.Max().ToString3()); var avg = Detail.SelectMany(p => { var avgs = new List(); double aa, ba; if (double.TryParse(p.MeasurementValueAavg, out aa)) avgs.Add(aa); if (double.TryParse(p.MeasurementValueBavg, out ba)) avgs.Add(ba); return avgs; } ).ToList(); // if (avg.Any()) Value.AverageMax = decimal.Parse(avg.Max().ToString3()); } ultraGrid1.PerformAction(UltraGridAction.ExitEditMode); ultraGrid1.UpdateData(); } } } }