F_PM_3601.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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. ClientRequestEntity cre = new ClientRequestEntity();
  226. cre.NameSpace = "F_PM_3601";
  227. cre.Name = "GetRegisterData";
  228. cre.Properties["REGISTERNO"] = this.txtRegisterNo.Text;
  229. if (string.IsNullOrWhiteSpace(this.cmbWORKSHOP.Text))
  230. {
  231. cre.Properties["WORKSHOP"] = "";
  232. }
  233. else
  234. {
  235. cre.Properties["WORKSHOP"] = Convert.ToInt32(this.cmbWORKSHOP.SelectedValue);
  236. }
  237. if (string.IsNullOrWhiteSpace(this.cmbFIRGOODSTYPE.Text))
  238. {
  239. cre.Properties["FIRGOODSTYPE"] = "";
  240. }
  241. else
  242. {
  243. cre.Properties["FIRGOODSTYPE"] = Convert.ToInt32(this.cmbFIRGOODSTYPE.SelectedValue);
  244. }
  245. if (string.IsNullOrWhiteSpace(this.cmbFIRBASIS.Text))
  246. {
  247. cre.Properties["FIRBASIS"] = "";
  248. }
  249. else
  250. {
  251. cre.Properties["FIRBASIS"] = Convert.ToInt32(this.cmbFIRBASIS.SelectedValue);
  252. }
  253. if (string.IsNullOrWhiteSpace(this.cmbStuts.Text))
  254. {
  255. cre.Properties["STATUS"] = "";
  256. }
  257. else
  258. {
  259. cre.Properties["STATUS"] = Convert.ToInt32(this.cmbStuts.SelectedValue);
  260. }
  261. cre.Properties["GOODSCODE"] = this.txtGoodsCode.Text;
  262. cre.Properties["CREATETIMEBEGIN"] = this.dtpCreatetimebegin.Value;
  263. cre.Properties["CREATETIMEEND"] = this.dtpCreatetimeend.Value;
  264. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  265. {
  266. return PMModuleProxyNew.Service.HandleRequest(cre);
  267. });
  268. if (sre.Status == Constant.ServiceResultStatus.Success)
  269. {
  270. if (sre.Data.Tables[0] != null && sre.Data.Tables[0].Rows.Count > 0)
  271. {
  272. dgvRegister.DataSource = sre.Data.Tables[0];
  273. this.dgvRegister.Rows[0].Selected = true;
  274. }
  275. else
  276. {
  277. // 提示未查找到数据
  278. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  279. MessageBoxButtons.OK, MessageBoxIcon.Information);
  280. DataTable dt = new DataTable();
  281. DataTable dtd = new DataTable();
  282. if (dgvRegister.DataSource != null)
  283. {
  284. dt = ((DataTable)dgvRegister.DataSource).Clone();
  285. }
  286. dgvRegister.DataSource = dt;
  287. if (dgvRegisterDetail.DataSource != null)
  288. {
  289. dtd = ((DataTable)dgvRegisterDetail.DataSource).Clone();
  290. }
  291. dgvRegisterDetail.DataSource = dtd;
  292. //图片清空
  293. this.pictureBox1.Image = Properties.Resources.bg;
  294. this.pictureBox2.Image = Properties.Resources.bg;
  295. this.pictureBox3.Image = Properties.Resources.bg;
  296. return;
  297. }
  298. }
  299. #endregion
  300. #region 明细
  301. //dgvRegister_SelectionChanged(null, null);
  302. #endregion
  303. }
  304. catch (Exception ex)
  305. {
  306. this.btnSearch.Enabled = true;
  307. this.btnClearCondition.Enabled = true;
  308. // 对异常进行共通处理
  309. ExceptionManager.HandleEventException(this.ToString(),
  310. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  311. }
  312. }
  313. /// <summary>
  314. /// 总单选择事件
  315. /// </summary>
  316. /// <param name="sender"></param>
  317. /// <param name="e"></param>
  318. private void dgvRegister_SelectionChanged(object sender, EventArgs e)
  319. {
  320. try
  321. {
  322. if (this.dgvRegister.CurrentRow != null)
  323. {
  324. int registerID = Convert.ToInt32(this.dgvRegister.CurrentRow.Cells["REGISTERID"].Value.ToString());
  325. if (_registerID != registerID)
  326. {
  327. ClientRequestEntity cre = new ClientRequestEntity();
  328. cre.NameSpace = "F_PM_3601";
  329. cre.Name = "GetRegisterDetail";
  330. cre.Properties["REGISTERID"] = registerID;
  331. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  332. {
  333. return PMModuleProxyNew.Service.HandleRequest(cre);
  334. });
  335. if (sre.Status == Constant.ServiceResultStatus.Success)
  336. {
  337. if (sre.Data.Tables[0] != null && sre.Data.Tables[0].Rows.Count > 0)
  338. {
  339. dgvBarcode.DataSource = sre.Data.Tables[0];
  340. this.dgvBarcode.Rows[0].Selected = true;
  341. }
  342. else
  343. {
  344. //清空
  345. if (dgvBarcode.DataSource != null)
  346. {
  347. dgvBarcode.DataSource = ((DataTable)dgvBarcode.DataSource).Clone();
  348. }
  349. else
  350. {
  351. dgvBarcode.DataSource = null;
  352. }
  353. }
  354. if (sre.Data.Tables.Count > 1 && sre.Data.Tables[1] != null && sre.Data.Tables[1].Rows.Count > 0)
  355. {
  356. DataTable imageTable = sre.Data.Tables[1];
  357. //加载品管签名
  358. if (!string.IsNullOrEmpty(imageTable.Rows[0]["PGSIGNATURE"].ToString()))
  359. {
  360. // 读取二进制数据
  361. byte[] binaryDataPG = (byte[])(imageTable.Rows[0]["PGSIGNATURE"]);
  362. // 解码为图像对象
  363. try
  364. {
  365. using (MemoryStream stream = new MemoryStream(binaryDataPG))
  366. {
  367. if (pictureBox1.Image != null)
  368. {
  369. // 其他操作
  370. // 显示图像在PictureBox中
  371. pictureBox1.Image = Image.FromStream(stream);
  372. }
  373. }
  374. }
  375. catch (ArgumentException ex)
  376. {
  377. // 处理异常,例如记录日志或显示用户友好的错误消息
  378. MessageBox.Show("品管签名加载失败: " + ex.Message);
  379. }
  380. }
  381. else
  382. {
  383. //图片清空
  384. this.pictureBox1.Image = Properties.Resources.bg;
  385. }
  386. //加载成检签名
  387. if (!string.IsNullOrEmpty(imageTable.Rows[0]["CJSIGNATURE"].ToString()))
  388. {
  389. // 读取二进制数据
  390. byte[] binaryDataCJ = (byte[])(imageTable.Rows[0]["CJSIGNATURE"]);
  391. // 解码为图像对象
  392. try
  393. {
  394. using (MemoryStream stream1 = new MemoryStream(binaryDataCJ))
  395. {
  396. if (pictureBox2.Image != null)
  397. {
  398. // 其他操作
  399. // 显示图像在PictureBox中
  400. pictureBox2.Image = Image.FromStream(stream1);
  401. }
  402. }
  403. }
  404. catch (ArgumentException ex)
  405. {
  406. // 处理异常,例如记录日志或显示用户友好的错误消息
  407. MessageBox.Show("成检签名加载失败: " + ex.Message);
  408. }
  409. }
  410. else
  411. {
  412. //图片清空
  413. this.pictureBox2.Image = Properties.Resources.bg;
  414. }
  415. //加载生控签名
  416. if (!string.IsNullOrEmpty(imageTable.Rows[0]["SKSIGNATURE"].ToString()))
  417. {
  418. // 读取二进制数据
  419. byte[] binaryDataSK = (byte[])(imageTable.Rows[0]["SKSIGNATURE"]);
  420. // 解码为图像对象
  421. try
  422. {
  423. using (MemoryStream stream2 = new MemoryStream(binaryDataSK))
  424. {
  425. if (pictureBox3.Image != null)
  426. {
  427. // 其他操作
  428. // 显示图像在PictureBox中
  429. pictureBox3.Image = Image.FromStream(stream2);
  430. }
  431. }
  432. }
  433. catch (ArgumentException ex)
  434. {
  435. // 处理异常,例如记录日志或显示用户友好的错误消息
  436. MessageBox.Show("生控签名加载失败: " + ex.Message);
  437. }
  438. }
  439. else
  440. {
  441. //图片清空
  442. this.pictureBox3.Image = Properties.Resources.bg;
  443. }
  444. }
  445. }
  446. }
  447. _registerID = registerID;
  448. }
  449. }
  450. catch (Exception ex)
  451. {
  452. this.btnSearch.Enabled = true;
  453. this.btnClearCondition.Enabled = true;
  454. // 对异常进行共通处理
  455. ExceptionManager.HandleEventException(this.ToString(),
  456. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  457. }
  458. }
  459. /// <summary>
  460. /// 清空条件按钮事件
  461. /// </summary>
  462. /// <param name="sender"></param>
  463. /// <param name="e"></param>
  464. private void btnClearCondition_Click(object sender, EventArgs e)
  465. {
  466. try
  467. {
  468. this.txtGoodsCode.Text = "";
  469. this.txtRegisterNo.Text = "";
  470. this.cmbFIRBASIS.SelectedIndex = Constant.INT_IS_ZERO;
  471. this.cmbFIRGOODSTYPE.SelectedIndex = Constant.INT_IS_ZERO;
  472. this.cmbWORKSHOP.SelectedIndex = Constant.INT_IS_ZERO;
  473. }
  474. catch (Exception ex)
  475. {
  476. this.btnSearch.Enabled = true;
  477. this.btnClearCondition.Enabled = true;
  478. // 对异常进行共通处理
  479. ExceptionManager.HandleEventException(this.ToString(),
  480. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  481. }
  482. }
  483. /// <summary>
  484. /// 自动适应列宽
  485. /// </summary>
  486. /// <param name="sender"></param>
  487. /// <param name="e"></param>
  488. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  489. {
  490. try
  491. {
  492. this.dgvRegister.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  493. this.dgvBarcode.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  494. this.dgvRegisterDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  495. }
  496. catch (Exception ex)
  497. {
  498. this.btnSearch.Enabled = true;
  499. this.btnClearCondition.Enabled = true;
  500. // 对异常进行共通处理
  501. ExceptionManager.HandleEventException(this.ToString(),
  502. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  503. }
  504. }
  505. /// <summary>
  506. /// 新建
  507. /// </summary>
  508. /// <param name="sender"></param>
  509. /// <param name="e"></param>
  510. private void btnFirAdd_Click(object sender, EventArgs e)
  511. {
  512. try
  513. {
  514. F_PM_3602 firEdit = new F_PM_3602(Constant.FormMode.Add, 0);
  515. firEdit.ShowDialog();
  516. }
  517. catch (Exception ex)
  518. {
  519. this.btnSearch.Enabled = true;
  520. this.btnClearCondition.Enabled = true;
  521. // 对异常进行共通处理
  522. ExceptionManager.HandleEventException(this.ToString(),
  523. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  524. }
  525. }
  526. /// <summary>
  527. /// 编辑
  528. /// </summary>
  529. /// <param name="sender"></param>
  530. /// <param name="e"></param>
  531. private void btnFirEdit_Click(object sender, EventArgs e)
  532. {
  533. try
  534. {
  535. DataGridViewRow currentRow = this.dgvRegister.CurrentRow;
  536. if (currentRow != null)
  537. // 获取相应节点数据
  538. {
  539. int status = Convert.ToInt32(currentRow.Cells["STATUSID"].Value);
  540. //判断状态(0:未登记(可编辑总单,没有明细)
  541. //1:部分检测中(不可编辑总单,点击条码)
  542. //2:待研发部检验(不可编辑总单,点击条码)
  543. //3:待签名(不可编辑)
  544. //4:已完结(不可编辑))
  545. if (status == 0)
  546. {
  547. F_PM_3602 frmPM3602 = new F_PM_3602(Constant.FormMode.Edit, Convert.ToInt32(currentRow.Cells["REGISTERID"].Value));
  548. DialogResult dialogresult = frmPM3602.ShowDialog();
  549. if (dialogresult.Equals(DialogResult.OK))
  550. {
  551. // 刷新窗口数据
  552. btnSearch_Click(sender, e);
  553. }
  554. }
  555. else if(status == 1 || status == 2)
  556. {
  557. if (this.dgvBarcode.CurrentRow == null)
  558. {
  559. MessageBox.Show("当前登记单状态不允许编辑总单,选择条码后可编辑检验结果!",
  560. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  561. return;
  562. }
  563. DataGridViewRow barRow = this.dgvBarcode.CurrentRow;
  564. int registerid = Convert.ToInt32(currentRow.Cells["REGISTERID"].Value);
  565. int barid = Convert.ToInt32(barRow.Cells["BARID"].Value);
  566. F_PM_3602 frmPM3602 = new F_PM_3602(Constant.FormMode.Edit, registerid, barid);
  567. DialogResult dialogresult = frmPM3602.ShowDialog();
  568. if (dialogresult.Equals(DialogResult.OK))
  569. {
  570. // 刷新窗口数据
  571. btnSearch_Click(sender, e);
  572. }
  573. }
  574. else if(status == 3 || status == 4)
  575. {
  576. MessageBox.Show("当前登记单状态不允许编辑",
  577. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  578. return;
  579. }
  580. }
  581. }
  582. catch (Exception ex)
  583. {
  584. this.btnSearch.Enabled = true;
  585. this.btnClearCondition.Enabled = true;
  586. // 对异常进行共通处理
  587. ExceptionManager.HandleEventException(this.ToString(),
  588. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  589. }
  590. }
  591. /// <summary>
  592. /// 条码选中查询明细
  593. /// </summary>
  594. /// <param name="sender"></param>
  595. /// <param name="e"></param>
  596. private void dgvBarcode_SelectionChanged(object sender, EventArgs e)
  597. {
  598. try
  599. {
  600. if (this.dgvRegister.CurrentRow != null && this.dgvBarcode.CurrentRow != null)
  601. {
  602. int registerID = Convert.ToInt32(this.dgvRegister.CurrentRow.Cells["REGISTERID"].Value.ToString());
  603. int barID = Convert.ToInt32(this.dgvBarcode.CurrentRow.Cells["BARID"].Value.ToString());
  604. ClientRequestEntity cre = new ClientRequestEntity();
  605. cre.NameSpace = "F_PM_3601";
  606. cre.Name = "GetItemDetail";
  607. cre.Properties["REGISTERID"] = registerID;
  608. cre.Properties["BARID"] = barID;
  609. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  610. {
  611. return PMModuleProxyNew.Service.HandleRequest(cre);
  612. });
  613. if (sre.Status == Constant.ServiceResultStatus.Success)
  614. {
  615. if (sre.Data.Tables[0] != null && sre.Data.Tables[0].Rows.Count > 0)
  616. {
  617. dgvRegisterDetail.DataSource = sre.Data.Tables[0];
  618. this.dgvRegisterDetail.Rows[0].Selected = true;
  619. this.dgvRegisterDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  620. }
  621. else
  622. {
  623. if (dgvRegisterDetail.DataSource != null )
  624. {
  625. dgvRegisterDetail.DataSource = ((DataTable)dgvRegisterDetail.DataSource).Clone();
  626. }
  627. else
  628. {
  629. dgvRegisterDetail.DataSource = null;
  630. }
  631. }
  632. }
  633. }
  634. }
  635. catch (Exception ex)
  636. {
  637. this.btnSearch.Enabled = true;
  638. this.btnClearCondition.Enabled = true;
  639. // 对异常进行共通处理
  640. ExceptionManager.HandleEventException(this.ToString(),
  641. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  642. }
  643. }
  644. #endregion
  645. #region 私有方法
  646. #endregion
  647. }
  648. }