ComBaseSplineStdSizeFrm.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using CoreFS.CA06;
  5. using Infragistics.Win.UltraWinEditors;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections;
  9. using System.Data;
  10. using System.Linq;
  11. using System.Windows.Forms;
  12. namespace Core.StlMes.Client.Qcm
  13. {
  14. public partial class ComBaseSplineStdSizeFrm : FrmBase
  15. {
  16. public ComBaseSplineStdSizeFrm()
  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. case "Close":
  35. this.Close();
  36. break;
  37. }
  38. }
  39. public void Query()
  40. {
  41. dataTable1.Clear();
  42. dataTable2.Clear();
  43. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseSplineStdSize.querySplineStd", new string[] { }, ob);
  44. GridHelper.CopyDataToDatatable(dt, dataTable3, true);
  45. foreach (var row in ultraGrid3.Rows)
  46. {
  47. GridEdite(row);
  48. }
  49. }
  50. public void Save()
  51. {
  52. var stdRow = ultraGrid3.Rows.Where(a => a.GetValue("CHK") == "True").FirstOrDefault();
  53. var sizeRows = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True");
  54. var specRows = ultraGrid2.Rows.Where(a => a.GetValue("CHK") == "True");
  55. if (stdRow == null && sizeRows.Count() == 0 && specRows.Count() == 0)
  56. {
  57. MessageUtil.ShowWarning("请选择一条记录!");
  58. return;
  59. }
  60. string[] stdParm = new string[3];
  61. string id = ultraGrid3.ActiveRow.GetValue("ID");
  62. if (stdRow != null)
  63. {
  64. stdParm = new string[] { stdRow.GetValue("spline_direction"), stdRow.GetValue("spline_std_code"), stdRow.GetValue("ID") };
  65. }
  66. ArrayList sizeList = new ArrayList();
  67. foreach (var row in sizeRows)
  68. {
  69. if (row.GetValue("ITEM_CODE_S") == "")
  70. {
  71. MessageUtil.ShowWarning("请选择试样尺寸");
  72. row.Cells["ITEM_CODE_S"].Activate();
  73. return;
  74. }
  75. if (row.GetValue("MIN_SIGN") != "" && row.GetValue("MIN_SIZE") == "")
  76. {
  77. MessageUtil.ShowWarning("请输入尺寸下限!");
  78. row.SetCellActive("MIN_SIZE");
  79. return;
  80. }
  81. else if (row.GetValue("MIN_SIGN") == "" && row.GetValue("MIN_SIZE") != "")
  82. {
  83. MessageUtil.ShowWarning("请选择尺寸下限符号!");
  84. row.SetCellActive("MIN_SIGN");
  85. return;
  86. }
  87. else if (row.GetValue("MAX_SIGN") != "" && row.GetValue("MAX_SIZE") == "")
  88. {
  89. MessageUtil.ShowWarning("请输入尺寸上限值!");
  90. row.SetCellActive("MAX_SIZE");
  91. return;
  92. }
  93. else if (row.GetValue("MAX_SIGN") == "" && row.GetValue("MAX_SIZE") != "")
  94. {
  95. MessageUtil.ShowWarning("请选择尺寸上限符号!");
  96. row.SetCellActive("MAX_SIGN");
  97. return;
  98. }
  99. else if (row.GetValue("MIN_SIGN") == "=" && row.GetValue("MAX_SIGN") != "")
  100. {
  101. MessageUtil.ShowWarning("尺寸下限符号为等号时,不能存在尺寸上限符号和尺寸上限值!");
  102. row.SetCellActive("MIN_SIGN");
  103. return;
  104. }
  105. else if (row.GetValue("MIN_SIZE") != "" && row.GetValue("MAX_SIZE") != ""
  106. && decimal.Parse(row.GetValue("MIN_SIZE")) >= decimal.Parse(row.GetValue("MAX_SIZE")))
  107. {
  108. MessageUtil.ShowWarning("尺寸下限值不能大于等于尺寸上限值!");
  109. row.SetCellActive("MIN_SIZE");
  110. return;
  111. }
  112. string[] parm = new string[] { row.GetValue("ITEM_CODE_S"), row.GetValue("MIN_SIZE"), row.GetValue("MAX_SIZE"),
  113. row.GetValue("RATE"), row.GetValue("MIN_SIGN"), row.GetValue("MAX_SIGN"), row.GetValue("ID"), row.GetValue("SEQ")};
  114. sizeList.Add(parm);
  115. }
  116. ArrayList specList = new ArrayList();
  117. foreach (var row in specRows)
  118. {
  119. if (row.GetValue("MIN_D_SIGN") != "" && row.GetValue("MIN_D") == "")
  120. {
  121. MessageUtil.ShowWarning("请输入外径下限值!");
  122. row.SetCellActive("MIN_D");
  123. return;
  124. }
  125. else if (row.GetValue("MIN_D_SIGN") == "" && row.GetValue("MIN_D") != "")
  126. {
  127. MessageUtil.ShowWarning("请选择外径下限符号!");
  128. row.SetCellActive("MIN_D_SIGN");
  129. return;
  130. }
  131. else if (row.GetValue("MAX_D_SIGN") != "" && row.GetValue("MAX_D") == "")
  132. {
  133. MessageUtil.ShowWarning("请输入外径上限值!");
  134. row.SetCellActive("MAX_D");
  135. return;
  136. }
  137. else if (row.GetValue("MAX_D_SIGN") == "" && row.GetValue("MAX_D") != "")
  138. {
  139. MessageUtil.ShowWarning("请选择外径上限符号!");
  140. row.SetCellActive("MAX_D_SIGN");
  141. return;
  142. }
  143. else if (row.GetValue("MIN_H_SIGN") != "" && row.GetValue("MIN_H") == "")
  144. {
  145. MessageUtil.ShowWarning("请输入壁厚下限值!");
  146. row.SetCellActive("MIN_H");
  147. return;
  148. }
  149. else if (row.GetValue("MIN_H_SIGN") == "" && row.GetValue("MIN_H") != "")
  150. {
  151. MessageUtil.ShowWarning("请选择壁厚下限符号!");
  152. row.SetCellActive("MIN_H_SIGN");
  153. return;
  154. }
  155. else if (row.GetValue("MAX_H_SIGN") != "" && row.GetValue("MAX_H") == "")
  156. {
  157. MessageUtil.ShowWarning("请输入壁厚上限值!");
  158. row.SetCellActive("MAX_H");
  159. return;
  160. }
  161. else if (row.GetValue("MAX_H_SIGN") == "" && row.GetValue("MAX_H") != "")
  162. {
  163. MessageUtil.ShowWarning("请选择壁厚上限符号!");
  164. row.SetCellActive("MAX_H_SIGN");
  165. return;
  166. }
  167. else if (row.GetValue("MIN_D_SIGN") == "=" && row.GetValue("MAX_D_SIGN") != "")
  168. {
  169. MessageUtil.ShowWarning("外径下限符号为等号时,不能存在外径上限符号和外径上限值!");
  170. row.SetCellActive("MAX_D_SIGN");
  171. return;
  172. }
  173. else if (row.GetValue("MIN_H_SIGN") == "=" && row.GetValue("MAX_H_SIGN") != "")
  174. {
  175. MessageUtil.ShowWarning("壁厚下限符号为等号时,不能存在壁厚上限符号和壁厚上限值!");
  176. row.SetCellActive("MAX_H_SIGN");
  177. return;
  178. }
  179. else if (row.GetValue("MIN_D") != "" && row.GetValue("MAX_D") != ""
  180. && decimal.Parse(row.GetValue("MIN_D")) >= decimal.Parse(row.GetValue("MAX_D")))
  181. {
  182. MessageUtil.ShowWarning("外径下限值不能大于等于外径上限值!");
  183. row.SetCellActive("MIN_D");
  184. return;
  185. }
  186. else if (row.GetValue("MIN_H") != "" && row.GetValue("MAX_H") != ""
  187. && decimal.Parse(row.GetValue("MIN_H")) >= decimal.Parse(row.GetValue("MAX_H")))
  188. {
  189. MessageUtil.ShowWarning("壁厚下限值不能大于等于壁厚上限值!");
  190. row.SetCellActive("MIN_H");
  191. return;
  192. }
  193. string[] parm = new string[] { row.GetValue("ITEM_CODE_S"), row.GetValue("MIN_D"),
  194. row.GetValue("MAX_D"), row.GetValue("MIN_H"), row.GetValue("MAX_H"), row.GetValue("MIN_D_SIGN"),
  195. row.GetValue("MAX_D_SIGN"), row.GetValue("MIN_H_SIGN"), row.GetValue("MAX_H_SIGN"), row.GetValue("ID"),
  196. row.GetValue("SEQ")};
  197. specList.Add(parm);
  198. }
  199. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == System.Windows.Forms.DialogResult.No)
  200. {
  201. return;
  202. }
  203. ServerHelper.SetData("com.steering.pss.qcm.ComBaseSplineStdSize.save", new object[] { stdParm, sizeList, specList }, ob);
  204. MessageUtil.ShowTips("保存成功!");
  205. Query();
  206. var actRow = ultraGrid3.Rows.Where(a => a.GetValue("ID") == id).FirstOrDefault();
  207. if (actRow != null)
  208. {
  209. actRow.Activate();
  210. }
  211. }
  212. private void Delete()
  213. {
  214. var stdRow = ultraGrid3.Rows.Where(a => a.GetValue("CHK") == "True").FirstOrDefault();
  215. var sizeRows = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True");
  216. var specRows = ultraGrid2.Rows.Where(a => a.GetValue("CHK") == "True");
  217. if (stdRow == null && sizeRows.Count() == 0 && specRows.Count() == 0)
  218. {
  219. MessageUtil.ShowWarning("请选择一条记录!");
  220. return;
  221. }
  222. string stdId = "";
  223. if (stdRow != null)
  224. {
  225. stdId = stdRow.GetValue("ID");
  226. }
  227. ArrayList sizeList = new ArrayList();
  228. foreach (var row in sizeRows)
  229. {
  230. sizeList.Add(new string[] { row.GetValue("ID"), row.GetValue("SEQ") });
  231. }
  232. ArrayList specList = new ArrayList();
  233. foreach (var row in specRows)
  234. {
  235. specList.Add(new string[] { row.GetValue("ID"), row.GetValue("SEQ") });
  236. }
  237. if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == System.Windows.Forms.DialogResult.No)
  238. {
  239. return;
  240. }
  241. ServerHelper.SetData("com.steering.pss.qcm.ComBaseSplineStdSize.delete", new object[] { stdId, sizeList, specList }, ob);
  242. MessageUtil.ShowTips("删除成功!");
  243. Query();
  244. }
  245. private void GridEdite(UltraGridRow row)
  246. {
  247. if (row.GetValue("CHK") == "True")
  248. {
  249. foreach (UltraGridCell cell in row.Cells)
  250. {
  251. if (cell.Column.CellActivation == Activation.AllowEdit)
  252. {
  253. cell.Activation = Activation.AllowEdit;
  254. }
  255. }
  256. }
  257. else
  258. {
  259. foreach (UltraGridCell cell in row.Cells)
  260. {
  261. if (cell.Column.Key == "CHK") continue;
  262. if (cell.Column.CellActivation == Activation.AllowEdit)
  263. {
  264. cell.Activation = Activation.ActivateOnly;
  265. }
  266. }
  267. }
  268. }
  269. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  270. {
  271. e.Cell.Row.Update();
  272. GridEdite(e.Cell.Row);
  273. }
  274. private void ComBaseSplineMinSizeFrm_Load(object sender, EventArgs e)
  275. {
  276. LoadItemData_sub("C", ultraComboEditor3);
  277. }
  278. private void LoadItemData_sub(string itemStyle, UltraComboEditor cmb)
  279. {
  280. ArrayList list = new ArrayList();
  281. list.Add(itemStyle);
  282. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreMaterialItemMng.loadItem",
  283. new object[] { list }, ob);
  284. dt.DefaultView.RowFilter = "ITEM_CODE IN ('I0009', 'I0010', 'I0083', 'I0011', 'I0012', 'I0081', 'I0013', 'I0082', 'I0014')";
  285. dt.DefaultView.Sort = "ITEM_NAME";
  286. DataRow dr = dt.NewRow();
  287. dr["ITEM_CODE"] = "";
  288. dt.Rows.InsertAt(dr, 0);
  289. cmb.DataSource = dt.DefaultView.ToTable();
  290. cmb.DisplayMember = "ITEM_NAME";
  291. cmb.ValueMember = "ITEM_CODE";
  292. cmb.DropDownListWidth = -1;
  293. ClsBaseInfo.SetComboItemHeight(cmb);
  294. }
  295. private void QuerySplineSize(string id)
  296. {
  297. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseSplineStdSize.querySplineSize",
  298. new object[] { id }, ob);
  299. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  300. foreach (var row in ultraGrid1.Rows)
  301. {
  302. GridEdite(row);
  303. }
  304. }
  305. private void QuerySplineSpec(string id)
  306. {
  307. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseSplineStdSize.querySplineSpec",
  308. new object[] { id }, ob);
  309. GridHelper.CopyDataToDatatable(dt, dataTable2, true);
  310. foreach (var row in ultraGrid2.Rows)
  311. {
  312. GridEdite(row);
  313. }
  314. }
  315. private void ultraGrid3_CellChange(object sender, CellEventArgs e)
  316. {
  317. e.Cell.Row.Update();
  318. if (e.Cell.Column.Key == "CHK")
  319. {
  320. UltraGridRow chkRow = e.Cell.Row;
  321. foreach (UltraGridRow row in ultraGrid3.Rows)
  322. {
  323. if (row.Cells["CHK"].Value.ToString() == "True" && row != chkRow)
  324. {
  325. row.Cells["CHK"].Value = "False";
  326. row.Update();
  327. }
  328. }
  329. }
  330. GridEdite(e.Cell.Row);
  331. e.Cell.Row.Update();
  332. }
  333. private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
  334. {
  335. e.Row.Cells["ID"].Value = ultraGrid3.GetActiveRowValue("ID");
  336. }
  337. private void ultraGrid2_AfterRowInsert(object sender, RowEventArgs e)
  338. {
  339. e.Row.Cells["ID"].Value = ultraGrid3.GetActiveRowValue("ID");
  340. }
  341. private void ultraGrid1_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  342. {
  343. if (ultraGrid3.GetActiveRowValue("ID") == "")
  344. {
  345. e.Cancel = true;
  346. }
  347. }
  348. private void ultraGrid2_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  349. {
  350. if (ultraGrid3.GetActiveRowValue("ID") == "")
  351. {
  352. e.Cancel = true;
  353. }
  354. }
  355. private void ultraGrid3_AfterRowActivate(object sender, EventArgs e)
  356. {
  357. string id = ultraGrid3.GetActiveRowValue("ID");
  358. QuerySplineSize(id);
  359. QuerySplineSpec(id);
  360. }
  361. private void ultraTextEditor1_EditorButtonClick(object sender, EditorButtonEventArgs e)
  362. {
  363. this.Cursor = Cursors.WaitCursor;
  364. var actRow = ultraGrid3.ActiveRow;
  365. ComBaseStdChoice baseStdChoice = new ComBaseStdChoice(new string[] { "S" }, actRow.GetValue("SPLINE_STD_CODE"), ob);
  366. this.Cursor = Cursors.Default;
  367. if (baseStdChoice.ShowDialog() == DialogResult.OK)
  368. {
  369. actRow.SetValue("SPLINE_STD_CODE", baseStdChoice.ChoiceStdCodes);
  370. actRow.SetValue("SPLINE_STD_NAME", baseStdChoice.ChoiceStdNames);
  371. }
  372. }
  373. private void ultraGrid2_CellChange(object sender, CellEventArgs e)
  374. {
  375. e.Cell.Row.Update();
  376. GridEdite(e.Cell.Row);
  377. }
  378. }
  379. }