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; 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 ComBaseSplineLengthCtrl : UserControl { private ComBaseSplineLengthBLL _splineLengthBLL; public ComBaseSplineLengthCtrl(System.Windows.Forms.Control container, OpeBase ob) { InitializeComponent(); _splineLengthBLL = new ComBaseSplineLengthBLL(ob); this.Dock = DockStyle.Fill; container.Controls.Add(this); ArrayList list = new ArrayList(); list.Add("A"); DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreMaterialItemMng.loadItem", new object[] { list }, ob); ultraComboEditor1.DataSource = dt; ultraComboEditor1.DisplayMember = "ITEM_NAME"; ultraComboEditor1.ValueMember = "ITEM_CODE"; ultraComboEditor1.DropDownListWidth = -1; ClsBaseInfo.SetComboItemHeight(ultraComboEditor1); list[0] = "C"; dt = ServerHelper.GetData("com.steering.pss.qcm.CoreMaterialItemMng.loadItem", new object[] { list }, ob); ultraComboEditor2.DataSource = dt; ultraComboEditor2.DisplayMember = "ITEM_NAME"; ultraComboEditor2.ValueMember = "ITEM_CODE"; ultraComboEditor2.DropDownListWidth = -1; ClsBaseInfo.SetComboItemHeight(ultraComboEditor2); } private string _itemCodeC = ""; private string _validflag = ""; public void Query(string itemCodeC, string validflag) { _itemCodeC = itemCodeC; _validflag = validflag; comBaseSplineLengthEntityBindingSource.DataSource = _splineLengthBLL.Query(itemCodeC, validflag); foreach (var row in entityGrid1.Rows) { GridEdite(row); } } public void Save() { var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True"); if (rows.Count() == 0) { MessageUtil.ShowWarning("请选择一条记录!"); return; } List parms = new List(); string id = ""; foreach (var row in rows) { if (entityGrid1.Rows.Where(a => a.GetValue("id") == row.GetValue("id")).Count() > 1) { MessageUtil.ShowWarning("优选顺序" + row.GetValue("id") + "在系统中已经存在!"); return; } ComBaseSplineLengthEntity parm = EntityHelper.CopyEntity(row.ListObject); id = parm.Id; parm.CreateName = CoreUserInfo.UserInfo.GetUserName(); parm.UpdateName = CoreUserInfo.UserInfo.GetUserName(); parms.Add(parm); } if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No) { return; } _splineLengthBLL.Save(parms); MessageUtil.ShowTips("保存成功!"); Relocate(id); } public void Relocate(string id) { Query(_itemCodeC, _validflag); var row = entityGrid1.Rows.AsQueryable().Where(a => a.GetValue("Id") == id).FirstOrDefault(); if (row != null) { row.Activate(); } } public void UpdateValidflag(string validflag) { entityGrid1.UpdateData(); var rows = entityGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True") .Select(a => EntityHelper.CopyEntity(a.ListObject)).ToList(); if (rows.Count() == 0) { MessageUtil.ShowWarning("请选择一条记录!"); return; } string id = ""; foreach (var row in rows) { row.DeleteName = CoreUserInfo.UserInfo.GetUserName(); row.UpdateName = CoreUserInfo.UserInfo.GetUserName(); id = row.Id; } if (MessageUtil.ShowYesNoAndQuestion("是否确认" + (validflag == "0" ? "作废" : "恢复") + "此记录?") == DialogResult.No) { return; } _splineLengthBLL.UpdateValidflag(rows, validflag); MessageUtil.ShowTips((validflag == "0" ? "作废" : "恢复") + "成功!"); Relocate(id); } private void entityGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { if (e.Row.GetValue("Validflag") == "无效") { e.Row.Appearance.ForeColor = Color.Red; } } 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; } } } } } }