F_PM_2101.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  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.dgvInCheckedNoDetail.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
  202. // 初始化时间控件为当前日期
  203. this.dtpStartTime.Value = DateTime.Now.Date;
  204. this.dtpEndTime.Value = DateTime.Now.Date;
  205. }
  206. catch (Exception ex)
  207. {
  208. // 对异常进行共通处理
  209. ExceptionManager.HandleEventException(this.ToString(),
  210. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  211. }
  212. }
  213. /// <summary>
  214. /// 窗体关闭事件
  215. /// </summary>
  216. /// <param name="sender"></param>
  217. /// <param name="e"></param>
  218. private void F_PM_2101_FormClosed(object sender, FormClosedEventArgs e)
  219. {
  220. _instance = null;
  221. }
  222. /// <summary>
  223. /// 清空按钮事件
  224. /// </summary>
  225. /// <param name="sender"></param>
  226. /// <param name="e"></param>
  227. private void btnClearCondition_Click(object sender, EventArgs e)
  228. {
  229. this.txtInCheckedNo.Clear();
  230. this.txtCheckedName.Clear();
  231. // 初始化时间控件为当前日期
  232. this.dtpStartTime.Value = DateTime.Now.Date;
  233. this.dtpEndTime.Value = DateTime.Now.Date;
  234. }
  235. /// <summary>
  236. /// 选定项改变事件
  237. /// </summary>
  238. /// <param name="sender"></param>
  239. /// <param name="e"></param>
  240. private void dgvInChecked_SelectionChanged(object sender, EventArgs e)
  241. {
  242. try
  243. {
  244. // 在绑定总表时 不查询明细
  245. if (!Convert.ToBoolean(this.Tag)
  246. || this.dgvInChecked.CurrentCell == null)
  247. {
  248. return;
  249. }
  250. // 选中行时查询明细
  251. else
  252. {
  253. if (this.txtInCheckedNo.ReadOnly)
  254. {
  255. return;
  256. }
  257. this.dgvInChecked.Enabled = false;
  258. this._selectedRowIndex = this.dgvInChecked.CurrentCell.RowIndex;
  259. this.dgvInCheckedNoDetail.DataSource = null;
  260. this.dgvInCheckededDetail.DataSource = null;
  261. this.dgvInCheckedWinDetail.DataSource = null;
  262. this.dgvFunctionUsers.DataSource = null;
  263. int InCheckedID = Convert.ToInt32(this.dgvInChecked.Rows[_selectedRowIndex].Cells["InCheckedID"].Value.ToString());
  264. DataSet dsProductionDefect = (DataSet)DoAsync(new AsyncMethod(() =>
  265. {
  266. return PMModuleProxy.Service.GetAllInCheckedDetail(InCheckedID);
  267. }));
  268. if (dsProductionDefect != null && dsProductionDefect.Tables.Count > Constant.INT_IS_ZERO)
  269. {
  270. //DataRow[] drInCheckedNo = dsProductionDefect.Tables[0].Select("InCheckedFlag=" + Constant.InCheckedFlag.InCheckedNo.GetHashCode());
  271. //if (drInCheckedNo.Length > 0)
  272. //{
  273. // this.dgvInCheckedNoDetail.DataSource = drInCheckedNo.CopyToDataTable();
  274. //}
  275. //DataRow[] drInCheckeded = dsProductionDefect.Tables[0].Select("InCheckedFlag=" + Constant.InCheckedFlag.InCheckeded.GetHashCode());
  276. //if (drInCheckeded.Length > 0)
  277. //{
  278. // this.dgvInCheckededDetail.DataSource = drInCheckeded.CopyToDataTable();
  279. //}
  280. //DataRow[] drInCheckedWin = dsProductionDefect.Tables[0].Select("InCheckedFlag=" + Constant.InCheckedFlag.InCheckedWin.GetHashCode());
  281. //if (drInCheckedWin.Length > 0)
  282. //{
  283. // this.dgvInCheckedWinDetail.DataSource = drInCheckedWin.CopyToDataTable();
  284. //}
  285. //if(dsProductionDefect.Tables[1].Rows.Count>0)
  286. //{
  287. // this.dgvFunctionUsers.DataSource = dsProductionDefect.Tables[1];
  288. //}
  289. this.dgvInCheckedNoDetail.DataSource = dsProductionDefect.Tables[0];
  290. this.dgvInCheckededDetail.DataSource = dsProductionDefect.Tables[1];
  291. this.dgvInCheckedWinDetail.DataSource = dsProductionDefect.Tables[2];
  292. this.dgvFunctionUsers.DataSource = dsProductionDefect.Tables[3];
  293. this.dgvInCheckedNoDetail.IsSetInputColumnsColor = true;
  294. }
  295. }
  296. }
  297. catch (Exception ex)
  298. {
  299. // 对异常进行共通处理
  300. ExceptionManager.HandleEventException(this.ToString(),
  301. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  302. }
  303. finally
  304. {
  305. this.dgvInChecked.Enabled = true;
  306. this.dgvInChecked.Focus();
  307. }
  308. }
  309. /// <summary>
  310. /// 搜索按钮事件
  311. /// </summary>
  312. /// <param name="sender"></param>
  313. /// <param name="e"></param>
  314. private void btnSearch_Click(object sender, EventArgs e)
  315. {
  316. try
  317. {
  318. // 记录当前选中行
  319. int selectRowIndex = this._selectedRowIndex;
  320. // 控制明细不查询
  321. this.Tag = false;
  322. // 异步处理
  323. this.btnSearch.Enabled = false;
  324. this.btnClearCondition.Enabled = false;
  325. this.dgvInChecked.DataSource = null;
  326. this.dgvFunctionUsers.DataSource = null;
  327. this.dgvInCheckededDetail.DataSource = null;
  328. this.dgvInCheckedNoDetail.DataSource = null;
  329. this.dgvInCheckedWinDetail.DataSource = null;
  330. InCheckedEntity requestEntity = CreatesearchInCheckedRequestEntity();
  331. DataSet dsInChecked = (DataSet)DoAsync(new AsyncMethod(() =>
  332. {
  333. return PMModuleProxy.Service.GetAllInChecked(requestEntity);
  334. }));
  335. this.btnSearch.Enabled = true;
  336. this.btnClearCondition.Enabled = true;
  337. if (dsInChecked != null)
  338. {
  339. base.DataSource = dsInChecked;
  340. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  341. {
  342. tsbtnInChecked.Enabled = true;
  343. tsbtnDisable.Enabled = true;
  344. this.dgvInChecked.DataSource = this.DataSource.Tables[0];
  345. selectRowIndex = 0;
  346. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  347. {
  348. tsbtnInChecked.Enabled = false;
  349. tsbtnDisable.Enabled = false;
  350. this.dgvInCheckedNoDetail.DataSource = null;
  351. // 提示未查找到数据
  352. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  353. MessageBoxButtons.OK, MessageBoxIcon.Information);
  354. }
  355. else
  356. {
  357. if (selectRowIndex >= Constant.INT_IS_ZERO)
  358. {
  359. //if (selectRowIndex >= dsInChecked.Tables[0].Rows.Count)
  360. //{
  361. // this.dgvInChecked.Rows[this.dgvInChecked.Rows.Count - 1].Selected = true;
  362. // this.dgvInChecked.CurrentCell = this.dgvInChecked.Rows[this.dgvInChecked.Rows.Count - 1].Cells["InCheckedNo"];
  363. //}
  364. //else
  365. //{
  366. // this.dgvInChecked.Rows[selectRowIndex].Selected = true;
  367. // this.dgvInChecked.CurrentCell = this.dgvInChecked.Rows[selectRowIndex].Cells["InCheckedNo"];
  368. //}
  369. this.Tag = true;
  370. dgvInChecked_SelectionChanged(null, null);
  371. }
  372. }
  373. }
  374. }
  375. }
  376. catch (Exception ex)
  377. {
  378. // 对异常进行共通处理
  379. ExceptionManager.HandleEventException(this.ToString(),
  380. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  381. }
  382. finally
  383. {
  384. this.tsrOperate.Enabled = true;
  385. this.btnSearch.Enabled = true;
  386. this.btnClearCondition.Enabled = true;
  387. // 控制明细不查询
  388. this.Tag = true;
  389. }
  390. }
  391. /// <summary>
  392. /// 关闭按钮事件
  393. /// </summary>
  394. /// <param name="sender"></param>
  395. /// <param name="e"></param>
  396. private void tsbtnClose_Click(object sender, EventArgs e)
  397. {
  398. this.Close();
  399. }
  400. /// <summary>
  401. /// 自动适应列宽
  402. /// </summary>
  403. /// <param name="sender"></param>
  404. /// <param name="e"></param>
  405. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  406. {
  407. this.dgvInChecked.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  408. this.dgvInCheckedNoDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  409. this.dgvInCheckededDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  410. this.dgvInCheckedWinDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  411. this.dgvFunctionUsers.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  412. }
  413. #endregion
  414. #region 私有方法
  415. /// <summary>
  416. /// 搜索条件
  417. /// </summary>
  418. /// <returns></returns>
  419. private InCheckedEntity CreatesearchInCheckedRequestEntity()
  420. {
  421. InCheckedEntity result = new InCheckedEntity();
  422. result.InCheckedNo = this.txtInCheckedNo.Text.Trim();
  423. result.InCheckedName = this.txtCheckedName.Text.Trim();
  424. result.BeginDate = this.dtpStartTime.Value;
  425. result.EndDate = this.dtpEndTime.Value.AddDays(1);
  426. return result;
  427. }
  428. #endregion
  429. /// <summary>
  430. /// 清除未盘点数据按钮事件
  431. /// </summary>
  432. /// <param name="sender"></param>
  433. /// <param name="e"></param>
  434. private void tsbtnClearData_Click(object sender, EventArgs e)
  435. {
  436. bool hasSearch = false;
  437. try
  438. {
  439. DataTable dt = this.dgvInCheckedNoDetail.DataSource as DataTable;
  440. if (dt == null)
  441. {
  442. MessageBox.Show("没有未盘点的数据",
  443. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  444. return;
  445. }
  446. dt.AcceptChanges();
  447. DataRow[] dr = dt.Select("Sel=1");
  448. if (dr.Length == 0)
  449. {
  450. if (this.dgvInChecked.CurrentCell != null)
  451. {
  452. int InCheckedID = Convert.ToInt32(this.dgvInChecked.Rows[this.dgvInChecked.CurrentCell.RowIndex].Cells["InCheckedID"].Value);
  453. string InCheckedNo = this.dgvInChecked.Rows[this.dgvInChecked.CurrentCell.RowIndex].Cells["InCheckedNo"].Value.ToString();
  454. F_PM_2117 frmPM2117 = new F_PM_2117(InCheckedID, InCheckedNo);
  455. DialogResult dialogResult2 = frmPM2117.ShowDialog();
  456. // 重新加载GridView
  457. if (dialogResult2 == DialogResult.OK)
  458. {
  459. //btnSearch_Click(sender, e);
  460. dgvInChecked_SelectionChanged(null, null);
  461. }
  462. }
  463. return;
  464. }
  465. DialogResult dialogResult
  466. = MessageBox.Show("是否清除选择未盘点产品?",
  467. this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  468. if (dialogResult.Equals(DialogResult.No))
  469. {
  470. return;
  471. }
  472. int incheckID = Convert.ToInt32(dr[0]["InCheckedID"]);
  473. string barcodes = "";
  474. foreach (DataRow r in dr)
  475. {
  476. barcodes += r["barcode"].ToString() + ",";
  477. }
  478. barcodes = barcodes.TrimEnd(',');
  479. // 清除
  480. int result = (int)DoAsync(() =>
  481. {
  482. return PMModuleProxy.Service.SaveClearInChecked(incheckID, barcodes);
  483. });
  484. if (result > Constant.INT_IS_ZERO)
  485. {
  486. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "盘点产品", "清除数据"),
  487. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  488. // 刷新窗口数据
  489. this.btnSearch_Click(sender, e);
  490. hasSearch = true;
  491. }
  492. else if (result == -Constant.INT_IS_ONE)
  493. {
  494. MessageBox.Show("返工产品不允许清除",
  495. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  496. return;
  497. }
  498. else if (result == -Constant.INT_IS_TWO)
  499. {
  500. MessageBox.Show("报损待审产品不允许清除",
  501. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  502. return;
  503. }
  504. else
  505. {
  506. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "盘点产品", "清除数据"),
  507. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  508. return;
  509. }
  510. }
  511. catch (Exception ex)
  512. {
  513. // 对异常进行共通处理
  514. ExceptionManager.HandleEventException(this.ToString(),
  515. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  516. }
  517. finally
  518. {
  519. if (!hasSearch)
  520. {
  521. this.dgvInCheckedNoDetail.IsSetInputColumnsColor = true;
  522. }
  523. }
  524. }
  525. private void dgvInCheckedNoDetail_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  526. {
  527. try
  528. {
  529. if (this.dgvInCheckedNoDetail.CurrentRow != null && this.dgvInCheckedNoDetail.IsCurrentCellDirty)
  530. {
  531. if ("Sel".Equals(this.dgvInCheckedNoDetail.Columns
  532. [this.dgvInCheckedNoDetail.CurrentCell.ColumnIndex].Name))
  533. {
  534. this.dgvInCheckedNoDetail.CommitEdit(DataGridViewDataErrorContexts.Commit);
  535. }
  536. }
  537. }
  538. catch (Exception ex)
  539. {
  540. // 对异常进行共通处理
  541. ExceptionManager.HandleEventException(this.ToString(),
  542. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  543. }
  544. }
  545. private void tsbtnAll_Click(object sender, EventArgs e)
  546. {
  547. DataTable returnData = (DataTable)this.dgvInCheckedNoDetail.DataSource;
  548. if (returnData != null)
  549. {
  550. //for (int i = 0; i < returnData.Rows.Count; i++)
  551. //{
  552. // returnData.Rows[i]["Sel"] = 1;
  553. //}
  554. for (int i = 0; i < returnData.DefaultView.Count; i++)
  555. {
  556. returnData.DefaultView[i]["Sel"] = 1;
  557. returnData.DefaultView[i].EndEdit();
  558. }
  559. }
  560. }
  561. private void tsbtnUnAll_Click(object sender, EventArgs e)
  562. {
  563. DataTable returnData = (DataTable)this.dgvInCheckedNoDetail.DataSource;
  564. if (returnData != null)
  565. {
  566. for (int i = 0; i < returnData.Rows.Count; i++)
  567. {
  568. returnData.Rows[i]["Sel"] = 0;
  569. returnData.Rows[i].EndEdit();
  570. }
  571. }
  572. }
  573. private void tsbtnEdit_Click(object sender, EventArgs e)
  574. {
  575. try
  576. {
  577. DataGridViewRow currentRow = this.dgvInChecked.CurrentRow;
  578. if (currentRow != null)
  579. {
  580. int InCheckedID = Convert.ToInt32(currentRow.Cells["InCheckedID"].Value);
  581. F_PM_2102 frm2102 = new F_PM_2102(InCheckedID, currentRow.Cells["Remarks"].Value.ToString(), currentRow.Cells["Incheckname"].Value.ToString());
  582. DialogResult dialogresult = frm2102.ShowDialog();
  583. if (dialogresult.Equals(DialogResult.OK))
  584. {
  585. btnSearch_Click(sender, e);
  586. }
  587. }
  588. }
  589. catch (Exception ex)
  590. {
  591. // 对异常进行共通处理
  592. ExceptionManager.HandleEventException(this.ToString(),
  593. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  594. }
  595. }
  596. private void dgvInChecked_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  597. {
  598. if (-1 < e.RowIndex && -1 < e.ColumnIndex && this.tsbtnEdit.Enabled && this.tsbtnEdit.Visible)
  599. {
  600. this.tsbtnEdit_Click(sender, e);
  601. }
  602. }
  603. private void dgvInCheckedNoDetail_Sorted(object sender, EventArgs e)
  604. {
  605. this.dgvInCheckedNoDetail.IsSetInputColumnsColor = true;
  606. }
  607. private void tsbtnCheckData_Click(object sender, EventArgs e)
  608. {
  609. bool hasSearch = false;
  610. try
  611. {
  612. DataTable dt = this.dgvInCheckedNoDetail.DataSource as DataTable;
  613. if (dt == null)
  614. {
  615. MessageBox.Show("没有未盘点的数据。",
  616. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  617. return;
  618. }
  619. dt.AcceptChanges();
  620. DataRow[] dr = dt.Select("Sel=1");
  621. if (dr.Length == 0)
  622. {
  623. if (this.dgvInChecked.CurrentCell != null)
  624. {
  625. int inCheckedID = Convert.ToInt32(this.dgvInChecked.Rows[this.dgvInChecked.CurrentCell.RowIndex].Cells["InCheckedID"].Value);
  626. DialogResult dialogResultAll = MessageBox.Show("是否盘点所有未盘点产品?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
  627. if (dialogResultAll == System.Windows.Forms.DialogResult.Yes)
  628. {
  629. ServiceResultEntity resultAll = (ServiceResultEntity)DoAsync(() =>
  630. {
  631. ClientRequestEntity cre = new ClientRequestEntity();
  632. cre.NameSpace = "InChecked";
  633. cre.Name = "CheckBarcodes";
  634. cre.Properties["CheckedID"] = inCheckedID;
  635. return PMModuleProxyNew.Service.HandleRequest(cre);
  636. });
  637. this.dgvInChecked_SelectionChanged(null, null);
  638. }
  639. }
  640. return;
  641. }
  642. DialogResult dialogResult = MessageBox.Show("是否盘点选中的产品?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
  643. if (dialogResult == System.Windows.Forms.DialogResult.No)
  644. {
  645. return;
  646. }
  647. int incheckID = Convert.ToInt32(dr[0]["InCheckedID"]);
  648. string barcodes = "";
  649. foreach (DataRow r in dr)
  650. {
  651. barcodes += r["barcode"].ToString() + ",";
  652. }
  653. barcodes = barcodes.TrimEnd(',');
  654. ServiceResultEntity result = (ServiceResultEntity)DoAsync(() =>
  655. {
  656. ClientRequestEntity cre = new ClientRequestEntity();
  657. cre.NameSpace = "InChecked";
  658. cre.Name = "CheckBarcodes";
  659. cre.Properties["CheckedID"] = incheckID;
  660. cre.Properties["Barcodes"] = barcodes;
  661. return PMModuleProxyNew.Service.HandleRequest(cre);
  662. });
  663. this.dgvInChecked_SelectionChanged(null, null);
  664. }
  665. catch (Exception ex)
  666. {
  667. // 对异常进行共通处理
  668. ExceptionManager.HandleEventException(this.ToString(),
  669. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  670. }
  671. finally
  672. {
  673. if (!hasSearch)
  674. {
  675. this.dgvInCheckedNoDetail.IsSetInputColumnsColor = true;
  676. }
  677. }
  678. }
  679. }
  680. }