F_PM_2601.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_2601.cs
  5. * 2.功能描述:注浆盘点一览
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/05/13 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.DockPanel;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  22. namespace Dongke.IBOSS.PRD.Client.PMModule
  23. {
  24. /// <summary>
  25. /// 注浆盘点一览
  26. /// </summary>
  27. public partial class F_PM_2601 : DockPanelBase
  28. {
  29. #region 成员变量
  30. // 窗体的单例模式
  31. private static F_PM_2601 _instance;
  32. #endregion
  33. #region 构造函数
  34. public F_PM_2601()
  35. {
  36. InitializeComponent();
  37. this.Text = "成型盘点";//FormTitles.F_PM_2101;
  38. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  39. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  40. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  41. this.tsbtnAll.Text = ButtonText.TSBTN_ALL;
  42. this.tsbtnUnAll.Text = ButtonText.TSBTN_UNALL;
  43. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  44. }
  45. /// <summary>
  46. /// 单例模式,防止重复创建窗体
  47. /// </summary>
  48. public static F_PM_2601 Instance
  49. {
  50. get
  51. {
  52. if (_instance == null)
  53. {
  54. _instance = new F_PM_2601();
  55. }
  56. return _instance;
  57. }
  58. }
  59. #endregion
  60. #region 事件
  61. /// <summary>
  62. /// 新建按钮事件
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="e"></param>
  66. private void tsbtnAdd_Click(object sender, EventArgs e)
  67. {
  68. try
  69. {
  70. F_PM_2602 frmPM2102 = new F_PM_2602();
  71. DialogResult dialogResult = frmPM2102.ShowDialog();
  72. // 重新加载GridView
  73. if (dialogResult == DialogResult.OK)
  74. {
  75. }
  76. }
  77. catch (Exception ex)
  78. {
  79. // 对异常进行共通处理
  80. ExceptionManager.HandleEventException(this.ToString(),
  81. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  82. }
  83. }
  84. /// <summary>
  85. /// 盘点按钮事件
  86. /// </summary>
  87. /// <param name="sender"></param>
  88. /// <param name="e"></param>
  89. private void tsbtnInChecked_Click(object sender, EventArgs e)
  90. {
  91. try
  92. {
  93. if (this.dgvInChecked.CurrentCell != null)
  94. {
  95. int checkedID = Convert.ToInt32(
  96. this.dgvInChecked.CurrentRow.Cells["GBCheckedID"].Value);
  97. string checkedNO =
  98. this.dgvInChecked.CurrentRow.Cells["GBCheckedNo"].Value.ToString();
  99. F_PM_2603 frmPM2603 = new F_PM_2603(checkedID, checkedNO);
  100. DialogResult dialogResult = frmPM2603.ShowDialog();
  101. // 重新加载GridView
  102. if (dialogResult == DialogResult.OK)
  103. {
  104. //btnSearch_Click(sender, e);
  105. dgvInChecked_SelectionChanged(null, null);
  106. }
  107. }
  108. }
  109. catch (Exception ex)
  110. {
  111. // 对异常进行共通处理
  112. ExceptionManager.HandleEventException(this.ToString(),
  113. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  114. }
  115. }
  116. /// <summary>
  117. /// 停用按钮事件
  118. /// </summary>
  119. /// <param name="sender"></param>
  120. /// <param name="e"></param>
  121. private void tsbtnDisable_Click(object sender, EventArgs e)
  122. {
  123. try
  124. {
  125. if (this.dgvInChecked.CurrentCell != null)
  126. {
  127. DialogResult dialogResult
  128. = MessageBox.Show(string.Format(Messages.MSG_CMN_Q002, "盘点单", "停用"),
  129. this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  130. if (dialogResult != DialogResult.OK)
  131. {
  132. return;
  133. }
  134. int checkedID = Convert.ToInt32(
  135. this.dgvInChecked.CurrentRow.Cells["GBCheckedID"].Value);
  136. // 停用
  137. ServiceResultEntity result = (ServiceResultEntity)DoAsync(() =>
  138. {
  139. ClientRequestEntity cre = new ClientRequestEntity();
  140. cre.NameSpace = "GBChecked";
  141. cre.Name = "DisableGBChecked";
  142. cre.Properties["CheckedID"] = checkedID;
  143. return PMModuleProxyNew.Service.HandleRequest(cre);
  144. });
  145. if (result.Status == Constant.ServiceResultStatus.Success)
  146. {
  147. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "盘点单", "停用"),
  148. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  149. // 刷新窗口数据
  150. this.btnSearch_Click(sender, e);
  151. }
  152. else
  153. {
  154. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "盘点单", "停用"),
  155. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  156. return;
  157. }
  158. }
  159. }
  160. catch (Exception ex)
  161. {
  162. // 对异常进行共通处理
  163. ExceptionManager.HandleEventException(this.ToString(),
  164. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  165. }
  166. }
  167. /// <summary>
  168. /// 窗体加载事件
  169. /// </summary>
  170. /// <param name="sender"></param>
  171. /// <param name="e"></param>
  172. private void F_PM_2101_Load(object sender, EventArgs e)
  173. {
  174. try
  175. {
  176. // 绑定权限
  177. FormPermissionManager.FormPermissionControl(this.Name, this,
  178. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  179. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  180. this.dgvInChecked.AutoGenerateColumns = false;
  181. this.dgvInCheckedNoDetail.AutoGenerateColumns = false;
  182. this.dgvInCheckededDetail.AutoGenerateColumns = false;
  183. this.dgvInCheckedWinDetail.AutoGenerateColumns = false;
  184. this.dgvLossDetail.AutoGenerateColumns = false;
  185. this.dgvInCheckedNoDetail.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
  186. // 初始化时间控件为当前日期
  187. this.dtpStartTime.Value = DateTime.Now.Date;
  188. this.dtpEndTime.Value = DateTime.Now.Date;
  189. }
  190. catch (Exception ex)
  191. {
  192. // 对异常进行共通处理
  193. ExceptionManager.HandleEventException(this.ToString(),
  194. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  195. }
  196. }
  197. /// <summary>
  198. /// 窗体关闭事件
  199. /// </summary>
  200. /// <param name="sender"></param>
  201. /// <param name="e"></param>
  202. private void F_PM_2101_FormClosed(object sender, FormClosedEventArgs e)
  203. {
  204. _instance = null;
  205. }
  206. /// <summary>
  207. /// 清空按钮事件
  208. /// </summary>
  209. /// <param name="sender"></param>
  210. /// <param name="e"></param>
  211. private void btnClearCondition_Click(object sender, EventArgs e)
  212. {
  213. this.txtInCheckedNo.Clear();
  214. this.txtCheckedName.Clear();
  215. // 初始化时间控件为当前日期
  216. this.dtpStartTime.Value = DateTime.Now.Date;
  217. this.dtpEndTime.Value = DateTime.Now.Date;
  218. }
  219. /// <summary>
  220. /// 选定项改变事件
  221. /// </summary>
  222. /// <param name="sender"></param>
  223. /// <param name="e"></param>
  224. private void dgvInChecked_SelectionChanged(object sender, EventArgs e)
  225. {
  226. try
  227. {
  228. // 在绑定总表时 不查询明细
  229. if (!Convert.ToBoolean(this.Tag)
  230. || this.dgvInChecked.CurrentCell == null)
  231. {
  232. return;
  233. }
  234. // 选中行时查询明细
  235. else
  236. {
  237. if (this.txtInCheckedNo.ReadOnly)
  238. {
  239. return;
  240. }
  241. this.dgvInChecked.Enabled = false;
  242. this.dgvInCheckedNoDetail.DataSource = null;
  243. this.dgvInCheckededDetail.DataSource = null;
  244. this.dgvInCheckedWinDetail.DataSource = null;
  245. this.dgvLossDetail.DataSource = null;
  246. this.dgvFunctionUsers.DataSource = null;
  247. int checkedID = Convert.ToInt32(this.dgvInChecked.CurrentRow.Cells["GBCheckedID"].Value.ToString());
  248. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() =>
  249. {
  250. ClientRequestEntity cre = new ClientRequestEntity();
  251. cre.NameSpace = "GBChecked";
  252. cre.Name = "GetAllGBCheckDetail";
  253. cre.Properties["CheckedID"] = checkedID;
  254. return PMModuleProxyNew.Service.HandleRequest(cre);
  255. }));
  256. if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
  257. {
  258. this.dgvFunctionUsers.DataSource = sre.Data.Tables[0];
  259. this.dgvInCheckedNoDetail.DataSource = sre.Data.Tables[1];
  260. this.dgvInCheckededDetail.DataSource = sre.Data.Tables[2];
  261. this.dgvInCheckedWinDetail.DataSource = sre.Data.Tables[3];
  262. this.dgvLossDetail.DataSource = sre.Data.Tables[4];
  263. dgvInCheckedNoDetail.IsSetInputColumnsColor = true;
  264. }
  265. }
  266. }
  267. catch (Exception ex)
  268. {
  269. // 对异常进行共通处理
  270. ExceptionManager.HandleEventException(this.ToString(),
  271. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  272. }
  273. finally
  274. {
  275. this.dgvInChecked.Enabled = true;
  276. this.dgvInChecked.Focus();
  277. }
  278. }
  279. /// <summary>
  280. /// 搜索按钮事件
  281. /// </summary>
  282. /// <param name="sender"></param>
  283. /// <param name="e"></param>
  284. private void btnSearch_Click(object sender, EventArgs e)
  285. {
  286. try
  287. {
  288. // 控制明细不查询
  289. this.Tag = false;
  290. // 异步处理
  291. this.btnSearch.Enabled = false;
  292. this.btnClearCondition.Enabled = false;
  293. this.dgvInChecked.DataSource = null;
  294. this.dgvFunctionUsers.DataSource = null;
  295. this.dgvInCheckededDetail.DataSource = null;
  296. this.dgvInCheckedNoDetail.DataSource = null;
  297. this.dgvInCheckedWinDetail.DataSource = null;
  298. this.dgvLossDetail.DataSource = null;
  299. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() =>
  300. {
  301. ClientRequestEntity cre = new ClientRequestEntity();
  302. cre.NameSpace = "GBChecked";
  303. cre.Name = "GetAllGBCheckList";
  304. cre.Properties["datebegin"] = this.dtpStartTime.Value;
  305. cre.Properties["dateend"] = this.dtpEndTime.Value.AddDays(1).AddSeconds(-1);
  306. cre.Properties["gbcheckedno"] = this.txtInCheckedNo.Text.Trim();
  307. cre.Properties["gbcheckname"] = this.txtCheckedName.Text.Trim();
  308. return PMModuleProxyNew.Service.HandleRequest(cre);
  309. }));
  310. this.btnSearch.Enabled = true;
  311. this.btnClearCondition.Enabled = true;
  312. if (sre != null && sre.Status == Constant.ServiceResultStatus.Success)
  313. {
  314. base.DataSource = sre.Data;
  315. if (this.DataSource != null && this.DataSource.Tables.Count > 0)
  316. {
  317. tsbtnInChecked.Enabled = true;
  318. tsbtnDisable.Enabled = true;
  319. this.dgvInChecked.DataSource = this.DataSource.Tables[0];
  320. if (this.DataSource.Tables[0].Rows.Count == 0)
  321. {
  322. tsbtnInChecked.Enabled = false;
  323. tsbtnDisable.Enabled = false;
  324. this.dgvInCheckedNoDetail.DataSource = null;
  325. // 提示未查找到数据
  326. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  327. MessageBoxButtons.OK, MessageBoxIcon.Information);
  328. }
  329. else
  330. {
  331. this.Tag = true;
  332. dgvInChecked_SelectionChanged(null, null);
  333. }
  334. }
  335. }
  336. }
  337. catch (Exception ex)
  338. {
  339. // 对异常进行共通处理
  340. ExceptionManager.HandleEventException(this.ToString(),
  341. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  342. }
  343. finally
  344. {
  345. this.tsrOperate.Enabled = true;
  346. this.btnSearch.Enabled = true;
  347. this.btnClearCondition.Enabled = true;
  348. // 控制明细不查询
  349. this.Tag = true;
  350. }
  351. }
  352. /// <summary>
  353. /// 关闭按钮事件
  354. /// </summary>
  355. /// <param name="sender"></param>
  356. /// <param name="e"></param>
  357. private void tsbtnClose_Click(object sender, EventArgs e)
  358. {
  359. this.Close();
  360. }
  361. /// <summary>
  362. /// 自动适应列宽
  363. /// </summary>
  364. /// <param name="sender"></param>
  365. /// <param name="e"></param>
  366. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  367. {
  368. this.dgvInChecked.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  369. this.dgvInCheckedNoDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  370. this.dgvInCheckededDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  371. this.dgvInCheckedWinDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  372. this.dgvLossDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  373. this.dgvFunctionUsers.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  374. }
  375. #endregion
  376. #region 私有方法
  377. #endregion
  378. /// <summary>
  379. /// 清除未盘点数据按钮事件
  380. /// </summary>
  381. /// <param name="sender"></param>
  382. /// <param name="e"></param>
  383. private void tsbtnClearData_Click(object sender, EventArgs e)
  384. {
  385. bool hasSearch = false;
  386. try
  387. {
  388. DataTable dt = this.dgvInCheckedNoDetail.DataSource as DataTable;
  389. if (dt == null)
  390. {
  391. MessageBox.Show("没有未盘点的数据",
  392. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  393. return;
  394. }
  395. dt.AcceptChanges();
  396. DataRow[] dr = dt.Select("Sel=1");
  397. if (dr.Length == 0)
  398. {
  399. if (this.dgvInChecked.CurrentCell != null)
  400. {
  401. int inCheckedID = Convert.ToInt32(this.dgvInChecked.Rows[this.dgvInChecked.CurrentCell.RowIndex].Cells["GBCheckedID"].Value);
  402. DialogResult dialogResultAll = MessageBox.Show("是否报损所有未盘点产品?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
  403. if (dialogResultAll == System.Windows.Forms.DialogResult.Yes)
  404. {
  405. ServiceResultEntity resultAll = (ServiceResultEntity)DoAsync(() =>
  406. {
  407. ClientRequestEntity cre = new ClientRequestEntity();
  408. cre.NameSpace = "GBChecked";
  409. cre.Name = "SaveClearGBChecked";
  410. cre.Properties["CheckedID"] = inCheckedID;
  411. return PMModuleProxyNew.Service.HandleRequest(cre);
  412. });
  413. this.dgvInChecked_SelectionChanged(null, null);
  414. }
  415. }
  416. return;
  417. //MessageBox.Show("没有选择任何未盘点的数据",
  418. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  419. //return;
  420. }
  421. DialogResult dialogResult
  422. = MessageBox.Show("是否报损选择的未盘点产品?",
  423. this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  424. if (dialogResult != DialogResult.Yes)
  425. {
  426. return;
  427. }
  428. int checkID = Convert.ToInt32(dr[0]["GBCheckedID"]);
  429. string barcodes = "";
  430. foreach (DataRow r in dr)
  431. {
  432. barcodes += r["barcode"].ToString() + ",";
  433. }
  434. barcodes = barcodes.TrimEnd(',');
  435. // 清除
  436. ServiceResultEntity result = (ServiceResultEntity)DoAsync(() =>
  437. {
  438. ClientRequestEntity cre = new ClientRequestEntity();
  439. cre.NameSpace = "GBChecked";
  440. cre.Name = "SaveClearGBChecked";
  441. cre.Properties["CheckedID"] = checkID;
  442. cre.Properties["Barcodes"] = barcodes;
  443. return PMModuleProxyNew.Service.HandleRequest(cre);
  444. });
  445. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "未盘点产品", "报损"),
  446. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  447. //this.btnSearch_Click(sender, e);
  448. this.dgvInChecked_SelectionChanged(null, null);
  449. hasSearch = true;
  450. }
  451. catch (Exception ex)
  452. {
  453. // 对异常进行共通处理
  454. ExceptionManager.HandleEventException(this.ToString(),
  455. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  456. }
  457. finally
  458. {
  459. if (!hasSearch)
  460. {
  461. this.dgvInCheckedNoDetail.IsSetInputColumnsColor = true;
  462. }
  463. }
  464. }
  465. private void dgvInCheckedNoDetail_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  466. {
  467. try
  468. {
  469. if (this.dgvInCheckedNoDetail.CurrentRow != null && this.dgvInCheckedNoDetail.IsCurrentCellDirty)
  470. {
  471. if ("Sel".Equals(this.dgvInCheckedNoDetail.Columns
  472. [this.dgvInCheckedNoDetail.CurrentCell.ColumnIndex].Name))
  473. {
  474. this.dgvInCheckedNoDetail.CommitEdit(DataGridViewDataErrorContexts.Commit);
  475. }
  476. }
  477. }
  478. catch (Exception ex)
  479. {
  480. // 对异常进行共通处理
  481. ExceptionManager.HandleEventException(this.ToString(),
  482. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  483. }
  484. }
  485. private void tsbtnAll_Click(object sender, EventArgs e)
  486. {
  487. DataTable returnData = (DataTable)this.dgvInCheckedNoDetail.DataSource;
  488. if (returnData != null)
  489. {
  490. //for (int i = 0; i < returnData.Rows.Count; i++)
  491. //{
  492. // returnData.Rows[i]["Sel"] = 1;
  493. //}
  494. for (int i = 0; i < returnData.DefaultView.Count; i++)
  495. {
  496. returnData.DefaultView[i]["Sel"] = 1;
  497. returnData.DefaultView[i].EndEdit();
  498. }
  499. }
  500. }
  501. private void tsbtnUnAll_Click(object sender, EventArgs e)
  502. {
  503. DataTable returnData = (DataTable)this.dgvInCheckedNoDetail.DataSource;
  504. if (returnData != null)
  505. {
  506. for (int i = 0; i < returnData.Rows.Count; i++)
  507. {
  508. returnData.Rows[i]["Sel"] = 0;
  509. returnData.Rows[i].EndEdit();
  510. }
  511. }
  512. }
  513. private void tsbtnEdit_Click(object sender, EventArgs e)
  514. {
  515. try
  516. {
  517. DataGridViewRow currentRow = this.dgvInChecked.CurrentRow;
  518. if (currentRow != null)
  519. {
  520. int checkedID = Convert.ToInt32(currentRow.Cells["GBCheckedID"].Value);
  521. F_PM_2602 frm2602 = new F_PM_2602(checkedID);
  522. DialogResult dialogresult = frm2602.ShowDialog();
  523. if (dialogresult.Equals(DialogResult.OK))
  524. {
  525. btnSearch_Click(sender, e);
  526. }
  527. }
  528. }
  529. catch (Exception ex)
  530. {
  531. // 对异常进行共通处理
  532. ExceptionManager.HandleEventException(this.ToString(),
  533. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  534. }
  535. }
  536. private void dgvInChecked_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  537. {
  538. if (-1 < e.RowIndex && -1 < e.ColumnIndex && this.tsbtnEdit.Enabled && this.tsbtnEdit.Visible)
  539. {
  540. this.tsbtnEdit_Click(sender, e);
  541. }
  542. }
  543. private void dgvInCheckedNoDetail_Sorted(object sender, EventArgs e)
  544. {
  545. dgvInCheckedNoDetail.IsSetInputColumnsColor = true;
  546. }
  547. private void tsbtnCheckData_Click(object sender, EventArgs e)
  548. {
  549. bool hasSearch = false;
  550. try
  551. {
  552. DataTable dt = this.dgvInCheckedNoDetail.DataSource as DataTable;
  553. if (dt == null)
  554. {
  555. MessageBox.Show("没有未盘点的数据。",
  556. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  557. return;
  558. }
  559. dt.AcceptChanges();
  560. DataRow[] dr = dt.Select("Sel=1");
  561. if (dr.Length == 0)
  562. {
  563. if (this.dgvInChecked.CurrentCell != null)
  564. {
  565. int inCheckedID = Convert.ToInt32(this.dgvInChecked.Rows[this.dgvInChecked.CurrentCell.RowIndex].Cells["GBCheckedID"].Value);
  566. DialogResult dialogResultAll = MessageBox.Show("是否盘点所有未盘点产品?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
  567. if (dialogResultAll == System.Windows.Forms.DialogResult.Yes)
  568. {
  569. ServiceResultEntity resultAll = (ServiceResultEntity)DoAsync(() =>
  570. {
  571. ClientRequestEntity cre = new ClientRequestEntity();
  572. cre.NameSpace = "GBChecked";
  573. cre.Name = "GBCheckBarcodes";
  574. cre.Properties["CheckedID"] = inCheckedID;
  575. return PMModuleProxyNew.Service.HandleRequest(cre);
  576. });
  577. this.dgvInChecked_SelectionChanged(null, null);
  578. }
  579. }
  580. return;
  581. }
  582. DialogResult dialogResult = MessageBox.Show("是否盘点选中的产品?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
  583. if (dialogResult == System.Windows.Forms.DialogResult.No)
  584. {
  585. return;
  586. }
  587. int incheckID = Convert.ToInt32(dr[0]["GBCheckedID"]);
  588. string barcodes = "";
  589. foreach (DataRow r in dr)
  590. {
  591. barcodes += r["barcode"].ToString() + ",";
  592. }
  593. barcodes = barcodes.TrimEnd(',');
  594. ServiceResultEntity result = (ServiceResultEntity)DoAsync(() =>
  595. {
  596. ClientRequestEntity cre = new ClientRequestEntity();
  597. cre.NameSpace = "GBChecked";
  598. cre.Name = "GBCheckBarcodes";
  599. cre.Properties["CheckedID"] = incheckID;
  600. cre.Properties["Barcodes"] = barcodes;
  601. return PMModuleProxyNew.Service.HandleRequest(cre);
  602. });
  603. this.dgvInChecked_SelectionChanged(null, null);
  604. }
  605. catch (Exception ex)
  606. {
  607. // 对异常进行共通处理
  608. ExceptionManager.HandleEventException(this.ToString(),
  609. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  610. }
  611. finally
  612. {
  613. if (!hasSearch)
  614. {
  615. this.dgvInCheckedNoDetail.IsSetInputColumnsColor = true;
  616. }
  617. }
  618. }
  619. }
  620. }