frmWmsQaInspection.cs 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. using ComponentFactory.Krypton.Toolkit;
  2. using NXWMS.Client.Code.Extends;
  3. using NXWMS.Client.Code.Models;
  4. using NXWMS.Client.Model.AppModels.Condition;
  5. using NXWMS.Client.Model.AppModels.Condition.Base;
  6. using NXWMS.Client.Model.AppModels.Condition.Common;
  7. using NXWMS.Client.Model.AppModels.Condition.Inspection;
  8. using NXWMS.Client.Model.AppModels.Result;
  9. using NXWMS.Client.Model.AppModels.Result.Base;
  10. using NXWMS.Client.Model.AppModels.Result.Common;
  11. using NXWMS.Client.Model.AppModels.Result.Inspection;
  12. using NXWMS.Client.Model.CoreModels;
  13. using NXWMS.Commons;
  14. using NXWMS.Forms.Inspection.frmInspectionChild;
  15. using NXWMS.Services;
  16. using System;
  17. using System.Collections.Generic;
  18. using System.ComponentModel;
  19. using System.Data;
  20. using System.Drawing;
  21. using System.Linq;
  22. using System.Text;
  23. using System.Text.RegularExpressions;
  24. using System.Web.UI.WebControls;
  25. using System.Windows.Forms;
  26. namespace NXWMS.Forms.Inspection
  27. {
  28. /// <summary>
  29. /// 质检单窗体
  30. /// </summary>
  31. public partial class frmWmsQaInspection : KryptonForm
  32. {
  33. /// <summary>
  34. /// 窗体构造函数
  35. /// </summary>
  36. public frmWmsQaInspection()
  37. {
  38. InitializeComponent();
  39. // 获取窗体的全类名
  40. _CrrentClassName = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName;
  41. }
  42. #region 全局变量
  43. /// <summary>
  44. /// 客户端字段排序列表(质检单主表)
  45. /// </summary>
  46. private List<ClientFieldOrderResult> _clientFieldOrderList;
  47. /// <summary>
  48. /// 客户端字段排序列表(质检单单明细表)
  49. /// </summary>
  50. private List<ClientFieldOrderResult> _clientFieldOrderDtlList;
  51. /// <summary>
  52. /// 当前窗体类名
  53. /// </summary>
  54. private string _CrrentClassName;
  55. /// <summary>
  56. /// 质检单主键ID,用于记录主表选中行的主键信息。
  57. /// 目前由于 加载控件不能传递具有参数的函数,所以临时使用全局变量。
  58. /// ToDo:后续修改优化加载控件的实现方式,支持传递具有参数的函数。
  59. /// 孙亚龙 舍弃于2020年9月7日
  60. /// </summary>
  61. //string InspectionId = string.Empty;
  62. /// <summary>
  63. /// 用于控制明细表数据的加载时机。
  64. /// 由于主表DataGridView数据加载时,会默认触发选中项更改事件。这时候加载明细表数据会发生异常。
  65. /// 使用全局变量,控制明细表的数据的加载时机,只能在主表数据全部初始化完成后,并且选中了一行主表数据的时候。
  66. /// </summary>
  67. bool isControlInspectionDtlShow = false;
  68. /// <summary>
  69. /// 定义委托
  70. /// 用于执行刷新页面数据的函数
  71. /// </summary>
  72. public delegate void dlgRefreshFrmHost();
  73. /// <summary>
  74. /// 定义委托变量
  75. /// 用于绑定刷新页面数据的函数
  76. /// </summary>
  77. public static dlgRefreshFrmHost RefreshFrmHost;
  78. #endregion
  79. #region 初始化数据
  80. /// <summary>
  81. /// 窗体加载事件
  82. /// </summary>
  83. /// <param name="sender"></param>
  84. /// <param name="e"></param>
  85. private void frmWmsQaInspection_Load(object sender, EventArgs e)
  86. {
  87. #region 获取主、明细表的显示列信息
  88. //获取质检单主表数据源配置
  89. var result = ConfigServices.configService.GetDataViewOrderList(new ClientFieldOrderCondition { SourceCode = $"{_CrrentClassName}" });
  90. if (result.Status == OperateStatus.Success)
  91. {
  92. _clientFieldOrderList = result.Data;
  93. }
  94. //获取质检单明细表表数据源配置
  95. var resultDtl = ConfigServices.configService.GetDataViewOrderList(new ClientFieldOrderCondition { SourceCode = $"{_CrrentClassName}_Dtl" });
  96. if (resultDtl.Status == OperateStatus.Success)
  97. {
  98. _clientFieldOrderDtlList = resultDtl.Data;
  99. }
  100. #endregion
  101. InitComboBoxItemData();
  102. kdtp_startCreateTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  103. kdtp_endCreateTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  104. kdtp_startCreateTime.Checked = false;
  105. kdtp_endCreateTime.Checked = false;
  106. kdtp_startInspectionTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  107. kdtp_endInspectionTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  108. kdtp_startInspectionTime.Checked = false;
  109. kdtp_endInspectionTime.Checked = false;
  110. RefreshFrmHost = new dlgRefreshFrmHost(RefreshInspectionSearchData);
  111. }
  112. /// <summary>
  113. /// 初始化下拉列表数据
  114. /// </summary>
  115. private void InitComboBoxItemData()
  116. {
  117. /*
  118. ToDo:后续把下拉列表转为 后台获取数据,目前是写死的。 1:内部质检;2:外部质检;
  119. */
  120. List<BasDictionaryResult> results = new List<BasDictionaryResult>();
  121. #region 单据类型
  122. results = BasDictionaryUtil.basDictionaryResultLst.FindAll(x => x.DICTIONARY_CODE == "InspectionTypeDesc");
  123. if (results.Count > 0)
  124. {
  125. kcmb_inspectionType.Items.Clear();
  126. kcmb_inspectionType.Items.Add(new ListItem
  127. {
  128. Value = "",
  129. Text = "请选择",
  130. });
  131. foreach (var item in results)
  132. {
  133. kcmb_inspectionType.Items.Add(new ListItem
  134. {
  135. Value = item.DICTIONARY_ITEM_CODE,
  136. Text = item.DICTIONARY_ITEM_NAME,
  137. });
  138. }
  139. kcmb_inspectionType.SelectedIndex = 0;
  140. }
  141. else
  142. {
  143. KryptonMessageBox.Show("未找到质检单类型的字典项数据!");
  144. }
  145. #endregion
  146. #region 单据状态
  147. results = BasDictionaryUtil.basDictionaryResultLst.FindAll(x => x.DICTIONARY_CODE == "InspectionDtlStatusDesc");
  148. if (results.Count > 0)
  149. {
  150. kcmb_inspectionDtlStatus.Items.Clear();
  151. kcmb_inspectionDtlStatus.Items.Add(new ListItem
  152. {
  153. Value = "",
  154. Text = "请选择",
  155. });
  156. foreach (var item in results)
  157. {
  158. kcmb_inspectionDtlStatus.Items.Add(new ListItem
  159. {
  160. Value = item.DICTIONARY_ITEM_CODE,
  161. Text = item.DICTIONARY_ITEM_NAME,
  162. });
  163. }
  164. kcmb_inspectionDtlStatus.SelectedIndex = 0;
  165. }
  166. else
  167. {
  168. KryptonMessageBox.Show("未找到质检单明细状态的字典项数据!");
  169. }
  170. #endregion
  171. #region 供应商信息
  172. var result = BaseServices.supplierService.GetList(new SupplierSearchCondition
  173. {
  174. IsUsed = true,
  175. PageIndex = 1,
  176. PageSize = 10000
  177. });
  178. if (result.Status == OperateStatus.Success)
  179. {
  180. kcmb_supplierMsg.Items.Clear();
  181. kcmb_supplierMsg.Items.Add(new ListItem
  182. {
  183. Value = "",
  184. Text = "请选择",
  185. });
  186. foreach (SupplierResult item in result.Data.RowData.ToList())
  187. {
  188. kcmb_supplierMsg.Items.Add(new ListItem
  189. {
  190. Value = item.SUPPLIER_CODE,
  191. Text = item.SUPPLIER_NAME,
  192. });
  193. }
  194. kcmb_supplierMsg.SelectedIndex = 0;
  195. }
  196. else
  197. {
  198. kcmb_supplierMsg.Items.Clear();
  199. KryptonMessageBox.Show(result.Message);
  200. }
  201. //kcmb_supplierMsg.Items.Clear();
  202. //kcmb_supplierMsg.Items.Add(new ListItem
  203. //{
  204. // Value = "",
  205. // Text = "请选择",
  206. //});
  207. //kcmb_supplierMsg.Items.Add(new ListItem
  208. //{
  209. // Value = "WX_NXZB_001",
  210. // Text = "无锡南兴装备",
  211. //});
  212. //kcmb_supplierMsg.Items.Add(new ListItem
  213. //{
  214. // Value = "WX_NXZB_002",
  215. // Text = "东莞南兴装备",
  216. //});
  217. //kcmb_supplierMsg.SelectedIndex = 0;
  218. #endregion
  219. #region 库区
  220. var regionResult = BaseServices.regionService.GetList(new RegionSearchCondition { IsUsed = true, ItemSQL = "REGION_CODE,REGION_NAME,AREA_NAME,AREA_CODE,WAREHOUSE_CODE,WAREHOUSE_NAME" });
  221. if (regionResult.Status == OperateStatus.Success)
  222. {
  223. kcmb_regionMsg.Items.Clear();
  224. kcmb_regionMsg.Items.Add(new ListItem
  225. {
  226. Value = "",
  227. Text = "请选择",
  228. });
  229. foreach (RegionResult item in regionResult.Data.RowData.ToList())
  230. {
  231. kcmb_regionMsg.Items.Add(new ListItem
  232. {
  233. Value = item.REGION_CODE,
  234. Text = item.REGION_NAME,
  235. });
  236. }
  237. kcmb_regionMsg.SelectedIndex = 0;
  238. }
  239. else
  240. {
  241. kcmb_regionMsg.Items.Clear();
  242. KryptonMessageBox.Show(regionResult.Message);
  243. }
  244. //kcmb_regionMsg.Items.Add(new ListItem
  245. //{
  246. // Value = "Region01",
  247. // Text = "库区1",
  248. //});
  249. //kcmb_regionMsg.Items.Add(new ListItem
  250. //{
  251. // Value = "Region02",
  252. // Text = "库区2",
  253. //});
  254. //kcmb_regionMsg.SelectedIndex = 0;
  255. #endregion
  256. #region 物料类型
  257. var materielTypeResult = BaseServices.materielTypeService.GetList(new MaterielTypeSearchCondition { IsUsed = true, ItemSQL = "MATERIEL_TYPE_CODE,MATERIEL_TYPE_NAME" });
  258. if (materielTypeResult.Status == OperateStatus.Success)
  259. {
  260. kcmb_materielTypeMsg.Items.Clear();
  261. kcmb_materielTypeMsg.Items.Add(new ListItem
  262. {
  263. Value = "",
  264. Text = "请选择",
  265. });
  266. foreach (var item in materielTypeResult.Data.RowData.ToList())
  267. {
  268. kcmb_materielTypeMsg.Items.Add(new ListItem
  269. {
  270. Value = item.MATERIEL_TYPE_CODE,
  271. Text = item.MATERIEL_TYPE_NAME,
  272. });
  273. }
  274. kcmb_materielTypeMsg.SelectedIndex = 0;
  275. }
  276. else
  277. {
  278. kcmb_materielTypeMsg.Items.Clear();
  279. KryptonMessageBox.Show(materielTypeResult.Message);
  280. }
  281. //kcmb_materielTypeMsg.Items.Add(new ListItem
  282. //{
  283. // Value = "TestMaterielType001",
  284. // Text = "测试物料类型1",
  285. //});
  286. //kcmb_materielTypeMsg.Items.Add(new ListItem
  287. //{
  288. // Value = "TestMaterielType002",
  289. // Text = "测试物料类型2",
  290. //});
  291. //kcmb_materielTypeMsg.Items.Add(new ListItem
  292. //{
  293. // Value = "TestMaterielType003",
  294. // Text = "测试物料类型3",
  295. //});
  296. //kcmb_materielTypeMsg.Items.Add(new ListItem
  297. //{
  298. // Value = "TestMaterielType004",
  299. // Text = "测试物料类型4",
  300. //});
  301. //kcmb_materielTypeMsg.SelectedIndex = 0;
  302. #endregion
  303. #region 质检结果
  304. results = BasDictionaryUtil.basDictionaryResultLst.FindAll(x => x.DICTIONARY_CODE == "InspectionResultDesc");
  305. if (results.Count > 0)
  306. {
  307. kcmb_inspectionResultMsg.Items.Clear();
  308. kcmb_inspectionResultMsg.Items.Add(new ListItem
  309. {
  310. Value = "",
  311. Text = "请选择",
  312. });
  313. foreach (var item in results)
  314. {
  315. kcmb_inspectionResultMsg.Items.Add(new ListItem
  316. {
  317. Value = item.DICTIONARY_ITEM_CODE,
  318. Text = item.DICTIONARY_ITEM_NAME,
  319. });
  320. }
  321. kcmb_inspectionResultMsg.SelectedIndex = 0;
  322. }
  323. else
  324. {
  325. KryptonMessageBox.Show("未找到质检结果的字典项数据!");
  326. }
  327. #endregion
  328. }
  329. #endregion
  330. #region 查询质检单数据
  331. /// <summary>
  332. /// 查询质检单数据
  333. /// </summary>
  334. /// <param name="sender"></param>
  335. /// <param name="e"></param>
  336. private void kbtnSearch_Click(object sender, EventArgs e)
  337. {
  338. var loadfrm = new frmLoading();
  339. loadfrm.Show();
  340. var message = loadfrm.EventCalExec(LoadWmsQaInspectionData);
  341. }
  342. /// <summary>
  343. /// 刷新质检单的查询数据
  344. /// </summary>
  345. private void RefreshInspectionSearchData()
  346. {
  347. var loadfrm = new frmLoading();
  348. loadfrm.Show();
  349. var message = loadfrm.EventCalExec(LoadWmsQaInspectionData);
  350. if (!string.IsNullOrWhiteSpace(message))
  351. {
  352. KryptonMessageBox.Show($"查询失败!\r\n{message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  353. }
  354. }
  355. /// <summary>
  356. /// 调用服务端接口,请求质检单主表数据
  357. /// </summary>
  358. /// <returns></returns>
  359. private string LoadWmsQaInspectionData()
  360. {
  361. var result = WmsInspectionService.wmsQaInspectionService.GetWmsQaInspectionListForPage(new WmsQaInspectionSearchMd
  362. {
  363. InspectionNoMsg = ktb_inspectionNo.Text,
  364. BillNoMsg = ktb_sourceNo.Text,
  365. PalletNoMsg = ktb_palletNoMsg.Text,
  366. MaterielMsg = ktb_materielMsg.Text,
  367. RegionNoMsg = ((ListItem)kcmb_regionMsg.SelectedItem).Value,
  368. BinNoMsg = ktb_binMsg.Text,
  369. InspectionResultMsg = ((ListItem)kcmb_inspectionResultMsg.SelectedItem).Value,
  370. MaterielTypeMsg = ((ListItem)kcmb_materielTypeMsg.SelectedItem).Value,
  371. InspectionTypeMsg = ((ListItem)kcmb_inspectionType.SelectedItem).Value,
  372. InspectionStatusMsg = ((ListItem)kcmb_inspectionDtlStatus.SelectedItem).Value,
  373. SupplierMsg = ((ListItem)kcmb_supplierMsg.SelectedItem).Value,
  374. StartCreateMsg = kdtp_startCreateTime.Checked ? kdtp_startCreateTime.Value.ToString() : null,
  375. EndCreateMsg = kdtp_endCreateTime.Checked ? kdtp_endCreateTime.Value.ToString() : null,
  376. StartInspectionTimeMsg = kdtp_startInspectionTime.Checked ? kdtp_startInspectionTime.Value.ToString() : null,
  377. EndInspectionTimeMsg = kdtp_endInspectionTime.Checked ? kdtp_endInspectionTime.Value.ToString() : null,
  378. PageNum = this.pageToolbar1.PageIndex,
  379. EveryPageQty = this.pageToolbar1.PageSize,
  380. }); ; ;
  381. if (result.Status == OperateStatus.Success)
  382. {
  383. kdgv_WmsQaInspection.Columns.Clear();
  384. kdgv_WmsQaInspectionDtl.DataSource = null;
  385. //InspectionId = string.Empty;
  386. isControlInspectionDtlShow = false;
  387. kdgv_WmsQaInspection.DataSource = result.Data;
  388. kdgv_WmsQaInspection.BuildDataGridView(_clientFieldOrderList.GetFieldOrderDic());
  389. kdgv_WmsQaInspection.ClearSelection();
  390. isControlInspectionDtlShow = true;
  391. SetStatusCellBackColor(kdgv_WmsQaInspection, "INSPECTION_STATUS");
  392. this.pageToolbar1.DataCount = result.DataCount;
  393. ktb_inspectionNo.Focus();
  394. return string.Empty;
  395. }
  396. else
  397. {
  398. ktb_inspectionNo.Focus();
  399. return result.Message;
  400. }
  401. }
  402. #endregion
  403. #region 查询质检单明细表数据
  404. /// <summary>
  405. /// 质检单主表选中行事件
  406. /// </summary>
  407. /// <param name="sender"></param>
  408. /// <param name="e"></param>
  409. private void kdgv_WmsQaInspection_SelectionChanged(object sender, EventArgs e)
  410. {
  411. if (kdgv_WmsQaInspection.SelectedRows.Count > 0 && isControlInspectionDtlShow)
  412. {
  413. //InspectionId = kdgv_WmsQaInspection.SelectedRows[0].Cells[1].Value.ToString();
  414. int mainTableId = Convert.ToInt32(kdgv_WmsQaInspection.SelectedRows[0].Cells[1].Value);
  415. var loadfrm = new frmLoading();
  416. loadfrm.Show();
  417. var message = loadfrm.EventCalExecExt1(LoadWmsQaInspectionDtlData, mainTableId);
  418. if (!string.IsNullOrWhiteSpace(message))
  419. {
  420. KryptonMessageBox.Show($"查询失败!\r\n{message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  421. }
  422. }
  423. }
  424. /// <summary>
  425. /// 调用服务端接口,请求质检单明细表数据
  426. /// </summary>
  427. /// <returns></returns>
  428. private string LoadWmsQaInspectionDtlData(int mainTableId)
  429. {
  430. //if (string.IsNullOrEmpty(InspectionId))
  431. //{
  432. // return "请选择记录!";
  433. //}
  434. var result = WmsInspectionService.wmsQaInspectionService.GetWmsQaInspectionDtlListForId(new WmsQaInspectionResult { INSPECTION_ID = Convert.ToInt32(mainTableId), REMARKS1 = "查询已删除明细数据" });
  435. if (result.Status == OperateStatus.Success)
  436. {
  437. kdgv_WmsQaInspectionDtl.Columns.Clear();
  438. kdgv_WmsQaInspectionDtl.DataSource = result.Data.WmsQaInspectionDtlList;
  439. kdgv_WmsQaInspectionDtl.BuildDataGridView(_clientFieldOrderDtlList.GetFieldOrderDic(), true, false);
  440. kdgv_WmsQaInspectionDtl.ClearSelection();
  441. SetStatusCellBackColor(kdgv_WmsQaInspectionDtl, "INSPECTION_DTL_STATUS");
  442. return string.Empty;
  443. }
  444. else
  445. {
  446. return result.Message;
  447. }
  448. }
  449. #endregion
  450. #region 质检单增、删、改、强制完成、质检审核等操作
  451. /// <summary>
  452. /// 质检审核
  453. /// </summary>
  454. /// <param name="sender"></param>
  455. /// <param name="e"></param>
  456. private void kbtn_InspectionCheck_Click(object sender, EventArgs e)
  457. {
  458. int rowsSelectedNum = 0;
  459. string inspectionId = string.Empty;
  460. int rowSelectIndex = 0;
  461. foreach (DataGridViewRow item in kdgv_WmsQaInspection.Rows)
  462. {
  463. DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)item.Cells[0];
  464. object obj = checkCell.EditedFormattedValue;
  465. if (Convert.ToBoolean(obj))
  466. {
  467. rowsSelectedNum++;
  468. inspectionId = item.Cells[1].Value.ToString();
  469. rowSelectIndex = item.Index;
  470. }
  471. }
  472. if (rowsSelectedNum > 0)
  473. {
  474. if (rowsSelectedNum == 1)
  475. {
  476. int inspectionStatus = Convert.ToInt32(kdgv_WmsQaInspection.Rows[rowSelectIndex].Cells["INSPECTION_STATUS"].Value);
  477. if (inspectionStatus == (int)InspectionStatus.初始创建)
  478. {
  479. frmChildInspectionCheck frm = new frmChildInspectionCheck();
  480. frm.InspectionId = inspectionId;
  481. frm.ShowDialog();
  482. }
  483. else if (inspectionStatus < (int)InspectionStatus.质检完成)
  484. {
  485. KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单不处于【初始创建】状态,无法再次进行质检审核!");
  486. }
  487. else if (inspectionStatus == (int)InspectionStatus.强制完成)
  488. {
  489. KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单已被【强制完成】,无法再次进行质检审核!");
  490. }
  491. else if (inspectionStatus == (int)InspectionStatus.已删除)
  492. {
  493. KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单【已被删除】,无法再次进行质检审核!");
  494. }
  495. else if (inspectionStatus == (int)InspectionStatus.质检完成)
  496. {
  497. KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单【已完成】,无法再次进行质检审核!");
  498. }
  499. else
  500. {
  501. KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单状态【{inspectionStatus}】是未知的,无法进行质检审核!");
  502. }
  503. }
  504. else
  505. {
  506. KryptonMessageBox.Show("不能对勾选的多行数据进行质检审核,请重新勾选一行数据!");
  507. }
  508. }
  509. else
  510. {
  511. KryptonMessageBox.Show("请勾选要质检审核的数据行!");
  512. }
  513. }
  514. /// <summary>
  515. /// 新增质检单
  516. /// </summary>
  517. /// <param name="sender"></param>
  518. /// <param name="e"></param>
  519. private void kbtnAdd_Click(object sender, EventArgs e)
  520. {
  521. frmChildAddWmsQaInspection frm = new frmChildAddWmsQaInspection();
  522. frm.ShowDialog();
  523. }
  524. /// <summary>
  525. /// 编辑质检单
  526. /// </summary>
  527. /// <param name="sender"></param>
  528. /// <param name="e"></param>
  529. private void kbtnEdit_Click(object sender, EventArgs e)
  530. {
  531. int rowsSelectedNum = 0;
  532. string inspectionId = string.Empty;
  533. int rowSelectIndex = 0;
  534. foreach (DataGridViewRow item in kdgv_WmsQaInspection.Rows)
  535. {
  536. DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)item.Cells[0];
  537. object obj = checkCell.EditedFormattedValue;
  538. if (Convert.ToBoolean(obj))
  539. {
  540. rowsSelectedNum++;
  541. inspectionId = item.Cells[1].Value.ToString();
  542. rowSelectIndex = item.Index;
  543. }
  544. }
  545. if (rowsSelectedNum > 0)
  546. {
  547. if (rowsSelectedNum == 1)
  548. {
  549. int inspectionStatus = Convert.ToInt32(kdgv_WmsQaInspection.Rows[rowSelectIndex].Cells["INSPECTION_STATUS"].Value);
  550. if (inspectionStatus == (int)InspectionStatus.初始创建)
  551. {
  552. frmChildEditWmsQaInspection frm = new frmChildEditWmsQaInspection();
  553. frm.InspectionId = inspectionId;
  554. frm.ShowDialog();
  555. }
  556. else if (inspectionStatus < (int)InspectionStatus.质检完成)
  557. {
  558. KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单不处于【初始创建】状态,无法再次进行编辑!");
  559. }
  560. else if (inspectionStatus == (int)InspectionStatus.强制完成)
  561. {
  562. KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单已被【强制完成】,无法再次进行编辑!");
  563. }
  564. else if (inspectionStatus == (int)InspectionStatus.已删除)
  565. {
  566. KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单【已被删除】,无法再次进行编辑!");
  567. }
  568. else if (inspectionStatus == (int)InspectionStatus.质检完成)
  569. {
  570. KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单【已完成】,无法再次进行编辑!");
  571. }
  572. else
  573. {
  574. KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单状态【{inspectionStatus}】是未知的,无法进行编辑!");
  575. }
  576. }
  577. else
  578. {
  579. KryptonMessageBox.Show("不能对勾选的多行数据进行编辑,请重新勾选一行数据!");
  580. }
  581. }
  582. else
  583. {
  584. KryptonMessageBox.Show("请勾选要编辑的数据行!");
  585. }
  586. }
  587. /// <summary>
  588. /// 删除质检单
  589. /// </summary>
  590. /// <param name="sender"></param>
  591. /// <param name="e"></param>
  592. private void kbtnRemove_Click(object sender, EventArgs e)
  593. {
  594. }
  595. /// <summary>
  596. /// 强制完成质检单
  597. /// </summary>
  598. /// <param name="sender"></param>
  599. /// <param name="e"></param>
  600. private void kbtn_ForceFinish_Click(object sender, EventArgs e)
  601. {
  602. }
  603. #endregion
  604. #region 导入、导出、打印、重置条件质检单数据
  605. /// <summary>
  606. /// 重置质检单查询条件
  607. /// </summary>
  608. /// <param name="sender"></param>
  609. /// <param name="e"></param>
  610. private void kbtnReset_Click(object sender, EventArgs e)
  611. {
  612. ktb_inspectionNo.Text = "";
  613. ktb_sourceNo.Text = "";
  614. ktb_materielMsg.Text = "";
  615. ktb_binMsg.Text = "";
  616. ktb_palletNoMsg.Text = "";
  617. kcmb_inspectionType.SelectedIndex = 0;
  618. kcmb_inspectionDtlStatus.SelectedIndex = 0;
  619. kcmb_supplierMsg.SelectedIndex = 0;
  620. kcmb_inspectionResultMsg.SelectedIndex = 0;
  621. kcmb_materielTypeMsg.SelectedIndex = 0;
  622. kcmb_regionMsg.SelectedIndex = 0;
  623. kdtp_startCreateTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  624. kdtp_startCreateTime.Checked = false;
  625. kdtp_endCreateTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  626. kdtp_endCreateTime.Checked = false;
  627. kdtp_startInspectionTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  628. kdtp_startInspectionTime.Checked = false;
  629. kdtp_endInspectionTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  630. kdtp_endInspectionTime.Checked = false;
  631. }
  632. /// <summary>
  633. /// 导出质检单数据
  634. /// </summary>
  635. /// <param name="sender"></param>
  636. /// <param name="e"></param>
  637. private void kbtnExport_Click(object sender, EventArgs e)
  638. {
  639. List<string> inspectionIdList = new List<string>();
  640. foreach (DataGridViewRow item in kdgv_WmsQaInspection.Rows)
  641. {
  642. DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)item.Cells[0];
  643. object obj = checkCell.EditedFormattedValue;
  644. if (Convert.ToBoolean(obj))
  645. {
  646. inspectionIdList.Add(item.Cells[1].Value.ToString());
  647. }
  648. }
  649. if (inspectionIdList.Count > 0)
  650. {
  651. List<WmsQaInspectionResult> wmsQaInspectionList = new List<WmsQaInspectionResult>();
  652. foreach (string item in inspectionIdList)
  653. {
  654. var result = WmsInspectionService.wmsQaInspectionService.GetWmsQaInspectionDtlListForId(new WmsQaInspectionResult { INSPECTION_ID = Convert.ToInt32(item) });
  655. if (result.Status == OperateStatus.Success)
  656. {
  657. wmsQaInspectionList.Add(result.Data);
  658. }
  659. }
  660. NxExcelHelper.ExportToExcel(GetWmsInspectionExportExcelData(wmsQaInspectionList), "质检单数据");
  661. }
  662. else
  663. {
  664. KryptonMessageBox.Show("请勾选要导出的数据行!");
  665. }
  666. }
  667. private DataTable GetWmsInspectionExportExcelData(List<WmsQaInspectionResult> wmsQaInspectionList)
  668. {
  669. DataTable dt = new DataTable();
  670. #region 准备导出列名
  671. DataColumn dc = new DataColumn("质检单号");
  672. dt.Columns.Add(dc);
  673. dc = new DataColumn("质检单类型");
  674. dt.Columns.Add(dc);
  675. dc = new DataColumn("质检方式");
  676. dt.Columns.Add(dc);
  677. dc = new DataColumn("质检人");
  678. dt.Columns.Add(dc);
  679. dc = new DataColumn("质检时间");
  680. dt.Columns.Add(dc);
  681. dc = new DataColumn("物料类型编码");
  682. dt.Columns.Add(dc);
  683. dc = new DataColumn("物料类型名称");
  684. dt.Columns.Add(dc);
  685. dc = new DataColumn("物料编码");
  686. dt.Columns.Add(dc);
  687. dc = new DataColumn("物料名称");
  688. dt.Columns.Add(dc);
  689. dc = new DataColumn("物料条码");
  690. dt.Columns.Add(dc);
  691. dc = new DataColumn("规格");
  692. dt.Columns.Add(dc);
  693. dc = new DataColumn("单位");
  694. dt.Columns.Add(dc);
  695. dc = new DataColumn("批次号");
  696. dt.Columns.Add(dc);
  697. dc = new DataColumn("包装");
  698. dt.Columns.Add(dc);
  699. dc = new DataColumn("供应商编码");
  700. dt.Columns.Add(dc);
  701. dc = new DataColumn("供应商名称");
  702. dt.Columns.Add(dc);
  703. dc = new DataColumn("生产日期");
  704. dt.Columns.Add(dc);
  705. dc = new DataColumn("失效日期");
  706. dt.Columns.Add(dc);
  707. dc = new DataColumn("质检单明细状态");
  708. dt.Columns.Add(dc);
  709. dc = new DataColumn("质检结果");
  710. dt.Columns.Add(dc);
  711. dc = new DataColumn("物品状态");
  712. dt.Columns.Add(dc);
  713. #endregion
  714. foreach (WmsQaInspectionResult retreatMd in wmsQaInspectionList)
  715. {
  716. foreach (WmsQaInspectionDtlResult retreatDtlMd in retreatMd.WmsQaInspectionDtlList)
  717. {
  718. DataRow dr = dt.NewRow();
  719. dr["质检单号"] = retreatMd.INSPECTION_NO;
  720. dr["质检单类型"] = retreatMd.INSPECTION_TYPE_NAME;
  721. dr["质检方式"] = retreatMd.INSPECTION_WAY_NAME;
  722. dr["质检人"] = retreatMd.INSPECTION_USER;
  723. dr["质检时间"] = retreatMd.INSPECTION_TIME;
  724. dr["物料类型编码"] = retreatDtlMd.MATERIEL_TYPE_CODE;
  725. dr["物料类型名称"] = retreatDtlMd.MATERIEL_TYPE_NAME;
  726. dr["物料编码"] = retreatDtlMd.MATERIEL_CODE;
  727. dr["物料名称"] = retreatDtlMd.MATERIEL_NAME;
  728. dr["物料条码"] = retreatDtlMd.MATERIEL_BARCODE;
  729. dr["规格"] = retreatDtlMd.MATERIEL_SPEC;
  730. dr["单位"] = retreatDtlMd.UNIT_CODE;
  731. dr["批次号"] = retreatDtlMd.BATCH_NO;
  732. dr["包装"] = retreatDtlMd.PACKAGE_CODE;
  733. dr["供应商编码"] = retreatDtlMd.SUPPLIER_CODE;
  734. dr["供应商名称"] = retreatDtlMd.SUPPLIER_NAME;
  735. dr["生产日期"] = retreatDtlMd.PRODUCT_DATE;
  736. dr["失效日期"] = retreatDtlMd.EXP_DATE;
  737. dr["质检单明细状态"] = retreatDtlMd.INSPECTION_DTL_STATUS_NAME;
  738. dr["质检结果"] = retreatDtlMd.INSPECTION_RESULT_NAME;
  739. dr["物品状态"] = retreatDtlMd.ITEM_STATUS_NAME;
  740. dt.Rows.Add(dr);
  741. }
  742. }
  743. return dt;
  744. }
  745. private void kbtnImport_Click(object sender, EventArgs e)
  746. {
  747. }
  748. private void kbtnPrint_Click(object sender, EventArgs e)
  749. {
  750. }
  751. #endregion
  752. #region DataGridView 相关事件
  753. /// <summary>
  754. /// 设置DatatGridView的第一列复选框的背景色
  755. /// </summary>
  756. /// <param name="sender"></param>
  757. /// <param name="e"></param>
  758. private void kdgv_WmsQaInspection_CellContentClick(object sender, DataGridViewCellEventArgs e)
  759. {
  760. if (e.ColumnIndex == 0)
  761. {
  762. DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)kdgv_WmsQaInspection.CurrentCell;
  763. if (Convert.ToBoolean(checkCell.EditedFormattedValue))
  764. {
  765. kdgv_WmsQaInspection.CurrentCell.Style.BackColor = Color.FromArgb(51, 153, 255);
  766. }
  767. else
  768. {
  769. kdgv_WmsQaInspection.CurrentCell.Style.BackColor = Color.Transparent;
  770. }
  771. }
  772. }
  773. /// <summary>
  774. /// 设置状态列的背景色
  775. /// </summary>
  776. /// <param name="dataGridView">dataGridView控件</param>
  777. /// <param name="columnName">状态列的列名称</param>
  778. private void SetStatusCellBackColor(KryptonDataGridView dataGridView, string columnName)
  779. {
  780. foreach (DataGridViewRow item in dataGridView.Rows)
  781. {
  782. string inspectionDtlStatus = item.Cells[columnName].Value.ToString();
  783. switch (Enum.Parse(typeof(InspectionStatus), inspectionDtlStatus))
  784. {
  785. case InspectionStatus.初始创建:
  786. //item.Cells[columnName].Style.ForeColor = Color.White;
  787. item.Cells[columnName].Style.BackColor = Color.FromArgb(214, 228, 243);
  788. break;
  789. case InspectionStatus.质检审核:
  790. //item.Cells[columnName].Style.ForeColor = Color.White;
  791. item.Cells[columnName].Style.BackColor = Color.LightYellow;
  792. break;
  793. case InspectionStatus.质检中:
  794. //item.Cells[columnName].Style.ForeColor = Color.White;
  795. item.Cells[columnName].Style.BackColor = Color.LightGreen;
  796. break;
  797. case InspectionStatus.结果确认完成:
  798. //item.Cells[columnName].Style.ForeColor = Color.White;
  799. item.Cells[columnName].Style.BackColor = Color.LightBlue;
  800. break;
  801. case InspectionStatus.质检完成:
  802. //item.Cells[columnName].Style.ForeColor = Color.White;
  803. item.Cells[columnName].Style.BackColor = Color.LightGray;
  804. break;
  805. case InspectionStatus.强制完成:
  806. //item.Cells[columnName].Style.ForeColor = Color.White;
  807. item.Cells[columnName].Style.BackColor = Color.DarkGray;
  808. break;
  809. case InspectionStatus.已删除:
  810. //item.Cells[columnName].Style.ForeColor = Color.White;
  811. item.Cells[columnName].Style.BackColor = Color.FromArgb(255, 69, 0);
  812. break;
  813. default:
  814. break;
  815. }
  816. }
  817. }
  818. private void kdgv_WmsQaInspection_DataError(object sender, DataGridViewDataErrorEventArgs e)
  819. {
  820. }
  821. private void kdgv_WmsQaInspectionDtl_DataError(object sender, DataGridViewDataErrorEventArgs e)
  822. {
  823. }
  824. #endregion
  825. #region 鼠标右键单击事件
  826. /// <summary>
  827. /// 刷新明细表数据
  828. /// </summary>
  829. /// <param name="sender"></param>
  830. /// <param name="e"></param>
  831. private void 刷新ToolStripMenuItem1_Click(object sender, EventArgs e)
  832. {
  833. if (kdgv_WmsQaInspectionDtl.Rows.Count > 0)
  834. {
  835. if (kdgv_WmsQaInspection.SelectedRows.Count > 0 && isControlInspectionDtlShow)
  836. {
  837. //InspectionId = kdgv_WmsQaInspection.SelectedRows[0].Cells[1].Value.ToString();
  838. int mainTableId = Convert.ToInt32(kdgv_WmsQaInspection.SelectedRows[0].Cells[1].Value);
  839. var loadfrm = new frmLoading();
  840. loadfrm.Show();
  841. var message = loadfrm.EventCalExecExt1(LoadWmsQaInspectionDtlData, mainTableId);
  842. if (!string.IsNullOrWhiteSpace(message))
  843. {
  844. KryptonMessageBox.Show($"查询失败!\r\n{message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  845. }
  846. }
  847. }
  848. }
  849. /// <summary>
  850. /// 刷新主表数据
  851. /// </summary>
  852. /// <param name="sender"></param>
  853. /// <param name="e"></param>
  854. private void 刷新ToolStripMenuItem_Click(object sender, EventArgs e)
  855. {
  856. if (kdgv_WmsQaInspection.Rows.Count > 0)
  857. {
  858. RefreshInspectionSearchData();
  859. }
  860. }
  861. #endregion
  862. private void pageToolbar1_OnPageChange(int PageIndex, int PageSzie)
  863. {
  864. this.kbtnSearch_Click(null, null);
  865. }
  866. }
  867. }