frmBalanceInventory.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. using ComponentFactory.Krypton.Toolkit;
  2. using NXWMS.Client.Code.Extends;
  3. using NXWMS.Client.Model.AppModels.Condition.Balance;
  4. using NXWMS.Client.Model.AppModels.Condition.Base;
  5. using NXWMS.Client.Model.AppModels.Result;
  6. using NXWMS.Client.Model.AppModels.Result.Balance;
  7. using NXWMS.Client.Model.AppModels.Result.Base;
  8. using NXWMS.Client.Model.CoreModels;
  9. using NXWMS.Client.String.Enums;
  10. using NXWMS.Commons;
  11. using NXWMS.Forms.Balance.frmBalanceChild;
  12. using NXWMS.Services;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.ComponentModel;
  16. using System.Data;
  17. using System.Drawing;
  18. using System.Linq;
  19. using System.Text;
  20. using System.Windows.Forms;
  21. namespace NXWMS.Forms.Balance
  22. {
  23. public partial class frmBalanceInventory : KryptonForm
  24. {
  25. /// <summary>
  26. /// 客户端字段排序列表
  27. /// </summary>
  28. private List<ClientFieldOrderResult> _clientFieldOrderList;
  29. /// <summary>
  30. /// 客户端字段排序列表
  31. /// </summary>
  32. private List<ClientFieldOrderResult> _clientDTLFieldOrderList;
  33. /// <summary>
  34. /// 界面最后执行操作
  35. /// </summary>
  36. private EnumOperation _LastOperation;
  37. /// <summary>
  38. /// 库区
  39. /// </summary>
  40. private List<RegionResult> regionList;
  41. /// <summary>
  42. /// 供应商
  43. /// </summary>
  44. private List<SupplierResult> supplierList;
  45. public frmBalanceInventory()
  46. {
  47. InitializeComponent();
  48. this.dataGridView.AutoGenerateColumns = false;
  49. InitData();
  50. InitControl();
  51. }
  52. /// <summary>
  53. /// 控件初始化
  54. /// </summary>
  55. private void InitControl()
  56. {
  57. CheckForIllegalCrossThreadCalls = false;
  58. dataGridView.AddColumnCheck(0, "Check", "选择");
  59. //dataGridView.BuildDataGridView(CommonUtil.GetFieldOrderDic(_clientFieldOrderList), false);
  60. //dataGridView.CellClick += new DataGridViewCellEventHandler(dataGridView_CellClick);
  61. //dataGridViewDTL.BuildDataGridView(CommonUtil.GetFieldOrderDic(_clientDTLFieldOrderList), false);
  62. var fieldList = new List<FieldValue>().Add<FieldValue>(new FieldValue { Code = "", Name = "全部" });
  63. cmbSearchSupplier.DataSource = fieldList.GetFieldValueIdList(supplierList, "SUPPLIER_ID", "SUPPLIER_NAME");
  64. cmbSearchSupplier.DisplayMember = "Name";
  65. cmbSearchSupplier.ValueMember = "Id";
  66. cmbSearchSupplier.SelectedIndex = -1;
  67. fieldList = new List<FieldValue>().Add<FieldValue>(new FieldValue { Id = "", Name = "全部" });
  68. cmbSearchType.DataSource = fieldList.GetFieldValueIdList<InventoryType>();
  69. cmbSearchType.DisplayMember = "Name";
  70. cmbSearchType.ValueMember = "Id";
  71. cmbSearchType.SelectedIndex = -1;
  72. fieldList = new List<FieldValue>().Add<FieldValue>(new FieldValue { Id = "", Name = "全部" });
  73. cmbSearchInventoryStatus.DataSource = fieldList.GetFieldValueIdList<InventoryStatusEnum>();
  74. cmbSearchInventoryStatus.DisplayMember = "Name";
  75. cmbSearchInventoryStatus.ValueMember = "Id";
  76. cmbSearchInventoryStatus.SelectedIndex = -1;
  77. fieldList = new List<FieldValue>().Add<FieldValue>(new FieldValue { Id = "", Name = "全部" });
  78. cmbSearchInventoryMode.DataSource = fieldList.GetFieldValueIdList<InventoryMode>();
  79. cmbSearchInventoryMode.DisplayMember = "Name";
  80. cmbSearchInventoryMode.ValueMember = "Id";
  81. cmbSearchInventoryMode.SelectedValue = -1;
  82. _pageIndex = 1;
  83. _pageSize = 20;
  84. }
  85. /// <summary>
  86. /// 数据初始化
  87. /// </summary>
  88. private void InitData()
  89. {
  90. var regionResult = BaseServices.regionService.GetList(new RegionSearchCondition { IsUsed = true, ItemSQL = "REGION_CODE,REGION_NAME" });
  91. if (regionResult.Status == OperateStatus.Success)
  92. {
  93. regionList = regionResult.Data.RowData.ToList();
  94. }
  95. var supplierResult = BaseServices.supplierService.GetList(new SupplierSearchCondition { IsUsed = true, ItemSQL = "SUPPLIER_CODE,SUPPLIER_NAME" });
  96. if (supplierResult.Status == OperateStatus.Success)
  97. {
  98. supplierList = supplierResult.Data.RowData.ToList();
  99. }
  100. //_clientFieldOrderList = new List<ClientFieldOrderResult>();
  101. //_clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "InventoryId", FieldDesc = "序号" });
  102. //_clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "InventoryNo", FieldDesc = "盘点单号" });
  103. //_clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "InventoryTypeName", FieldDesc = "单据类型" });
  104. //_clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "InventoryPercentage", FieldDesc = "随机盘点比例" });
  105. //_clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "InventoryModeName", FieldDesc = "盘点方式" });
  106. //_clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "InventoryBeginTime", FieldDesc = "盘点开始时间" });
  107. //_clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "InventoryEndTime", FieldDesc = "盘点结束时间" });
  108. //_clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "InventoryStatusName", FieldDesc = "盘点单状态" });
  109. //_clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "ResultFlagName", FieldDesc = "盘点结果确认标识" });
  110. //_clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "CreateName", FieldDesc = "创建人" });
  111. //_clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "CreateTime", FieldDesc = "创建时间" });
  112. //_clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "UpdateName", FieldDesc = "更新人" });
  113. //_clientFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "UpdateTime", FieldDesc = "更新时间" });
  114. _clientDTLFieldOrderList = new List<ClientFieldOrderResult>();
  115. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "MaterielCode", FieldDesc = "物料编码" });
  116. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "MaterielName", FieldDesc = "物料名称" });
  117. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "MaterielTypeCode", FieldDesc = "物料类型编码" });
  118. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "MaterielTypeName", FieldDesc = "物料类型名称" });
  119. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "SUPPLIER_NAME", FieldDesc = "供应商" });
  120. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "BatchNo", FieldDesc = "批次号" });
  121. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "Qty", FieldDesc = "账面数量" });
  122. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "ActualInventoryQty", FieldDesc = "实际盘点数量" });
  123. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "InventoryResultQty", FieldDesc = "盘点结果确认数量" });
  124. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "UnitName", FieldDesc = "单位" });
  125. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "WarehouseName", FieldDesc = "仓库" });
  126. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "RegionName", FieldDesc = "库区" });
  127. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "BinName", FieldDesc = "库位" });
  128. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "TrayCode", FieldDesc = "组盘码" });
  129. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "PalletCode", FieldDesc = "托盘号" });
  130. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "InventoryDetailStatusName", FieldDesc = "明细状态" });
  131. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "CreateName", FieldDesc = "创建人" });
  132. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "CreateTime", FieldDesc = "创建时间" });
  133. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "UpdateName", FieldDesc = "更新人" });
  134. _clientDTLFieldOrderList.Add(new ClientFieldOrderResult { FieldName = "UpdateTime", FieldDesc = "更新时间" });
  135. }
  136. private void btnSearch_Click(object sender, EventArgs e)
  137. {
  138. //dataGridView.DataSource = new List<InventoryMainSearchResult>();
  139. //dataGridViewDTL.DataSource = new List<InventoryDetailSearchResult>();
  140. //this.clearCkeck();
  141. _pageIndex = 1;
  142. var loadfrm = new frmLoading();
  143. loadfrm.Show();
  144. var message = loadfrm.EventCalExec(LoadSearch, this.pageTool.PageIndex, this.pageTool.PageSize);
  145. pageTool.DataCount = _totalCount;
  146. if (!string.IsNullOrWhiteSpace(message))
  147. {
  148. KryptonMessageBox.Show($"查询失败!\r\n{message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  149. }
  150. }
  151. private int _pageSize;
  152. private int _pageIndex;
  153. private int _totalCount;
  154. private string LoadSearch(int pageIndex, int pageSize)
  155. {
  156. this.dataGridView.SelectionChanged -= this.dataGridView_SelectionChanged;
  157. var result = BalanceServices.balanceSearchService.GetMainInventoryList(new InventoryMainSearchCondition
  158. {
  159. OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  160. InventoryBeginFinishDate = dtpSearchInventoryBeginFinishDate.GetDateTimeValue(),
  161. InventoryBeginStartDate = dtpSearchInventoryBeginStartDate.GetDateTimeValue(),
  162. InventoryEndFinishDate = dtpSearchInventoryEndFinishDate.GetDateTimeValue(),
  163. InventoryEndStartDate = dtpSearchInventoryEndStartDate.GetDateTimeValue(),
  164. InventoryMode = cmbSearchInventoryMode.SelectedValue.GetObjectToString(),
  165. InventoryStatus = cmbSearchInventoryStatus.SelectedValue.GetObjectToInt(),
  166. InventoryType = cmbSearchType.SelectedValue.GetObjectToString(),
  167. PalletInfo = txtSearchPallet.Text,
  168. SupplierCode = cmbSearchSupplier.SelectedValue.GetObjectToString(),
  169. BatchNo = txtSearchBatch.Text,
  170. MaterielInfo = txtSearchMateriel.Text,
  171. PageIndex = pageIndex,
  172. PageSize = pageSize
  173. });
  174. if (result.Status == OperateStatus.Success)
  175. {
  176. _totalCount = result.Data.TotalCount;
  177. _pageIndex = pageIndex;
  178. _pageSize = pageSize;
  179. if (result.Data.RowData.Any())
  180. {
  181. dataGridView.DataSource = result.Data.RowData.ToList();
  182. }
  183. else
  184. {
  185. if (dataGridView.DataSource != null)
  186. {
  187. dataGridView.DataSource = new List<InventoryMainSearchResult>();
  188. }
  189. }
  190. this.dataGridView.SelectionChanged += this.dataGridView_SelectionChanged;
  191. this.dataGridView_SelectionChanged(null, null);
  192. return string.Empty;
  193. }
  194. else
  195. {
  196. this.dataGridView.SelectionChanged += this.dataGridView_SelectionChanged;
  197. dataGridViewDTL.DataSource = null;
  198. return result.Message;
  199. }
  200. }
  201. private string LoadDTLSearch(int id, int pageIndex, int pageSize)
  202. {
  203. var result = BalanceServices.balanceSearchService.GetDetailInventoryList(new InventoryDetailSearchCondition
  204. {
  205. OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  206. Id = id,
  207. });
  208. if (result.Status == OperateStatus.Success)
  209. {
  210. if (result.Data.Any())
  211. {
  212. dataGridViewDTL.Columns.Clear();
  213. dataGridViewDTL.DataSource = result.Data.ToList();
  214. dataGridViewDTL.BuildDataGridView(CommonUtil.GetFieldOrderDic(_clientDTLFieldOrderList));
  215. }
  216. else
  217. {
  218. if (dataGridViewDTL.DataSource != null)
  219. {
  220. dataGridViewDTL.DataSource = new List<InventoryDetailSearchResult>();
  221. }
  222. dataGridViewDTL.BuildDataGridView(CommonUtil.GetFieldOrderDic(_clientDTLFieldOrderList), false);
  223. }
  224. return string.Empty;
  225. }
  226. else
  227. {
  228. return result.Message;
  229. }
  230. }
  231. private void btnSearchExport_Click(object sender, EventArgs e)
  232. {
  233. this.dataGridView.DataGridViewExport($"{AppConfig.CurrentMenu.FirstOrDefault().MenuName}列表" + DateTime.Now.ToString("yyyyMMddHH"));
  234. }
  235. private void btnAdd_Click(object sender, EventArgs e)
  236. {
  237. var form = new frmOperateBalanceInventory();
  238. form._FunctionType = frmOperateBalanceInventory.EnumFunctionType.Add;
  239. if (form.ShowDialog() == DialogResult.Yes)
  240. {
  241. btnSearch_Click(null, null);
  242. }
  243. }
  244. /// <summary>
  245. /// 当前页面操作的主键
  246. /// </summary>
  247. private string _PrimaryKey = "ColumInventoryId";
  248. /// <summary>
  249. /// 当前页面操作单号
  250. /// </summary>
  251. private string _PrimaryNo = "InventoryNo";
  252. private void btnEdit_Click(object sender, EventArgs e)
  253. {
  254. //SelectInit();
  255. if (this.dataGridView.SelectedRows.Count > 0)
  256. {
  257. var form = new frmOperateBalanceInventory();
  258. form._FunctionType = frmOperateBalanceInventory.EnumFunctionType.Edit;
  259. form._InventoryNo = SelectedNO;
  260. if (form.ShowDialog() == DialogResult.Yes)
  261. {
  262. btnSearch_Click(null, null);
  263. }
  264. }
  265. else
  266. {
  267. KryptonMessageBox.Show($"请选择记录!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  268. }
  269. }
  270. /// <summary>
  271. /// 选择行主键列表
  272. /// </summary>
  273. //private List<int> _CheckRowIdList = new List<int>();
  274. private void clearCkeck()
  275. {
  276. for (var n = 0; n < this.dataGridView.Rows.Count; n++)
  277. {
  278. if ((bool)this.dataGridView.Rows[n].Cells["Check"].Value)
  279. {
  280. this.dataGridView.Rows[n].Cells["Check"].Value = false;
  281. }
  282. }
  283. }
  284. private IEnumerable<int> _CheckRowIdList
  285. {
  286. get
  287. {
  288. var result = new List<int>();
  289. for (var n = 0; n < this.dataGridView.Rows.Count; n++)
  290. {
  291. if (Convert.ToBoolean(this.dataGridView.Rows[n].Cells["Check"].Value))
  292. {
  293. result.Add(Convert.ToInt32(this.dataGridView.Rows[n].Cells[this._PrimaryKey].Value));
  294. }
  295. }
  296. return result;
  297. }
  298. }
  299. private void btnRemove_Click(object sender, EventArgs e)
  300. {
  301. if (_CheckRowIdList.Count() == 0)
  302. {
  303. return;
  304. }
  305. if (KryptonMessageBox.Show($"确认删除选中数据?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
  306. {
  307. _LastOperation = EnumOperation.Remove;
  308. var editResult = BalanceServices.balanceOperateService.InventoryStatusChange(new InventoryStatusChangeCondition
  309. {
  310. OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  311. Ids = string.Join(",", _CheckRowIdList),
  312. InventoryStatus = InventoryStatusEnum.Deleted,
  313. });
  314. if (editResult.Status == OperateStatus.Success)
  315. {
  316. KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  317. btnSearch_Click(null, null);
  318. }
  319. else
  320. {
  321. KryptonMessageBox.Show($"操作失败!\r\n{editResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  322. }
  323. }
  324. }
  325. private void btnComplete_Click(object sender, EventArgs e)
  326. {
  327. if (this._CheckRowIdList.Count() == 0)
  328. {
  329. return;
  330. }
  331. if (_CheckRowIdList.Count() == 1)
  332. {
  333. if (KryptonMessageBox.Show($"确认强制完成选中盘点单数据吗?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
  334. {
  335. _LastOperation = EnumOperation.Remove;
  336. var editResult = BalanceServices.balanceOperateService.InventoryStatusChange(new InventoryStatusChangeCondition
  337. {
  338. OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  339. Ids = string.Join(",", _CheckRowIdList),
  340. InventoryStatus = InventoryStatusEnum.ForceEndInventor,
  341. InventoryModeMsg = "结束盘点"
  342. });
  343. if (editResult.Status == OperateStatus.Success)
  344. {
  345. KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  346. btnSearch_Click(null, null);
  347. }
  348. else
  349. {
  350. KryptonMessageBox.Show($"操作失败!\r\n{editResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  351. }
  352. }
  353. }
  354. else
  355. {
  356. KryptonMessageBox.Show($"只能选择一行盘点单数据!");
  357. }
  358. }
  359. private void btnInventoryConfirm_Click(object sender, EventArgs e)
  360. {
  361. if (this._CheckRowIdList.Count() == 0)
  362. {
  363. return;
  364. }
  365. if (_CheckRowIdList.Count() == 1)
  366. {
  367. for (int i = 0; i < dataGridView.Rows.Count; i++)
  368. {
  369. if (dataGridView.Rows[i].Cells["InventoryStatus"].Value.ToString() == "已确认")
  370. {
  371. KryptonMessageBox.Show($"盘点单已进行过盘点结果确认操作!!");
  372. return;
  373. }
  374. }
  375. var form = new frmOperateBalanceInventory();
  376. form._FunctionType = frmOperateBalanceInventory.EnumFunctionType.ResultConfirm;
  377. form._InventoryNo = SelectedNO;
  378. if (form.ShowDialog() == DialogResult.Yes)
  379. {
  380. btnSearch_Click(null, null);
  381. }
  382. }
  383. else
  384. {
  385. KryptonMessageBox.Show($"只能选择一行盘点单数据!");
  386. }
  387. }
  388. private void btnBeginInventory_Click(object sender, EventArgs e)
  389. {
  390. if (this._CheckRowIdList.Count() == 0)
  391. {
  392. return;
  393. }
  394. if (_CheckRowIdList.Count() == 1)
  395. {
  396. for (int i = 0; i < dataGridView.Rows.Count; i++)
  397. {
  398. if (Convert.ToBoolean(this.dataGridView.Rows[i].Cells["Check"].Value))
  399. {
  400. //InventoryStatus
  401. if (Convert.ToInt32(this.dataGridView.Rows[i].Cells["InventoryStatus"].Value) >= 88)
  402. {
  403. KryptonMessageBox.Show($"盘点单已经进行过正常盘点操作,不能再次盘点!");
  404. return;
  405. }
  406. }
  407. }
  408. FrmInventoryOperate frm = new FrmInventoryOperate();
  409. frm.InventoryId = _CheckRowIdList.ToList()[0].ToString();
  410. frm.InventoryModeMsg = "正常盘点";
  411. if (frm.ShowDialog() == DialogResult.Yes)
  412. {
  413. btnSearch_Click(null, null);
  414. }
  415. }
  416. else
  417. {
  418. KryptonMessageBox.Show($"只能选择一行盘点单数据!");
  419. }
  420. }
  421. private int SelectedID
  422. {
  423. get
  424. {
  425. if (this.dataGridView.SelectedRows.Count > 0)
  426. {
  427. return Convert.ToInt32(this.dataGridView.SelectedRows[0].Cells[_PrimaryKey].Value);
  428. }
  429. else
  430. {
  431. return -1;
  432. }
  433. }
  434. }
  435. private string SelectedNO
  436. {
  437. get
  438. {
  439. if (this.dataGridView.SelectedRows.Count > 0)
  440. {
  441. var no = this.dataGridView.SelectedRows[0].Cells[this._PrimaryNo].Value.ToString();
  442. return no;
  443. }
  444. else
  445. {
  446. return "";
  447. }
  448. }
  449. }
  450. private void btnDifferenceInventory_Click(object sender, EventArgs e)
  451. {
  452. if (this._CheckRowIdList.Count() == 0)
  453. {
  454. return;
  455. }
  456. if (_CheckRowIdList.Count() == 1)
  457. {
  458. for (int i = 0; i < dataGridView.Rows.Count; i++)
  459. {
  460. if (Convert.ToBoolean(this.dataGridView.Rows[i].Cells["Check"].Value))
  461. {
  462. //InventoryStatus
  463. if (Convert.ToInt32(this.dataGridView.Rows[i].Cells["InventoryStatus"].Value) < 88)
  464. {
  465. KryptonMessageBox.Show($"盘点单未进行过正常盘点操作,不能直接进行差异盘点!");
  466. return;
  467. }
  468. //InventoryStatus
  469. if (Convert.ToInt32(this.dataGridView.Rows[i].Cells["InventoryStatus"].Value) >= 99)
  470. {
  471. KryptonMessageBox.Show($"盘点单已经全部完成盘点操作,不能再次差异盘点!");
  472. return;
  473. }
  474. }
  475. }
  476. FrmInventoryOperate frm = new FrmInventoryOperate();
  477. frm.InventoryId = _CheckRowIdList.ToList()[0].ToString();
  478. frm.InventoryModeMsg = "差异盘点";
  479. if (frm.ShowDialog() == DialogResult.Yes)
  480. {
  481. btnSearch_Click(null, null);
  482. }
  483. }
  484. else
  485. {
  486. KryptonMessageBox.Show($"只能选择一行盘点单数据!");
  487. }
  488. #region 20210219 孙亚龙舍弃旧代码
  489. //if (SelectedID >= 0)
  490. //{
  491. // var detailResult = BalanceServices.balanceSearchService.GetDetailInventoryList(new InventoryDetailSearchCondition
  492. // {
  493. // Id = SelectedID
  494. // });
  495. // if (detailResult.Status == OperateStatus.Success)
  496. // {
  497. // if (detailResult.Data.Count > 0)
  498. // {
  499. // if (KryptonMessageBox.Show($"当前选中记录存在差异数量\r\n是否需要重新盘点?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
  500. // {
  501. // var editResult = BalanceServices.balanceOperateService.InventoryStatusChange(new InventoryStatusChangeCondition
  502. // {
  503. // OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  504. // Ids = string.Join(",", _CheckRowIdList),
  505. // InventoryStatus = InventoryStatus.BeginInventory,
  506. // });
  507. // if (editResult.Status == OperateStatus.Success)
  508. // {
  509. // var form = new frmOperateBalanceInventory();
  510. // form._FunctionType = frmOperateBalanceInventory.EnumFunctionType.InventorySecond;
  511. // form._InventoryNo = SelectedNO;
  512. // if (form.ShowDialog() == DialogResult.Yes)
  513. // {
  514. // btnSearch_Click(null, null);
  515. // }
  516. // // KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  517. // //btnSearch_Click(null, null);
  518. // }
  519. // else
  520. // {
  521. // KryptonMessageBox.Show($"操作失败!\r\n{editResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  522. // }
  523. // //var editResult = BalanceServices.balanceOperateService.InventoryStatusChange(new InventoryStatusChangeCondition
  524. // //{
  525. // // OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  526. // // Ids = string.Join(",", _CheckRowIdList),
  527. // // InventoryStatus = InventoryStatus.BeginInventory,
  528. // //});
  529. // //if (editResult.Status == OperateStatus.Success)
  530. // //{
  531. // // KryptonMessageBox.Show($"已更新成开始盘点!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  532. // // btnSearch_Click(null, null);
  533. // //}
  534. // //else
  535. // //{
  536. // // KryptonMessageBox.Show($"操作失败!\r\n{editResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  537. // //}
  538. // }
  539. // }
  540. // else
  541. // {
  542. // KryptonMessageBox.Show($"当前选中记录不存在差异数量,不需要差异盘点!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  543. // }
  544. // }
  545. // else
  546. // {
  547. // KryptonMessageBox.Show($"获取盘点差异失败!\r\n{detailResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  548. // }
  549. //}
  550. //else
  551. //{
  552. // KryptonMessageBox.Show($"请选择记录!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  553. //}
  554. #endregion
  555. }
  556. private void dataGridView_SelectionChanged(object sender, EventArgs e)
  557. {
  558. if (dataGridView.SelectedRows.Count > 0)
  559. {
  560. //int rowIndec = dgv_WmsInArrival.CurrentCell.RowIndex;
  561. //int columnIndex = dgv_WmsInArrival.CurrentCell.RowIndex;
  562. //arrivalId = dgv_WmsInArrival.SelectedRows[0].Cells[1].Value.ToString();
  563. int mainTableId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
  564. var message = frmLoading.ExecFun(() =>
  565. {
  566. return this.LoadDTLSearch(this.SelectedID, 0, 0);
  567. });
  568. // var message = loadfrm.EventCalExec(this.LoadDTLSearch,0,0);
  569. if (!string.IsNullOrWhiteSpace(message))
  570. {
  571. KryptonMessageBox.Show($"查询失败!\r\n{message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  572. }
  573. }
  574. }
  575. private void button1_Click(object sender, EventArgs e)
  576. {
  577. this.clearCkeck();
  578. }
  579. private void frmBalanceInventory_Load(object sender, EventArgs e)
  580. {
  581. this.btnSearch_Click(null, null);
  582. }
  583. }
  584. }