ComBaseDetectionRltFrm.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Format;
  3. using Core.Mes.Client.Comm.Server;
  4. using Core.Mes.Client.Comm.Tool;
  5. using Core.StlMes.Client.Qcm.model;
  6. using CoreFS.CA06;
  7. using Infragistics.Win.UltraWinGrid;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.Linq;
  12. namespace Core.StlMes.Client.Qcm
  13. {
  14. public partial class ComBaseDetectionRltFrm : FrmBase
  15. {
  16. public ComBaseDetectionRltFrm()
  17. {
  18. InitializeComponent();
  19. }
  20. public override void ToolBar_Click(object sender, string ToolbarKey)
  21. {
  22. base.ToolBar_Click(sender, ToolbarKey);
  23. switch (ToolbarKey)
  24. {
  25. case "Query":
  26. Query();
  27. break;
  28. case "Save":
  29. Save();
  30. break;
  31. case "Delete":
  32. Delete();
  33. break;
  34. }
  35. }
  36. private void ComBaseDetectionRltFrm_Load(object sender, EventArgs e)
  37. {
  38. EntityHelper.ShowGridCaption<ComBaseDetectionRltEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  39. EntityHelper.ShowGridCaption<ComBaseDetectionRltEntity>(ultraGrid2.DisplayLayout.Bands[0]);
  40. QcmBaseCommon.InitDrop(labelComboBox1.ComboBox, "com.steering.pss.qcm.ComBaseQuery.getComBasePhyD", "PHY_NAME", "PHY_CODE", true, this.ob);
  41. QcmBaseCommon.InitDrop(labelComboBox2.ComboBox, "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4021", "BASENAME", "BASECODE", false, this.ob);
  42. QcmBaseCommon.InitDrop(ultraComboEditor1, "com.steering.pss.qcm.ComBaseQuery.getComBasePhyD", "PHY_NAME", "PHY_CODE", true, this.ob);
  43. QcmBaseCommon.InitDrop(ultraComboEditor2, "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4021", "BASENAME", "BASECODE", false, this.ob);
  44. QcmBaseCommon.InitDrop(ultraComboEditor3, "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4022", "BASENAME", "BASECODE", false, this.ob);
  45. }
  46. private void Query()
  47. {
  48. string phyCode = labelComboBox1.Checked ? labelComboBox1.SelecteValue.ToString2() : "";
  49. //查询标准
  50. List<ComBaseDetectionRltEntity> dtSource = EntityHelper.GetData<ComBaseDetectionRltEntity>("com.steering.pss.qcm.DAL.ComBaseDetectionRltDAL.QueryStd",
  51. new object[] { phyCode }, ob);
  52. comBaseDetectionRltEntityBindingSource.DataSource = dtSource;
  53. foreach (var row in ultraGrid1.Rows)
  54. {
  55. GridEdite(row);
  56. }
  57. GridHelper.RefreshAndAutoSize(ultraGrid1);
  58. //查询等级
  59. string stdCode = labelComboBox2.Checked ? labelComboBox2.SelecteValue.ToString2() : "";
  60. List<ComBaseDetectionRltEntity> dtSourceLv = EntityHelper.GetData<ComBaseDetectionRltEntity>("com.steering.pss.qcm.DAL.ComBaseDetectionRltDAL.QueryLv",
  61. new object[] { stdCode }, ob);
  62. bindingSource1.DataSource = dtSourceLv;
  63. foreach (var row in ultraGrid2.Rows)
  64. {
  65. GridEdite(row);
  66. }
  67. GridHelper.RefreshAndAutoSize(ultraGrid2);
  68. }
  69. private void Relocate(string id)
  70. {
  71. Query();
  72. var row = ultraGrid1.Rows.Where(a => a.GetValue("id") == id).FirstOrDefault();
  73. if (row != null)
  74. {
  75. row.Activate();
  76. }
  77. }
  78. private void Save()
  79. {
  80. var chkRows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  81. List<string> parms = new List<string>();
  82. string id = "";
  83. foreach (var chkRow in chkRows)
  84. {
  85. ComBaseDetectionRltEntity parmEntity = (ComBaseDetectionRltEntity)chkRow.ListObject;
  86. parmEntity.PhyName = chkRow.GetText("phyCode");
  87. parmEntity.StdDesc = chkRow.GetText("stdCode");
  88. if (parmEntity.PhyCode == "")
  89. {
  90. MessageUtil.ShowWarning("请选择探伤项!", ultraGrid1, chkRow.Cells["phyCode"]);
  91. return;
  92. }
  93. if (parmEntity.StdCode == "")
  94. {
  95. MessageUtil.ShowWarning("请选择参考标准!", ultraGrid1, chkRow.Cells["stdCode"]);
  96. return;
  97. }
  98. parms.Add(JSONFormat.Format(parmEntity));
  99. id = parmEntity.Id.ToString();
  100. }
  101. var chkRows2 = ultraGrid2.Rows.Where(a => a.GetValue("Chk") == "True");
  102. foreach (var chkRow in chkRows2)
  103. {
  104. ComBaseDetectionRltEntity parmEntity = (ComBaseDetectionRltEntity)chkRow.ListObject;
  105. parmEntity.StdDesc = chkRow.GetText("stdCode");
  106. parmEntity.LvDesc = chkRow.GetText("lvCode");
  107. if (parmEntity.StdCode == "")
  108. {
  109. MessageUtil.ShowWarning("请选择参考标准!", ultraGrid2, chkRow.Cells["stdCode"]);
  110. return;
  111. }
  112. if (parmEntity.LvCode == "")
  113. {
  114. MessageUtil.ShowWarning("请选择级别!", ultraGrid2, chkRow.Cells["lvCode"]);
  115. return;
  116. }
  117. parms.Add(JSONFormat.Format(parmEntity));
  118. id = parmEntity.Id.ToString();
  119. }
  120. if (chkRows.Count() + chkRows2.Count() == 0)
  121. {
  122. MessageUtil.ShowWarning("请选择需要保存的记录!");
  123. return;
  124. }
  125. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == System.Windows.Forms.DialogResult.No)
  126. {
  127. return;
  128. }
  129. ServerHelper.SetData("com.steering.pss.qcm.DAL.ComBaseDetectionRltDAL.Save", new object[] { parms }, ob);
  130. MessageUtil.ShowTips("保存成功!");
  131. Relocate(id);
  132. }
  133. private void Delete()
  134. {
  135. var chkRows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  136. List<string> parms = new List<string>();
  137. string id = "";
  138. foreach (var chkRow in chkRows)
  139. {
  140. ComBaseDetectionRltEntity parmEntity = (ComBaseDetectionRltEntity)chkRow.ListObject;
  141. parms.Add(JSONFormat.Format(parmEntity));
  142. id = parmEntity.Id.ToString();
  143. }
  144. var chkRows2 = ultraGrid2.Rows.Where(a => a.GetValue("Chk") == "True");
  145. foreach (var chkRow in chkRows2)
  146. {
  147. ComBaseDetectionRltEntity parmEntity = (ComBaseDetectionRltEntity)chkRow.ListObject;
  148. parms.Add(JSONFormat.Format(parmEntity));
  149. id = parmEntity.Id.ToString();
  150. }
  151. if (chkRows.Count() + chkRows2.Count() == 0)
  152. {
  153. MessageUtil.ShowWarning("请选择需要删除的记录!");
  154. return;
  155. }
  156. if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == System.Windows.Forms.DialogResult.No)
  157. {
  158. return;
  159. }
  160. ServerHelper.SetData("com.steering.pss.qcm.DAL.ComBaseDetectionRltDAL.Delete", new object[] { parms }, ob);
  161. MessageUtil.ShowTips("删除成功!");
  162. Relocate(id);
  163. }
  164. private void GridEdite(UltraGridRow row)
  165. {
  166. if (row.GetValue("Chk") == "True")
  167. {
  168. foreach (UltraGridCell cell in row.Cells)
  169. {
  170. if (cell.Column.CellActivation == Activation.AllowEdit)
  171. {
  172. cell.Activation = Activation.AllowEdit;
  173. }
  174. }
  175. }
  176. else
  177. {
  178. foreach (UltraGridCell cell in row.Cells)
  179. {
  180. if (cell.Column.Key.Contains("Chk")) continue;
  181. if (cell.Column.CellActivation == Activation.AllowEdit)
  182. {
  183. cell.Activation = Activation.ActivateOnly;
  184. }
  185. }
  186. }
  187. ultraGrid1.UpdateData();
  188. }
  189. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  190. {
  191. e.Cell.Row.Update();
  192. GridEdite(e.Cell.Row);
  193. }
  194. private void ultraGrid2_CellChange(object sender, CellEventArgs e)
  195. {
  196. e.Cell.Row.Update();
  197. GridEdite(e.Cell.Row);
  198. }
  199. }
  200. }