frmPurRequirePlanMAdd.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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 com.hnshituo.pur.vo;
  10. using Core.Mes.Client.Comm.Server;
  11. using Core.Mes.Client.Comm.Tool;
  12. using CoreFS.CA06;
  13. using Pur.configure;
  14. using Pur.Entity;
  15. using Pur.Entity.require_planEntiy;
  16. namespace Pur.require_plan
  17. {
  18. public partial class frmPurRequirePlanMAdd : FrmPmsBase
  19. {
  20. public string tips = "0";
  21. public string requirePlanMId = "";
  22. public string txt_REQORGID = "";
  23. private string strCustomInfo;
  24. private string mrId="";
  25. public frmPurRequirePlanMAdd()
  26. {
  27. InitializeComponent();
  28. }
  29. public frmPurRequirePlanMAdd(OpeBase OB,String customInfo)
  30. {
  31. this.ob = OB;
  32. this.strCustomInfo = customInfo;
  33. InitializeComponent();
  34. }
  35. public frmPurRequirePlanMAdd(OpeBase opeBase, string strCoustomInfo, string mrId)
  36. {
  37. // TODO: Complete member initialization
  38. this.ob = opeBase;
  39. this.strCustomInfo = strCoustomInfo;
  40. InitializeComponent();
  41. this.mrId = mrId;
  42. btn_add.Text = "复制&A";
  43. }
  44. private void frmPurRequirePlanMAdd_Load(object sender, EventArgs e)
  45. {
  46. Init();
  47. }
  48. private void Init()
  49. {
  50. //紧急程度类型
  51. txt_URGENCYTYPE.SelectedIndex = 0;
  52. //加载计划类型数据
  53. DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1221" }, this.ob);
  54. if (strCustomInfo == "1")//生产厂
  55. {
  56. comm.FilComboboxAdd(txt_RequeType, dt1, "baseCode", "baseName", "validflag NOT in ('0') and baseCode in ('122101')", false, "", "");
  57. txt_auditType.Visible = true;
  58. txt_auditType_lab.Visible = true;
  59. }
  60. else if (strCustomInfo == "2")//供应部
  61. {
  62. comm.FilComboboxAdd(txt_RequeType, dt1, "baseCode", "baseName", "validflag NOT in ('0') and baseCode in ('122101')", false, "", "");
  63. //ultraTabControl2.Tabs[1].Visible = false;
  64. txt_auditType.Visible = false;
  65. txt_auditType_lab.Visible = false;
  66. }
  67. else//厂区
  68. {
  69. comm.FilComboboxAdd(txt_RequeType, dt1, "baseCode", "baseName", "validflag NOT in ('0') and baseCode in ('122104')", false, "", "");
  70. txt_auditType.Visible = true;
  71. txt_auditType_lab.Visible = true;
  72. }
  73. //加载流程类型
  74. DataTable dt8 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "122601" }, this.ob);
  75. comm.FilComboboxAdd(txt_auditType, dt8, "baseCode", "baseName", "validflag NOT in ('0')", false, "", "");
  76. txt_RequeType.SelectedIndex = 0;
  77. txt_URGENCYTYPE.SelectedIndex = 0;
  78. txt_auditType.SelectedIndex = 0;
  79. txt_MRPERIODEND.Enabled = false;
  80. txt_REQORGNAME.Text = UserInfo.GetDepartment();
  81. txt_REQORGID = UserInfo.GetDeptid();
  82. if (strCustomInfo == "2")
  83. {
  84. if (DateTime.Now < DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM/01")))
  85. {
  86. txt_MRPERIODEND.Value = DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM"));
  87. }
  88. else
  89. {
  90. txt_MRPERIODEND.Value = DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
  91. }
  92. }
  93. else
  94. {
  95. if (DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")))
  96. {
  97. txt_MRPERIODEND.Value = DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM"));
  98. }
  99. else
  100. {
  101. txt_MRPERIODEND.Value = DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
  102. }
  103. }
  104. }
  105. /// <summary>
  106. /// 紧急采购允许输入月份
  107. /// </summary>
  108. /// <param name="sender"></param>
  109. /// <param name="e"></param>
  110. private void txt_URGENCYTYPE_ValueChanged(object sender, EventArgs e)// 紧急采购允许输入月份
  111. {
  112. if (txt_URGENCYTYPE.SelectedIndex == 1)
  113. {
  114. txt_MRPERIODEND.Enabled = true;
  115. }
  116. else
  117. {
  118. txt_MRPERIODEND.Enabled = false;
  119. txt_MRPERIODEND.Value = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM")) : DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
  120. }
  121. }
  122. //新增操作
  123. private void btn_add_Click(object sender, EventArgs e)
  124. {
  125. if (testReqM() == false)
  126. {
  127. return;
  128. }
  129. RequirePlanM ReqM = new RequirePlanM();
  130. ReqM.CreateName = UserInfo.GetUserName();
  131. ReqM.CreateUserid = UserInfo.GetUserID();
  132. ReqM.CreateTime = DateTime.Now;
  133. if (txt_MRPERIODEND.Enabled == false)
  134. {
  135. if (strCustomInfo == "2")
  136. {
  137. ReqM.MrPeriodEnd = DateTime.Now < DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM/01")) ? DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM")) : DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
  138. }
  139. else
  140. {
  141. ReqM.MrPeriodEnd = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM")) : DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM"));
  142. }
  143. }
  144. else
  145. {
  146. ReqM.MrPeriodEnd = Convert.ToDateTime(txt_MRPERIODEND.Value);
  147. }
  148. ReqM.UrgencyType = txt_URGENCYTYPE.Value.ToString();
  149. ReqM.ReqOrgName = txt_REQORGNAME.Text.Trim();//申请者机构名称
  150. ReqM.ReqOrgId = txt_REQORGID;//申请者机构ID
  151. ReqM.ApplyReqOrgName = UserInfo.GetDepartment();
  152. ReqM.ApplyReqOrgId = UserInfo.GetDeptid();
  153. ReqM.Validflag = "1";
  154. ReqM.RequireType = txt_RequeType.Value.ToString();
  155. ReqM.Status = "1";
  156. ReqM.TenantId = strCustomInfo != "2" ? txt_auditType.Value.ToString().Trim() : null;
  157. ReqM.TenantName = strCustomInfo != "2" ? txt_auditType.Text.Trim() : null;
  158. if (ReqM.RequireType == "122104")
  159. {
  160. ReqM.Status = "-2";//子计划
  161. }
  162. CoreResult crt = new CoreResult();
  163. if (!String.IsNullOrEmpty(mrId))
  164. {
  165. ReqM.MrId = mrId;
  166. crt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "do_Copy", new object[] { ReqM, strCustomInfo });
  167. }
  168. else
  169. {
  170. crt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "insert_id", new object[] { ReqM, strCustomInfo });
  171. }
  172. if (crt.Resultcode != 0)
  173. {
  174. MessageUtil.ShowTips("操作失败! " + crt.Resultmsg);
  175. tips = "0";
  176. return;
  177. }
  178. else
  179. {
  180. MessageUtil.ShowTips("操作成功! 新增需求计划头:" + crt.Resultmsg);
  181. requirePlanMId = crt.Resultmsg;
  182. tips = "1";
  183. this.Close();
  184. }
  185. }
  186. /// <summary>
  187. /// 需求头信息校验
  188. /// </summary>
  189. /// <returns></returns>
  190. private bool testReqM()// 需求头信息校验
  191. {
  192. if (txt_MRPERIODEND.Text == "")
  193. {
  194. MessageUtil.ShowTips("计划月份不能为空!");
  195. txt_MRPERIODEND.Focus();
  196. return false;
  197. }
  198. if (txt_MRPERIODEND.Enabled == false && (DateTime.Now > DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26"))))
  199. {
  200. if (MessageUtil.ShowYesNoAndQuestion("需求提报截止日期为每月25号,若提交将默认为下月需求计划。确定新增?") != DialogResult.Yes)
  201. {
  202. txt_MRPERIODEND.Focus();
  203. return false;
  204. }
  205. }
  206. if (txt_RequeType.Value == null)
  207. {
  208. MessageUtil.ShowTips("请选择需求计划类型!");
  209. txt_RequeType.Focus();
  210. return false;
  211. }
  212. if (txt_URGENCYTYPE.SelectedIndex == -1)
  213. {
  214. MessageUtil.ShowTips("请选择紧急程度类型!");
  215. txt_URGENCYTYPE.Focus();
  216. return false;
  217. }
  218. if (String.IsNullOrEmpty(txt_REQORGID))
  219. {
  220. MessageUtil.ShowTips("请选择使用单位!");
  221. txt_REQORGNAME.Focus();
  222. return false;
  223. }
  224. if (String.IsNullOrEmpty(txt_REQORGNAME.Text.Trim()))
  225. {
  226. MessageUtil.ShowTips("请选择使用单位!");
  227. txt_REQORGNAME.Focus();
  228. return false;
  229. }
  230. if (strCustomInfo != "2")
  231. {
  232. if (txt_auditType.SelectedIndex == -1)
  233. {
  234. MessageUtil.ShowTips("请选择审批流程类型!");
  235. txt_auditType.Focus();
  236. return false;
  237. }
  238. }
  239. else
  240. {
  241. if (txt_REQORGID.Length >= 9)
  242. {
  243. if (txt_REQORGID.Substring(0, 9) == "002001029")
  244. {
  245. MessageUtil.ShowTips("替生产厂提报的需求计划不能选【供应部】和下面的科室作为申请单位!");
  246. txt_REQORGNAME.Focus();
  247. return false;
  248. }
  249. }
  250. }
  251. return true;
  252. }
  253. private void txt_REQORGNAME_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  254. {
  255. frmdepartment frm = new frmdepartment(this.ob);
  256. //frm.StartPosition = FormStartPosition.Manual;
  257. //frm.Location = publicPms.getShowLocation(frm);
  258. frm.ShowDialog();
  259. String strdeptId = frm.BuyerUnitCode;
  260. String strDeptName = frm.Fulltext;
  261. if (!String.IsNullOrEmpty(strdeptId) && !String.IsNullOrEmpty(strDeptName))
  262. {
  263. txt_REQORGID = strdeptId;
  264. txt_REQORGNAME.Text = strDeptName;
  265. }
  266. }
  267. }
  268. }