| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- 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<MchRemanenceResultEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- Detail = new List<MchRemanenceResultDEntity>();
- gx = "701314";
- Value = null;
- }
- public List<MchRemanenceResultDEntity> 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<MchRemanenceResultEntity>;
- return (list == null) || !list.Any() ? new MchRemanenceResultEntity() : list.FirstOrDefault();
- }
- set
- {
- if (value == null)
- {
- mchPathResultEntityBindingSource.DataSource = new List<MchRemanenceResultEntity>
- {
- new MchRemanenceResultEntity()
- };
- ScrappedList = new List<MchBugDEntity>();
- Detail = new List<MchRemanenceResultDEntity>();
- }
- else
- {
- if (PortHttBatchSampleResultEntitys!=null)
- value.ProWt = comm.GetWeight(PortHttBatchSampleResultEntitys, gx, (int) (value.ProNum ?? 0),
- (int) (PlnZyJgxCEntity.ProCount ?? 0));
- mchPathResultEntityBindingSource.DataSource = new List<MchRemanenceResultEntity> {value.Clone()};
- if (_plineCode != Value.PlineCode)
- {
- Names = EntityHelper.GetData<HttSignatureEntity>(
- "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<MchRemanenceResultDEntity>();
- ScrappedList = new List<MchBugDEntity>();
- // 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>();
- 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>();
- 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();
- }
- }
- }
- }
|