CraftOrdDesignAuditCtrl.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Core.StlMes.Client.SaleOrder.BLL;
  10. using CoreFS.CA06;
  11. using Core.Mes.Client.Comm.Tool;
  12. using Infragistics.Win.UltraWinGrid;
  13. using CoreFS.SA06;
  14. using Core.Mes.Client.Comm.Server;
  15. namespace Core.StlMes.Client.SaleOrder.Control
  16. {
  17. public partial class CraftOrdDesignAuditCtrl : UserControl
  18. {
  19. private CraftOrdDesignBLL _craftOrdDesignBLL;
  20. private OpeBase ob = null;
  21. public CraftOrdDesignAuditCtrl(System.Windows.Forms.Control container, OpeBase ob)
  22. {
  23. InitializeComponent();
  24. this.ob = ob;
  25. _craftOrdDesignBLL = new CraftOrdDesignBLL(ob);
  26. this.Dock = DockStyle.Fill;
  27. container.Controls.Add(this);
  28. EntityHelper.ShowGridCaption<CraftOrdDesignAuditEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  29. }
  30. private string[] _dataPurviewIds;
  31. private string _userId;
  32. private CraftOrdDesignEntity _queryCondition;
  33. /// <summary>
  34. /// 查询工艺评审主表
  35. /// </summary>
  36. /// <param name="craftOrdDesign"></param>
  37. public void Query(CraftOrdDesignEntity craftOrdDesign, string[] DataPurviewIds, string userId)
  38. {
  39. _dataPurviewIds = DataPurviewIds;
  40. _userId = userId;
  41. _queryCondition = craftOrdDesign;
  42. craftOrdDesignEntityBindingSource.DataSource = _craftOrdDesignBLL.QueryAudit(craftOrdDesign, DataPurviewIds, userId);
  43. foreach (UltraGridRow row in ultraGrid1.Rows)
  44. {
  45. GridEdite(row);
  46. }
  47. }
  48. /// <summary>
  49. /// 科室审核审核
  50. /// </summary>
  51. public void Audit(string reason)
  52. {
  53. ultraGrid1.UpdateData();
  54. IQueryable<UltraGridRow> rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'");
  55. if (rows.Count() == 0)
  56. {
  57. MessageUtil.ShowWarning("请选择一行记录!");
  58. return;
  59. }
  60. List<CraftOrdDesignEntity> craftOrdDesignList = new List<CraftOrdDesignEntity>();
  61. foreach (UltraGridRow row in rows)
  62. {
  63. CraftOrdDesignEntity craftOrdDesign = (CraftOrdDesignEntity)row.ListObject;
  64. CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign);
  65. if (craftOrdDesignSts.Validflag != "3")
  66. {
  67. MessageUtil.ShowWarning("只能审核待审状态的工艺文件!");
  68. Relocate(craftOrdDesign);
  69. return;
  70. }
  71. craftOrdDesignList.Add(new CraftOrdDesignEntity()
  72. {
  73. LockFlag = "1",
  74. Validflag = "6",
  75. AuditName = CoreUserInfo.UserInfo.GetUserName(),
  76. OrdLnPk = craftOrdDesign.OrdLnPk,
  77. CraftSeq = craftOrdDesign.CraftSeq,
  78. Reason = reason
  79. });
  80. }
  81. _craftOrdDesignBLL.Audit(craftOrdDesignList);
  82. MessageUtil.ShowTips("审核成功!");
  83. Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]);
  84. }
  85. /// <summary>
  86. /// 相关科室审核
  87. /// </summary>
  88. public void Audit1(string reason)
  89. {
  90. ultraGrid1.UpdateData();
  91. IQueryable<UltraGridRow> rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'");
  92. if (rows.Count() == 0)
  93. {
  94. MessageUtil.ShowWarning("请选择一行记录!");
  95. return;
  96. }
  97. List<CraftOrdDesignEntity> craftOrdDesignList = new List<CraftOrdDesignEntity>();
  98. foreach (UltraGridRow row in rows)
  99. {
  100. CraftOrdDesignEntity craftOrdDesign = (CraftOrdDesignEntity)row.ListObject;
  101. CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign);
  102. if (craftOrdDesignSts.Validflag != "6")
  103. {
  104. MessageUtil.ShowWarning("只能审核待审状态的工艺文件!");
  105. Relocate(craftOrdDesign);
  106. return;
  107. }
  108. craftOrdDesignList.Add(new CraftOrdDesignEntity()
  109. {
  110. LockFlag = "1",
  111. Validflag = "4",
  112. AuditName1 = CoreUserInfo.UserInfo.GetUserName(),
  113. OrdLnPk = craftOrdDesign.OrdLnPk,
  114. CraftSeq = craftOrdDesign.CraftSeq,
  115. Reason = reason
  116. });
  117. }
  118. _craftOrdDesignBLL.Audit1(craftOrdDesignList);
  119. MessageUtil.ShowTips("审核成功!");
  120. Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]);
  121. }
  122. /// <summary>
  123. /// 部门审批
  124. /// </summary>
  125. public void Approval(string reason)
  126. {
  127. ultraGrid1.UpdateData();
  128. IQueryable<UltraGridRow> rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'");
  129. if (rows.Count() == 0)
  130. {
  131. MessageUtil.ShowWarning("请选择一行记录!");
  132. return;
  133. }
  134. List<CraftOrdDesignEntity> craftOrdDesignList = new List<CraftOrdDesignEntity>();
  135. foreach (UltraGridRow row in rows)
  136. {
  137. CraftOrdDesignEntity craftOrdDesign = EntityHelper.CopyEntity<CraftOrdDesignEntity>(row.ListObject);
  138. CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign);
  139. if (craftOrdDesignSts.Validflag != "4")
  140. {
  141. MessageUtil.ShowWarning("只能审批待审批状态的工艺文件!");
  142. Relocate(craftOrdDesign);
  143. return;
  144. }
  145. string validflag = craftOrdDesign.CraftSeq > 1 ? "8" : "1";
  146. //只有技术中心科室的人需要批准操作,否则审批之后直接生效。
  147. /*DataTable dtComMsc = GetComMscByOrdLnPk(craftOrdDesign.OrdLnPk, ob);
  148. if (dtComMsc.Rows[0]["DEPARTMENT_CODE"].ToString() == "002001007")
  149. {
  150. validflag = "7";
  151. }*/
  152. craftOrdDesign.LockFlag = "1";
  153. craftOrdDesign.Validflag = validflag;
  154. craftOrdDesign.ApprovalName = CoreUserInfo.UserInfo.GetUserName();
  155. craftOrdDesign.Reason = reason;
  156. craftOrdDesignList.Add(craftOrdDesign);
  157. }
  158. _craftOrdDesignBLL.Approval(craftOrdDesignList);
  159. MessageUtil.ShowTips("审批成功!");
  160. Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]);
  161. }
  162. /// <summary>
  163. /// 批准
  164. /// </summary>
  165. public void Approval1(string reason)
  166. {
  167. ultraGrid1.UpdateData();
  168. IQueryable<UltraGridRow> rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'");
  169. if (rows.Count() == 0)
  170. {
  171. MessageUtil.ShowWarning("请选择一行记录!");
  172. return;
  173. }
  174. List<CraftOrdDesignEntity> craftOrdDesignList = new List<CraftOrdDesignEntity>();
  175. foreach (UltraGridRow row in rows)
  176. {
  177. CraftOrdDesignEntity craftOrdDesign = EntityHelper.CopyEntity<CraftOrdDesignEntity>(row.ListObject);
  178. CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign);
  179. if (craftOrdDesignSts.Validflag != "7")
  180. {
  181. MessageUtil.ShowWarning("只能批准待批准状态的工艺文件!");
  182. Relocate(craftOrdDesign);
  183. return;
  184. }
  185. craftOrdDesign.LockFlag = "1";
  186. craftOrdDesign.Validflag = craftOrdDesign.CraftSeq > 1 ? "8" : "1";
  187. craftOrdDesign.ApprovalName1 = CoreUserInfo.UserInfo.GetUserName();
  188. craftOrdDesign.Reason = reason;
  189. craftOrdDesignList.Add(craftOrdDesign);
  190. }
  191. _craftOrdDesignBLL.UpdateApprove1Name(craftOrdDesignList);
  192. _craftOrdDesignBLL.Approval1(craftOrdDesignList);
  193. MessageUtil.ShowTips("批准成功!");
  194. Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]);
  195. }
  196. /// <summary>
  197. /// 作废
  198. /// </summary>
  199. public void AuditOrApprovalFail(string type, string reason)
  200. {
  201. ultraGrid1.UpdateData();
  202. IQueryable<UltraGridRow> rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'");
  203. if (rows.Count() == 0)
  204. {
  205. MessageUtil.ShowWarning("请选择一行记录!");
  206. return;
  207. }
  208. List<CraftOrdDesignEntity> craftOrdDesignList = new List<CraftOrdDesignEntity>();
  209. foreach (UltraGridRow row in rows)
  210. {
  211. CraftOrdDesignEntity craftOrdDesign = (CraftOrdDesignEntity)row.ListObject;
  212. CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign);
  213. if (type == "科室审核" && craftOrdDesignSts.Validflag != "3")
  214. {
  215. MessageUtil.ShowWarning("只能审核待审状态的工艺文件!");
  216. Relocate(craftOrdDesign);
  217. return;
  218. }
  219. if (type == "相关科室审核" && craftOrdDesignSts.Validflag != "6")
  220. {
  221. MessageUtil.ShowWarning("只能审核待审状态的工艺文件!");
  222. Relocate(craftOrdDesign);
  223. return;
  224. }
  225. if (type == "审批" && craftOrdDesignSts.Validflag != "4")
  226. {
  227. MessageUtil.ShowWarning("只能审批待审批状态的工艺文件!");
  228. Relocate(craftOrdDesign);
  229. return;
  230. }
  231. if (type == "批准" && craftOrdDesignSts.Validflag != "7")
  232. {
  233. MessageUtil.ShowWarning("只能批准待批准状态的工艺文件!");
  234. Relocate(craftOrdDesign);
  235. return;
  236. }
  237. craftOrdDesignList.Add(new CraftOrdDesignEntity()
  238. {
  239. ApprovalName = CoreUserInfo.UserInfo.GetUserName(),
  240. AuditName = CoreUserInfo.UserInfo.GetUserName(),
  241. OrdLnPk = craftOrdDesign.OrdLnPk,
  242. CraftSeq = craftOrdDesign.CraftSeq,
  243. Reason = reason,
  244. LockFlag = "1",
  245. Validflag = "5"
  246. });
  247. }
  248. if (type == "科室审核")
  249. {
  250. _craftOrdDesignBLL.Audit(craftOrdDesignList);
  251. }
  252. else if (type == "相关科室审核")
  253. {
  254. _craftOrdDesignBLL.Audit1(craftOrdDesignList);
  255. }
  256. else if (type == "审批")
  257. {
  258. _craftOrdDesignBLL.Approval(craftOrdDesignList);
  259. }
  260. else if (type == "批准")
  261. {
  262. _craftOrdDesignBLL.Approval1(craftOrdDesignList);
  263. }
  264. MessageUtil.ShowTips("操作成功!");
  265. Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]);
  266. }
  267. /// <summary>
  268. /// 获取冶金规范的使用次数
  269. /// </summary>
  270. /// <param name="ordLnPk"></param>
  271. /// <returns></returns>
  272. public static DataTable GetComMscByOrdLnPk(string ordLnPk, OpeBase ob)
  273. {
  274. return ServerHelper.GetData("com.steering.pss.sale.order.ReviewForm.CoreOrderReviewTechnology.getComMscByOrdLnPk",
  275. new object[] { ordLnPk }, ob);
  276. }
  277. private void Relocate(CraftOrdDesignEntity craftOrdDesign)
  278. {
  279. Query(_queryCondition, _dataPurviewIds, _userId);
  280. if (craftOrdDesign == null) return;
  281. IQueryable<UltraGridRow> queryableRows = ultraGrid1.Rows.AsQueryable().Where(
  282. a => a.GetValue("OrdLnPk") == craftOrdDesign.OrdLnPk && a.GetValue("CraftSeq") == craftOrdDesign.CraftSeq.ToString2());
  283. if (queryableRows.Count() > 0)
  284. {
  285. queryableRows.First().Activate();
  286. }
  287. }
  288. private void GridEdite(UltraGridRow row)
  289. {
  290. if (row.GetValue("CHK") == "True")
  291. {
  292. foreach (UltraGridCell cell in row.Cells)
  293. {
  294. if (cell.Column.CellActivation == Activation.AllowEdit)
  295. {
  296. cell.Activation = Activation.AllowEdit;
  297. }
  298. }
  299. }
  300. else
  301. {
  302. foreach (UltraGridCell cell in row.Cells)
  303. {
  304. if (cell.Column.Key == "CHK") continue;
  305. if (cell.Column.CellActivation == Activation.AllowEdit)
  306. {
  307. cell.Activation = Activation.ActivateOnly;
  308. }
  309. }
  310. }
  311. ultraGrid1.UpdateData();
  312. }
  313. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  314. {
  315. e.Cell.Row.Update();
  316. }
  317. PopupTextBox popupTextBox;
  318. private void ultraTextEditor2_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  319. {
  320. string key = ultraGrid1.ActiveCell.Column.Key;
  321. if (key == "CraftChangeMemo" || key == "OrderSpecialDesc" || key == "OrderAddDesc" || key == "OrderAddDescA")
  322. {
  323. popupTextBox = new PopupTextBox(ultraGrid1.ActiveCell.Value.ToString());
  324. popupTextBox.TxtInfo.ReadOnly = true;
  325. popupTextBox.UltraPanel1.Visible = false;
  326. popupTextBox.Show();
  327. }
  328. }
  329. private void craftImg_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  330. {
  331. string filePathOld = ultraGrid1.ActiveCell.Row.GetValue("CraftPathOld");
  332. dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePathOld);
  333. down.DeleteButton.Visible = false;
  334. down.ShowDialog();
  335. }
  336. }
  337. }