DtPhyRStd.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Format;
  3. using Core.Mes.Client.Comm.Server;
  4. using System;
  5. using System.Collections;
  6. using System.Data;
  7. using System.Windows.Forms;
  8. namespace Core.StlMes.Client.Qcm
  9. {
  10. class DtPhyRStd : DtBaseQcm
  11. {
  12. private FrmPhyRStd _frm;
  13. public DtPhyRStd(FrmPhyRStd frm)
  14. {
  15. _frm = frm;
  16. RegistQuery(Query, "DefaultQuery");
  17. RegistAction(Add, ActionType.Add);
  18. RegistAction(Modify, ActionType.Modify);
  19. RegistAction(Save, ActionType.Save);
  20. RegistAction(Delete, ActionType.Delete);
  21. RegistAction(Resume, ActionType.Resume);
  22. RegistAction(SubMitAudit, ActionType.SubMitAudit);
  23. RegistAction(Audit, ActionType.Audit);
  24. RegistAction(Group, ActionType.Group);
  25. }
  26. protected void Query()
  27. {
  28. ArrayList list = new ArrayList();
  29. list.Add(_frm.LblIsDelete.Checked ? "0" : "1");
  30. list.Add(_frm.CmbPhyType2.SelecteValue == null ? "" : _frm.CmbPhyType2.SelecteValue.ToString());
  31. list.Add(_frm.CmbPhyType2.SelecteValue == null ? "" : _frm.CmbPhyType2.SelecteValue.ToString());
  32. list.Add(_frm.CmbPhyType2.SelecteValue == null ? "" : _frm.CmbPhyType2.SelecteValue.ToString());
  33. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBasePhyRStdMng.query", new object[] { list }, _frm.ob);
  34. GridHelper.CopyDataToDatatable(dt, _frm.DataTable, true);
  35. GridHelper.RefreshAndAutoSize(_frm.Grid);
  36. }
  37. protected bool Add()
  38. {
  39. bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(_frm.FileList);
  40. if (isSuccess)
  41. {
  42. //MessageBox.Show("上传成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  43. //return pathList;
  44. int count = ServerHelper.SetData("com.steering.pss.qcm.ComBasePhyRStdMng.insert",
  45. new object[] { Parm }, _frm.ob);
  46. if (count > 0)
  47. return true;
  48. else
  49. {
  50. //删掉上传的图片。
  51. Core.Mes.Client.Comm.Server.FileHelper.Delete(_frm.FilePath);
  52. return false;
  53. }
  54. }
  55. else
  56. {
  57. MessageBox.Show("文件上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  58. return false;
  59. }
  60. }
  61. protected bool Modify()
  62. {
  63. bool flag = Core.Mes.Client.Comm.Server.FileHelper.Delete(_frm.OldfilePath);
  64. if (flag)
  65. {
  66. bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(_frm.FileList);
  67. if (isSuccess)
  68. {
  69. int count = ServerHelper.SetData("com.steering.pss.qcm.ComBasePhyRStdMng.update",
  70. new object[] { Parm }, _frm.ob);
  71. if (count > 0)
  72. return true;
  73. else
  74. {
  75. //删掉上传的图片。
  76. Core.Mes.Client.Comm.Server.FileHelper.Delete(_frm.FilePath);
  77. return false;
  78. }
  79. }
  80. return false;
  81. }
  82. else
  83. {
  84. return false;
  85. }
  86. }
  87. protected bool Save()
  88. {
  89. throw new NotImplementedException();
  90. }
  91. protected bool Group()
  92. {
  93. throw new NotImplementedException();
  94. }
  95. protected bool Delete()
  96. {
  97. ArrayList list = new ArrayList();
  98. list.Add(_frm.Grid.ActiveRow.Cells["PHY_STD_ID"].Value.ToString());
  99. list.Add(_frm.UserInfo.GetUserName());
  100. list.Add("0");
  101. ServerHelper.SetData("com.steering.pss.qcm.ComBasePhyRStdMng.deleteOrResume",
  102. new object[] { list }, _frm.ob);
  103. return true;
  104. }
  105. protected bool Resume()
  106. {
  107. ArrayList list = new ArrayList();
  108. list.Add(_frm.Grid.ActiveRow.Cells["PHY_STD_ID"].Value.ToString());
  109. list.Add(_frm.UserInfo.GetUserName());
  110. list.Add("1");
  111. ServerHelper.SetData("com.steering.pss.qcm.ComBasePhyRStdMng.deleteOrResume",
  112. new object[] { list }, _frm.ob);
  113. return true;
  114. }
  115. protected bool SubMitAudit()
  116. {
  117. throw new NotImplementedException();
  118. }
  119. protected bool Audit()
  120. {
  121. throw new NotImplementedException();
  122. }
  123. protected override bool CheckData(ActionType actionType, out ArrayList parm, out string msg)
  124. {
  125. msg = "";
  126. parm = new ArrayList();
  127. if (actionType != ActionType.Add && actionType != ActionType.Modify) return true;
  128. ComBasePhyRStdEntity comBasePhyRStdEntity = GetParm(actionType);
  129. if (comBasePhyRStdEntity == null) return false;
  130. string strObj = JSONFormat.Format(comBasePhyRStdEntity);
  131. if (IsExistPhyStdId(strObj))
  132. {
  133. string newPhyStdId = _frm.CmbPhyType.SelecteValue.ToString()
  134. + _frm.CmbStdName.SelecteValue.ToString()
  135. + _frm.CmbStdAlpha.SelecteValue.ToString()
  136. + _frm.CmbPhyStd.SelecteValue.ToString();
  137. string oldPhyStdId = _frm.Grid.ActiveRow.Cells["PHY_STD_ID"].Value.ToString();
  138. if (actionType == ActionType.Add)
  139. {
  140. msg = "系统已经存在检验项和标准的对应关系!";
  141. return false;
  142. }
  143. else if (actionType == ActionType.Modify && newPhyStdId != oldPhyStdId)
  144. {
  145. msg = "系统已经存在检验项和标准的对应关系!";
  146. return false;
  147. }
  148. }
  149. parm.Add(strObj);
  150. return true;
  151. }
  152. protected ComBasePhyRStdEntity GetParm(ActionType actionType)
  153. {
  154. if (actionType == ActionType.Modify || actionType == ActionType.Add)
  155. {
  156. FrmDtConverter<ComBasePhyRStdEntity> convert = new FrmDtConverter<ComBasePhyRStdEntity>();
  157. ComBasePhyRStdEntity comBasePhyRStdEntity = convert.Convert(_frm.FlowPanel, _frm.UserInfo, ControlAttributeType.NoQueryControl);
  158. if (comBasePhyRStdEntity == null)
  159. {
  160. return null;
  161. }
  162. comBasePhyRStdEntity.StdFilePath = _frm.UltraTextEditor1.Text.Trim();
  163. if (_frm.Grid.ActiveRow != null)
  164. comBasePhyRStdEntity.PhyStdId = _frm.Grid.ActiveRow.Cells["PHY_STD_ID"].Value.ToString();
  165. return comBasePhyRStdEntity;
  166. }
  167. return null;
  168. }
  169. protected override bool IsSelectData(ActionType actionType, out string msg)
  170. {
  171. msg = "";
  172. if (actionType != ActionType.Add)
  173. {
  174. if (_frm.Grid.ActiveRow == null)
  175. {
  176. return false;
  177. }
  178. }
  179. return true;
  180. }
  181. private bool IsExistPhyStdId(string strJSON)
  182. {
  183. try
  184. {
  185. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBasePhyRStdMng.isExistPhyStdId",
  186. new object[] { strJSON }, _frm.ob);
  187. if (dt.Rows[0][0].ToString() == "0")
  188. {
  189. return false;
  190. }
  191. }
  192. catch { }
  193. return true;
  194. }
  195. }
  196. }