F_PP_0301.cs 19 KB

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