using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Qcm.BLL; using Core.StlMes.Client.Qcm.model; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Windows.Forms; namespace Core.StlMes.Client.Qcm.Control { public partial class ComMscRJgCtrl : UserControl { private ComMscRJgBLL _mscRJgBLL; public ComMscRJgCtrl(OpeBase ob, System.Windows.Forms.Control container) { InitializeComponent(); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); _mscRJgBLL = new ComMscRJgBLL(ob); container.Controls.Add(this); this.Dock = DockStyle.Fill; } public void GetMscRJgBySpec(string ordLnPk, bool isCraft) { List listSource = _mscRJgBLL.GetMscRJgBySpec(ordLnPk); comMscRJgEntityBindingSource.DataSource = listSource; SlmOrdDesignMscJgEntity designMscJg = _mscRJgBLL.GetKeyJgByOrdLnPk(ordLnPk, isCraft); if (designMscJg != null) { foreach (UltraGridRow row in ultraGrid1.Rows) { if (row.GetValue("KeyJg") == designMscJg.KeyJg) { row.Cells["CHK"].Value = true; } } } GridHelper.RefreshAndAutoSize(ultraGrid1); ultraGrid1.UpdateData(); } public void InsertDesignMscRJg(string ordLnPk, bool isCraft) { ultraGrid1.UpdateData(); if (MessageUtil.ShowYesNoAndQuestion("是否确认设定接箍?") == DialogResult.No) { return; } List parms = new List(); foreach (UltraGridRow row in ultraGrid1.Rows) { SlmOrdDesignMscJgEntity parm = EntityHelper.CopyEntity(row.ListObject); if (row.GetValue("CHK").ToString() == "True") { parm.SetJg = "1"; } else { parm.SetJg = "0"; } parms.Add(parm); } _mscRJgBLL.InsertDesignMscRJg(parms, ordLnPk, isCraft); MessageUtil.ShowTips("设定接箍成功!"); } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { ultraGrid1.UpdateData(); if (e.Cell.Column.Key == "CHK") { if (e.Cell.Value.ToString() == "True") { IQueryable rows = ultraGrid1.Rows.AsQueryable().Where( a => a.GetValue("KeyJg") != e.Cell.Row.GetValue("KeyJg") && a.GetValue("CHK") == "True"); if (rows.Count() > 0) { rows.First().Cells["CHK"].Value = false; } } } ultraGrid1.UpdateData(); } } }