F_PC_1001.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943
  1. /*******************************************************************************
  2. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PC_1001.cs
  5. * 2.功能描述:模具档案
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2017/12/07 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Reflection;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.Controls;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.PCModule
  22. {
  23. /// <summary>
  24. /// 模具档案
  25. /// </summary>
  26. public partial class F_PC_1001 : DKDockPanelBase
  27. {
  28. #region 成员变量
  29. private static F_PC_1001 _instance = null;
  30. #endregion
  31. #region 单例模式
  32. /// <summary>
  33. /// 单例模式,防止重复创建窗体
  34. /// </summary>
  35. public static F_PC_1001 Instance
  36. {
  37. get
  38. {
  39. if (_instance == null)
  40. {
  41. _instance = new F_PC_1001();
  42. }
  43. return _instance;
  44. }
  45. }
  46. #endregion
  47. #region 构造函数
  48. /// <summary>
  49. ///
  50. /// </summary>
  51. public F_PC_1001()
  52. {
  53. InitializeComponent();
  54. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  55. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  56. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  57. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  58. this.dgvMould.AutoGenerateColumns = false;
  59. }
  60. #endregion
  61. #region 控件事件
  62. /// <summary>
  63. /// 关闭
  64. /// </summary>
  65. /// <param name="sender"></param>
  66. /// <param name="e"></param>
  67. private void F_PC_1001_FormClosed(object sender, FormClosedEventArgs e)
  68. {
  69. _instance = null;
  70. }
  71. /// <summary>
  72. /// 画面加载
  73. /// </summary>
  74. /// <param name="sender"></param>
  75. /// <param name="e"></param>
  76. private void F_PC_1001_Load(object sender, System.EventArgs e)
  77. {
  78. try
  79. {
  80. FormPermissionManager.FormPermissionControl(this.Name, this,
  81. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  82. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  83. this.dtpPDateBegin.Value = DateTime.Now;
  84. this.dtpPDateEnd.Value = DateTime.Now;
  85. this.dtpScrapDateBegin.Value = DateTime.Now;
  86. this.dtpScrapDateEnd.Value = DateTime.Now;
  87. ClientRequestEntity cre = new ClientRequestEntity();
  88. cre.NameSpace = "FPC1001";
  89. cre.Name = "GetFPC1001LoadData";
  90. ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
  91. this.ckcMouldType.DataSource = sre.Data.Tables["MouldType"];
  92. this.ckcSuppliers.DataSource = sre.Data.Tables["Suppliers"];
  93. this.calMouldStatus.DataSource = sre.Data.Tables["MouldStatus"];
  94. this.calMouldStatus.SetItemCheckedByValue(true, 1m, 2m, 3m);
  95. this.dgvMould.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
  96. }
  97. catch (Exception ex)
  98. {
  99. // 对异常进行共通处理
  100. ExceptionManager.HandleEventException(this.ToString(),
  101. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  102. }
  103. }
  104. /// <summary>
  105. /// 生产日期
  106. /// </summary>
  107. /// <param name="sender"></param>
  108. /// <param name="e"></param>
  109. private void chkPDate_CheckedChanged(object sender, EventArgs e)
  110. {
  111. this.dtpPDateBegin.Enabled = this.chkPDate.Checked;
  112. this.dtpPDateEnd.Enabled = this.chkPDate.Checked;
  113. }
  114. /// <summary>
  115. /// 报废日期
  116. /// </summary>
  117. /// <param name="sender"></param>
  118. /// <param name="e"></param>
  119. private void chkScrapDate_CheckedChanged(object sender, EventArgs e)
  120. {
  121. this.dtpScrapDateBegin.Enabled = this.chkScrapDate.Checked;
  122. this.dtpScrapDateEnd.Enabled = this.chkScrapDate.Checked;
  123. }
  124. /// <summary>
  125. /// 清除查询条件
  126. /// </summary>
  127. /// <param name="sender"></param>
  128. /// <param name="e"></param>
  129. private void tsbtnClearCondition_Click(object sender, EventArgs e)
  130. {
  131. this.txtModelBarcode.Clear();
  132. this.txtUserCode.Clear();
  133. this.txtGoodsCode.Clear();
  134. this.txtRemarks.Clear();
  135. this.ckcMouldType.ClearValue();
  136. this.ckcSuppliers.ClearValue();
  137. this.chkPDate.Checked = true;
  138. this.chkScrapDate.Checked = false;
  139. this.dtpPDateBegin.Value = DateTime.Now;
  140. this.dtpPDateEnd.Value = DateTime.Now;
  141. this.dtpScrapDateBegin.Value = DateTime.Now;
  142. this.dtpScrapDateEnd.Value = DateTime.Now;
  143. this.calMouldStatus.SetItemCheckedByValue(true, 1m, 2m, 3m);
  144. }
  145. /// <summary>
  146. /// 查询
  147. /// </summary>
  148. /// <param name="sender"></param>
  149. /// <param name="e"></param>
  150. private void tsbtnSearch_Click(object sender, EventArgs e)
  151. {
  152. try
  153. {
  154. this.QueryDataFromOther();
  155. this.dgvMould.IsSetInputColumnsColor = true;
  156. }
  157. catch (Exception ex)
  158. {
  159. // 对异常进行共通处理
  160. ExceptionManager.HandleEventException(this.ToString(),
  161. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  162. }
  163. }
  164. /// <summary>
  165. /// 排序
  166. /// </summary>
  167. /// <param name="sender"></param>
  168. /// <param name="e"></param>
  169. private void dgvMould_Sorted(object sender, EventArgs e)
  170. {
  171. this.dgvMould.IsSetInputColumnsColor = true;
  172. }
  173. /// <summary>
  174. /// 自适应列宽
  175. /// </summary>
  176. /// <param name="sender"></param>
  177. /// <param name="e"></param>
  178. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  179. {
  180. this.dgvMould.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  181. }
  182. /// <summary>
  183. /// 关闭画面
  184. /// </summary>
  185. /// <param name="sender"></param>
  186. /// <param name="e"></param>
  187. private void tsbtnClose_Click(object sender, EventArgs e)
  188. {
  189. this.Close();
  190. }
  191. /// <summary>
  192. /// 新建
  193. /// </summary>
  194. /// <param name="sender"></param>
  195. /// <param name="e"></param>
  196. private void tsbtnAdd_Click(object sender, EventArgs e)
  197. {
  198. try
  199. {
  200. F_PC_1002 fpc1002 = new F_PC_1002(0);
  201. if (fpc1002.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  202. {
  203. this.tsbtnSearch_Click(null, null);
  204. }
  205. }
  206. catch (Exception ex)
  207. {
  208. // 对异常进行共通处理
  209. ExceptionManager.HandleEventException(this.ToString(),
  210. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  211. }
  212. }
  213. /// <summary>
  214. /// 编辑
  215. /// </summary>
  216. /// <param name="sender"></param>
  217. /// <param name="e"></param>
  218. private void tsbtnEdit_Click(object sender, EventArgs e)
  219. {
  220. if (this.dgvMould.CurrentRow == null || this.dgvMould.CurrentRow.Index < 0)
  221. {
  222. return;
  223. }
  224. try
  225. {
  226. int mouldID = Convert.ToInt32(this.dgvMould.CurrentRow.Cells["MouldID"].Value);
  227. F_PC_1002 fpc1002 = new F_PC_1002(mouldID);
  228. if (fpc1002.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  229. {
  230. this.tsbtnSearch_Click(null, null);
  231. }
  232. }
  233. catch (Exception ex)
  234. {
  235. // 对异常进行共通处理
  236. ExceptionManager.HandleEventException(this.ToString(),
  237. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  238. }
  239. }
  240. /// <summary>
  241. /// 打印
  242. /// </summary>
  243. /// <param name="sender"></param>
  244. /// <param name="e"></param>
  245. private void tsbtnPrint_Click(object sender, EventArgs e)
  246. {
  247. if (this.dgvMould.CurrentRow == null || this.dgvMould.CurrentRow.Index < 0)
  248. {
  249. return;
  250. }
  251. try
  252. {
  253. string barcode = this.dgvMould.CurrentRow.Cells["MouldBarcode"].Value.ToString();
  254. F_MST_013006.PrintBarcode(barcode, 1, this);
  255. }
  256. catch (Exception ex)
  257. {
  258. // 对异常进行共通处理
  259. ExceptionManager.HandleEventException(this.ToString(),
  260. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  261. }
  262. }
  263. /// <summary>
  264. /// 双击编辑
  265. /// </summary>
  266. /// <param name="sender"></param>
  267. /// <param name="e"></param>
  268. private void dgvMould_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  269. {
  270. if (!this.tsbtnEdit.Visible || !this.tsbtnEdit.Enabled)
  271. {
  272. return;
  273. }
  274. if (e.ColumnIndex < 0 || e.RowIndex < 0 || "Sel" == dgvMould.Columns[e.ColumnIndex].Name)
  275. {
  276. return;
  277. }
  278. try
  279. {
  280. int mouldID = Convert.ToInt32(this.dgvMould.CurrentRow.Cells["MouldID"].Value);
  281. F_PC_1002 fpc1002 = new F_PC_1002(mouldID);
  282. if (fpc1002.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  283. {
  284. this.tsbtnSearch_Click(null, null);
  285. }
  286. }
  287. catch (Exception ex)
  288. {
  289. // 对异常进行共通处理
  290. ExceptionManager.HandleEventException(this.ToString(),
  291. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  292. }
  293. }
  294. /// <summary>
  295. /// 报废
  296. /// </summary>
  297. /// <param name="sender"></param>
  298. /// <param name="e"></param>
  299. private void tsbtnScrap_Click(object sender, EventArgs e)
  300. {
  301. try
  302. {
  303. DataTable dt = this.dgvMould.DataSource as DataTable;
  304. if (dt == null || dt.Rows.Count == 0)
  305. {
  306. return;
  307. }
  308. DataRow[] items = dt.Select("Sel = 1 and MouldStatus in (1,3)");
  309. if (items == null || items.Length == 0)
  310. {
  311. MessageBox.Show("没有选择任何模具,或所选模具不是【在库】、【待产】状态",
  312. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  313. MessageBoxDefaultButton.Button1);
  314. return;
  315. }
  316. List<string> ids = new List<string>();
  317. foreach (DataRow item in items)
  318. {
  319. ids.Add(item["MouldID"].ToString());
  320. }
  321. F_PC_1004 fpc1004 = new F_PC_1004(string.Join(",", ids), Constant.MouldOperationType.InvToScrap);
  322. if (fpc1004.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  323. {
  324. this.tsbtnSearch_Click(null, null);
  325. }
  326. }
  327. catch (Exception ex)
  328. {
  329. // 对异常进行共通处理
  330. ExceptionManager.HandleEventException(this.ToString(),
  331. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  332. }
  333. }
  334. /// <summary>
  335. /// 撤销报废
  336. /// </summary>
  337. /// <param name="sender"></param>
  338. /// <param name="e"></param>
  339. private void tsbtnUndoScrap_Click(object sender, EventArgs e)
  340. {
  341. try
  342. {
  343. DataTable dt = this.dgvMould.DataSource as DataTable;
  344. if (dt == null || dt.Rows.Count == 0)
  345. {
  346. return;
  347. }
  348. DataRow[] items = dt.Select("Sel = 1 and MouldStatus = 4");
  349. if (items == null || items.Length == 0)
  350. {
  351. MessageBox.Show("没有选择任何模具,或所选模具不是【报废】状态",
  352. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  353. MessageBoxDefaultButton.Button1);
  354. return;
  355. }
  356. List<string> ids = new List<string>();
  357. foreach (DataRow item in items)
  358. {
  359. ids.Add(item["MouldID"].ToString());
  360. }
  361. F_PC_1004 fpc1004 = new F_PC_1004(string.Join(",", ids), Constant.MouldOperationType.ScrapToInv);
  362. if (fpc1004.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  363. {
  364. this.tsbtnSearch_Click(null, null);
  365. }
  366. }
  367. catch (Exception ex)
  368. {
  369. // 对异常进行共通处理
  370. ExceptionManager.HandleEventException(this.ToString(),
  371. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  372. }
  373. }
  374. /// <summary>
  375. /// 领用
  376. /// </summary>
  377. /// <param name="sender"></param>
  378. /// <param name="e"></param>
  379. private void tsbtnOut_Click(object sender, EventArgs e)
  380. {
  381. try
  382. {
  383. DataTable dt = this.dgvMould.DataSource as DataTable;
  384. if (dt == null || dt.Rows.Count == 0)
  385. {
  386. return;
  387. }
  388. DataRow[] items = dt.Select("Sel = 1 and MouldStatus = 1");
  389. if (items == null || items.Length == 0)
  390. {
  391. MessageBox.Show("没有选择任何模具,或所选模具不是【在库】状态",
  392. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  393. MessageBoxDefaultButton.Button1);
  394. return;
  395. }
  396. List<string> ids = new List<string>();
  397. foreach (DataRow item in items)
  398. {
  399. ids.Add(item["MouldID"].ToString());
  400. }
  401. F_PC_1004 fpc1004 = new F_PC_1004(string.Join(",", ids), Constant.MouldOperationType.InvToOut);
  402. if (fpc1004.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  403. {
  404. this.tsbtnSearch_Click(null, null);
  405. }
  406. }
  407. catch (Exception ex)
  408. {
  409. // 对异常进行共通处理
  410. ExceptionManager.HandleEventException(this.ToString(),
  411. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  412. }
  413. }
  414. /// <summary>
  415. /// 回收
  416. /// </summary>
  417. /// <param name="sender"></param>
  418. /// <param name="e"></param>
  419. private void tsbtnIn_Click(object sender, EventArgs e)
  420. {
  421. try
  422. {
  423. DataTable dt = this.dgvMould.DataSource as DataTable;
  424. if (dt == null || dt.Rows.Count == 0)
  425. {
  426. return;
  427. }
  428. DataRow[] items = dt.Select("Sel = 1 and MouldStatus = 3");
  429. if (items == null || items.Length == 0)
  430. {
  431. MessageBox.Show("没有选择任何模具,或所选模具不是【待产】状态",
  432. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  433. MessageBoxDefaultButton.Button1);
  434. return;
  435. }
  436. List<string> ids = new List<string>();
  437. foreach (DataRow item in items)
  438. {
  439. ids.Add(item["MouldID"].ToString());
  440. }
  441. F_PC_1004 fpc1004 = new F_PC_1004(string.Join(",", ids), Constant.MouldOperationType.OutToInv);
  442. if (fpc1004.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  443. {
  444. this.tsbtnSearch_Click(null, null);
  445. }
  446. }
  447. catch (Exception ex)
  448. {
  449. // 对异常进行共通处理
  450. ExceptionManager.HandleEventException(this.ToString(),
  451. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  452. }
  453. }
  454. /// <summary>
  455. /// 替换条码
  456. /// </summary>
  457. /// <param name="sender"></param>
  458. /// <param name="e"></param>
  459. private void tsbtnChangeBarcode_Click(object sender, EventArgs e)
  460. {
  461. if (this.dgvMould.CurrentRow == null || this.dgvMould.CurrentRow.Index < 0)
  462. {
  463. return;
  464. }
  465. try
  466. {
  467. int mouldID = Convert.ToInt32(this.dgvMould.CurrentRow.Cells["MouldID"].Value);
  468. F_PC_1003 fpc1003 = new F_PC_1003(mouldID);
  469. if (fpc1003.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  470. {
  471. this.tsbtnSearch_Click(null, null);
  472. }
  473. }
  474. catch (Exception ex)
  475. {
  476. // 对异常进行共通处理
  477. ExceptionManager.HandleEventException(this.ToString(),
  478. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  479. }
  480. }
  481. /// <summary>
  482. /// 变更型号
  483. /// </summary>
  484. /// <param name="sender"></param>
  485. /// <param name="e"></param>
  486. private void tsbtnChangeGoodsCode_Click(object sender, EventArgs e)
  487. {
  488. try
  489. {
  490. DataTable dt = this.dgvMould.DataSource as DataTable;
  491. if(dt == null || dt.Rows.Count == 0)
  492. {
  493. return;
  494. }
  495. DataRow[] items = dt.Select("Sel = 1 and MouldStatus in (1,2,3)");
  496. if (items == null || items.Length == 0)
  497. {
  498. MessageBox.Show("没有选择任何模具,或所选模具不是【在产,待产】状态",
  499. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  500. MessageBoxDefaultButton.Button1);
  501. return;
  502. }
  503. List<string> ids = new List<string>();
  504. foreach (DataRow item in items)
  505. {
  506. ids.Add(item["MouldID"].ToString());
  507. }
  508. int mouldplan = GetMouldPlan(string.Join(",", ids));
  509. if (Convert.ToInt32(items[0]["MouldStatus"]) != 3 && mouldplan > 0)
  510. {
  511. MessageBox.Show("已报工的模具,不能变更型号!",
  512. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  513. MessageBoxDefaultButton.Button1);
  514. return;
  515. }
  516. F_PC_1004 fpc1004 = new F_PC_1004(string.Join(",", ids), Constant.MouldOperationType.ChangeGoodsCode);
  517. if (fpc1004.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  518. {
  519. this.tsbtnSearch_Click(null, null);
  520. }
  521. }
  522. catch (Exception ex)
  523. {
  524. // 对异常进行共通处理
  525. ExceptionManager.HandleEventException(this.ToString(),
  526. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  527. }
  528. }
  529. /// <summary>
  530. ///
  531. /// </summary>
  532. /// <param name="sender"></param>
  533. /// <param name="e"></param>
  534. private void dgvMould_SelectionChanged(object sender, EventArgs e)
  535. {
  536. try
  537. {
  538. }
  539. catch (Exception ex)
  540. {
  541. // 对异常进行共通处理
  542. ExceptionManager.HandleEventException(this.ToString(),
  543. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  544. }
  545. }
  546. /// <summary>
  547. ///
  548. /// </summary>
  549. /// <param name="sender"></param>
  550. /// <param name="e"></param>
  551. private void dgvMould_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  552. {
  553. if (dgvMould.CurrentCell == null ||
  554. dgvMould.CurrentCell.RowIndex < 0 ||
  555. dgvMould.CurrentCell.ColumnIndex < 0)
  556. {
  557. return;
  558. }
  559. try
  560. {
  561. if (dgvMould.Columns[dgvMould.CurrentCell.ColumnIndex].Name == "Sel")
  562. {
  563. this.dgvMould.CommitEdit(DataGridViewDataErrorContexts.Commit);
  564. this.dgvMould.EndEdit();
  565. DataRowView drv = (this.dgvMould.CurrentRow.DataBoundItem as DataRowView);
  566. if (drv != null)
  567. {
  568. drv.EndEdit();
  569. }
  570. }
  571. }
  572. catch (Exception ex)
  573. {
  574. // 对异常进行共通处理
  575. ExceptionManager.HandleEventException(this.ToString(),
  576. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  577. }
  578. }
  579. /// <summary>
  580. /// 全选
  581. /// </summary>
  582. /// <param name="sender"></param>
  583. /// <param name="e"></param>
  584. private void tsbtnSelectAll_Click(object sender, EventArgs e)
  585. {
  586. try
  587. {
  588. DataTable dt = this.dgvMould.DataSource as DataTable;
  589. if (dt == null || dt.DefaultView.Count == 0)
  590. {
  591. return;
  592. }
  593. foreach (DataRowView item in dt.DefaultView)
  594. {
  595. item["Sel"] = 1;
  596. item.EndEdit();
  597. }
  598. }
  599. catch (Exception ex)
  600. {
  601. // 对异常进行共通处理
  602. ExceptionManager.HandleEventException(this.ToString(),
  603. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  604. }
  605. }
  606. /// <summary>
  607. /// 不选
  608. /// </summary>
  609. /// <param name="sender"></param>
  610. /// <param name="e"></param>
  611. private void tsbtnUnSelect_Click(object sender, EventArgs e)
  612. {
  613. try
  614. {
  615. DataTable dt = this.dgvMould.DataSource as DataTable;
  616. if (dt == null || dt.Rows.Count == 0)
  617. {
  618. return;
  619. }
  620. foreach (DataRow item in dt.Rows)
  621. {
  622. item["Sel"] = 0;
  623. item.EndEdit();
  624. }
  625. }
  626. catch (Exception ex)
  627. {
  628. // 对异常进行共通处理
  629. ExceptionManager.HandleEventException(this.ToString(),
  630. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  631. }
  632. }
  633. /// <summary>
  634. /// 反选
  635. /// </summary>
  636. /// <param name="sender"></param>
  637. /// <param name="e"></param>
  638. private void tsbtnReSelect_Click(object sender, EventArgs e)
  639. {
  640. try
  641. {
  642. DataTable dt = this.dgvMould.DataSource as DataTable;
  643. if (dt == null || dt.DefaultView.Count == 0)
  644. {
  645. return;
  646. }
  647. foreach (DataRowView item in dt.DefaultView)
  648. {
  649. if (Convert.ToInt32(item["Sel"]) == 0)
  650. {
  651. item["Sel"] = 1;
  652. }
  653. else
  654. {
  655. item["Sel"] = 0;
  656. }
  657. item.EndEdit();
  658. }
  659. }
  660. catch (Exception ex)
  661. {
  662. // 对异常进行共通处理
  663. ExceptionManager.HandleEventException(this.ToString(),
  664. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  665. }
  666. }
  667. /// <summary>
  668. /// 撤销报工
  669. /// </summary>
  670. /// <param name="sender"></param>
  671. /// <param name="e"></param>
  672. private void tsbtnUnmouldPlan_Click(object sender, EventArgs e)
  673. {
  674. try
  675. {
  676. DataTable dt = this.dgvMould.DataSource as DataTable;
  677. if (dt == null || dt.Rows.Count == 0)
  678. {
  679. return;
  680. }
  681. DataRow[] item1 = dt.Select("Sel = 1 and plan_code is null ");
  682. if (item1 != null && item1.Length > 0)
  683. {
  684. MessageBox.Show("存在未报工模具",
  685. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  686. MessageBoxDefaultButton.Button1);
  687. return;
  688. }
  689. DataRow[] items = dt.Select("Sel = 1 and plan_code is not null ");
  690. if (items == null || items.Length == 0)
  691. {
  692. MessageBox.Show("没有选择任何模具,或不存在已报工模具",
  693. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  694. MessageBoxDefaultButton.Button1);
  695. return;
  696. }
  697. //模具id
  698. List<string> ids = new List<string>();
  699. foreach (DataRow item in items)
  700. {
  701. ids.Add(item["MouldID"].ToString());
  702. }
  703. F_PC_1004 fpc1004 = new F_PC_1004(string.Join(",", ids), Constant.MouldOperationType.UnMouldPlan);
  704. if (fpc1004.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  705. {
  706. this.tsbtnSearch_Click(null, null);
  707. }
  708. }
  709. catch (Exception ex)
  710. {
  711. // 对异常进行共通处理
  712. ExceptionManager.HandleEventException(this.ToString(),
  713. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  714. }
  715. }
  716. /// <summary>
  717. /// 产品报工
  718. /// </summary>
  719. /// <param name="sender"></param>
  720. /// <param name="e"></param>
  721. private void tsbtnMouldPlan_Click(object sender, EventArgs e)
  722. {
  723. try
  724. {
  725. DataTable dt = this.dgvMould.DataSource as DataTable;
  726. if (dt == null || dt.Rows.Count == 0)
  727. {
  728. return;
  729. }
  730. DataRow[] item1 = dt.Select("Sel = 1 and plan_code is not null ");
  731. if (item1 != null && item1.Length>0 )
  732. {
  733. MessageBox.Show("存在已报工模具",
  734. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  735. MessageBoxDefaultButton.Button1);
  736. return;
  737. }
  738. DataRow[] items = dt.Select("Sel = 1 and plan_code is null ");
  739. if (items == null || items.Length == 0)
  740. {
  741. MessageBox.Show("没有选择任何模具,或不存在未报工模具",
  742. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  743. MessageBoxDefaultButton.Button1);
  744. return;
  745. }
  746. //模具id
  747. List<string> ids = new List<string>();
  748. foreach (DataRow item in items)
  749. {
  750. ids.Add(item["MouldID"].ToString());
  751. }
  752. DataTable GoodsDT = GoodsIdSame(string.Join(",", ids));
  753. if (GoodsDT.Rows.Count > 1)
  754. {
  755. MessageBox.Show("存在不同产品型号的模具!",
  756. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  757. MessageBoxDefaultButton.Button1);
  758. return;
  759. }
  760. F_PC_1004 fpc1004 = new F_PC_1004(string.Join(",", ids), Constant.MouldOperationType.MouldPlan);
  761. if (fpc1004.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  762. {
  763. this.tsbtnSearch_Click(null, null);
  764. }
  765. }
  766. catch (Exception ex)
  767. {
  768. // 对异常进行共通处理
  769. ExceptionManager.HandleEventException(this.ToString(),
  770. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  771. }
  772. }
  773. #endregion
  774. #region 私有方法
  775. /// <summary>
  776. /// 查询数据
  777. /// </summary>
  778. /// <returns>验证通过true,其他false</returns>
  779. private void QueryDataFromOther()
  780. {
  781. try
  782. {
  783. ClientRequestEntity cre = new ClientRequestEntity();
  784. cre.NameSpace = "FPC1001";
  785. cre.Name = "GetFPC1001QueryData";
  786. cre.Properties["MouldBarcode"] = this.txtModelBarcode.Text.Trim();
  787. cre.Properties["UserCode"] = this.txtUserCode.Text.Trim();
  788. cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
  789. cre.Properties["Remarks"] = this.txtRemarks.Text;
  790. cre.Properties["MouldTypes"] = this.ckcMouldType.CheckedValue;
  791. cre.Properties["Suppliers"] = this.ckcSuppliers.CheckedValue;
  792. if (this.chkPDate.Checked)
  793. {
  794. cre.Properties["PDateBegin"] = this.dtpPDateBegin.BeginTime;
  795. cre.Properties["PDateEnd"] = this.dtpPDateEnd.EndTime;
  796. }
  797. if (this.chkScrapDate.Checked)
  798. {
  799. cre.Properties["ScrapDateBegin"] = this.dtpScrapDateBegin.BeginTime;
  800. cre.Properties["ScrapDateEnd"] = this.dtpScrapDateEnd.EndTime;
  801. }
  802. cre.Properties["MouldStatus"] = this.calMouldStatus.CheckedValue;
  803. this.dgvMould.DataSource = null;
  804. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  805. {
  806. return PCModuleProxyNew.Service.HandleRequest(cre);
  807. }
  808. );
  809. if (sre.Status == Constant.ServiceResultStatus.Success)
  810. {
  811. // 查询成功
  812. this.dgvMould.DataSource = sre.Data.Tables[0];
  813. }
  814. }
  815. catch (Exception ex)
  816. {
  817. throw ex;
  818. }
  819. }
  820. /// <summary>
  821. /// 模具是否报工
  822. /// </summary>
  823. /// <returns></returns>
  824. private int GetMouldPlan(string ids)
  825. {
  826. try
  827. {
  828. //模具计划数量
  829. int mouldcount = 0;
  830. ClientRequestEntity cre = new ClientRequestEntity();
  831. cre.NameSpace = "FPC1001";
  832. cre.Name = "GetMouldPlan";
  833. cre.Properties["MouldIDs"] = ids;
  834. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  835. {
  836. return PCModuleProxyNew.Service.HandleRequest(cre);
  837. }
  838. );
  839. if (sre.Status == Constant.ServiceResultStatus.Success)
  840. {
  841. // 查询成功
  842. mouldcount = Convert.ToInt32( sre.Data.Tables[0].Rows[0][0]);
  843. }
  844. return mouldcount;
  845. }
  846. catch (Exception ex)
  847. {
  848. throw ex;
  849. }
  850. }
  851. /// <summary>
  852. /// 产品型号是否相同
  853. /// </summary>
  854. /// <param name="ids"></param>
  855. /// <returns></returns>
  856. private DataTable GoodsIdSame(string ids)
  857. {
  858. try
  859. {
  860. ClientRequestEntity cre = new ClientRequestEntity();
  861. cre.NameSpace = "FPC1001";
  862. cre.Name = "GoodsIdSame";
  863. cre.Properties["MouldIDs"] = ids;
  864. DataTable result = new DataTable();
  865. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  866. {
  867. return PCModuleProxyNew.Service.HandleRequest(cre);
  868. }
  869. );
  870. if (sre.Status == Constant.ServiceResultStatus.Success)
  871. {
  872. // 查询成功
  873. result = sre.Data.Tables[0];
  874. }
  875. return result;
  876. }
  877. catch (Exception ex)
  878. {
  879. throw ex;
  880. }
  881. }
  882. #endregion
  883. }
  884. }