FrmPurRequirePlanReceive2.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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 Infragistics.Win.UltraWinGrid;
  15. using Pur.Entity;
  16. using Pur.Entity.require_planEntiy;
  17. namespace Pur.require_plan
  18. {
  19. public partial class FrmPurRequirePlanReceive2 : FrmPmsBase
  20. {
  21. String strCustom = "";
  22. public string tips="0";
  23. public string[] strViewsCol;
  24. public FrmPurRequirePlanReceive2()
  25. {
  26. InitializeComponent();
  27. }
  28. public FrmPurRequirePlanReceive2(OpeBase OB, string[] strViews,String Custom)
  29. {
  30. this.strCustom = Custom;
  31. this.ob = OB;
  32. this.strViewsCol = strViews;
  33. InitializeComponent();
  34. }
  35. private void FrmPurRequirePlanReceive2_Load(object sender, EventArgs e)
  36. {
  37. ultraTabControl1.SelectedTab=ultraTabControl1.Tabs[0];
  38. ultraTabControl2.Tabs[1].Visible = false;
  39. txt_Status.SelectedIndex = 0;
  40. ultraComboEditor2.SelectedIndex = 0;
  41. ck_ctime.Checked=true;
  42. CK_isAll.Checked = false;
  43. txtMrPeriodStart.Value = DateTime.Now.AddMonths(-1);
  44. txtMrPeriodEnd.Value = DateTime.Now.AddDays(1);
  45. GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] { "CHECK" });
  46. GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] { "CHECK" });
  47. GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0], new string[] {});
  48. doQuery();
  49. }
  50. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  51. {
  52. switch (e.Tool.Key)
  53. {
  54. case "doQuery": // 刷新
  55. doQuery();
  56. break;
  57. case "doCreate": // 编制
  58. doCreate();
  59. break;
  60. case "cancelCreate": //取消编制
  61. cancelCreate();
  62. break;
  63. case "doExit": // 退出
  64. this.Close();
  65. break;
  66. }
  67. }
  68. // 刷新待编制和已编制
  69. private void doQuery()
  70. {
  71. dataTable1.Clear();
  72. dataTable2.Clear();
  73. dataTable3.Clear();
  74. try
  75. {
  76. this.Cursor = Cursors.WaitCursor;
  77. //string str = Core.Mes.Client.Comm.Tool.EntityHelper.StrGetControlvalueFromMod("tg_128_st", "cxuser", "cxuser", "PUR_REQUIRE_PLAN_M", "suppone_entity", new string[] { "txt_" }, true, txt_MRID.Parent);
  78. //str = Core.Mes.Client.Comm.Tool.EntityHelper.StrGetControlvalueFromMod("tg_128_st", "cxuser", "cxuser", "PUR_REQUIRE_PLAN_D", "suppone_entity", new string[] { "txt_" }, true, txt_MRLINEID.Parent);
  79. RequirePlanM RqPM = new RequirePlanM();
  80. if (txt_Status.Value != null)
  81. {
  82. RqPM.Status = txt_Status.Value.ToString();
  83. }
  84. if (ultraTextEditor1.Text != null)
  85. {
  86. RqPM.MrId = ultraTextEditor1.Text;
  87. }
  88. if (ultraComboEditor2.Value != null)
  89. {
  90. RqPM.UrgencyType = ultraComboEditor2.Value.ToString();
  91. }
  92. if (ck_ctime.Checked == true)
  93. {
  94. if (txtMrPeriodStart.Text != "")
  95. {
  96. RqPM.CreateTime = Convert.ToDateTime(txtMrPeriodStart.Value);
  97. }
  98. if (txtMrPeriodEnd.Text != "")
  99. {
  100. RqPM.DeleteTime = Convert.ToDateTime(txtMrPeriodEnd.Value);
  101. }
  102. }
  103. if (CK_isAll.Checked)
  104. {
  105. RqPM.DeleteName = "3";//待编制子计划查询
  106. }
  107. else
  108. {
  109. RqPM.DeleteName = "2";//全部子计划查询
  110. }
  111. RqPM.Validflag = "1";
  112. RqPM.ValidDataPurviewIds = strViewsCol;//我能看到那些部门的
  113. RqPM.BpmUserId = UserInfo.GetUserID();
  114. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "find_status", new object[] { RqPM });
  115. foreach (DataRow row in dt.Rows)
  116. {
  117. row["mrPeriodEnd"] = Convert.ToDateTime(row["mrPeriodEnd"]).ToString("yyyy/MM");
  118. }
  119. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  120. GridHelper.RefreshAndAutoSize(ultraGrid1);
  121. RqPM.DeleteName = "4";//已编制主计划查询查询
  122. DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "find_status", new object[] { RqPM });
  123. foreach (DataRow row in dt2.Rows)
  124. {
  125. row["mrPeriodEnd"] = Convert.ToDateTime(row["mrPeriodEnd"]).ToString("yyyy/MM");
  126. }
  127. GridHelper.CopyDataToDatatable(dt2, dataTable2, true);
  128. GridHelper.RefreshAndAutoSize(ultraGrid2);
  129. }
  130. catch (Exception ex)
  131. {
  132. MessageUtil.ShowTips("加载数据失败:" + ex);
  133. }
  134. finally
  135. {
  136. this.Cursor = Cursors.Default;
  137. }
  138. }
  139. // 编制
  140. private void doCreate()
  141. {
  142. try
  143. {
  144. String strtenantId1 = "";
  145. int i = 0;
  146. ultraGrid1.UpdateData();
  147. ArrayList list = new ArrayList();
  148. foreach (UltraGridRow row in ultraGrid1.Rows)
  149. {
  150. if (Convert.ToBoolean(row.GetCellValue("CHECK")) == true)
  151. {
  152. string strMrId = row.GetCellValue("MrId").ToString().Trim();
  153. RequirePlanM pm = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { strMrId });
  154. //头是否处于可删该的状态
  155. if (pm.Status == "0" || pm.Status == "2" || pm.Status == "3")
  156. {
  157. MessageUtil.ShowTips("需求子计划头【" + strMrId + "】为已编制,或请刷新后再操作!");
  158. return;
  159. }
  160. string strtenantId = pm.TenantId;
  161. if (String.IsNullOrEmpty(strtenantId))
  162. {
  163. MessageUtil.ShowTips("需求子计划头【" + strMrId + "】未维护审批流程类型!");
  164. return;
  165. }
  166. if (i == 0)
  167. {
  168. strtenantId1 = strtenantId;
  169. }
  170. else
  171. {
  172. if (strtenantId1 != strtenantId)
  173. {
  174. MessageUtil.ShowTips("只能合并审批流程一致的需求子计划,需求子计划头【" + strMrId + "】审批流程类型不一致!");
  175. return;
  176. }
  177. }
  178. RequirePlanD pd = new RequirePlanD();
  179. pd.MrId = strMrId;
  180. pd.Validflag = "1";
  181. List<RequirePlanD> listd = this.execute<List<RequirePlanD>>("com.hnshituo.pur.requireplan.service.RequirePlanDService","find", new object[] { pd, 0, 0 });
  182. if (listd.Count <= 0)
  183. {
  184. MessageUtil.ShowTips("需求子计划头【" + strMrId + "】无需求计划行,请先添加物料后再操作!");
  185. return;
  186. }
  187. i++;
  188. list.Add(strMrId);
  189. }
  190. }
  191. if (list.Count <= 0)
  192. {
  193. MessageUtil.ShowTips("请选择需要汇总的需求子计划头!");
  194. return;
  195. }
  196. FrmPurRequirePlanSummmary frm = new FrmPurRequirePlanSummmary(this.ob, list, 1,strCustom);
  197. frm.ShowDialog();
  198. if (frm.Tips == "1")
  199. {
  200. doQuery();
  201. tips = "1";
  202. }
  203. }
  204. catch (Exception ex)
  205. {
  206. MessageUtil.ShowTips("操作失败:"+ex.Message);
  207. }
  208. }
  209. //取消编制
  210. private void cancelCreate()
  211. {
  212. ultraGrid2.UpdateData();
  213. ArrayList list = new ArrayList();
  214. foreach (UltraGridRow row in ultraGrid2.Rows)
  215. {
  216. if (Convert.ToBoolean(row.GetCellValue("CHECK")) == true)
  217. {
  218. String strMrId = row.GetCellValue("mrId").ToString().Trim();
  219. RequirePlanM pm = this.execute<RequirePlanM>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { strMrId });
  220. if (pm.CreateUserid != UserInfo.GetUserID())
  221. {
  222. MessageUtil.ShowTips("无权限,只能操作自己的提交的需求计划");
  223. return;
  224. }
  225. if (pm.Status != "1" && pm.Status != "4")
  226. {
  227. MessageUtil.ShowTips("需求计划头【" + strMrId + "】为已编制、审批中或已审批状态之一,暂无权限进行增删改,或请刷新后再操作!");
  228. return;
  229. }
  230. pm.DeleteName = UserInfo.GetUserName();
  231. pm.DeleteTime = DateTime.Now;
  232. pm.DeleteUserid = UserInfo.GetUserID();
  233. list.Add(pm);
  234. }
  235. }
  236. if (list.Count <= 0)
  237. {
  238. MessageUtil.ShowTips("请选择需撤销的编制后需求主计划!");
  239. }
  240. if (MessageUtil.ShowYesNoAndQuestion("确定撤销上述" + list.Count + "个已编制需求计划?") != DialogResult.Yes)
  241. {
  242. return;
  243. }
  244. CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "doDeleteM_batch", new object[] { list,strCustom});
  245. if (re.Resultcode != 0)
  246. {
  247. MessageUtil.ShowTips("操作失败:" + re.Resultmsg);
  248. }
  249. else
  250. {
  251. MessageUtil.ShowTips("操作成功");
  252. tips = "1"; ;
  253. }
  254. }
  255. //激活子计划Grid
  256. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  257. {
  258. UltraGridRow row = ultraGrid1.ActiveRow;
  259. if (row == null || ultraTabControl1.SelectedTab != ultraTabControl1.Tabs[0])
  260. {
  261. return;
  262. }
  263. String strMrId = row.GetCellValue("mrId").ToString().Trim();
  264. getDetail(strMrId);
  265. }
  266. //激活主计划Grid
  267. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  268. {
  269. UltraGridRow row = ultraGrid2.ActiveRow;
  270. if (row == null || ultraTabControl1.SelectedTab != ultraTabControl1.Tabs[1])
  271. {
  272. return;
  273. }
  274. String strMrId = row.GetCellValue("mrId").ToString().Trim();
  275. getDetail(strMrId);
  276. RequirePlanM RqPM = new RequirePlanM();
  277. RqPM.MrId = strMrId;
  278. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanMService", "find_SourcePlan", new object[] { RqPM });
  279. foreach (DataRow row1 in dt.Rows)
  280. {
  281. row1["mrPeriodEnd"] = Convert.ToDateTime(row1["mrPeriodEnd"]).ToString("yyyy/MM");
  282. }
  283. GridHelper.CopyDataToDatatable(dt, dataTable4, true);
  284. GridHelper.RefreshAndAutoSize(ultraGrid4);
  285. }
  286. //查询从表
  287. private void getDetail(String strMrId)
  288. {
  289. dataSet3.Clear();
  290. dataSet4.Clear();
  291. RequirePlanD rpd = new RequirePlanD();
  292. rpd.Validflag = "1";
  293. rpd.MrId = strMrId;
  294. DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd });
  295. GridHelper.CopyDataToDatatable(dt1, dataTable3, true);
  296. GridHelper.RefreshAndAutoSize(ultraGrid3);
  297. }
  298. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  299. {
  300. if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])
  301. {
  302. CK_isAll.Enabled = true;
  303. ultraToolbarsManager1.Tools[1].SharedProps.Enabled = true;
  304. ultraToolbarsManager1.Tools[2].SharedProps.Enabled = false;
  305. ultraTabControl2.Tabs[1].Visible = false;
  306. //this.ToolBarItemEnable(this, "doQuery", true);
  307. //this.ToolBarItemEnable(this, "doCreate", true);
  308. //this.ToolBarItemEnable(this, "cancelCreate", false);
  309. //this.ToolBarItemEnable(this, "doExit", true);
  310. }
  311. else
  312. {
  313. CK_isAll.Enabled = false;
  314. ultraToolbarsManager1.Tools[1].SharedProps.Enabled = false;
  315. ultraToolbarsManager1.Tools[2].SharedProps.Enabled = true;
  316. ultraTabControl2.Tabs[1].Visible = true;
  317. //this.ToolBarItemEnable(this, "doQuery", true);
  318. //this.ToolBarItemEnable(this, "doCreate", false);
  319. //this.ToolBarItemEnable(this, "cancelCreate", true);
  320. //this.ToolBarItemEnable(this, "doExit", true);
  321. }
  322. }
  323. private void ck_ctime_CheckedChanged(object sender, EventArgs e)
  324. {
  325. txtMrPeriodEnd.Enabled = ck_ctime.Checked;
  326. txtMrPeriodStart.Enabled = ck_ctime.Checked;
  327. }
  328. private void FrmPurRequirePlanReceive2_Shown(object sender, EventArgs e)
  329. {
  330. //this.ToolBarItemEnable(this, "doQuery", true);
  331. //this.ToolBarItemEnable(this, "doCreate", true);
  332. //this.ToolBarItemEnable(this, "cancelCreate", false);
  333. //this.ToolBarItemEnable(this, "doExit", true);
  334. }
  335. }
  336. }