using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; 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; namespace Core.StlMes.Client.Qcm { public partial class ComBaseDetectionRltFrm : FrmBase { public ComBaseDetectionRltFrm() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { base.ToolBar_Click(sender, ToolbarKey); switch (ToolbarKey) { case "Query": Query(); break; case "Save": Save(); break; case "Delete": Delete(); break; } } private void ComBaseDetectionRltFrm_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]); QcmBaseCommon.InitDrop(labelComboBox1.ComboBox, "com.steering.pss.qcm.ComBaseQuery.getComBasePhyD", "PHY_NAME", "PHY_CODE", true, this.ob); QcmBaseCommon.InitDrop(labelComboBox2.ComboBox, "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4021", "BASENAME", "BASECODE", false, this.ob); QcmBaseCommon.InitDrop(ultraComboEditor1, "com.steering.pss.qcm.ComBaseQuery.getComBasePhyD", "PHY_NAME", "PHY_CODE", true, this.ob); QcmBaseCommon.InitDrop(ultraComboEditor2, "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4021", "BASENAME", "BASECODE", false, this.ob); QcmBaseCommon.InitDrop(ultraComboEditor3, "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4022", "BASENAME", "BASECODE", false, this.ob); } private void Query() { string phyCode = labelComboBox1.Checked ? labelComboBox1.SelecteValue.ToString2() : ""; //查询标准 List dtSource = EntityHelper.GetData("com.steering.pss.qcm.DAL.ComBaseDetectionRltDAL.QueryStd", new object[] { phyCode }, ob); comBaseDetectionRltEntityBindingSource.DataSource = dtSource; foreach (var row in ultraGrid1.Rows) { GridEdite(row); } GridHelper.RefreshAndAutoSize(ultraGrid1); //查询等级 string stdCode = labelComboBox2.Checked ? labelComboBox2.SelecteValue.ToString2() : ""; List dtSourceLv = EntityHelper.GetData("com.steering.pss.qcm.DAL.ComBaseDetectionRltDAL.QueryLv", new object[] { stdCode }, ob); bindingSource1.DataSource = dtSourceLv; foreach (var row in ultraGrid2.Rows) { GridEdite(row); } GridHelper.RefreshAndAutoSize(ultraGrid2); } private void Relocate(string id) { Query(); var row = ultraGrid1.Rows.Where(a => a.GetValue("id") == id).FirstOrDefault(); if (row != null) { row.Activate(); } } private void Save() { var chkRows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True"); List parms = new List(); string id = ""; foreach (var chkRow in chkRows) { ComBaseDetectionRltEntity parmEntity = (ComBaseDetectionRltEntity)chkRow.ListObject; parmEntity.PhyName = chkRow.GetText("phyCode"); parmEntity.StdDesc = chkRow.GetText("stdCode"); if (parmEntity.PhyCode == "") { MessageUtil.ShowWarning("请选择探伤项!", ultraGrid1, chkRow.Cells["phyCode"]); return; } if (parmEntity.StdCode == "") { MessageUtil.ShowWarning("请选择参考标准!", ultraGrid1, chkRow.Cells["stdCode"]); return; } parms.Add(JSONFormat.Format(parmEntity)); id = parmEntity.Id.ToString(); } var chkRows2 = ultraGrid2.Rows.Where(a => a.GetValue("Chk") == "True"); foreach (var chkRow in chkRows2) { ComBaseDetectionRltEntity parmEntity = (ComBaseDetectionRltEntity)chkRow.ListObject; parmEntity.StdDesc = chkRow.GetText("stdCode"); parmEntity.LvDesc = chkRow.GetText("lvCode"); if (parmEntity.StdCode == "") { MessageUtil.ShowWarning("请选择参考标准!", ultraGrid2, chkRow.Cells["stdCode"]); return; } if (parmEntity.LvCode == "") { MessageUtil.ShowWarning("请选择级别!", ultraGrid2, chkRow.Cells["lvCode"]); return; } parms.Add(JSONFormat.Format(parmEntity)); id = parmEntity.Id.ToString(); } if (chkRows.Count() + chkRows2.Count() == 0) { MessageUtil.ShowWarning("请选择需要保存的记录!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == System.Windows.Forms.DialogResult.No) { return; } ServerHelper.SetData("com.steering.pss.qcm.DAL.ComBaseDetectionRltDAL.Save", new object[] { parms }, ob); MessageUtil.ShowTips("保存成功!"); Relocate(id); } private void Delete() { var chkRows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True"); List parms = new List(); string id = ""; foreach (var chkRow in chkRows) { ComBaseDetectionRltEntity parmEntity = (ComBaseDetectionRltEntity)chkRow.ListObject; parms.Add(JSONFormat.Format(parmEntity)); id = parmEntity.Id.ToString(); } var chkRows2 = ultraGrid2.Rows.Where(a => a.GetValue("Chk") == "True"); foreach (var chkRow in chkRows2) { ComBaseDetectionRltEntity parmEntity = (ComBaseDetectionRltEntity)chkRow.ListObject; parms.Add(JSONFormat.Format(parmEntity)); id = parmEntity.Id.ToString(); } if (chkRows.Count() + chkRows2.Count() == 0) { MessageUtil.ShowWarning("请选择需要删除的记录!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == System.Windows.Forms.DialogResult.No) { return; } ServerHelper.SetData("com.steering.pss.qcm.DAL.ComBaseDetectionRltDAL.Delete", new object[] { parms }, ob); MessageUtil.ShowTips("删除成功!"); Relocate(id); } 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.Contains("Chk")) continue; if (cell.Column.CellActivation == Activation.AllowEdit) { cell.Activation = Activation.ActivateOnly; } } } ultraGrid1.UpdateData(); } private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { e.Cell.Row.Update(); GridEdite(e.Cell.Row); } private void ultraGrid2_CellChange(object sender, CellEventArgs e) { e.Cell.Row.Update(); GridEdite(e.Cell.Row); } } }