using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using Core.StlMes.Client.Mcp.Control.Entity; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using Infragistics.Win.UltraWinToolbars; namespace Core.StlMes.Client.Mcp.Control { public partial class RemanenceRecord : FrmBase { public List Detail { get; private set; } public RemanenceRecord(List _detail) { InitializeComponent(); if (_detail == null) _detail = new List(); mchRemanenceResultDEntityBindingSource.DataSource = _detail.Select(p => p.Clone()).ToList(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); ultraGridDetailDes1.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default; ultraGridDetailDes1.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False; } private void ultraToolbarsManager1_ToolClick(object sender, ToolClickEventArgs e) { switch (e.Tool.Key) { case "Save": Save(); break; case "Close": CloseFrm(); break; } } private void CloseFrm() { DialogResult = DialogResult.Cancel; Close(); } /// /// 保存可疑、剔除品 /// private void Save() { ultraGridDetailDes1.UpdateData(); var list1 = mchRemanenceResultDEntityBindingSource.DataSource as List; list1 = list1.Where(p => p.chk).ToList(); Detail = list1; DialogResult = DialogResult.OK; } private void ultraGridDetailDes1_AfterRowInsert(object sender, RowEventArgs e) { e.Row.Cells["Measurement"].Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); e.Row.Cells["chk"].Value = true; } private void ultraGridDetailDes1_ClickCell(object sender, ClickCellEventArgs e) { if (ultraGridDetailDes1.ActiveRow.IsAddRow) { int a = ultraGridDetailDes1.ActiveCell.Row.Index; int b = ultraGridDetailDes1.ActiveCell.Column.Index; ultraGridDetailDes1.Rows.Band.AddNew(); ultraGridDetailDes1.Rows[a].Cells[b].Activated = true; ultraGridDetailDes1.PerformAction(UltraGridAction.EnterEditMode); } } private void ultraGridDetailDes1_CellChange(object sender, CellEventArgs e) { int countA = 0,countB = 0; double A0, A90, A180, A270,B0,B90,B180,B270 = 0D; if (double.TryParse(e.Cell.Row.Cells["MeasurementValueA0"].Text, out A0)) countA++; if (double.TryParse(e.Cell.Row.Cells["MeasurementValueA90"].Text, out A90)) countA++; if (double.TryParse(e.Cell.Row.Cells["MeasurementValueA180"].Text, out A180)) countA++; if (double.TryParse(e.Cell.Row.Cells["MeasurementValueA270"].Text, out A270)) countA++; if (double.TryParse(e.Cell.Row.Cells["MeasurementValueB0"].Text, out B0)) countB++; if (double.TryParse(e.Cell.Row.Cells["MeasurementValueB90"].Text, out B90)) countB++; if (double.TryParse(e.Cell.Row.Cells["MeasurementValueB180"].Text, out B180)) countB++; if (double.TryParse(e.Cell.Row.Cells["MeasurementValueB270"].Text, out B270)) countB++; e.Cell.Row.Cells["MeasurementValueAavg"].Value = countA > 0 ? Math.Round((A0 + A90 + A180 + A270)/countA, 2).ToString3() : ""; e.Cell.Row.Cells["MeasurementValueBavg"].Value = countB > 0 ? Math.Round((B0 + B90 + B180 + B270) / countB, 2).ToString3() : ""; } } }