CraftAutoPeopleCtrl.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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 Core.Mes.Client.Comm.Server;
  13. using Core.StlMes.Client.Qcm;
  14. using CoreFS.SA06;
  15. namespace Core.StlMes.Client.SaleOrder.Control
  16. {
  17. public partial class CraftAutoPeopleCtrl : UserControl
  18. {
  19. private CraftAutoPeopleBLL _craftAutoPeople;
  20. private OpeBase _ob;
  21. public CraftAutoPeopleCtrl(System.Windows.Forms.Control container, OpeBase ob)
  22. {
  23. InitializeComponent();
  24. _ob = ob;
  25. _craftAutoPeople = new CraftAutoPeopleBLL(ob);
  26. container.Controls.Add(this);
  27. this.Dock = DockStyle.Fill;
  28. }
  29. private string _customInfo = "";
  30. public void Query(string customInfo)
  31. {
  32. _customInfo = customInfo;
  33. craftAutoPeopleEntityBindingSource.DataSource = _craftAutoPeople.Query(customInfo);
  34. }
  35. public void QueryPopup(string ordLnPk)
  36. {
  37. craftAutoPeopleEntityBindingSource.DataSource = _craftAutoPeople.QueryPopup(ordLnPk);
  38. entityGrid1.DisplayLayout.Bands[0].Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No;
  39. DataRow dr = _craftAutoPeople.GetCraftOrdUnit(ordLnPk);
  40. if (dr != null)
  41. {
  42. var row = entityGrid1.Rows.Where(a => a.GetValue("AuditCode") == dr["AUDIT_CODE"].ToString() && a.GetValue("AuditCode1") == dr["AUDIT_CODE1"].ToString()
  43. && a.GetValue("ApproveCode") == dr["APPROVE_CODE"].ToString() && a.GetValue("ApproveCode1") == dr["APPROVE_CODE1"].ToString()).FirstOrDefault();
  44. if (row != null)
  45. {
  46. row.Cells["Chk"].Value = true;
  47. row.Update();
  48. }
  49. }
  50. }
  51. public bool Submit(string ordLnPk, string userId, string userName)
  52. {
  53. var row = entityGrid1.Rows.Where(a=>a.GetValue("Chk") == "True").FirstOrDefault();
  54. if (row == null)
  55. {
  56. MessageUtil.ShowWarning("请选择一条记录!");
  57. return false;
  58. }
  59. _craftAutoPeople.Submit(ordLnPk, row.GetValue("AuditCode"), row.GetValue("AuditCode1"),
  60. row.GetValue("ApproveCode"), row.GetValue("ApproveCode1"), userId, userName);
  61. MessageUtil.ShowTips("确认成功!");
  62. return true;
  63. }
  64. public void Save()
  65. {
  66. entityGrid1.UpdateData();
  67. var rows = entityGrid1.Rows.Where(a=>a.GetValue("Chk") == "True");
  68. List<CraftAutoPeopleEntity> parms = new List<CraftAutoPeopleEntity>();
  69. if (rows.Where(a => a.GetValue("AutoFlag") == "True").GroupBy(a => a.GetValue("unitCode")).Where(a => a.Count() > 1).Count() > 0)
  70. {
  71. MessageUtil.ShowWarning("保存的数据中,自动审核存在重复的数据!");
  72. return;
  73. }
  74. int count = rows.Where(a => a.GetValue("AutoFlag") == "False").GroupBy(a => new { unitCode = a.GetValue("unitCode"), auditCode = a.GetValue("auditCode"),
  75. auditCode1 = a.GetValue("auditCode1"), approveCode = a.GetValue("approveCode"), approveCode1 = a.GetValue("approveCode1") })
  76. .Where(a=>a.Count() > 1).Count();
  77. if (count > 0)
  78. {
  79. MessageUtil.ShowWarning("保存的数据中,人工审核存在重复的数据!");
  80. return;
  81. }
  82. foreach (var row in rows)
  83. {
  84. CraftAutoPeopleEntity parm = EntityHelper.CopyEntity<CraftAutoPeopleEntity>(row.ListObject);
  85. bool isExistUnit;
  86. if (parm.AutoFlag == true)
  87. {
  88. isExistUnit = _craftAutoPeople.IsExistUnit(parm.UnitCode, (parm.Pk == null ? "0" : parm.Pk.ToString()));
  89. }
  90. else
  91. {
  92. isExistUnit = _craftAutoPeople.IsExistUnit2(parm.UnitCode, parm.AuditCode, parm.AuditCode1,
  93. parm.ApproveCode, parm.ApproveCode1, (parm.Pk == null ? "0" : parm.Pk.ToString()));
  94. }
  95. if (parm.UnitCode == "")
  96. {
  97. MessageUtil.ShowWarning("请选择管理科室!");
  98. row.SetCellActive("UnitDesc");
  99. return;
  100. }
  101. if (parm.AuditCode == "")
  102. {
  103. MessageUtil.ShowWarning("请选择科室审核人!");
  104. row.SetCellActive("AuditDesc");
  105. return;
  106. }
  107. if (parm.AuditCode1 == "")
  108. {
  109. MessageUtil.ShowWarning("请选择相关科室审核人!");
  110. row.SetCellActive("AuditDesc1");
  111. return;
  112. }
  113. if (parm.ApproveCode == "")
  114. {
  115. MessageUtil.ShowWarning("请选择审批人!");
  116. row.SetCellActive("ApproveDesc");
  117. return;
  118. }
  119. if (isExistUnit)
  120. {
  121. MessageUtil.ShowWarning("存在相同的数据!");
  122. row.SetCellActive("UnitDesc");
  123. return;
  124. }
  125. parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
  126. parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  127. parms.Add(parm);
  128. }
  129. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
  130. {
  131. return;
  132. }
  133. _craftAutoPeople.Save(parms);
  134. MessageUtil.ShowTips("保存成功!");
  135. Query(_customInfo);
  136. }
  137. public void Delete()
  138. {
  139. entityGrid1.UpdateData();
  140. var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  141. List<CraftAutoPeopleEntity> parms = new List<CraftAutoPeopleEntity>();
  142. foreach (var row in rows)
  143. {
  144. CraftAutoPeopleEntity parm = EntityHelper.CopyEntity<CraftAutoPeopleEntity>(row.ListObject);
  145. parms.Add(parm);
  146. }
  147. if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == DialogResult.No)
  148. {
  149. return;
  150. }
  151. _craftAutoPeople.Delete(parms);
  152. MessageUtil.ShowTips("删除成功!");
  153. Query(_customInfo);
  154. }
  155. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  156. {
  157. var row = entityGrid1.ActiveRow;
  158. DataTable dt;
  159. BaseInfoPopup popup;
  160. switch (entityGrid1.ActiveCell.Column.Key)
  161. {
  162. case "UnitDesc":
  163. dt = ServerHelper.GetData("com.steering.pss.sale.order.DAL.CraftAutoPeopleDAL.GetUnit",
  164. new object[]{}, _ob);
  165. dt.Columns["DEPARTNAME1"].Caption = "管理部门";
  166. dt.Columns["DEPARTNAME"].Caption = "管理科室";
  167. popup = new BaseInfoPopup(dt, "DEPARTNAME", "DEPARTID");
  168. if (popup.ShowDialog() == DialogResult.OK)
  169. {
  170. row.SetValue("UnitCode", popup.ChoicedRow.GetValue("DEPARTID"));
  171. row.SetValue("UnitDesc", popup.ChoicedRow.GetValue("DEPARTNAME"));
  172. }
  173. break;
  174. case "AuditDesc":
  175. dt = ServerHelper.GetData("com.steering.pss.sale.order.DAL.CraftAutoPeopleDAL.GetAudit",
  176. new object[]{}, _ob);
  177. dt.Columns["USERNAME"].Caption = "评审人";
  178. dt.Columns["DEPARTNAME1"].Caption = "管理部门";
  179. dt.Columns["DEPARTNAME"].Caption = "管理科室";
  180. popup = new BaseInfoPopup(dt, "USERNAME", "DEPARTID", "USERID");
  181. if (popup.ShowDialog() == DialogResult.OK)
  182. {
  183. row.SetValue("AuditCode", popup.ChoicedRow.GetValue("USERID"));
  184. row.SetValue("AuditDesc", popup.ChoicedRow.GetValue("USERNAME"));
  185. }
  186. break;
  187. case "AuditDesc1":
  188. dt = ServerHelper.GetData("com.steering.pss.sale.order.DAL.CraftAutoPeopleDAL.GetAudit",
  189. new object[] { }, _ob);
  190. dt.Columns["USERNAME"].Caption = "评审人";
  191. dt.Columns["DEPARTNAME1"].Caption = "管理部门";
  192. dt.Columns["DEPARTNAME"].Caption = "管理科室";
  193. popup = new BaseInfoPopup(dt, "USERNAME", "DEPARTID", "USERID");
  194. if (popup.ShowDialog() == DialogResult.OK)
  195. {
  196. row.SetValue("AuditCode1", popup.ChoicedRow.GetValue("USERID"));
  197. row.SetValue("AuditDesc1", popup.ChoicedRow.GetValue("USERNAME"));
  198. }
  199. break;
  200. case "ApproveDesc":
  201. dt = ServerHelper.GetData("com.steering.pss.sale.order.DAL.CraftAutoPeopleDAL.GetAudit",
  202. new object[] { }, _ob);
  203. dt.Columns["USERNAME"].Caption = "评审人";
  204. dt.Columns["DEPARTNAME1"].Caption = "管理部门";
  205. dt.Columns["DEPARTNAME"].Caption = "管理科室";
  206. popup = new BaseInfoPopup(dt, "USERNAME", "DEPARTID", "USERID");
  207. if (popup.ShowDialog() == DialogResult.OK)
  208. {
  209. row.SetValue("ApproveCode", popup.ChoicedRow.GetValue("USERID"));
  210. row.SetValue("ApproveDesc", popup.ChoicedRow.GetValue("USERNAME"));
  211. }
  212. break;
  213. case "ApproveDesc1":
  214. dt = ServerHelper.GetData("com.steering.pss.sale.order.DAL.CraftAutoPeopleDAL.GetAudit",
  215. new object[] { }, _ob);
  216. dt.Rows.InsertAt(dt.NewRow(), 0);
  217. dt.Columns["USERNAME"].Caption = "评审人";
  218. dt.Columns["DEPARTNAME1"].Caption = "管理部门";
  219. dt.Columns["DEPARTNAME"].Caption = "管理科室";
  220. popup = new BaseInfoPopup(dt, "USERNAME", "DEPARTID", "USERID");
  221. if (popup.ShowDialog() == DialogResult.OK)
  222. {
  223. row.SetValue("ApproveCode1", popup.ChoicedRow.GetValue("USERID"));
  224. row.SetValue("ApproveDesc1", popup.ChoicedRow.GetValue("USERNAME"));
  225. }
  226. break;
  227. }
  228. row.Update();
  229. }
  230. private void entityGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  231. {
  232. e.Cell.Row.Update();
  233. }
  234. private void entityGrid1_AfterRowInsert(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e)
  235. {
  236. if (_customInfo == "Auto")
  237. {
  238. e.Row.Cells["autoFlag"].Value = true;
  239. }
  240. else
  241. {
  242. e.Row.Cells["autoFlag"].Value = false;
  243. }
  244. }
  245. }
  246. }