DtGrandeRSpec.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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 Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. namespace Core.StlMes.Client.Qcm
  12. {
  13. class DtGrandeRSpec : DtBaseQcm
  14. {
  15. private PopupGrandeRSpec _popGradeRSpec = null;
  16. public DtGrandeRSpec(PopupGrandeRSpec popGradeRSpec)
  17. {
  18. _popGradeRSpec = popGradeRSpec;
  19. this.RegistAction(SaveGradRSpec, ActionType.Save);
  20. this.RegistAction(DeleteSpec, ActionType.Delete);
  21. this.RegistAction(ResumeSpec, ActionType.Resume);
  22. this.RegistQuery(QueryGrade, "QueryGrade");
  23. this.RegistQuery(QueryGradeRSpec, "QueryGradeRSpec");
  24. this.DefaultQueryKey = "QueryGrade";
  25. }
  26. protected override bool CheckData(ActionType actionType, out ArrayList parm, out string msg)
  27. {
  28. _popGradeRSpec.UltraGrid2.UpdateData();
  29. parm = new ArrayList();
  30. msg = "";
  31. string gradeJson = JSONFormat.Format(_popGradeRSpec.UltraGrid1.ActiveRow.ListObject);
  32. ArrayList parmSpec = new ArrayList();
  33. foreach (UltraGridRow row in _popGradeRSpec.UltraGrid2.Rows)
  34. {
  35. if (row.GetValue("CHK") == "True")
  36. {
  37. ComMscGradeRSpecEntity comMscGradeRSpecEntity = EntityHelper.CopyEntity<ComMscGradeRSpecEntity>((ComMscGradeRSpecEntity)row.ListObject);
  38. comMscGradeRSpecEntity.CreateName = _popGradeRSpec.UserInfo.GetUserName();
  39. comMscGradeRSpecEntity.UpdateName = _popGradeRSpec.UserInfo.GetUserName();
  40. comMscGradeRSpecEntity.DeleteName = _popGradeRSpec.UserInfo.GetUserName();
  41. bool checkResult = CheckData(comMscGradeRSpecEntity, row, actionType, out msg);
  42. if (checkResult == false) return false;
  43. string strJSON = JSONFormat.Format(comMscGradeRSpecEntity);
  44. parmSpec.Add(strJSON);
  45. }
  46. }
  47. parm.Add(gradeJson);
  48. parm.Add(parmSpec);
  49. return true;
  50. }
  51. protected override bool IsSelectData(ActionType actionType, out string msg)
  52. {
  53. _popGradeRSpec.UltraGrid1.UpdateData();
  54. _popGradeRSpec.UltraGrid2.UpdateData();
  55. msg = "";
  56. return true;
  57. //UltraGridRow[] rows = _popGradeRSpec.UltraGrid2.Rows.AsQueryable().Where("CHK = 'True'").ToArray();
  58. //if(rows.Length == 0)
  59. //{
  60. // return false;
  61. //}
  62. //else
  63. //{
  64. // return true;
  65. //}
  66. }
  67. private bool CheckData(ComMscGradeRSpecEntity comMscGradeRSpecEntity, UltraGridRow row,
  68. ActionType actionType, out string msg)
  69. {
  70. msg = "";
  71. if (actionType == ActionType.Save)
  72. {
  73. if (comMscGradeRSpecEntity.DimaterMin.ToString() == "")
  74. {
  75. msg = "请输入外径(下限)!";
  76. row.SetCellActive("DimaterMin");
  77. return false;
  78. }
  79. if (comMscGradeRSpecEntity.DimaterMax.ToString() == "")
  80. {
  81. msg = "请输入外径(上限)!";
  82. row.SetCellActive("DimaterMax");
  83. return false;
  84. }
  85. if (comMscGradeRSpecEntity.HeightMin.ToString() == "")
  86. {
  87. msg = "请输入壁厚(下限)!";
  88. row.SetCellActive("HeightMin");
  89. return false;
  90. }
  91. if (comMscGradeRSpecEntity.HeightMiax.ToString() == "")
  92. {
  93. msg = "请输入壁厚(上限)!";
  94. row.SetCellActive("HeightMiax");
  95. return false;
  96. }
  97. if (comMscGradeRSpecEntity.DimaterMin.ToString().TryParseDecimal() == false)
  98. {
  99. msg = "外径(下限)不是有效数字!";
  100. row.SetCellActive("DimaterMin");
  101. return false;
  102. }
  103. if (comMscGradeRSpecEntity.DimaterMax.ToString().TryParseDecimal() == false)
  104. {
  105. msg = "外径(上限)不是有效数字!";
  106. row.SetCellActive("DimaterMax");
  107. return false;
  108. }
  109. if (comMscGradeRSpecEntity.HeightMin.ToString().TryParseDecimal() == false)
  110. {
  111. msg = "壁厚(下限)不是有效数字!";
  112. row.SetCellActive("HEIGHT_MIN");
  113. return false;
  114. }
  115. if (comMscGradeRSpecEntity.HeightMiax.ToString().TryParseDecimal() == false)
  116. {
  117. msg = "壁厚(上限)不是有效数字!";
  118. row.SetCellActive("HeightMiax");
  119. return false;
  120. }
  121. if (decimal.Parse(comMscGradeRSpecEntity.DimaterMin.ToString()) <= 0)
  122. {
  123. msg = "外径(下限)不能小于或者等于0!";
  124. row.SetCellActive("DimaterMin");
  125. return false;
  126. }
  127. if (decimal.Parse(comMscGradeRSpecEntity.DimaterMax.ToString()) <= 0)
  128. {
  129. msg = "外径(上限)不能小于或者等于0!";
  130. row.SetCellActive("DimaterMax");
  131. return false;
  132. }
  133. if (decimal.Parse(comMscGradeRSpecEntity.HeightMin.ToString()) <= 0)
  134. {
  135. msg = "壁厚(下限)不能小于或者等于0!";
  136. row.SetCellActive("HeightMin");
  137. return false;
  138. }
  139. if (decimal.Parse(comMscGradeRSpecEntity.HeightMiax.ToString()) <= 0)
  140. {
  141. msg = "壁厚(上限)不能小于或者等于0!";
  142. row.SetCellActive("HeightMiax");
  143. return false;
  144. }
  145. if (decimal.Parse(comMscGradeRSpecEntity.DimaterMax.ToString())
  146. < decimal.Parse(comMscGradeRSpecEntity.DimaterMin.ToString()))
  147. {
  148. msg = "外径(上限)不能小于外径(下限)!";
  149. row.SetCellActive("DimaterMax");
  150. return false;
  151. }
  152. if (decimal.Parse(comMscGradeRSpecEntity.HeightMiax.ToString())
  153. < decimal.Parse(comMscGradeRSpecEntity.HeightMin.ToString()))
  154. {
  155. msg = "壁厚(上限)不能小于壁厚(下限)!";
  156. row.SetCellActive("HeightMiax");
  157. return false;
  158. }
  159. if (IsExistSpec(comMscGradeRSpecEntity) == true)
  160. {
  161. msg = "该钢种下已存在相同的规格范围,请检查后再进行保存!";
  162. row.Activate();
  163. return false;
  164. }
  165. }
  166. else if (actionType == ActionType.Delete)
  167. {
  168. comMscGradeRSpecEntity.Validflag = "0";
  169. }
  170. else if (actionType == ActionType.Resume)
  171. {
  172. comMscGradeRSpecEntity.Validflag = "1";
  173. }
  174. return true;
  175. }
  176. private bool IsExistSpec(ComMscGradeRSpecEntity comMscGradeRSpecEntity)
  177. {
  178. string strJSON = JSONFormat.Format(comMscGradeRSpecEntity);
  179. string newPrimaryKey = comMscGradeRSpecEntity.Msc.ToString() + comMscGradeRSpecEntity.MscPline.ToString() +
  180. comMscGradeRSpecEntity.Gradecode.ToString() +
  181. comMscGradeRSpecEntity.HeightMin.ToString() + comMscGradeRSpecEntity.HeightMiax.ToString() +
  182. comMscGradeRSpecEntity.DimaterMin.ToString() + comMscGradeRSpecEntity.DimaterMax.ToString();
  183. if (comMscGradeRSpecEntity.CreateTime.ToString() != ""
  184. && newPrimaryKey == comMscGradeRSpecEntity.PrimaryKey.ToString())
  185. {
  186. return false;
  187. }
  188. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.GrandeRSpec.isExitSpec",
  189. new object[] { strJSON }, _popGradeRSpec.ob);
  190. if (dt.Rows[0][0].ToString() == "0")
  191. {
  192. return false;
  193. }
  194. else
  195. {
  196. return true;
  197. }
  198. }
  199. public void QueryGrade()
  200. {
  201. ComMscGradeEntity comMscGradeEntity = new ComMscGradeEntity();
  202. comMscGradeEntity.Msc = _popGradeRSpec.Msc;
  203. comMscGradeEntity.MscPline = _popGradeRSpec.MscPline;
  204. // comMscGradeEntity.Gradecode = _popGradeRSpec.GradeCode;
  205. string strJSON = JSONFormat.Format(comMscGradeEntity);
  206. List<ComMscGradeEntity> list = EntityHelper.GetData<ComMscGradeEntity>(
  207. "com.steering.pss.qcm.GrandeRSpec.queryGrade", new object[] { strJSON }, _popGradeRSpec.ob);
  208. _popGradeRSpec.ComMscGradeEntityBindingSource.DataSource = list;
  209. GridHelper.RefreshAndAutoSize(_popGradeRSpec.UltraGrid1);
  210. }
  211. public void QueryGradeRSpec()
  212. {
  213. ComMscGradeEntity comMscGradeEntity = (ComMscGradeEntity)_popGradeRSpec.UltraGrid1.ActiveRow.ListObject;
  214. string strJSON = JSONFormat.Format(comMscGradeEntity);
  215. string strIsDelete = _popGradeRSpec.CkbDelete.Checked ? "0" : "1";
  216. List<ComMscGradeRSpecEntity> list = EntityHelper.GetData<ComMscGradeRSpecEntity>(
  217. "com.steering.pss.qcm.GrandeRSpec.querySpec", new object[] { strJSON, strIsDelete }, _popGradeRSpec.ob);
  218. _popGradeRSpec.ComMscGradeRSpecEntityBindingSource.DataSource = list;
  219. GridHelper.RefreshAndAutoSize(_popGradeRSpec.UltraGrid2);
  220. }
  221. public bool SaveGradRSpec()
  222. {
  223. ServerHelper.SetData("com.steering.pss.qcm.GrandeRSpec.saveSpec",
  224. new object[] { Parm[0], Parm[1] }, _popGradeRSpec.ob);
  225. return true;
  226. }
  227. public bool DeleteSpec()
  228. {
  229. ServerHelper.SetData("com.steering.pss.qcm.GrandeRSpec.deleteOrResumeSpec",
  230. new object[] { Parm[1] }, _popGradeRSpec.ob);
  231. return true;
  232. }
  233. public bool ResumeSpec()
  234. {
  235. ServerHelper.SetData("com.steering.pss.qcm.GrandeRSpec.deleteOrResumeSpec",
  236. new object[] { Parm[1] }, _popGradeRSpec.ob);
  237. return true;
  238. }
  239. }
  240. }