| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- 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<ComBaseDetectionRltEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<ComBaseDetectionRltEntity>(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<ComBaseDetectionRltEntity> dtSource = EntityHelper.GetData<ComBaseDetectionRltEntity>("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<ComBaseDetectionRltEntity> dtSourceLv = EntityHelper.GetData<ComBaseDetectionRltEntity>("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<string> parms = new List<string>();
- 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<string> parms = new List<string>();
- 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);
- }
- }
- }
|