F_PM_3601.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_3601.cs
  5. * 2.功能描述:首件登记
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 秦祺 2024/9/11 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.WCF.DataModels;
  14. using Dongke.IBOSS.PRD.WCF.Proxys;
  15. using System;
  16. using System.Data;
  17. using System.Drawing;
  18. using System.IO;
  19. using System.Windows.Forms;
  20. namespace Dongke.IBOSS.PRD.Client.PMModule
  21. {
  22. public partial class F_PM_3601 : DKDockPanelBase
  23. {
  24. #region 成员变量
  25. // 窗体的单例模式
  26. private static F_PM_3601 _instance;
  27. private int _registerID = 0;
  28. #endregion
  29. #region 构造函数
  30. public F_PM_3601()
  31. {
  32. InitializeComponent();
  33. // 窗体显示的Title
  34. this.Text = "首件登记";
  35. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  36. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  37. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  38. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  39. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  40. }
  41. #endregion
  42. #region 单例模式
  43. /// <summary>
  44. /// 单例模式,防止重复创建窗体
  45. /// </summary>
  46. public static F_PM_3601 Instance
  47. {
  48. get
  49. {
  50. if (_instance == null || _instance.IsDisposed)
  51. {
  52. _instance = new F_PM_3601();
  53. }
  54. return _instance;
  55. }
  56. }
  57. #endregion
  58. #region 事件处理
  59. /// <summary>
  60. /// 窗体加载事件
  61. /// </summary>
  62. /// <param name="sender"></param>
  63. /// <param name="e"></param>
  64. private void F_PM_3601_Load(object sender, EventArgs e)
  65. {
  66. try
  67. {
  68. //时间控件
  69. this.dtpCreatetimebegin.Value = DateTime.Now.Date;
  70. this.dtpCreatetimeend.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  71. //不自动添加列
  72. dgvRegister.AutoGenerateColumns = false;
  73. dgvBarcode.AutoGenerateColumns = false;
  74. dgvRegisterDetail.AutoGenerateColumns = false;
  75. #region 车间
  76. DataTable dtWorkShop = new DataTable();
  77. dtWorkShop.Columns.Add("WorkShopID");
  78. dtWorkShop.Columns.Add("WorkShopNames");
  79. DataRow drWorkShop = dtWorkShop.NewRow();
  80. drWorkShop["WorkShopID"] = DBNull.Value;
  81. drWorkShop["WorkShopNames"] = Constant.CBO_SELECT_EMPTY_NAME;
  82. dtWorkShop.Rows.Add(drWorkShop);
  83. drWorkShop = dtWorkShop.NewRow();
  84. drWorkShop["WorkShopID"] = 1;
  85. drWorkShop["WorkShopNames"] = "1";
  86. dtWorkShop.Rows.Add(drWorkShop);
  87. drWorkShop = dtWorkShop.NewRow();
  88. drWorkShop["WorkShopID"] = 2;
  89. drWorkShop["WorkShopNames"] = "2";
  90. dtWorkShop.Rows.Add(drWorkShop);
  91. drWorkShop = dtWorkShop.NewRow();
  92. drWorkShop["WorkShopID"] = 3;
  93. drWorkShop["WorkShopNames"] = "3";
  94. dtWorkShop.Rows.Add(drWorkShop);
  95. cmbWORKSHOP.DisplayMember = "WorkShopID";
  96. cmbWORKSHOP.ValueMember = "WorkShopNames";
  97. cmbWORKSHOP.DataSource = dtWorkShop;
  98. #endregion
  99. #region 状态
  100. DataTable dtStatus = new DataTable();
  101. dtStatus.Columns.Add("Status");
  102. dtStatus.Columns.Add("StatusName");
  103. DataRow drStatus = dtStatus.NewRow();
  104. drStatus["Status"] = DBNull.Value;
  105. drStatus["StatusName"] = Constant.CBO_SELECT_EMPTY_NAME;
  106. dtStatus.Rows.Add(drStatus);
  107. drStatus = dtStatus.NewRow();
  108. drStatus["Status"] = 0;
  109. drStatus["StatusName"] = "未登记";
  110. dtStatus.Rows.Add(drStatus);
  111. drStatus = dtStatus.NewRow();
  112. drStatus["Status"] = 1;
  113. drStatus["StatusName"] = "检测中";
  114. dtStatus.Rows.Add(drStatus);
  115. drStatus = dtStatus.NewRow();
  116. drStatus["Status"] = 2;
  117. drStatus["StatusName"] = "待研发部检验";
  118. dtStatus.Rows.Add(drStatus);
  119. drStatus = dtStatus.NewRow();
  120. drStatus["Status"] = 3;
  121. drStatus["StatusName"] = "待签名";
  122. dtStatus.Rows.Add(drStatus);
  123. drStatus = dtStatus.NewRow();
  124. drStatus["Status"] = 4;
  125. drStatus["StatusName"] = "已完结";
  126. dtStatus.Rows.Add(drStatus);
  127. cmbStuts.DisplayMember = "StatusName";
  128. cmbStuts.ValueMember = "Status";
  129. cmbStuts.DataSource = dtStatus;
  130. #endregion
  131. #region 首件检验产品类型
  132. // 获取产品类型
  133. ServiceResultEntity sreType = DoAsync<ServiceResultEntity>(() =>
  134. {
  135. return ReportModuleProxy.Service.GetRptDictionaryData(0, "TPC025");
  136. }
  137. );
  138. if (sreType.Data == null)
  139. {
  140. return;
  141. }
  142. if (sreType.Data != null && sreType.Data.Tables[0].Rows.Count > 0)
  143. {
  144. // 设置空选项
  145. DataRow dataRow = sreType.Data.Tables[0].NewRow();
  146. dataRow["DictionaryID"] = DBNull.Value;
  147. dataRow["DictionaryValue"] = Constant.CBO_SELECT_EMPTY_NAME;
  148. dataRow["DisplayNo"] = 0;
  149. sreType.Data.Tables[0].Rows.InsertAt(dataRow, 0);
  150. this.cmbFIRGOODSTYPE.DisplayMember = "DictionaryValue";
  151. this.cmbFIRGOODSTYPE.ValueMember = "DictionaryID";
  152. this.cmbFIRGOODSTYPE.DataSource = sreType.Data.Tables[0];
  153. }
  154. #endregion
  155. #region 首件检验检验依据
  156. // 获取检验依据
  157. ServiceResultEntity sreType1 = DoAsync<ServiceResultEntity>(() =>
  158. {
  159. return ReportModuleProxy.Service.GetRptDictionaryData(0, "TPC026");
  160. }
  161. );
  162. if (sreType1.Data == null)
  163. {
  164. return;
  165. }
  166. if (sreType1.Data != null && sreType1.Data.Tables[0].Rows.Count > 0)
  167. {
  168. // 设置空选项
  169. DataRow dataRow = sreType1.Data.Tables[0].NewRow();
  170. dataRow["DictionaryID"] = DBNull.Value;
  171. dataRow["DictionaryValue"] = Constant.CBO_SELECT_EMPTY_NAME;
  172. dataRow["DisplayNo"] = 0;
  173. sreType1.Data.Tables[0].Rows.InsertAt(dataRow, 0);
  174. this.cmbFIRBASIS.DisplayMember = "DictionaryValue";
  175. this.cmbFIRBASIS.ValueMember = "DictionaryID";
  176. this.cmbFIRBASIS.DataSource = sreType1.Data.Tables[0];
  177. }
  178. #endregion
  179. }
  180. catch (Exception ex)
  181. {
  182. // 对异常进行共通处理
  183. ExceptionManager.HandleEventException(this.ToString(),
  184. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  185. }
  186. }
  187. /// <summary>
  188. /// 窗体关闭事件
  189. /// </summary>
  190. /// <param name="sender"></param>
  191. /// <param name="e"></param>
  192. private void F_PM_3601_FormClosed(object sender, FormClosedEventArgs e)
  193. {
  194. _instance = null;
  195. }
  196. /// <summary>
  197. /// 关闭按钮
  198. /// </summary>
  199. /// <param name="sender"></param>
  200. /// <param name="e"></param>
  201. private void tsbtnClose_Click(object sender, EventArgs e)
  202. {
  203. this.Close();
  204. }
  205. /// <summary>
  206. /// 查询按钮事件
  207. /// </summary>
  208. /// <param name="sender"></param>
  209. /// <param name="e"></param>
  210. private void btnSearch_Click(object sender, EventArgs e)
  211. {
  212. try
  213. {
  214. #region 总单
  215. this.btnSearch.Focus();
  216. //数据清空
  217. this.dgvRegister.DataSource = null;
  218. this.dgvRegisterDetail.DataSource = null;
  219. this.dgvBarcode.DataSource = null;
  220. _registerID = 0;
  221. //图片清空
  222. this.pictureBox1.Image = Properties.Resources.bg;
  223. this.pictureBox2.Image = Properties.Resources.bg;
  224. this.pictureBox3.Image = Properties.Resources.bg;
  225. this.pictureBox4.Image = Properties.Resources.bg;
  226. this.pictureBox5.Image = Properties.Resources.bg;
  227. this.pictureBox6.Image = Properties.Resources.bg;
  228. ClientRequestEntity cre = new ClientRequestEntity();
  229. cre.NameSpace = "F_PM_3601";
  230. cre.Name = "GetRegisterData";
  231. cre.Properties["REGISTERNO"] = this.txtRegisterNo.Text;
  232. if (string.IsNullOrWhiteSpace(this.cmbWORKSHOP.Text))
  233. {
  234. cre.Properties["WORKSHOP"] = "";
  235. }
  236. else
  237. {
  238. cre.Properties["WORKSHOP"] = Convert.ToInt32(this.cmbWORKSHOP.SelectedValue);
  239. }
  240. if (string.IsNullOrWhiteSpace(this.cmbFIRGOODSTYPE.Text))
  241. {
  242. cre.Properties["FIRGOODSTYPE"] = "";
  243. }
  244. else
  245. {
  246. cre.Properties["FIRGOODSTYPE"] = Convert.ToInt32(this.cmbFIRGOODSTYPE.SelectedValue);
  247. }
  248. if (string.IsNullOrWhiteSpace(this.cmbFIRBASIS.Text))
  249. {
  250. cre.Properties["FIRBASIS"] = "";
  251. }
  252. else
  253. {
  254. cre.Properties["FIRBASIS"] = Convert.ToInt32(this.cmbFIRBASIS.SelectedValue);
  255. }
  256. if (string.IsNullOrWhiteSpace(this.cmbStuts.Text))
  257. {
  258. cre.Properties["STATUS"] = "";
  259. }
  260. else
  261. {
  262. cre.Properties["STATUS"] = Convert.ToInt32(this.cmbStuts.SelectedValue);
  263. }
  264. cre.Properties["GOODSCODE"] = this.txtGoodsCode.Text;
  265. cre.Properties["CREATETIMEBEGIN"] = this.dtpCreatetimebegin.Value;
  266. cre.Properties["CREATETIMEEND"] = this.dtpCreatetimeend.Value;
  267. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  268. {
  269. return PMModuleProxyNew.Service.HandleRequest(cre);
  270. });
  271. if (sre.Status == Constant.ServiceResultStatus.Success)
  272. {
  273. if (sre.Data.Tables[0] != null && sre.Data.Tables[0].Rows.Count > 0)
  274. {
  275. dgvRegister.DataSource = sre.Data.Tables[0];
  276. this.dgvRegister.Rows[0].Selected = true;
  277. }
  278. else
  279. {
  280. // 提示未查找到数据
  281. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  282. MessageBoxButtons.OK, MessageBoxIcon.Information);
  283. DataTable dt = new DataTable();
  284. DataTable dtd = new DataTable();
  285. if (dgvRegister.DataSource != null)
  286. {
  287. dt = ((DataTable)dgvRegister.DataSource).Clone();
  288. }
  289. dgvRegister.DataSource = dt;
  290. if (dgvRegisterDetail.DataSource != null)
  291. {
  292. dtd = ((DataTable)dgvRegisterDetail.DataSource).Clone();
  293. }
  294. dgvRegisterDetail.DataSource = dtd;
  295. //图片清空
  296. this.pictureBox1.Image = Properties.Resources.bg;
  297. this.pictureBox2.Image = Properties.Resources.bg;
  298. this.pictureBox3.Image = Properties.Resources.bg;
  299. this.pictureBox4.Image = Properties.Resources.bg;
  300. this.pictureBox5.Image = Properties.Resources.bg;
  301. this.pictureBox6.Image = Properties.Resources.bg;
  302. return;
  303. }
  304. }
  305. #endregion
  306. #region 明细
  307. //dgvRegister_SelectionChanged(null, null);
  308. #endregion
  309. }
  310. catch (Exception ex)
  311. {
  312. this.btnSearch.Enabled = true;
  313. this.btnClearCondition.Enabled = true;
  314. // 对异常进行共通处理
  315. ExceptionManager.HandleEventException(this.ToString(),
  316. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  317. }
  318. }
  319. /// <summary>
  320. /// 总单选择事件
  321. /// </summary>
  322. /// <param name="sender"></param>
  323. /// <param name="e"></param>
  324. private void dgvRegister_SelectionChanged(object sender, EventArgs e)
  325. {
  326. try
  327. {
  328. if (this.dgvRegister.CurrentRow != null)
  329. {
  330. int registerID = Convert.ToInt32(this.dgvRegister.CurrentRow.Cells["REGISTERID"].Value.ToString());
  331. if (_registerID != registerID)
  332. {
  333. ClientRequestEntity cre = new ClientRequestEntity();
  334. cre.NameSpace = "F_PM_3601";
  335. cre.Name = "GetRegisterDetail";
  336. cre.Properties["REGISTERID"] = registerID;
  337. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  338. {
  339. return PMModuleProxyNew.Service.HandleRequest(cre);
  340. });
  341. if (sre.Status == Constant.ServiceResultStatus.Success)
  342. {
  343. if (sre.Data.Tables[0] != null && sre.Data.Tables[0].Rows.Count > 0)
  344. {
  345. dgvBarcode.DataSource = sre.Data.Tables[0];
  346. this.dgvBarcode.Rows[0].Selected = true;
  347. }
  348. else
  349. {
  350. //清空
  351. if (dgvBarcode.DataSource != null)
  352. {
  353. dgvBarcode.DataSource = ((DataTable)dgvBarcode.DataSource).Clone();
  354. }
  355. else
  356. {
  357. dgvBarcode.DataSource = null;
  358. }
  359. }
  360. if (sre.Data.Tables.Count > 1 && sre.Data.Tables[1] != null && sre.Data.Tables[1].Rows.Count > 0)
  361. {
  362. DataTable imageTable = sre.Data.Tables[1];
  363. //加载品管签名
  364. if (!string.IsNullOrEmpty(imageTable.Rows[0]["PGSIGNATURE"].ToString()))
  365. {
  366. // 读取二进制数据
  367. byte[] binaryDataPG = (byte[])(imageTable.Rows[0]["PGSIGNATURE"]);
  368. // 解码为图像对象
  369. try
  370. {
  371. using (MemoryStream stream = new MemoryStream(binaryDataPG))
  372. {
  373. if (pictureBox1.Image != null)
  374. {
  375. // 其他操作
  376. // 显示图像在PictureBox中
  377. pictureBox1.Image = Image.FromStream(stream);
  378. }
  379. }
  380. }
  381. catch (ArgumentException ex)
  382. {
  383. // 处理异常,例如记录日志或显示用户友好的错误消息
  384. MessageBox.Show("品管签名加载失败: " + ex.Message);
  385. }
  386. }
  387. else
  388. {
  389. //图片清空
  390. this.pictureBox1.Image = Properties.Resources.bg;
  391. }
  392. //加载成检签名
  393. if (!string.IsNullOrEmpty(imageTable.Rows[0]["CJSIGNATURE"].ToString()))
  394. {
  395. // 读取二进制数据
  396. byte[] binaryDataCJ = (byte[])(imageTable.Rows[0]["CJSIGNATURE"]);
  397. // 解码为图像对象
  398. try
  399. {
  400. using (MemoryStream stream1 = new MemoryStream(binaryDataCJ))
  401. {
  402. if (pictureBox2.Image != null)
  403. {
  404. // 其他操作
  405. // 显示图像在PictureBox中
  406. pictureBox2.Image = Image.FromStream(stream1);
  407. }
  408. }
  409. }
  410. catch (ArgumentException ex)
  411. {
  412. // 处理异常,例如记录日志或显示用户友好的错误消息
  413. MessageBox.Show("成检签名加载失败: " + ex.Message);
  414. }
  415. }
  416. else
  417. {
  418. //图片清空
  419. this.pictureBox2.Image = Properties.Resources.bg;
  420. }
  421. //加载生控签名
  422. if (!string.IsNullOrEmpty(imageTable.Rows[0]["SKSIGNATURE"].ToString()))
  423. {
  424. // 读取二进制数据
  425. byte[] binaryDataSK = (byte[])(imageTable.Rows[0]["SKSIGNATURE"]);
  426. // 解码为图像对象
  427. try
  428. {
  429. using (MemoryStream stream2 = new MemoryStream(binaryDataSK))
  430. {
  431. if (pictureBox3.Image != null)
  432. {
  433. // 其他操作
  434. // 显示图像在PictureBox中
  435. pictureBox3.Image = Image.FromStream(stream2);
  436. }
  437. }
  438. }
  439. catch (ArgumentException ex)
  440. {
  441. // 处理异常,例如记录日志或显示用户友好的错误消息
  442. MessageBox.Show("生控签名加载失败: " + ex.Message);
  443. }
  444. }
  445. else
  446. {
  447. //图片清空
  448. this.pictureBox3.Image = Properties.Resources.bg;
  449. }
  450. //加载研发签名
  451. if (!string.IsNullOrEmpty(imageTable.Rows[0]["YFSIGNATURE"].ToString()))
  452. {
  453. // 读取二进制数据
  454. byte[] binaryDataYF = (byte[])(imageTable.Rows[0]["YFSIGNATURE"]);
  455. // 解码为图像对象
  456. try
  457. {
  458. using (MemoryStream stream1 = new MemoryStream(binaryDataYF))
  459. {
  460. if (pictureBox4.Image != null)
  461. {
  462. // 其他操作
  463. // 显示图像在PictureBox中
  464. pictureBox4.Image = Image.FromStream(stream1);
  465. }
  466. }
  467. }
  468. catch (ArgumentException ex)
  469. {
  470. // 处理异常,例如记录日志或显示用户友好的错误消息
  471. MessageBox.Show("研发签名加载失败: " + ex.Message);
  472. }
  473. }
  474. else
  475. {
  476. //图片清空
  477. this.pictureBox4.Image = Properties.Resources.bg;
  478. }
  479. //加载工艺签名
  480. if (!string.IsNullOrEmpty(imageTable.Rows[0]["GYSIGNATURE"].ToString()))
  481. {
  482. // 读取二进制数据
  483. byte[] binaryDataGY = (byte[])(imageTable.Rows[0]["GYSIGNATURE"]);
  484. // 解码为图像对象
  485. try
  486. {
  487. using (MemoryStream stream1 = new MemoryStream(binaryDataGY))
  488. {
  489. if (pictureBox5.Image != null)
  490. {
  491. // 其他操作
  492. // 显示图像在PictureBox中
  493. pictureBox5.Image = Image.FromStream(stream1);
  494. }
  495. }
  496. }
  497. catch (ArgumentException ex)
  498. {
  499. // 处理异常,例如记录日志或显示用户友好的错误消息
  500. MessageBox.Show("工艺签名加载失败: " + ex.Message);
  501. }
  502. }
  503. else
  504. {
  505. //图片清空
  506. this.pictureBox5.Image = Properties.Resources.bg;
  507. }
  508. //加载项目组签名
  509. if (!string.IsNullOrEmpty(imageTable.Rows[0]["XMZSIGNATURE"].ToString()))
  510. {
  511. // 读取二进制数据
  512. byte[] binaryDataXMZ = (byte[])(imageTable.Rows[0]["XMZSIGNATURE"]);
  513. // 解码为图像对象
  514. try
  515. {
  516. using (MemoryStream stream1 = new MemoryStream(binaryDataXMZ))
  517. {
  518. if (pictureBox6.Image != null)
  519. {
  520. // 其他操作
  521. // 显示图像在PictureBox中
  522. pictureBox6.Image = Image.FromStream(stream1);
  523. }
  524. }
  525. }
  526. catch (ArgumentException ex)
  527. {
  528. // 处理异常,例如记录日志或显示用户友好的错误消息
  529. MessageBox.Show("项目组签名加载失败: " + ex.Message);
  530. }
  531. }
  532. else
  533. {
  534. //图片清空
  535. this.pictureBox6.Image = Properties.Resources.bg;
  536. }
  537. }
  538. }
  539. }
  540. _registerID = registerID;
  541. }
  542. }
  543. catch (Exception ex)
  544. {
  545. this.btnSearch.Enabled = true;
  546. this.btnClearCondition.Enabled = true;
  547. // 对异常进行共通处理
  548. ExceptionManager.HandleEventException(this.ToString(),
  549. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  550. }
  551. }
  552. /// <summary>
  553. /// 清空条件按钮事件
  554. /// </summary>
  555. /// <param name="sender"></param>
  556. /// <param name="e"></param>
  557. private void btnClearCondition_Click(object sender, EventArgs e)
  558. {
  559. try
  560. {
  561. this.txtGoodsCode.Text = "";
  562. this.txtRegisterNo.Text = "";
  563. this.cmbFIRBASIS.SelectedIndex = Constant.INT_IS_ZERO;
  564. this.cmbFIRGOODSTYPE.SelectedIndex = Constant.INT_IS_ZERO;
  565. this.cmbWORKSHOP.SelectedIndex = Constant.INT_IS_ZERO;
  566. }
  567. catch (Exception ex)
  568. {
  569. this.btnSearch.Enabled = true;
  570. this.btnClearCondition.Enabled = true;
  571. // 对异常进行共通处理
  572. ExceptionManager.HandleEventException(this.ToString(),
  573. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  574. }
  575. }
  576. /// <summary>
  577. /// 自动适应列宽
  578. /// </summary>
  579. /// <param name="sender"></param>
  580. /// <param name="e"></param>
  581. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  582. {
  583. try
  584. {
  585. this.dgvRegister.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  586. this.dgvBarcode.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  587. this.dgvRegisterDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  588. }
  589. catch (Exception ex)
  590. {
  591. this.btnSearch.Enabled = true;
  592. this.btnClearCondition.Enabled = true;
  593. // 对异常进行共通处理
  594. ExceptionManager.HandleEventException(this.ToString(),
  595. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  596. }
  597. }
  598. /// <summary>
  599. /// 新建
  600. /// </summary>
  601. /// <param name="sender"></param>
  602. /// <param name="e"></param>
  603. private void btnFirAdd_Click(object sender, EventArgs e)
  604. {
  605. try
  606. {
  607. F_PM_3602 firEdit = new F_PM_3602(Constant.FormMode.Add, 0);
  608. firEdit.ShowDialog();
  609. }
  610. catch (Exception ex)
  611. {
  612. this.btnSearch.Enabled = true;
  613. this.btnClearCondition.Enabled = true;
  614. // 对异常进行共通处理
  615. ExceptionManager.HandleEventException(this.ToString(),
  616. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  617. }
  618. }
  619. /// <summary>
  620. /// 编辑
  621. /// </summary>
  622. /// <param name="sender"></param>
  623. /// <param name="e"></param>
  624. private void btnFirEdit_Click(object sender, EventArgs e)
  625. {
  626. try
  627. {
  628. DataGridViewRow currentRow = this.dgvRegister.CurrentRow;
  629. if (currentRow != null)
  630. // 获取相应节点数据
  631. {
  632. int status = Convert.ToInt32(currentRow.Cells["STATUSID"].Value);
  633. //判断状态(0:未登记(可编辑总单,没有明细)
  634. //1:部分检测中(不可编辑总单,点击条码)
  635. //2:待研发部检验(不可编辑总单,点击条码)
  636. //3:待签名(不可编辑)
  637. //4:已完结(不可编辑))
  638. if (status == 0)
  639. {
  640. F_PM_3602 frmPM3602 = new F_PM_3602(Constant.FormMode.Edit, Convert.ToInt32(currentRow.Cells["REGISTERID"].Value));
  641. DialogResult dialogresult = frmPM3602.ShowDialog();
  642. if (dialogresult.Equals(DialogResult.OK))
  643. {
  644. // 刷新窗口数据
  645. btnSearch_Click(sender, e);
  646. }
  647. }
  648. else if(status == 1 || status == 2)
  649. {
  650. if (this.dgvBarcode.CurrentRow == null)
  651. {
  652. MessageBox.Show("当前登记单状态不允许编辑总单,选择条码后可编辑检验结果!",
  653. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  654. return;
  655. }
  656. DataGridViewRow barRow = this.dgvBarcode.CurrentRow;
  657. int registerid = Convert.ToInt32(currentRow.Cells["REGISTERID"].Value);
  658. int barid = Convert.ToInt32(barRow.Cells["BARID"].Value);
  659. F_PM_3602 frmPM3602 = new F_PM_3602(Constant.FormMode.Edit, registerid, barid);
  660. DialogResult dialogresult = frmPM3602.ShowDialog();
  661. if (dialogresult.Equals(DialogResult.OK))
  662. {
  663. // 刷新窗口数据
  664. btnSearch_Click(sender, e);
  665. }
  666. }
  667. else if(status == 3 || status == 4)
  668. {
  669. MessageBox.Show("当前登记单状态不允许编辑",
  670. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  671. return;
  672. }
  673. }
  674. }
  675. catch (Exception ex)
  676. {
  677. this.btnSearch.Enabled = true;
  678. this.btnClearCondition.Enabled = true;
  679. // 对异常进行共通处理
  680. ExceptionManager.HandleEventException(this.ToString(),
  681. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  682. }
  683. }
  684. /// <summary>
  685. /// 条码选中查询明细
  686. /// </summary>
  687. /// <param name="sender"></param>
  688. /// <param name="e"></param>
  689. private void dgvBarcode_SelectionChanged(object sender, EventArgs e)
  690. {
  691. try
  692. {
  693. if (this.dgvRegister.CurrentRow != null && this.dgvBarcode.CurrentRow != null)
  694. {
  695. int registerID = Convert.ToInt32(this.dgvRegister.CurrentRow.Cells["REGISTERID"].Value.ToString());
  696. int barID = Convert.ToInt32(this.dgvBarcode.CurrentRow.Cells["BARID"].Value.ToString());
  697. ClientRequestEntity cre = new ClientRequestEntity();
  698. cre.NameSpace = "F_PM_3601";
  699. cre.Name = "GetItemDetail";
  700. cre.Properties["REGISTERID"] = registerID;
  701. cre.Properties["BARID"] = barID;
  702. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  703. {
  704. return PMModuleProxyNew.Service.HandleRequest(cre);
  705. });
  706. if (sre.Status == Constant.ServiceResultStatus.Success)
  707. {
  708. if (sre.Data.Tables[0] != null && sre.Data.Tables[0].Rows.Count > 0)
  709. {
  710. dgvRegisterDetail.DataSource = sre.Data.Tables[0];
  711. this.dgvRegisterDetail.Rows[0].Selected = true;
  712. this.dgvRegisterDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  713. }
  714. else
  715. {
  716. if (dgvRegisterDetail.DataSource != null )
  717. {
  718. dgvRegisterDetail.DataSource = ((DataTable)dgvRegisterDetail.DataSource).Clone();
  719. }
  720. else
  721. {
  722. dgvRegisterDetail.DataSource = null;
  723. }
  724. }
  725. }
  726. }
  727. }
  728. catch (Exception ex)
  729. {
  730. this.btnSearch.Enabled = true;
  731. this.btnClearCondition.Enabled = true;
  732. // 对异常进行共通处理
  733. ExceptionManager.HandleEventException(this.ToString(),
  734. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  735. }
  736. }
  737. /// <summary>
  738. /// 删除
  739. /// </summary>
  740. /// <param name="sender"></param>
  741. /// <param name="e"></param>
  742. /// <remarks>李士越</remarks>
  743. private void del_button_Click(object sender, EventArgs e)
  744. {
  745. try
  746. {
  747. int statusid = Convert.ToInt32(this.dgvRegister.CurrentRow.Cells["STATUSID"].Value.ToString());
  748. if (statusid != 0)
  749. {
  750. MessageBox.Show("当前登记单状态不允许删除",
  751. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  752. return;
  753. }
  754. int registerid = Convert.ToInt32(this.dgvRegister.CurrentRow.Cells["REGISTERID"].Value.ToString());
  755. ClientRequestEntity cre = new ClientRequestEntity();
  756. cre.NameSpace = "F_PM_3601";
  757. cre.Name = "DelInfo";
  758. cre.Properties["REGISTERID"] = registerid;
  759. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  760. {
  761. return PMModuleProxyNew.Service.HandleRequest(cre);
  762. });
  763. if (sre.Status == Constant.ServiceResultStatus.Success)
  764. {
  765. MessageBox.Show("当前登记单状态删除成功",
  766. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
  767. }
  768. // 刷新窗口数据
  769. btnSearch_Click(sender, e);
  770. }
  771. catch (Exception ex)
  772. {
  773. this.btnSearch.Enabled = true;
  774. this.btnClearCondition.Enabled = true;
  775. // 对异常进行共通处理
  776. ExceptionManager.HandleEventException(this.ToString(),
  777. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  778. }
  779. }
  780. /// <summary>
  781. /// 查看型式检验
  782. /// </summary>
  783. /// <param name="sender"></param>
  784. /// <param name="e"></param>
  785. /// <remarks>李士越</remarks>
  786. private void ShowTest_Click(object sender, EventArgs e)
  787. {
  788. try
  789. {
  790. //获取选中的BARCODE
  791. if (this.dgvRegister.CurrentRow != null && this.dgvBarcode.CurrentRow != null)
  792. {
  793. string barID = this.dgvBarcode.CurrentRow.Cells["BARCODE"].Value.ToString();
  794. //查找型式检验数据
  795. ClientRequestEntity cre = new ClientRequestEntity();
  796. cre.NameSpace = "F_PM_3601";
  797. cre.Name = "ShowTest";
  798. cre.Properties["barCode"] = barID;
  799. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() => PMModuleProxyNew.Service.HandleRequest(cre));
  800. //无数据
  801. if (sre.Data.Tables[0].Rows.Count == 0)
  802. {
  803. // 提示信息
  804. MessageBox.Show("未查询到数据",
  805. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  806. return;
  807. }
  808. //构造查看形式检验结果页面
  809. F_PM_3603 firEdit = new F_PM_3603(Constant.FormMode.Display, sre.Data.Tables[0]);
  810. firEdit.ShowDialog();
  811. }
  812. //没选中 提示选择条码
  813. else
  814. {
  815. MessageBox.Show("请选择条码",
  816. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  817. }
  818. }
  819. catch (Exception ex)
  820. {
  821. this.btnSearch.Enabled = true;
  822. this.btnClearCondition.Enabled = true;
  823. // 对异常进行共通处理
  824. ExceptionManager.HandleEventException(this.ToString(),
  825. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  826. }
  827. }
  828. #endregion
  829. #region 私有方法
  830. #endregion
  831. }
  832. }