FrmPurRequireApproval.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;using Pur.Entity;
  10. using Core.Mes.Client.Comm.Control;
  11. using Pur.Entity.require_planEntiy;
  12. using Infragistics.Win.UltraWinGrid;
  13. using Core.Mes.Client.Comm.Tool;
  14. using Pur.Pop_upWindow;
  15. using com.hnshituo.bpm.req.vo;
  16. using com.hnshituo.pur.vo;
  17. using Infragistics.Win;
  18. using Bpm;
  19. namespace Pur.require_plan
  20. {
  21. public partial class FrmPurRequireApproval : FrmPmsBase
  22. {
  23. public FrmPurRequireApproval()
  24. {
  25. InitializeComponent();
  26. this.IsLoadUserView = true;
  27. ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  28. ultraGrid2.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
  29. }
  30. private void FrmPurRequireApproval_Load(object sender, EventArgs e)
  31. {
  32. ck_Mtime.Checked = true;
  33. cop_planMouthStart.Value = DateTime.Now.AddMonths(-1);
  34. cop_planMouthEnd.Value = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Now.AddMonths(1) : DateTime.Now.AddMonths(2);
  35. txt_Status.SelectedIndex = 1;//审批中
  36. ultraComboEditor2.SelectedIndex = 0;
  37. GetPUR_REQUIRE_PLAN();
  38. GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0],new string[]{ });
  39. GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] { });
  40. }
  41. //菜单按钮事件
  42. public override void ToolBar_Click(object sender, string ToolbarKey)
  43. {
  44. switch (ToolbarKey)
  45. {
  46. case "Query":
  47. GetPUR_REQUIRE_PLAN();
  48. break;
  49. case "Approval":
  50. AppPUR_REQUIRE_PLAN();
  51. break;
  52. case "Process":
  53. ProPUR_REQUIRE_PLAN();
  54. break;
  55. }
  56. }
  57. private void ProPUR_REQUIRE_PLAN()
  58. {
  59. UltraGridRow uge = ultraGrid1.ActiveRow;
  60. if (uge == null)
  61. {
  62. MessageUtil.ShowWarning("请选择一条需求计划进行查看");
  63. return;
  64. }
  65. string mrId = uge.Cells["mrId"].Value.ToString();
  66. ProcInstDetail detail = new ProcInstDetail(BpmFlowConstants.PROCDEF_PUR_REQUIREPLAN_AUDIT, mrId);
  67. detail.ShowDialog();
  68. }
  69. /// <summary>
  70. /// 审批
  71. /// </summary>
  72. private void AppPUR_REQUIRE_PLAN()
  73. {
  74. UltraGridRow uge = ultraGrid1.ActiveRow;
  75. if (uge == null)
  76. {
  77. MessageUtil.ShowWarning("请选择待审批的需求计划!");
  78. return;
  79. }
  80. String strMrId = uge.Cells["MrId"].Value.ToString();
  81. if (String.IsNullOrEmpty(strMrId))
  82. {
  83. MessageUtil.ShowWarning("选择的需求计划号为空!");
  84. return;
  85. }
  86. RequirePlanM rpm = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { strMrId });
  87. if (rpm == null)
  88. {
  89. MessageUtil.ShowTips("未发现需求计划:" + strMrId+"信息记录!");
  90. return;
  91. }
  92. if (rpm.Status!="2")
  93. {
  94. MessageUtil.ShowWarning("需求计划:" + strMrId + "尚未送审或已审批,请刷新后再操作!");
  95. return;
  96. }
  97. frmExamineShow Fex = new frmExamineShow();
  98. Fex.ShowDialog();
  99. if (Fex.Status == null)
  100. {
  101. return;
  102. }
  103. //if (!Fex.Status.Equals("1"))
  104. //{
  105. // MessageUtil.ShowTips("审批失败!");
  106. // return;
  107. //}
  108. //if (!Fex.Status.Equals("2"))
  109. //{
  110. // MessageUtil.ShowTips("审批失败!");
  111. // return;
  112. //}
  113. try
  114. {
  115. //RequirePlanM RqPM = new RequirePlanM();
  116. //RqPM.Status = "3";
  117. //RqPM.MrId = uge.Cells["MrId"].Value.ToString();
  118. //RqPM.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
  119. //RqPM.UpdateTime = DateTime.Now;
  120. //RqPM.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  121. //this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "update", new object[] { RqPM });
  122. ReqCompleteTask req = new ReqCompleteTask();
  123. req.OperatorUserId = UserInfo.GetUserID();
  124. req.TaskId = uge.Cells["BpmTaskId"].Value.ToString();
  125. if (Fex.Status.Equals("2"))
  126. {
  127. req.AuditData = true;
  128. req.AuditMessage = Fex.ExamineMessage;
  129. if (rpm.UrgencyType=="2"&&DateTime.Now > DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")))
  130. {
  131. if (MessageUtil.ShowYesNoAndQuestion("已超出审批时限(每月25号截止),若审批通过则将默认归属于为" + DateTime.Now.AddMonths(2).ToString("yyyy/MM") + "的需求! 或请退回走紧急采购。") != DialogResult.Yes)
  132. {
  133. return;
  134. }
  135. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "bpmAudit", new object[] { req });
  136. if (crt.Resultcode == -1)
  137. {
  138. MessageUtil.ShowTips("需求计划:" + strMrId + "审批失败!" + crt.Resultmsg);
  139. return;
  140. }
  141. //更新计划月份
  142. RequirePlanM ReqM = new RequirePlanM();
  143. ReqM.MrId = strMrId;
  144. ReqM.MrPeriodEnd = DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
  145. ReqM.AuditedTime = DateTime.Now;
  146. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "doUpdate", new object[] { ReqM });
  147. }
  148. else
  149. {
  150. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "bpmAudit", new object[] { req });
  151. if (crt.Resultcode == -1)
  152. {
  153. MessageUtil.ShowTips("需求计划:" + strMrId + "审批失败!" + crt.Resultmsg);
  154. return;
  155. }
  156. }
  157. MessageUtil.ShowTips("操作成功");
  158. GetPUR_REQUIRE_PLAN();
  159. }
  160. else if (Fex.Status.Equals("1"))
  161. {
  162. req.AuditData = false;
  163. req.AuditMessage = Fex.ExamineMessage;
  164. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "bpmAudit", new object[] { req });
  165. if (crt.Resultcode == -1)
  166. {
  167. MessageUtil.ShowTips("需求计划:" + strMrId + "审批失败!" + crt.Resultmsg);
  168. return;
  169. }
  170. RequirePlanM ReqM = new RequirePlanM();
  171. ReqM.MrId = strMrId;
  172. ReqM.Status = "4";
  173. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "doUpdate", new object[] { ReqM });
  174. if (rt.Resultcode != 0)
  175. {
  176. MessageUtil.ShowTips("需求计划:" + strMrId + "审批失败!" + crt.Resultmsg);
  177. return;
  178. }
  179. MessageUtil.ShowTips("操作成功");
  180. GetPUR_REQUIRE_PLAN();
  181. }
  182. }
  183. catch (Exception e)
  184. {
  185. MessageUtil.ShowTips("需求计划:" + strMrId + "审批失败!" + e);
  186. }
  187. }
  188. /// <summary>
  189. /// 查询
  190. /// </summary>
  191. private void GetPUR_REQUIRE_PLAN()
  192. {
  193. try
  194. {
  195. this.Cursor = Cursors.WaitCursor;
  196. message.Clear();
  197. dataSet1.Clear();
  198. dataSet2.Clear();
  199. RequirePlanM RqPM = new RequirePlanM();
  200. RqPM.MrId = ultraTextEditor1.Text.ToString().Trim();
  201. if (ultraComboEditor2.SelectedIndex != -1)
  202. {
  203. RqPM.UrgencyType = ultraComboEditor2.Value.ToString();
  204. }
  205. //计划时间
  206. if (ck_Mtime.Checked == true)
  207. {
  208. if (cop_planMouthStart.Text != "")
  209. {
  210. DateTime Start1 = DateTime.Parse(Convert.ToDateTime(cop_planMouthStart.Value).ToString("yyyy/MM"));
  211. RqPM.MrPeriodStart = Start1;
  212. }
  213. if (cop_planMouthEnd.Text != "")
  214. {
  215. DateTime End1 = DateTime.Parse(Convert.ToDateTime(cop_planMouthEnd.Value).ToString("yyyy/MM"));
  216. RqPM.MrPeriodEnd = End1;
  217. }
  218. }
  219. RqPM.Validflag = "1";
  220. RqPM.BpmUserId = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
  221. RqPM.ValidDataPurviewIds = this.ValidDataPurviewIds;
  222. DataTable dt=new DataTable();
  223. if (txt_Status.SelectedIndex == -1)
  224. {
  225. return;
  226. }
  227. if (txt_Status.Value.ToString().Trim() == "wait")
  228. {
  229. dt = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "find_audit_status", new object[] { RqPM });
  230. }
  231. else if (txt_Status.Value.ToString().Trim() == "did")
  232. {
  233. dt = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "find_audited_status", new object[] { RqPM });
  234. }
  235. else
  236. {
  237. dt = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "find_status", new object[] { RqPM });
  238. }
  239. foreach (DataRow row in dt.Rows)
  240. {
  241. row["mrPeriodEnd"] = Convert.ToDateTime(row["mrPeriodEnd"]).ToString("yyyy/MM");
  242. }
  243. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  244. GridHelper.RefreshAndAutoSize(ultraGrid1);
  245. }
  246. catch (Exception ex)
  247. {
  248. MessageUtil.ShowTips("加载数据失败:"+ex.Message);
  249. }
  250. finally
  251. {
  252. this.Cursor = Cursors.Default;
  253. }
  254. }
  255. /// <summary>
  256. /// 未审批点击事件
  257. /// </summary>
  258. /// <param name="sender"></param>
  259. /// <param name="e"></param>
  260. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  261. {
  262. dataTable2.Clear();
  263. message.Clear();
  264. if (ultraGrid1.ActiveRow == null)
  265. {
  266. return;
  267. }
  268. String strMrId=ultraGrid1.ActiveRow.Cells["mrId"].Value.ToString();
  269. getdetail(strMrId);
  270. //加载评审意见
  271. getOrderReview(strMrId);
  272. }
  273. private void getdetail(String strMrId)
  274. {
  275. if (String.IsNullOrEmpty(strMrId))
  276. {
  277. return;
  278. }
  279. RequirePlanM RqPM = new RequirePlanM();
  280. RqPM.MrId = strMrId;
  281. RqPM.Validflag = "1";
  282. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { RqPM });
  283. GridHelper.CopyDataToDatatable(dt1, dataTable2, true);
  284. GridHelper.RefreshAndAutoSize(ultraGrid2);
  285. }
  286. private void txt_Status_ValueChanged(object sender, EventArgs e)
  287. {
  288. GetPUR_REQUIRE_PLAN();
  289. }
  290. /// <summary>
  291. /// 获取评审意见
  292. /// </summary>
  293. /// <param name="strOrderId"></param>
  294. private void getOrderReview(string strOrderId)
  295. {
  296. DataTable dt11 = this.execute<DataTable>("com.hnshituo.pur.order.service.OrderMService", "getReviewMsg", new object[] { strOrderId });
  297. GridHelper.CopyDataToDatatable(dt11, dataTable7, true);
  298. GridHelper.RefreshAndAutoSize(ultraGrid3);
  299. }
  300. private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
  301. {
  302. }
  303. }
  304. }