frmPopAddReceive.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using com.hnshituo.pur.vo;
  11. using Core.Mes.Client.Comm.Control;
  12. using Core.Mes.Client.Comm.Tool;
  13. using CoreFS.CA06;
  14. using Pur.Entity;
  15. using Pur.Entity.configureEntity;
  16. namespace Pur.Pop_upWindow
  17. {
  18. public partial class frmPopAddReceive : FrmPmsBase
  19. {
  20. public String tips = "0";
  21. ArrayList list = new ArrayList();//待编制的需求行
  22. public frmPopAddReceive()
  23. {
  24. InitializeComponent();
  25. }
  26. public frmPopAddReceive(OpeBase OB, ArrayList list1)
  27. {
  28. InitializeComponent();
  29. this.list = list1;
  30. this.ob = OB;
  31. this.Text = "选择采购计划----总【" + list1 .Count+ "】条待编制接收需求计划行";
  32. }
  33. private void frmPopAddReceive_Load(object sender, EventArgs e)
  34. {
  35. ck_Mtime.Checked = true;
  36. cop_planMouthStart.Value = DateTime.Now.AddMonths(-1);
  37. cop_planMouthEnd.Value = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Now.AddMonths(1) : DateTime.Now.AddMonths(2);
  38. doQuery();
  39. }
  40. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  41. {
  42. switch (e.Tool.Key)
  43. {
  44. case "doQuery": // 刷新
  45. doQuery();
  46. break;
  47. case "doSure": // 添加
  48. doSure();
  49. break;
  50. case "doClose": // 关闭
  51. this.Close();
  52. break;
  53. }
  54. }
  55. private void doSure()
  56. {
  57. if (ultraGrid1.ActiveRow == null)
  58. {
  59. MessageUtil.ShowTips("请选择采购计划");
  60. return;
  61. }
  62. String strMrId = ultraGrid1.ActiveRow.Cells["MRID"].Value.ToString();
  63. if (String.IsNullOrEmpty(strMrId))
  64. {
  65. MessageUtil.ShowTips("请选择采购计划号为空");
  66. return;
  67. }
  68. EntityPurPlanM M_PurPlanM = new EntityPurPlanM();
  69. M_PurPlanM = this.execute<EntityPurPlanM>("com.hnshituo.pur.purplan.service.PurPlanMService", "findById", new object[] { strMrId });
  70. if (M_PurPlanM== null)
  71. {
  72. MessageUtil.ShowTips("未发现采购计划:" + strMrId+" 信息记录");
  73. return;
  74. }
  75. if (M_PurPlanM.CreateUserid != UserInfo.GetUserID())
  76. {
  77. MessageUtil.ShowTips("非本人创建采购计划");
  78. return;
  79. }
  80. if (M_PurPlanM.Status != "1" && M_PurPlanM.Status != "4")
  81. {
  82. MessageUtil.ShowTips("采购计划不在待提报和审批不通过状态无法添加行");
  83. return;
  84. }
  85. if (this.list.Count <= 0)
  86. {
  87. MessageUtil.ShowTips("未发现可添加接收需求计划行");
  88. return;
  89. }
  90. EntityPurPlanM PurPlanM = new EntityPurPlanM();
  91. PurPlanM.MrId = strMrId;
  92. PurPlanM.CreateUserid = UserInfo.GetUserID();
  93. PurPlanM.CreateTime = DateTime.Now;
  94. PurPlanM.CreateName = UserInfo.GetUserName();
  95. if (MessageUtil.ShowYesNoAndQuestion("确定添加需求计划到采购计划:" + strMrId + " ?") == DialogResult.No)
  96. {
  97. return;
  98. }
  99. CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.purplan.service.PurPlanMService", "addRow", new object[] { PurPlanM, this.list });
  100. if (rt.Resultcode != 0)
  101. {
  102. MessageUtil.ShowTips("操作失败:" + rt.Resultmsg);
  103. this.tips = "0";
  104. return;
  105. }
  106. else
  107. {
  108. MessageUtil.ShowTips("操作成功");
  109. this.tips = "1";
  110. this.Close();
  111. return;
  112. }
  113. }
  114. private void doQuery()
  115. {
  116. dataTable1.Clear();
  117. EntityPurPlanM entity = new EntityPurPlanM();
  118. if (ultraTextEditor5.Text.Trim() != "")
  119. {
  120. entity.MrId = ultraTextEditor5.Text.ToString().Trim();
  121. }
  122. entity.DeleteName = "add";
  123. if (ck_Mtime.Checked == true)
  124. {
  125. if (cop_planMouthStart.Text != "")
  126. {
  127. DateTime Start1 = DateTime.Parse(Convert.ToDateTime(cop_planMouthStart.Value).ToString("yyyy/MM"));
  128. entity.MrPeriodStart = Start1;
  129. }
  130. if (cop_planMouthEnd.Text != "")
  131. {
  132. DateTime End1 = DateTime.Parse(Convert.ToDateTime(cop_planMouthEnd.Value).ToString("yyyy/MM"));
  133. entity.MrPeriodEnd = End1;
  134. }
  135. }
  136. //entity.DeleteName = "1";//判断是否需要查待编的,1不显示,0显示
  137. entity.Validflag = "1";
  138. entity.ValidDataPurviewIds = this.ValidDataPurviewIds;
  139. entity.OperatorUserId = UserInfo.GetUserID();
  140. entity.BpmUserId = UserInfo.GetUserID();
  141. //判断当前拥有此页面功能的角色是否启用数据权限,//0未启用
  142. string QstrDataFlag = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getRoleDataFlag", new object[] { UserInfo.GetUserID(), "Pur.pur_plan.FrmPur_Plan" });
  143. if (QstrDataFlag == "0")//0未启用
  144. {
  145. entity.CreateUserid = this.UserInfo.GetUserID();
  146. }
  147. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.purplan.service.PurPlanMService", "getPurPlanM", new object[] { entity });
  148. foreach (DataRow row in dt.Rows)
  149. {
  150. row["mrPeriodEnd"] = Convert.ToDateTime(row["mrPeriodEnd"]).ToString("yyyy/MM");
  151. }
  152. //按创建时间降序
  153. if (dt.Rows.Count > 0)
  154. {
  155. dt.DefaultView.Sort = "CREATETIME DESC";
  156. dt = dt.DefaultView.ToTable();
  157. }
  158. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
  159. }
  160. private void ck_Mtime_CheckedChanged(object sender, EventArgs e)
  161. {
  162. cop_planMouthStart.Enabled = ck_Mtime.Checked;
  163. cop_planMouthEnd.Enabled = ck_Mtime.Checked;
  164. }
  165. }
  166. }