using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Linq; using System.Windows.Forms; using com.steering.mes.mcp.entity; 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.UltraWinGrid; using Infragistics.Win.UltraWinToolbars; namespace Core.StlMes.Client.Mcp.Control { public partial class FrmHttScrapLen : FrmBase { public FrmHttScrapLen(OpeBase ob) { InitializeComponent(); this.ob = ob; ScrappedLenList = new List(); } private string heatPlanNo = ""; public FrmHttScrapLen(OpeBase ob, List list2, string HeatPlanNo, int Process_seq, string defaultBatchNo) { InitializeComponent(); this.ob = ob; heatPlanNo = HeatPlanNo; ScrappedLenList = list2 == null ? new List() : list2.Select(p => p.Clone()).ToList(); var dt4 = ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.ScrapHelper.doQueryBatchNo", new object[] { heatPlanNo, Process_seq }, ob); if (dt4.Rows.Count <= 0) { var row = dt4.NewRow(); row["PHY_BATCH_NO"] = defaultBatchNo; dt4.Rows.Add(row); } BatchNo.DataSource = dt4; BatchNo.DisplayMember = "PHY_BATCH_NO"; BatchNo.ValueMember = "PHY_BATCH_NO"; YdmBaseClass.SetComboItemHeight(BatchNo); ScrappedLenList.ForEach(p => { p.Chk = true; if (dt4.Rows.Count <= 0) { p.BatchNo = ""; return; } if (dt4.AsEnumerable().All(q => q["PHY_BATCH_NO"].ToString2() != p.BatchNo)) p.BatchNo = dt4.Rows[dt4.Rows.Count - 1]["PHY_BATCH_NO"].ToString(); }); httWasteResultEntityBindingSource2.DataSource = ScrappedLenList; EntityHelper.ShowGridCaption(ultraGridDetailDes2.DisplayLayout.Bands[0]); } /// /// 废品米长 /// public List ScrappedLenList { get; private set; } 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() { ultraGridDetailDes2.UpdateData(); var list2 = httWasteResultEntityBindingSource2.DataSource as List; list2 = list2.Where(p => p.Chk).ToList(); foreach (var httWasteResultEntity in list2) { if (httWasteResultEntity.TotalLen==null) { MessageUtil.ShowTips("废品总米长不能为空!"); return; } } ScrappedLenList = list2; DialogResult = DialogResult.OK; } private void FrmScrap_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGridDetailDes2.DisplayLayout.Bands[0]); } private void ultraGridDetailDes1_CellChange(object sender, CellEventArgs e) { if (e.Cell.Column.Key == "Chk") GridEdite(e.Cell.Row); else if (e.Cell.Column.Key == "DefFillCode") e.Cell.Row.Cells["DefFillName"].Value = e.Cell.Text; } /// /// ulltragrid控件受勾影响(打钩可编辑,不打勾不能编辑)** /// /// private void GridEdite(UltraGridRow row) { ultraGridDetailDes2.UpdateData(); if (row.GetValue("Chk") == "True") { foreach (var cell in row.Cells) if (cell.Column.CellActivation == Activation.AllowEdit) cell.Activation = Activation.AllowEdit; } else { foreach (var cell in row.Cells) { if (cell.Column.Key.Contains("Chk")) continue; if (cell.Column.CellActivation == Activation.AllowEdit) cell.Activation = Activation.ActivateOnly; } } ultraGridDetailDes2.UpdateData(); } private void ultraGridDetailDes_AfterRowInsert(object sender, RowEventArgs e) { DataTable dt4 = BatchNo.DataSource as DataTable; if (dt4 != null && dt4.Rows.Count == 1) { e.Row.Cells["BatchNo"].Value = dt4.Rows[0]["PHY_BATCH_NO"].ToString(); } GridEdite(e.Row); } private void ultraGridDetailDes2_InitializeRow(object sender, InitializeRowEventArgs e) { } private void ultraGridDetailDes2_InitializeTemplateAddRow(object sender, InitializeTemplateAddRowEventArgs e) { if (ultraGridDetailDes2.ActiveRow == null) { e.TemplateAddRow.Activated = true; } } } }