F_PP_0201.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. /*******************************************************************************
  2. * Copyright(c) 2019 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PP_0201.cs
  5. * 2.功能描述:月计划
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 徐伟 2019/08/27 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Reflection;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.Client.CommonModule;
  15. using Dongke.IBOSS.PRD.Client.Controls;
  16. using Dongke.IBOSS.PRD.Client.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.Proxys;
  19. namespace Dongke.IBOSS.PRD.Client.PPModule
  20. {
  21. /// <summary>
  22. /// 月计划窗体
  23. /// </summary>
  24. public partial class F_PP_0201 : DKDockPanelBase
  25. {
  26. #region 默认方法
  27. /********************************************************/
  28. private static F_PP_0201 _instance = null;
  29. public static F_PP_0201 Instance
  30. {
  31. get
  32. {
  33. if (_instance == null)
  34. {
  35. _instance = new F_PP_0201();
  36. }
  37. return _instance;
  38. }
  39. }
  40. private void F_PP_0201_FormClosed(object sender, FormClosedEventArgs e)
  41. {
  42. _instance = null;
  43. }
  44. //单实例
  45. public F_PP_0201()
  46. {
  47. InitializeComponent();
  48. this.Text = "月计划";
  49. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  50. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  51. this.dgvPlan.AutoGenerateColumns = false;
  52. }
  53. //窗体加载
  54. private void F_PP_0201_Load(object sender, System.EventArgs e)
  55. {
  56. try
  57. {
  58. // 加载权限
  59. FormPermissionManager.FormPermissionControl(this.Name, this,
  60. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  61. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  62. //加载计划类型
  63. PlanMonthTypeLoad();
  64. //默认清空条件
  65. SearchEnpty();
  66. }
  67. catch (Exception ex)
  68. {
  69. // 对异常进行共通处理
  70. ExceptionManager.HandleEventException(this.ToString(),
  71. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  72. }
  73. }
  74. #endregion
  75. #region 窗体事件定义和处理
  76. /********************************************************/
  77. //双击进入编辑
  78. private void DgvPlan_DoubleClick(object sender, EventArgs e)
  79. {
  80. PlanMonthEdit();
  81. }
  82. //清空搜索条件
  83. private void BtnEmpty_Click(object sender, EventArgs e)
  84. {
  85. SearchEnpty();
  86. }
  87. //月计划 查询处理
  88. private void BtnSearch_Click(object sender, EventArgs e)
  89. {
  90. PlanMonthSearch();
  91. }
  92. //自适应列宽
  93. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  94. {
  95. this.dgvPlan.AutoResizeColumns();
  96. }
  97. //关闭画面
  98. private void tsbtnClose_Click(object sender, EventArgs e)
  99. {
  100. this.Close();
  101. }
  102. //搜索
  103. private void TsbtnSearch_Click(object sender, EventArgs e)
  104. {
  105. PlanMonthSearch();
  106. }
  107. //清空
  108. private void TsbtnClearCondition_Click(object sender, EventArgs e)
  109. {
  110. SearchEnpty();
  111. }
  112. //显示历史版本处理
  113. private void ShowVer_Click(object sender, EventArgs e)
  114. {
  115. PlanMonthSearch();
  116. }
  117. //月计划 自由比对
  118. private void TsbtnVer_Click(object sender, EventArgs e)
  119. {
  120. PlanMonthVer();
  121. }
  122. //月计划 同表比对
  123. private void TsbtnSame_Click(object sender, EventArgs e)
  124. {
  125. PlanMonthSame();
  126. }
  127. //月计划选中记录后
  128. private void DgvPlan_SelectionChanged(object sender, EventArgs e)
  129. {
  130. //切换编辑和删除菜单按钮变为可用
  131. tsbtnPlanGoodsAdd.Enabled = dgvPlan.SelectedRows.Count > 0;
  132. //副本
  133. tsbtnCopy.Enabled = dgvPlan.SelectedRows.Count > 0;
  134. //编辑组
  135. tsbtnEdit.Enabled = dgvPlan.SelectedRows.Count > 0;
  136. tsbtnDelete.Enabled = dgvPlan.SelectedRows.Count > 0;
  137. //月计划编辑和删除
  138. tsbtnPlanEdit.Enabled = dgvPlan.SelectedRows.Count > 0;
  139. tsbtnPlanDelete.Enabled = dgvPlan.SelectedRows.Count > 0;
  140. //显示产品产量列表
  141. PlanMonthGoodsSearch();
  142. }
  143. //产量计划选中记录后
  144. private void DgvDetail_SelectionChanged(object sender, EventArgs e)
  145. {
  146. //产量计划编辑和删除
  147. tsbtnPlanGoodsEdit.Enabled = dgvDetail.SelectedRows.Count > 0;
  148. tsbtnPlanGoodsDelete.Enabled = dgvDetail.SelectedRows.Count > 0;
  149. }
  150. //月计划 新建
  151. private void TsbtnPlanAdd_Click(object sender, EventArgs e)
  152. {
  153. PlanMonthAdd();
  154. }
  155. //保存副本
  156. private void TsbtnCopy_Click(object sender, EventArgs e)
  157. {
  158. PlanMonthCopy();
  159. }
  160. //双击修改
  161. private void DgvDetail_DoubleClick(object sender, EventArgs e)
  162. {
  163. PlanMonthGoodsEdit();
  164. }
  165. //产品产量 新建
  166. private void TsbtnPlanGoodsAdd_Click(object sender, EventArgs e)
  167. {
  168. PlanMonthGoodsAdd();
  169. }
  170. //月计划 修改
  171. private void TsbtnPlanEdit_Click(object sender, EventArgs e)
  172. {
  173. PlanMonthEdit();
  174. }
  175. //产品产量 修改
  176. private void TsbtnPlanGoodsEdit_Click(object sender, EventArgs e)
  177. {
  178. PlanMonthGoodsEdit();
  179. }
  180. //月计划 删除
  181. private void TsbtnPlanDelete_Click(object sender, EventArgs e)
  182. {
  183. PlanMonthDelete();
  184. }
  185. //产品产量 删除
  186. private void TsbtnPlanGoodsDelete_Click(object sender, EventArgs e)
  187. {
  188. PlanMonthGoodsDelete();
  189. }
  190. #endregion
  191. #region 月计划处理方法
  192. /********************************************************/
  193. //清空搜索条件
  194. private void SearchEnpty()
  195. {
  196. pName.Text = "";
  197. pYearNo.Text = "";
  198. pMonthNo.Text = "";
  199. pType.SelectedIndex = -1;
  200. pRemarks.Text = "";
  201. }
  202. //加载计划类型
  203. private void PlanMonthTypeLoad()
  204. {
  205. ClientRequestEntity cre = new ClientRequestEntity();
  206. ServiceResultEntity result = PPModuleProxy.Service.PlanTypeSearch(cre);
  207. pType.DisplayMember = "PLANTYPENAME";
  208. pType.ValueMember = "PLANTYPEID";
  209. pType.DataSource = result.Data.Tables[0];
  210. pType.SelectedIndex = -1;
  211. }
  212. //月计划 查询处理
  213. private void PlanMonthSearch(int id=0)
  214. {
  215. ClientRequestEntity cre = new ClientRequestEntity();
  216. if (pYearNo.Text.Trim() != "") cre.Properties["YEARNO"] = Convert.ToInt32(pYearNo.Text.Trim());
  217. if (pMonthNo.Text.Trim() != "") cre.Properties["MONTHNO"] = Convert.ToInt32(pMonthNo.Text.Trim());
  218. if (pName.Text.Trim() != "") cre.Properties["PLANNAME"] = pName.Text.Trim();
  219. if (pType.SelectedValue != null) cre.Properties["PLANTYPEID"] = pType.SelectedValue.ToString().Trim();
  220. if (pRemarks.Text.Trim() != "") cre.Properties["REMARKS"] = pRemarks.Text.Trim();
  221. ServiceResultEntity result;
  222. //是否显示版本数据
  223. if (showVer.Checked)
  224. result = PPModuleProxy.Service.PlanMonthVerSearch(cre);
  225. else
  226. result = PPModuleProxy.Service.PlanMonthSearch(cre);
  227. dgvPlan.DataSource = result.Data.Tables[0];
  228. //选中原来的行 默认选择0行
  229. if (dgvPlan.Rows.Count == 0)
  230. dgvDetail.DataSource = null;
  231. else
  232. {
  233. if (id == 0)
  234. dgvPlan.Rows[0].Selected = true;
  235. else
  236. for (int i = 0; i < dgvPlan.Rows.Count; i++)
  237. if (dgvPlan.Rows[i].Cells["PLANID"].Value.ToString() == id.ToString())
  238. dgvPlan.Rows[i].Selected = true;
  239. }
  240. }
  241. //月计划 添加处理
  242. private void PlanMonthAdd()
  243. {
  244. F_PP_0202 yearForm = new F_PP_0202();
  245. yearForm.planId = 0;
  246. //加载计划类型
  247. ClientRequestEntity cre = new ClientRequestEntity();
  248. ServiceResultEntity result = PPModuleProxy.Service.PlanTypeSearch(cre);
  249. yearForm.planType.DisplayMember = "PLANTYPENAME";
  250. yearForm.planType.ValueMember = "PLANTYPEID";
  251. yearForm.planType.DataSource = result.Data.Tables[0];
  252. yearForm.planType.SelectedValue = -1;
  253. yearForm.planYearNo.Value = pYearNo.Value;
  254. yearForm.planMonthNo.Value = pMonthNo.Value;
  255. yearForm.planName.Text = pName.Text;
  256. if(pType.SelectedValue is object) yearForm.planType.SelectedValue = pType.SelectedValue;
  257. yearForm.planRemarks.Text = pRemarks.Text;
  258. yearForm.ShowDialog();
  259. if (yearForm.DialogResult == DialogResult.OK)
  260. PlanMonthSearch(PPModuleProxy.Service.Seq("SEQ_PP_PLAN_MONTH_PLANID.CURRVAL"));
  261. }
  262. //月计划 修改处理
  263. private void PlanMonthEdit()
  264. {
  265. if(dgvPlan.SelectedRows.Count>0)
  266. {
  267. F_PP_0202 yearForm = new F_PP_0202();
  268. yearForm.planId = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PlanId"].Value.ToString());
  269. //加载计划类型
  270. ClientRequestEntity cre = new ClientRequestEntity();
  271. ServiceResultEntity result = PPModuleProxy.Service.PlanTypeSearch(cre);
  272. yearForm.planType.DisplayMember = "PLANTYPENAME";
  273. yearForm.planType.ValueMember = "PLANTYPEID";
  274. yearForm.planType.DataSource = result.Data.Tables[0];
  275. yearForm.planType.SelectedValue = -1;
  276. //更新操作 直接从datagrid中取值
  277. yearForm.planYearNo.Value = Convert.ToDecimal(dgvPlan.SelectedRows[0].Cells["YearNo"].Value.ToString());
  278. yearForm.planMonthNo.Value = Convert.ToDecimal(dgvPlan.SelectedRows[0].Cells["MonthNo"].Value.ToString());
  279. yearForm.planName.Text = dgvPlan.SelectedRows[0].Cells["PlanName"].Value.ToString();
  280. yearForm.planType.SelectedValue = dgvPlan.SelectedRows[0].Cells["PlanTypeId"].Value;
  281. yearForm.planRemarks.Text = dgvPlan.SelectedRows[0].Cells["Remarks"].Value.ToString();
  282. yearForm.ShowDialog();
  283. //保存
  284. if (yearForm.DialogResult == DialogResult.OK)
  285. PlanMonthSearch(Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PlanId"].Value));
  286. }
  287. }
  288. //月计划 删除处理
  289. private void PlanMonthDelete()
  290. {
  291. if(dgvPlan.SelectedRows.Count>0)
  292. {
  293. if(MessageBox.Show($"您确认要删除【计划名称:{dgvPlan.SelectedRows[0].Cells["PLANNAME"].Value}】的记录吗?\n产品产量计划【{dgvDetail.Rows.Count}】条记录会一同被删除!","提示信息",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning)== DialogResult.OK)
  294. {
  295. ClientRequestEntity cre = new ClientRequestEntity();
  296. cre.Properties["PLANID"] = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PLANID"].Value);
  297. //删除产品产量记录
  298. PPModuleProxy.Service.PlanMonthGoodsDelete(cre);
  299. //删除月计划记录
  300. PPModuleProxy.Service.PlanMonthDelete(cre);
  301. PlanMonthSearch();
  302. }
  303. }
  304. }
  305. //月计划 保存副本
  306. private void PlanMonthCopy()
  307. {
  308. if(MessageBox.Show($"您确认要保存【计划名称:{dgvPlan.SelectedRows[0].Cells["PLANNAME"].Value}】的副本吗?","提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)== DialogResult.OK)
  309. {
  310. int planId = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PlanId"].Value.ToString());
  311. int newPlanId = PPModuleProxy.Service.PlanMonthCopy(planId);
  312. PlanMonthSearch(newPlanId);
  313. }
  314. }
  315. #endregion
  316. #region 产品产量计划处理
  317. /********************************************************/
  318. //加载产品列表
  319. private void PlanGoodsLoad(F_PP_0203 goodsForm)
  320. {
  321. //加载产品
  322. ClientRequestEntity cre = new ClientRequestEntity();
  323. //只找出有效标识为1的产品
  324. cre.Properties["CEASEFLAG"] = "1";
  325. ServiceResultEntity result = PPModuleProxy.Service.PlanGoodsSearch(cre);
  326. //产品编码
  327. goodsForm.goodsCode.DisplayMember = "GOODSCODE";
  328. goodsForm.goodsCode.ValueMember = "GOODSID";
  329. goodsForm.goodsCode.DataSource = result.Data.Tables[0];
  330. goodsForm.goodsCode.SelectedValue = -1;
  331. //产品名称
  332. goodsForm.goodsName.DisplayMember = "GOODSNAME";
  333. goodsForm.goodsName.ValueMember = "GOODSID";
  334. goodsForm.goodsName.DataSource = result.Data.Tables[0];
  335. goodsForm.goodsName.SelectedValue = -1;
  336. //产品规格
  337. goodsForm.goodsSpecification.DisplayMember = "GOODSSPECIFICATION";
  338. goodsForm.goodsSpecification.ValueMember = "GOODSID";
  339. goodsForm.goodsSpecification.DataSource = result.Data.Tables[0];
  340. goodsForm.goodsSpecification.SelectedValue = -1;
  341. //产品型号
  342. goodsForm.goodsModel.DisplayMember = "GOODSMODEL";
  343. goodsForm.goodsModel.ValueMember = "GOODSID";
  344. goodsForm.goodsModel.DataSource = result.Data.Tables[0];
  345. goodsForm.goodsModel.SelectedValue = -1;
  346. }
  347. //产品产量 查询处理
  348. private void PlanMonthGoodsSearch(int id=0)
  349. {
  350. if (dgvPlan.SelectedRows.Count > 0)
  351. {
  352. ClientRequestEntity cre = new ClientRequestEntity();
  353. cre.Properties["PLANID"] = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PLANID"].Value);
  354. ServiceResultEntity result = PPModuleProxy.Service.PlanMonthGoodsSearch(cre);
  355. dgvDetail.DataSource = result.Data.Tables[0];
  356. //选中原来的行 默认选择0行
  357. if (id == 0 && dgvDetail.Rows.Count > 0)
  358. dgvDetail.Rows[0].Selected = true;
  359. else
  360. {
  361. for (int i = 0; i < dgvDetail.Rows.Count; i++)
  362. if (dgvDetail.Rows[i].Cells["PLANGOODSID"].Value.ToString() == id.ToString())
  363. dgvDetail.Rows[i].Selected = true;
  364. }
  365. }
  366. }
  367. //产品产量 添加处理
  368. private void PlanMonthGoodsAdd()
  369. {
  370. if(dgvPlan.SelectedRows.Count>0)
  371. {
  372. F_PP_0203 goodsForm = new F_PP_0203();
  373. goodsForm.planGoodsId = 0;
  374. //传入计划ID和冗余数据
  375. goodsForm.planId = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PLANID"].Value);
  376. goodsForm.planYearNo = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["YEARNO"].Value);
  377. goodsForm.planMonthNo = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["MONTHNO"].Value);
  378. goodsForm.planStartDate = Convert.ToDateTime(dgvPlan.SelectedRows[0].Cells["STARTDATE"].Value);
  379. goodsForm.planEndDate = Convert.ToDateTime(dgvPlan.SelectedRows[0].Cells["ENDDATE"].Value);
  380. //加载产品选择选项
  381. PlanGoodsLoad(goodsForm);
  382. goodsForm.ShowDialog();
  383. if (goodsForm.DialogResult == DialogResult.OK)
  384. PlanMonthGoodsSearch(PPModuleProxy.Service.Seq("SEQ_PP_PLAN_MONTH_PLANGOODSID.CURRVAL"));
  385. }
  386. }
  387. //产品产量 修改处理
  388. private void PlanMonthGoodsEdit()
  389. {
  390. if (dgvDetail.SelectedRows.Count > 0)
  391. {
  392. F_PP_0203 goodsForm = new F_PP_0203();
  393. goodsForm.planGoodsId = Convert.ToInt32(dgvDetail.SelectedRows[0].Cells["PlanGoodsId"].Value.ToString());
  394. //加载产品选择选项
  395. PlanGoodsLoad(goodsForm);
  396. //更新操作 直接从datagrid中取值
  397. goodsForm.goodsCode.SelectedValue = dgvDetail.SelectedRows[0].Cells["GOODSID"].Value;
  398. goodsForm.goodsName.SelectedValue = dgvDetail.SelectedRows[0].Cells["GOODSID"].Value;
  399. goodsForm.goodsSpecification.SelectedValue = dgvDetail.SelectedRows[0].Cells["GOODSID"].Value;
  400. goodsForm.goodsModel.SelectedValue = dgvDetail.SelectedRows[0].Cells["GOODSID"].Value;
  401. goodsForm.planQuantity.Value = Convert.ToDecimal(dgvDetail.SelectedRows[0].Cells["PlanQuantity"].Value);
  402. goodsForm.planRemarks.Text = dgvDetail.SelectedRows[0].Cells["PlanRemarks"].Value.ToString();
  403. goodsForm.ShowDialog();
  404. if (goodsForm.DialogResult == DialogResult.OK)
  405. PlanMonthGoodsSearch(Convert.ToInt32(dgvDetail.SelectedRows[0].Cells["PlanGoodsId"].Value));
  406. }
  407. }
  408. //产品产量 删除处理
  409. private void PlanMonthGoodsDelete()
  410. {
  411. if (dgvDetail.SelectedRows.Count > 0)
  412. {
  413. if (MessageBox.Show($"您确认要删除【产品编码:{dgvDetail.SelectedRows[0].Cells["GOODSCODE"].Value} 产品名称:{dgvDetail.SelectedRows[0].Cells["GOODSNAME"].Value}】的记录吗?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
  414. {
  415. ClientRequestEntity cre = new ClientRequestEntity();
  416. cre.Properties["PLANGOODSID"] = Convert.ToInt32(dgvDetail.SelectedRows[0].Cells["PLANGOODSID"].Value);
  417. //删除产品产量记录
  418. PPModuleProxy.Service.PlanMonthGoodsDelete(cre);
  419. PlanMonthSearch();
  420. }
  421. }
  422. }
  423. #endregion
  424. #region * 月计划比对
  425. /********************************************************/
  426. //自由比对
  427. private void PlanMonthVer()
  428. {
  429. F_PP_0110 verForm = new F_PP_0110();
  430. verForm.ShowDialog();
  431. }
  432. //同表比对
  433. private void PlanMonthSame()
  434. {
  435. F_PP_0111 verForm = new F_PP_0111();
  436. verForm.ShowDialog();
  437. }
  438. #endregion
  439. }
  440. }