using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Qcm.model; using CoreFS.CA06; using CoreFS.SA06; using Infragistics.Win.UltraWinGrid; using Newtonsoft.Json; 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 ComBaseImpactTempCCtrl : UserControl { private OpeBase ob; public ComBaseImpactTempCCtrl(System.Windows.Forms.Control container, OpeBase ob) { InitializeComponent(); this.ob = ob; container.Controls.Add(this); this.Dock = DockStyle.Fill; EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); 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); ultraComboEditor3.DataSource = dt; ultraComboEditor3.DisplayMember = "ITEM_NAME"; ultraComboEditor3.ValueMember = "ITEM_CODE"; ultraComboEditor3.DropDownListWidth = -1; ClsBaseInfo.SetComboItemHeight(ultraComboEditor3); } private string _id = ""; private string _validflag = ""; public void Query(string id, string validflag) { _id = id; _validflag = validflag; List data = EntityHelper.GetData( "com.steering.pss.qcm.DAL.ComBaseImpactTempCDAL.Query", new object[] { id, validflag }, ob); this.comBaseImpactTempCEntityBindingSource.DataSource = data; foreach (var row in ultraGrid1.Rows) { GridEdite(row); } } public List GetSaveParms() { var rows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True"); List parms = new List(); foreach (var row in rows) { ComBaseImpactTempCEntity parm = EntityHelper.CopyEntity(row.ListObject); if (parm.ItemCodeC == "") { MessageUtil.ShowWarning("请选择试样尺寸!"); row.SetCellActive("ItemCodeC"); return null; } if (parm.MinH == null || parm.MaxH == null) { MessageUtil.ShowWarning("请输入壁厚下限或者壁厚上限!"); row.SetCellActive("MinH"); return null; } parm.CreateName = CoreUserInfo.UserInfo.GetUserName(); parm.UpdateName = CoreUserInfo.UserInfo.GetUserName(); parms.Add(parm); } return parms; } public void UpdateValidflag(string validflag) { var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True") .Select(a => EntityHelper.CopyEntity(a.ListObject)).ToList(); List jsons = new List(); foreach (var row in rows) { row.DeleteName = CoreUserInfo.UserInfo.GetUserName(); row.UpdateName = CoreUserInfo.UserInfo.GetUserName(); jsons.Add(JsonConvert.SerializeObject(row)); } ServerHelper.SetData("com.steering.pss.qcm.DAL.ComBaseImpactTempCDAL.UpdateValidflag", new object[] { jsons, validflag }, ob); } 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 ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { if (e.Row.GetValue("Validflag") == "无效") { e.Row.Appearance.ForeColor = Color.Red; } } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { e.Cell.Row.Update(); GridEdite(e.Cell.Row); } private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e) { e.Row.SetValue("Id", _id); } } }