using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Control.Entity; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; using Infragistics.Win.UltraWinToolbars; namespace Core.StlMes.Client.Mcp.Control.HeatTreatment { public partial class FrmChooseStandard : FrmBase { private readonly List _listDefault; public FrmChooseStandard(List listDefault, List listProbe, OpeBase Ob) { InitializeComponent(); ob = Ob; _listDefault = listDefault; listProbe.ForEach(p=>p.Chk = true); var ProDefault = _listDefault.Where(p => p.ReportColumn.ToUpper() == "STANDARD_NAME").ToList(); if (ProDefault.Any() ) { DataTable dt; if (ProDefault[0].DroplistUsed != "") { dt = ServerHelper.GetData( "com.steering.mes.mcp.heatTreatment.ScrapHelper.doQuery", new object[] {"4021", ProDefault[0].DroplistUsed.Split(';')}, ob); } else { dt = ServerHelper.GetData( "com.steering.mes.mcp.collarMaterial.ComBaseInfo.getBaseInfo", new object[] {"4021"}, ob); } Standard.DataSource = dt; Standard.ValueMember = "BASECODE"; Standard.DisplayMember = "BASENAME"; if (ProDefault[0].TextDefault != "") { DataTable dtDefault = ServerHelper.GetData( "com.steering.mes.mcp.heatTreatment.ScrapHelper.doQuery", new object[] { "4021", ProDefault[0].TextDefault.Split(';') }, ob); if (dtDefault.Rows.Count > 0) { foreach (DataRow row in dtDefault.Rows) { if (listProbe.All(p => p.StandardCode != row["BASECODE"].ToString2())) { listProbe.Add(new HttCrackDetectionStandardEntity() { StandardCode = row["BASECODE"].ToString2(), StandardName = row["BASENAME"].ToString2() }); } } } } } httCrackDetectionStandardEntityBindingSource.DataSource = listProbe; } private void ultraToolbarsManager1_ToolClick(object sender, ToolClickEventArgs e) { switch (e.Tool.Key) { case "Save": Save(); break; case "Close": CloseFrm(); break; } } protected override void OnLoad(EventArgs e) { base.OnLoad(e); foreach (var ugc in ultraGridDetailDes1.DisplayLayout.Bands[0].Columns) ugc.SortIndicator = SortIndicator.Disabled; ultraGridDetailDes1.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False; EntityHelper.ShowGridCaption(ultraGridDetailDes1.DisplayLayout.Bands[0]); } private void CloseFrm() { DialogResult = DialogResult.Cancel; Close(); } /// /// 保存可疑、剔除品 /// private void Save() { ultraGridDetailDes1.UpdateData(); List list = GetValue(); if (!list.Any()) { MessageBox.Show("请选择探伤的标准"); return; } if (list.Any(p => p.StandardCode == "")) { MessageBox.Show("探伤标准不能为空"); return; } DialogResult = DialogResult.OK; } private void ultraGridDetailDes1_InitializeTemplateAddRow(object sender, Infragistics.Win.UltraWinGrid.InitializeTemplateAddRowEventArgs e) { if (ultraGridDetailDes1.ActiveRow == null && ultraGridDetailDes1.Rows.Count<=0) e.TemplateAddRow.Activated = true; } public List GetValue() { ultraGridDetailDes1.UpdateData(); List data = httCrackDetectionStandardEntityBindingSource.DataSource as List; if (data.Any()) { return data.Where(p => p.Chk).ToList(); } return new List(); } private void ultraGridDetailDes1_CellChange(object sender, CellEventArgs e) { ultraGridDetailDes1.UpdateData(); if (e.Cell.Column.Key == "StandardCode") { HttCrackDetectionStandardEntity HttCrackDetectionStandardEntity = e.Cell.Row.ListObject as HttCrackDetectionStandardEntity; if (HttCrackDetectionStandardEntity == null) return; HttCrackDetectionStandardEntity.StandardName = e.Cell.Text; } } } }