DtMscRBlSpec.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. using Core.Mes.Client.Comm.Format;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using CoreFS.CA06;
  5. using CoreFS.SA06;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.Linq;
  12. namespace Core.StlMes.Client.Qcm
  13. {
  14. class DtMscRBlSpec : DtBaseQcm
  15. {
  16. private CtrlMscRBlSpec _ctrlMscRBlSpec;
  17. public DtMscRBlSpec(CtrlMscRBlSpec ctrlMscRBlSpec)
  18. {
  19. _ctrlMscRBlSpec = ctrlMscRBlSpec;
  20. this.DefaultQueryKey = "Get";
  21. RegistQuery(Get, "Get");
  22. RegistQuery(GetHead, "GetHead");
  23. RegistAction(Set, ActionType.Save);
  24. RegistAction(UpdateState, ActionType.Delete);
  25. RegistAction(UpdateState, ActionType.Resume);
  26. }
  27. protected override bool CheckData(ActionType actionType, out System.Collections.ArrayList parm, out string msg)
  28. {
  29. msg = "";
  30. parm = new ArrayList();
  31. ArrayList list = new ArrayList();
  32. UltraGridRow[] rows = _ctrlMscRBlSpec.QueryableRows.ToArray();
  33. foreach (UltraGridRow row in rows)
  34. {
  35. ComMscRBlSpecEntity mscRBlSpecEntity = EntityHelper.CopyEntity<ComMscRBlSpecEntity>((ComMscRBlSpecEntity)row.ListObject);
  36. bool result = CheckData(mscRBlSpecEntity, row, actionType, out msg);
  37. if (result == false) return false;
  38. string strJSON = JSONFormat.Format(mscRBlSpecEntity);
  39. list.Add(strJSON);
  40. }
  41. parm.Add(list);
  42. string strAction = Enum.GetName(typeof(ActionType), actionType);
  43. parm.Add(strAction);
  44. return true;
  45. }
  46. private bool CheckData(ComMscRBlSpecEntity mscRBlSpecEntity, UltraGridRow row, ActionType actionType, out string msg)
  47. {
  48. msg = "";
  49. switch (actionType)
  50. {
  51. case ActionType.Save:
  52. //if (mscRBlSpecEntity.SpecCode.ToString() != "" &&
  53. // _ctrlMscRBlSpec.CmbSpec.IsItemInList(mscRBlSpecEntity.SpecCode.ToString()) == false)
  54. //{
  55. // msg = "输入的规格不在基础数据中,请重新选择规格!";
  56. // row.SetCellActive("SpecCode");
  57. // return false;
  58. //}
  59. if (mscRBlSpecEntity.SpecCode.ToString2() == "" && mscRBlSpecEntity.MinD == null && mscRBlSpecEntity.MaxD == null
  60. && mscRBlSpecEntity.MinH == null && mscRBlSpecEntity.MaxH == null)
  61. {
  62. msg = "请维护适用规格";
  63. row.Activate();
  64. return false;
  65. }
  66. else if (mscRBlSpecEntity.SpecCode.ToString2() != "" && (mscRBlSpecEntity.MinD != null || mscRBlSpecEntity.MaxD != null
  67. || mscRBlSpecEntity.MinH != null && mscRBlSpecEntity.MaxH != null))
  68. {
  69. msg = "不能同时维护其他规格与适用成品规格";
  70. row.Activate();
  71. return false;
  72. }
  73. if (mscRBlSpecEntity.MinD != null && mscRBlSpecEntity.MaxD != null && mscRBlSpecEntity.MinD > mscRBlSpecEntity.MaxD)
  74. {
  75. msg = "外径最小值不能大于最大值!";
  76. row.SetCellActive("MinD");
  77. return false;
  78. }
  79. if (mscRBlSpecEntity.MinH != null && mscRBlSpecEntity.MaxH != null && mscRBlSpecEntity.MinH > mscRBlSpecEntity.MaxH)
  80. {
  81. msg = "壁厚最小值不能大于最大值!";
  82. row.SetCellActive("MinH");
  83. return false;
  84. }
  85. break;
  86. case ActionType.Delete:
  87. if (mscRBlSpecEntity.RowIndex.ToString() == "")
  88. {
  89. msg = "系统不存在该条记录,不能作废!";
  90. row.Activate();
  91. return false;
  92. }
  93. break;
  94. case ActionType.Resume:
  95. if (mscRBlSpecEntity.RowIndex.ToString() == "")
  96. {
  97. msg = "系统不存在该条记录,不能恢复!";
  98. row.Activate();
  99. return false;
  100. }
  101. break;
  102. }
  103. mscRBlSpecEntity.Msc = _ctrlMscRBlSpec.QueryCondition.Msc.ToString();
  104. mscRBlSpecEntity.GroupNum = _ctrlMscRBlSpec.QueryCondition.GroupNum.ToString();
  105. mscRBlSpecEntity.CreateName = CoreUserInfo.UserInfo.GetUserName();
  106. mscRBlSpecEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  107. mscRBlSpecEntity.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  108. return true;
  109. }
  110. protected override bool IsSelectData(ActionType actionType, out string msg)
  111. {
  112. msg = "";
  113. int count = _ctrlMscRBlSpec.QueryableRows.Count();
  114. if (count == 0)
  115. {
  116. msg = "请选择一条规格后,再进行操作!";
  117. return false;
  118. }
  119. return true;
  120. }
  121. public void Get()
  122. {
  123. string strJSON = JSONFormat.Format(_ctrlMscRBlSpec.QueryCondition);
  124. List<ComMscRBlSpecEntity> listSource = EntityHelper.GetData<ComMscRBlSpecEntity>(
  125. "com.steering.pss.qcm.MscRBlSpec.get", new object[] { strJSON }, _ctrlMscRBlSpec.Ob);
  126. _ctrlMscRBlSpec.MscRBlSpecSrc.DataSource = listSource;
  127. foreach (UltraGridRow row in _ctrlMscRBlSpec.UltraGrid1.Rows)
  128. {
  129. _ctrlMscRBlSpec.ControlUltraGrid1Edit(row);
  130. _ctrlMscRBlSpec.SetInvalidColor(row);
  131. }
  132. }
  133. public void GetHead()
  134. {
  135. string strJSON = JSONFormat.Format(_ctrlMscRBlSpec.QueryCondition);
  136. List<ComMscRBlSpecEntity> listSource = EntityHelper.GetData<ComMscRBlSpecEntity>(
  137. "com.steering.pss.qcm.MscRBlSpec.getBlSpecHead", new object[] { strJSON }, _ctrlMscRBlSpec.Ob);
  138. _ctrlMscRBlSpec.MscRBlSpecSrc.DataSource = listSource;
  139. }
  140. public bool Set()
  141. {
  142. ArrayList list = (ArrayList)Parm[0];
  143. ServerHelper.SetData("com.steering.pss.qcm.MscRBlSpec.set",
  144. new object[] { list }, _ctrlMscRBlSpec.Ob);
  145. return true;
  146. }
  147. public bool UpdateState()
  148. {
  149. ArrayList list = (ArrayList)Parm[0];
  150. string strAction = Parm[1].ToString();
  151. ServerHelper.SetData("com.steering.pss.qcm.MscRBlSpec.updateState",
  152. new object[] { list, strAction }, _ctrlMscRBlSpec.Ob);
  153. return true;
  154. }
  155. public DataTable GetGroupBl(string groupNum, string msc)
  156. {
  157. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.MscRBlSpec.getGroupBl",
  158. new object[] { groupNum, msc }, _ctrlMscRBlSpec.Ob);
  159. return dt;
  160. }
  161. /// <summary>
  162. /// 获取分组中备料的适用信息
  163. /// </summary>
  164. /// <param name="msc"></param>
  165. /// <param name="groupNum"></param>
  166. /// <param name="pscBl"></param>
  167. /// <param name="ob"></param>
  168. /// <returns></returns>
  169. public static DataTable GetGroupBlInfo(string msc, string groupNum, string pscBl, OpeBase ob)
  170. {
  171. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.MscRBlSpec.getGroupBlInfo",
  172. new object[] { msc, groupNum, pscBl }, ob);
  173. return dt;
  174. }
  175. }
  176. }