DtBaseStdRSpec.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. using Core.Mes.Client.Comm.Format;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using CoreFS.SA06;
  5. using Infragistics.Win.UltraWinGrid;
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Linq;
  11. namespace Core.StlMes.Client.Qcm
  12. {
  13. public class DtBaseStdRSpec : DtBaseQcm
  14. {
  15. private CtrlBaseStdRSpec _ctrlBaseStdRSpec;
  16. private string _rlcMinD = null;
  17. private string _rlcMaxD = null;
  18. private string _rlcMinH = null;
  19. private string _rlcMaxH = null;
  20. private string _rlcSpecCode = "";
  21. public DtBaseStdRSpec(CtrlBaseStdRSpec ctrlBaseStdRSpec)
  22. {
  23. _ctrlBaseStdRSpec = ctrlBaseStdRSpec;
  24. this.DefaultQueryKey = "Query";
  25. this.RegistQuery(Query, "Query");
  26. this.RegistAction(NoQuery, ActionType.Save);
  27. this.RegistAction(NoQuery, ActionType.Delete);
  28. this.RegistAction(NoQuery, ActionType.Resume);
  29. }
  30. protected override bool CheckData(ActionType actionType, out System.Collections.ArrayList parm, out string msg)
  31. {
  32. parm = new ArrayList();
  33. msg = "";
  34. ArrayList list = new ArrayList();
  35. UltraGridRow[] rows = _ctrlBaseStdRSpec.QueryableRows.ToArray();
  36. foreach (UltraGridRow row in rows)
  37. {
  38. BaseStdRSpecEntity baseStdRSpecEntity = EntityHelper.CopyEntity<BaseStdRSpecEntity>((BaseStdRSpecEntity)row.ListObject);
  39. if (CheckData(baseStdRSpecEntity, row, actionType, out msg) == false)
  40. {
  41. return false;
  42. }
  43. string strJSON = JSONFormat.Format(baseStdRSpecEntity);
  44. list.Add(strJSON);
  45. _rlcMinD = string.Format("{0:####.00}", baseStdRSpecEntity.MinD);
  46. _rlcMaxD = string.Format("{0:####.00}", baseStdRSpecEntity.MaxD);
  47. _rlcMinH = string.Format("{0:####.00}", baseStdRSpecEntity.MinH);
  48. _rlcMaxH = string.Format("{0:####.00}", baseStdRSpecEntity.MaxH);
  49. _rlcSpecCode = baseStdRSpecEntity.SpecCode.ToString();
  50. }
  51. parm.Add(list);
  52. string strAction = Enum.GetName(typeof(ActionType), actionType);
  53. parm.Add(strAction);
  54. return true;
  55. }
  56. private bool CheckData(BaseStdRSpecEntity baseStdRSpecEntity, UltraGridRow row,
  57. ActionType actionType, out string msg)
  58. {
  59. msg = "";
  60. if (actionType == ActionType.Save)
  61. {
  62. if (baseStdRSpecEntity.MscStyle.ToString() == "")
  63. {
  64. msg = "请选择规格类型";
  65. row.SetCellActive("MscStyle");
  66. return false;
  67. }
  68. if (baseStdRSpecEntity.MscStyle.ToString() == "A")
  69. {
  70. if (baseStdRSpecEntity.MinD.ToString() == "")
  71. {
  72. msg = "请输入外径(下限)!";
  73. row.SetCellActive("MinD");
  74. return false;
  75. }
  76. if (baseStdRSpecEntity.MaxD.ToString() == "")
  77. {
  78. msg = "请输入外径(上限)!";
  79. row.SetCellActive("MaxD");
  80. return false;
  81. }
  82. if (baseStdRSpecEntity.MinH.ToString() == "")
  83. {
  84. msg = "请输入壁厚(下限)!";
  85. row.SetCellActive("MinH");
  86. return false;
  87. }
  88. if (baseStdRSpecEntity.MaxH.ToString() == "")
  89. {
  90. msg = "请输入壁厚(上限)!";
  91. row.SetCellActive("MaxH");
  92. return false;
  93. }
  94. if (decimal.Parse(baseStdRSpecEntity.MinD.ToString()) <= 0)
  95. {
  96. msg = "外径(下限)不能小于或者等于0!";
  97. row.SetCellActive("MinD");
  98. return false;
  99. }
  100. if (decimal.Parse(baseStdRSpecEntity.MaxD.ToString()) <= 0)
  101. {
  102. msg = "外径(上限)不能小于或者等于0!";
  103. row.SetCellActive("MaxD");
  104. return false;
  105. }
  106. if (decimal.Parse(baseStdRSpecEntity.MinH.ToString()) <= 0)
  107. {
  108. msg = "壁厚(下限)不能小于或者等于0!";
  109. row.SetCellActive("MinH");
  110. return false;
  111. }
  112. if (decimal.Parse(baseStdRSpecEntity.MaxH.ToString()) <= 0)
  113. {
  114. msg = "壁厚(上限)不能小于或者等于0!";
  115. row.SetCellActive("MaxH");
  116. return false;
  117. }
  118. if (decimal.Parse(baseStdRSpecEntity.MaxD.ToString())
  119. < decimal.Parse(baseStdRSpecEntity.MinD.ToString()))
  120. {
  121. msg = "外径(上限)不能小于外径(下限)!";
  122. row.SetCellActive("MaxD");
  123. return false;
  124. }
  125. if (decimal.Parse(baseStdRSpecEntity.MaxH.ToString())
  126. < decimal.Parse(baseStdRSpecEntity.MinH.ToString()))
  127. {
  128. msg = "壁厚(上限)不能小于壁厚(下限)!";
  129. row.SetCellActive("MaxH");
  130. return false;
  131. }
  132. }
  133. else if (baseStdRSpecEntity.MscStyle.ToString() == "B")
  134. {
  135. if (baseStdRSpecEntity.MinD.ToString() == "")
  136. {
  137. msg = "请输入外径(下限)!";
  138. row.SetCellActive("MinD");
  139. return false;
  140. }
  141. if (baseStdRSpecEntity.MaxD.ToString() == "")
  142. {
  143. msg = "请输入外径(上限)!";
  144. row.SetCellActive("MaxD");
  145. return false;
  146. }
  147. if (decimal.Parse(baseStdRSpecEntity.MinD.ToString()) <= 0)
  148. {
  149. msg = "外径(下限)不能小于或者等于0!";
  150. row.SetCellActive("MinD");
  151. return false;
  152. }
  153. if (decimal.Parse(baseStdRSpecEntity.MaxD.ToString()) <= 0)
  154. {
  155. msg = "外径(上限)不能小于或者等于0!";
  156. row.SetCellActive("MaxD");
  157. return false;
  158. }
  159. if (decimal.Parse(baseStdRSpecEntity.MaxD.ToString())
  160. < decimal.Parse(baseStdRSpecEntity.MinD.ToString()))
  161. {
  162. msg = "外径(上限)不能小于外径(下限)!";
  163. row.SetCellActive("MaxD");
  164. return false;
  165. }
  166. }
  167. else if (baseStdRSpecEntity.MscStyle.ToString() == "C")
  168. {
  169. if (baseStdRSpecEntity.SpecCode.ToString() == "")
  170. {
  171. msg = "请选择其它规格!";
  172. row.SetCellActive("SpecCode");
  173. return false;
  174. }
  175. }
  176. if (IsExistSpec(baseStdRSpecEntity) == true)
  177. {
  178. msg = "该标准下已存在相同的规格范围,请检查后再进行保存!";
  179. row.Activate();
  180. return false;
  181. }
  182. }
  183. else if (actionType == ActionType.Delete)
  184. {
  185. baseStdRSpecEntity.Validflag = "0";
  186. }
  187. else if (actionType == ActionType.Resume)
  188. {
  189. baseStdRSpecEntity.Validflag = "1";
  190. }
  191. baseStdRSpecEntity.CreateName = CoreUserInfo.UserInfo.GetUserName();
  192. baseStdRSpecEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  193. baseStdRSpecEntity.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  194. return true;
  195. }
  196. protected override bool IsSelectData(ActionType actionType, out string msg)
  197. {
  198. msg = "";
  199. return true;
  200. }
  201. public void Query()
  202. {
  203. string strJSON = JSONFormat.Format(_ctrlBaseStdRSpec.QueryCondition);
  204. List<BaseStdRSpecEntity> listSource = EntityHelper.GetData<BaseStdRSpecEntity>(
  205. "com.steering.pss.qcm.BaseStdRSpec.query", new object[] { strJSON }, _ctrlBaseStdRSpec.Ob);
  206. _ctrlBaseStdRSpec.BaseStdRSpecEntityBindingSource.DataSource = listSource;
  207. if ((_rlcMinD + _rlcMaxD + _rlcMinH + _rlcMaxH + _rlcSpecCode) != "")
  208. {
  209. UltraGridRow[] rows = _ctrlBaseStdRSpec.UltraGrid1.Rows.AsQueryable().Where(
  210. a => string.Format("{0:####.00}", a.Cells["MinD"].Value) == _rlcMinD && string.Format("{0:####.00}", a.Cells["MaxD"].Value) == _rlcMaxD
  211. && string.Format("{0:####.00}", a.Cells["MinH"].Value) == _rlcMinH
  212. && string.Format("{0:####.00}", a.Cells["MaxH"].Value) == _rlcMaxH && a.GetValue("SpecCode") == _rlcSpecCode).ToArray();
  213. if (rows.Length > 0)
  214. {
  215. rows[0].Activate();
  216. }
  217. _rlcMinD = "";
  218. _rlcMaxD = "";
  219. _rlcMinH = "";
  220. _rlcMaxH = "";
  221. _rlcSpecCode = "";
  222. }
  223. else
  224. {
  225. if (_ctrlBaseStdRSpec.UltraGrid1.Rows.Count > 0)
  226. {
  227. _ctrlBaseStdRSpec.UltraGrid1.Rows[0].Activate();
  228. }
  229. }
  230. foreach (UltraGridRow row in _ctrlBaseStdRSpec.UltraGrid1.Rows)
  231. {
  232. _ctrlBaseStdRSpec.ControlGridEdit(row);
  233. }
  234. //GridHelper.RefreshAndAutoSize(_ctrlBaseStdRSpec.UltraGrid1);
  235. }
  236. public bool NoQuery()
  237. {
  238. ArrayList list = (ArrayList)Parm[0];
  239. string strAction = Parm[1].ToString();
  240. ServerHelper.SetData("com.steering.pss.qcm.BaseStdRSpec.noQuery",
  241. new object[] { list, strAction }, _ctrlBaseStdRSpec.Ob);
  242. return true;
  243. }
  244. public ArrayList GetNoQueryParms(ActionType actionType, out string msg)
  245. {
  246. msg = "";
  247. ArrayList list = new ArrayList();
  248. if (IsSelectData(actionType, out msg) == false)
  249. {
  250. return null;
  251. }
  252. else
  253. {
  254. if (CheckData(actionType, out list, out msg) == false)
  255. {
  256. return null;
  257. }
  258. else
  259. {
  260. return (ArrayList)list[0];
  261. }
  262. }
  263. }
  264. private bool IsExistSpec(BaseStdRSpecEntity baseStdRSpecEntity)
  265. {
  266. string strJSON = JSONFormat.Format(baseStdRSpecEntity);
  267. string newPrimaryKey = baseStdRSpecEntity.StdCode.ToString() + baseStdRSpecEntity.MinD.ToString() +
  268. baseStdRSpecEntity.MaxD.ToString() + baseStdRSpecEntity.MinH.ToString() + baseStdRSpecEntity.MaxH.ToString()
  269. + baseStdRSpecEntity.SpecCode.ToString();
  270. string oldPrimaryKey = baseStdRSpecEntity.StdCodeOld.ToString() + baseStdRSpecEntity.MinDOld.ToString() +
  271. baseStdRSpecEntity.MaxDOld.ToString() + baseStdRSpecEntity.MinHOld.ToString() + baseStdRSpecEntity.MaxHOld.ToString()
  272. + baseStdRSpecEntity.SpecCodeOld.ToString();
  273. if (baseStdRSpecEntity.Validflag.ToString() != ""
  274. && newPrimaryKey == oldPrimaryKey)
  275. {
  276. return false;
  277. }
  278. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.BaseStdRSpec.isExistSpec",
  279. new object[] { strJSON }, _ctrlBaseStdRSpec.Ob);
  280. if (dt.Rows[0][0].ToString() == "0")
  281. {
  282. return false;
  283. }
  284. else
  285. {
  286. return true;
  287. }
  288. }
  289. }
  290. }