using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Qcm.BLL; using Core.StlMes.Client.Qcm.model; using CoreFS.CA06; using CoreFS.SA06; using Infragistics.Win.UltraWinGrid; using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Linq; using System.Windows.Forms; namespace Core.StlMes.Client.Qcm.Control { public partial class ComBaseImpactCCtrl : UserControl { private ComBaseImpactCBLL _impactCBLL; public ComBaseImpactCCtrl(System.Windows.Forms.Control container, OpeBase ob) { InitializeComponent(); _impactCBLL = new ComBaseImpactCBLL(ob); this.Dock = DockStyle.Fill; container.Controls.Add(this); DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.DAL.ComBaseImpactDAL.getItemC", new object[] { }, ob); DataRow dr = dt.NewRow(); dr["ITEM_CODE"] = ""; dt.Rows.InsertAt(dr, 0); ultraComboEditor1.DataSource = dt; ultraComboEditor1.DisplayMember = "ITEM_NAME"; ultraComboEditor1.ValueMember = "ITEM_CODE"; ultraComboEditor1.DropDownListWidth = -1; ClsBaseInfo.SetComboItemHeight(ultraComboEditor1); } private string _id = ""; private string _validflag = ""; public void Query(string id, string validflag) { _id = id; _validflag = validflag; this.comBaseImpactCEntityBindingSource.DataSource = _impactCBLL.Query(id, validflag); foreach (var row in entityGrid1.Rows) { GridEdite(row); } } public List GetSaveParms() { var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True"); List parms = new List(); foreach (var row in rows) { ComBaseImpactCEntity parm = EntityHelper.CopyEntity(row.ListObject); if (parm.ItemCodeC == "") { MessageUtil.ShowWarning("请选择试样尺寸!"); row.SetCellActive("ItemCodeC"); return null; } if (parm.ItemWidth == null) { MessageUtil.ShowWarning("请输入试样宽度!"); row.SetCellActive("ItemWidth"); return null; } if (parm.DeclineRatio == null) { MessageUtil.ShowWarning("请输入递减系数!"); row.SetCellActive("DeclineRatio"); return null; } parm.CreateName = CoreUserInfo.UserInfo.GetUserName(); parm.UpdateName = CoreUserInfo.UserInfo.GetUserName(); parms.Add(parm); } return parms; } public void UpdateValidflag(string validflag) { var rows = entityGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True") .Select(a => EntityHelper.CopyEntity(a.ListObject)).ToList(); foreach (var row in rows) { row.DeleteName = CoreUserInfo.UserInfo.GetUserName(); row.UpdateName = CoreUserInfo.UserInfo.GetUserName(); } _impactCBLL.UpdateValidflag(rows, validflag); } private void entityGrid1_AfterRowInsert(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e) { e.Row.SetValue("Id", _id); } private void entityGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { e.Cell.Row.Update(); GridEdite(e.Cell.Row); } private void GridEdite(UltraGridRow row) { if (row.GetValue("Chk") == "True") { foreach (UltraGridCell cell in row.Cells) { if (cell.Column.CellActivation == Activation.AllowEdit) { cell.Activation = Activation.AllowEdit; } } } else { foreach (UltraGridCell cell in row.Cells) { if (cell.Column.Key == "Chk") continue; if (cell.Column.CellActivation == Activation.AllowEdit) { cell.Activation = Activation.ActivateOnly; } } } } private void entityGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { if (e.Row.GetValue("Validflag") == "无效") { e.Row.Appearance.ForeColor = Color.Red; } } } }