F_PP_0101.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. /*******************************************************************************
  2. * Copyright(c) 2019 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PP_0101.cs
  5. * 2.功能描述:年计划
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 徐伟 2019/08/27 1.00 新建
  9. *******************************************************************************/
  10. using Dongke.IBOSS.PRD.Basics.BaseResources;
  11. using Dongke.IBOSS.PRD.Client.CommonModule;
  12. using Dongke.IBOSS.PRD.Client.Controls;
  13. using Dongke.IBOSS.PRD.Client.DataModels;
  14. using Dongke.IBOSS.PRD.WCF.DataModels;
  15. using Dongke.IBOSS.PRD.WCF.Proxys;
  16. using System;
  17. using System.Reflection;
  18. using System.Windows.Forms;
  19. namespace Dongke.IBOSS.PRD.Client.PPModule
  20. {
  21. /// <summary>
  22. /// 年计划窗体
  23. /// </summary>
  24. public partial class F_PP_0101 : DKDockPanelBase
  25. {
  26. #region 默认方法
  27. /********************************************************/
  28. private static F_PP_0101 _instance = null;
  29. public static F_PP_0101 Instance
  30. {
  31. get
  32. {
  33. if (_instance == null)
  34. {
  35. _instance = new F_PP_0101();
  36. }
  37. return _instance;
  38. }
  39. }
  40. private void F_PP_0101_FormClosed(object sender, FormClosedEventArgs e)
  41. {
  42. _instance = null;
  43. }
  44. //单实例
  45. public F_PP_0101()
  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_0101_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. PlanYearTypeLoad();
  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. PlanYearEdit();
  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. PlanYearSearch();
  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. PlanYearSearch();
  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. PlanYearSearch();
  116. }
  117. //年计划 自由比对
  118. private void TsbtnVer_Click(object sender, EventArgs e)
  119. {
  120. PlanYearVer();
  121. }
  122. //年计划 同表比对
  123. private void TsbtnSame_Click(object sender, EventArgs e)
  124. {
  125. PlanYearSame();
  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. PlanYearGoodsSearch();
  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. PlanYearAdd();
  154. }
  155. //保存副本
  156. private void TsbtnCopy_Click(object sender, EventArgs e)
  157. {
  158. PlanYearCopy();
  159. }
  160. //双击修改
  161. private void DgvDetail_DoubleClick(object sender, EventArgs e)
  162. {
  163. PlanYearGoodsEdit();
  164. }
  165. //产品产量 新建
  166. private void TsbtnPlanGoodsAdd_Click(object sender, EventArgs e)
  167. {
  168. PlanYearGoodsAdd();
  169. }
  170. //年计划 修改
  171. private void TsbtnPlanEdit_Click(object sender, EventArgs e)
  172. {
  173. PlanYearEdit();
  174. }
  175. //产品产量 修改
  176. private void TsbtnPlanGoodsEdit_Click(object sender, EventArgs e)
  177. {
  178. PlanYearGoodsEdit();
  179. }
  180. //年计划 删除
  181. private void TsbtnPlanDelete_Click(object sender, EventArgs e)
  182. {
  183. PlanYearDelete();
  184. }
  185. //产品产量 删除
  186. private void TsbtnPlanGoodsDelete_Click(object sender, EventArgs e)
  187. {
  188. PlanYearGoodsDelete();
  189. }
  190. #endregion
  191. #region 年计划处理方法
  192. /********************************************************/
  193. //清空搜索条件
  194. private void SearchEnpty()
  195. {
  196. pName.Text = "";
  197. pYearNo.Text = "";
  198. pType.SelectedIndex = -1;
  199. pRemarks.Text = "";
  200. }
  201. //加载计划类型
  202. private void PlanYearTypeLoad()
  203. {
  204. ClientRequestEntity cre = new ClientRequestEntity();
  205. ServiceResultEntity result = PPModuleProxy.Service.PlanTypeSearch(cre);
  206. pType.DisplayMember = "PLANTYPENAME";
  207. pType.ValueMember = "PLANTYPEID";
  208. pType.DataSource = result.Data.Tables[0];
  209. pType.SelectedIndex = -1;
  210. }
  211. //年计划 查询处理
  212. private void PlanYearSearch(int id=0)
  213. {
  214. ClientRequestEntity cre = new ClientRequestEntity();
  215. if (pYearNo.Text.Trim() != "") cre.Properties["YEARNO"] = Convert.ToInt32(pYearNo.Text.Trim());
  216. if (pName.Text.Trim() != "") cre.Properties["PLANNAME"] = pName.Text.Trim();
  217. if (pType.SelectedValue != null) cre.Properties["PLANTYPEID"] = pType.SelectedValue.ToString().Trim();
  218. if (pRemarks.Text.Trim() != "") cre.Properties["REMARKS"] = pRemarks.Text.Trim();
  219. ServiceResultEntity result;
  220. //是否显示版本数据
  221. if (showVer.Checked)
  222. result = PPModuleProxy.Service.PlanYearVerSearch(cre);
  223. else
  224. result = PPModuleProxy.Service.PlanYearSearch(cre);
  225. dgvPlan.DataSource = result.Data.Tables[0];
  226. //选中原来的行 默认选择0行
  227. if (dgvPlan.Rows.Count == 0)
  228. dgvDetail.DataSource = null;
  229. else
  230. {
  231. if(id==0)
  232. dgvPlan.Rows[0].Selected = true;
  233. else
  234. for (int i = 0; i < dgvPlan.Rows.Count; i++)
  235. if (dgvPlan.Rows[i].Cells["PLANID"].Value.ToString() == id.ToString())
  236. dgvPlan.Rows[i].Selected = true;
  237. }
  238. }
  239. //年计划 添加处理
  240. private void PlanYearAdd()
  241. {
  242. F_PP_0102 yearForm = new F_PP_0102();
  243. yearForm.planId = 0;
  244. //加载计划类型
  245. ClientRequestEntity cre = new ClientRequestEntity();
  246. ServiceResultEntity result = PPModuleProxy.Service.PlanTypeSearch(cre);
  247. yearForm.planType.DisplayMember = "PLANTYPENAME";
  248. yearForm.planType.ValueMember = "PLANTYPEID";
  249. yearForm.planType.DataSource = result.Data.Tables[0];
  250. yearForm.planType.SelectedValue = -1;
  251. yearForm.planYearNo.Value = pYearNo.Value;
  252. yearForm.planName.Text = pName.Text;
  253. if(pType.SelectedValue is object) yearForm.planType.SelectedValue = pType.SelectedValue;
  254. yearForm.planRemarks.Text = pRemarks.Text;
  255. yearForm.ShowDialog();
  256. if (yearForm.DialogResult == DialogResult.OK)
  257. PlanYearSearch(PPModuleProxy.Service.Seq("SEQ_PP_PLAN_YEAR_PLANID.CURRVAL"));
  258. }
  259. //年计划 修改处理
  260. private void PlanYearEdit()
  261. {
  262. if(dgvPlan.SelectedRows.Count>0)
  263. {
  264. F_PP_0102 yearForm = new F_PP_0102();
  265. yearForm.planId = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PlanId"].Value.ToString());
  266. //加载计划类型
  267. ClientRequestEntity cre = new ClientRequestEntity();
  268. ServiceResultEntity result = PPModuleProxy.Service.PlanTypeSearch(cre);
  269. yearForm.planType.DisplayMember = "PLANTYPENAME";
  270. yearForm.planType.ValueMember = "PLANTYPEID";
  271. yearForm.planType.DataSource = result.Data.Tables[0];
  272. yearForm.planType.SelectedValue = -1;
  273. //更新操作 直接从datagrid中取值
  274. yearForm.planYearNo.Value = Convert.ToDecimal(dgvPlan.SelectedRows[0].Cells["YearNo"].Value.ToString());
  275. yearForm.planName.Text = dgvPlan.SelectedRows[0].Cells["PlanName"].Value.ToString();
  276. yearForm.planType.SelectedValue = dgvPlan.SelectedRows[0].Cells["PlanTypeId"].Value;
  277. yearForm.planStartMonth.Value = Convert.ToDecimal(dgvPlan.SelectedRows[0].Cells["StartMonth"].Value.ToString().Trim());
  278. yearForm.planEndMonth.Value = Convert.ToDecimal(dgvPlan.SelectedRows[0].Cells["EndMonth"].Value.ToString().Trim());
  279. yearForm.planRemarks.Text = dgvPlan.SelectedRows[0].Cells["Remarks"].Value.ToString();
  280. yearForm.ShowDialog();
  281. //保存
  282. if (yearForm.DialogResult == DialogResult.OK)
  283. PlanYearSearch(Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PlanId"].Value));
  284. }
  285. }
  286. //年计划 删除处理
  287. private void PlanYearDelete()
  288. {
  289. if(dgvPlan.SelectedRows.Count>0)
  290. {
  291. if(MessageBox.Show($"您确认要删除【计划名称:{dgvPlan.SelectedRows[0].Cells["PLANNAME"].Value}】的记录吗?\n产品产量计划【{dgvDetail.Rows.Count}】条记录会一同被删除!","提示信息",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning)== DialogResult.OK)
  292. {
  293. ClientRequestEntity cre = new ClientRequestEntity();
  294. cre.Properties["PLANID"] = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PLANID"].Value);
  295. //删除产品产量记录
  296. PPModuleProxy.Service.PlanYearGoodsDelete(cre);
  297. //删除年计划记录
  298. PPModuleProxy.Service.PlanYearDelete(cre);
  299. PlanYearSearch();
  300. }
  301. }
  302. }
  303. //年计划 保存副本
  304. private void PlanYearCopy()
  305. {
  306. if(MessageBox.Show($"您确认要保存【计划名称:{dgvPlan.SelectedRows[0].Cells["PLANNAME"].Value}】的副本吗?","提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)== DialogResult.OK)
  307. {
  308. int planId = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PlanId"].Value.ToString());
  309. int newPlanId = PPModuleProxy.Service.PlanYearCopy(planId);
  310. PlanYearSearch(newPlanId);
  311. }
  312. }
  313. #endregion
  314. #region 产品产量计划处理
  315. /********************************************************/
  316. //加载产品列表
  317. private void PlanGoodsLoad(F_PP_0103 goodsForm)
  318. {
  319. //加载产品
  320. ClientRequestEntity cre = new ClientRequestEntity();
  321. //只找出有效标识为1的产品
  322. cre.Properties["CEASEFLAG"] = "1";
  323. ServiceResultEntity result = PPModuleProxy.Service.PlanGoodsSearch(cre);
  324. //产品编码
  325. goodsForm.goodsCode.DisplayMember = "GOODSCODE";
  326. goodsForm.goodsCode.ValueMember = "GOODSID";
  327. goodsForm.goodsCode.DataSource = result.Data.Tables[0];
  328. goodsForm.goodsCode.SelectedValue = -1;
  329. //产品名称
  330. goodsForm.goodsName.DisplayMember = "GOODSNAME";
  331. goodsForm.goodsName.ValueMember = "GOODSID";
  332. goodsForm.goodsName.DataSource = result.Data.Tables[0];
  333. goodsForm.goodsName.SelectedValue = -1;
  334. //产品规格
  335. goodsForm.goodsSpecification.DisplayMember = "GOODSSPECIFICATION";
  336. goodsForm.goodsSpecification.ValueMember = "GOODSID";
  337. goodsForm.goodsSpecification.DataSource = result.Data.Tables[0];
  338. goodsForm.goodsSpecification.SelectedValue = -1;
  339. //产品型号
  340. goodsForm.goodsModel.DisplayMember = "GOODSMODEL";
  341. goodsForm.goodsModel.ValueMember = "GOODSID";
  342. goodsForm.goodsModel.DataSource = result.Data.Tables[0];
  343. goodsForm.goodsModel.SelectedValue = -1;
  344. }
  345. //产品产量 查询处理
  346. private void PlanYearGoodsSearch(int id=0)
  347. {
  348. if (dgvPlan.SelectedRows.Count > 0)
  349. {
  350. ClientRequestEntity cre = new ClientRequestEntity();
  351. cre.Properties["PLANID"] = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PLANID"].Value);
  352. ServiceResultEntity result = PPModuleProxy.Service.PlanYearGoodsSearch(cre);
  353. dgvDetail.DataSource = result.Data.Tables[0];
  354. //选中原来的行 默认选择0行
  355. if (id == 0 && dgvDetail.Rows.Count > 0)
  356. dgvDetail.Rows[0].Selected = true;
  357. else
  358. {
  359. for (int i = 0; i < dgvDetail.Rows.Count; i++)
  360. if (dgvDetail.Rows[i].Cells["PLANGOODSID"].Value.ToString() == id.ToString())
  361. dgvDetail.Rows[i].Selected = true;
  362. }
  363. }
  364. }
  365. //产品产量 添加处理
  366. private void PlanYearGoodsAdd()
  367. {
  368. if(dgvPlan.SelectedRows.Count>0)
  369. {
  370. F_PP_0103 goodsForm = new F_PP_0103();
  371. goodsForm.planGoodsId = 0;
  372. //传入计划ID和冗余数据
  373. goodsForm.planId = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["PLANID"].Value);
  374. goodsForm.planYearNo = Convert.ToInt32(dgvPlan.SelectedRows[0].Cells["YEARNO"].Value);
  375. goodsForm.planStartDate = Convert.ToDateTime(dgvPlan.SelectedRows[0].Cells["STARTDATE"].Value);
  376. goodsForm.planEndDate = Convert.ToDateTime(dgvPlan.SelectedRows[0].Cells["ENDDATE"].Value);
  377. //加载产品选择选项
  378. PlanGoodsLoad(goodsForm);
  379. goodsForm.ShowDialog();
  380. if (goodsForm.DialogResult == DialogResult.OK)
  381. PlanYearGoodsSearch(PPModuleProxy.Service.Seq("SEQ_PP_PLAN_YEAR_PLANGOODSID.CURRVAL"));
  382. }
  383. }
  384. //产品产量 修改处理
  385. private void PlanYearGoodsEdit()
  386. {
  387. if (dgvDetail.SelectedRows.Count > 0)
  388. {
  389. F_PP_0103 goodsForm = new F_PP_0103();
  390. goodsForm.planGoodsId = Convert.ToInt32(dgvDetail.SelectedRows[0].Cells["PlanGoodsId"].Value.ToString());
  391. //加载产品选择选项
  392. PlanGoodsLoad(goodsForm);
  393. //更新操作 直接从datagrid中取值
  394. goodsForm.goodsCode.SelectedValue = dgvDetail.SelectedRows[0].Cells["GOODSID"].Value;
  395. goodsForm.goodsName.SelectedValue = dgvDetail.SelectedRows[0].Cells["GOODSID"].Value;
  396. goodsForm.goodsSpecification.SelectedValue = dgvDetail.SelectedRows[0].Cells["GOODSID"].Value;
  397. goodsForm.goodsModel.SelectedValue = dgvDetail.SelectedRows[0].Cells["GOODSID"].Value;
  398. goodsForm.planQuantity.Value = Convert.ToDecimal(dgvDetail.SelectedRows[0].Cells["PlanQuantity"].Value);
  399. goodsForm.planRemarks.Text = dgvDetail.SelectedRows[0].Cells["PlanRemarks"].Value.ToString();
  400. goodsForm.ShowDialog();
  401. if (goodsForm.DialogResult == DialogResult.OK)
  402. PlanYearGoodsSearch(Convert.ToInt32(dgvDetail.SelectedRows[0].Cells["PlanGoodsId"].Value));
  403. }
  404. }
  405. //产品产量 删除处理
  406. private void PlanYearGoodsDelete()
  407. {
  408. if (dgvDetail.SelectedRows.Count > 0)
  409. {
  410. if (MessageBox.Show($"您确认要删除【产品编码:{dgvDetail.SelectedRows[0].Cells["GOODSCODE"].Value} 产品名称:{dgvDetail.SelectedRows[0].Cells["GOODSNAME"].Value}】的记录吗?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
  411. {
  412. ClientRequestEntity cre = new ClientRequestEntity();
  413. cre.Properties["PLANGOODSID"] = Convert.ToInt32(dgvDetail.SelectedRows[0].Cells["PLANGOODSID"].Value);
  414. //删除产品产量记录
  415. PPModuleProxy.Service.PlanYearGoodsDelete(cre);
  416. PlanYearSearch();
  417. }
  418. }
  419. }
  420. #endregion
  421. #region * 年计划比对
  422. /********************************************************/
  423. //自由比对
  424. private void PlanYearVer()
  425. {
  426. F_PP_0110 verForm = new F_PP_0110();
  427. verForm.ShowDialog();
  428. }
  429. //同表比对
  430. private void PlanYearSame()
  431. {
  432. F_PP_0111 verForm = new F_PP_0111();
  433. verForm.ShowDialog();
  434. }
  435. #endregion
  436. }
  437. }