F_PM_2101.cs 30 KB

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