123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914 |
- using ComponentFactory.Krypton.Toolkit;
- using NXWMS.Client.Code.Extends;
- using NXWMS.Client.Code.Models;
- using NXWMS.Client.Model.AppModels.Condition;
- using NXWMS.Client.Model.AppModels.Condition.Base;
- using NXWMS.Client.Model.AppModels.Condition.Common;
- using NXWMS.Client.Model.AppModels.Condition.Inspection;
- using NXWMS.Client.Model.AppModels.Result;
- using NXWMS.Client.Model.AppModels.Result.Base;
- using NXWMS.Client.Model.AppModels.Result.Common;
- using NXWMS.Client.Model.AppModels.Result.Inspection;
- using NXWMS.Client.Model.CoreModels;
- using NXWMS.Commons;
- using NXWMS.Forms.Inspection.frmInspectionChild;
- using NXWMS.Services;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Web.UI.WebControls;
- using System.Windows.Forms;
- namespace NXWMS.Forms.Inspection
- {
- /// <summary>
- /// 质检单窗体
- /// </summary>
- public partial class frmWmsQaInspection : KryptonForm
- {
- /// <summary>
- /// 窗体构造函数
- /// </summary>
- public frmWmsQaInspection()
- {
- InitializeComponent();
- // 获取窗体的全类名
- _CrrentClassName = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName;
- }
- #region 全局变量
- /// <summary>
- /// 客户端字段排序列表(质检单主表)
- /// </summary>
- private List<ClientFieldOrderResult> _clientFieldOrderList;
- /// <summary>
- /// 客户端字段排序列表(质检单单明细表)
- /// </summary>
- private List<ClientFieldOrderResult> _clientFieldOrderDtlList;
- /// <summary>
- /// 当前窗体类名
- /// </summary>
- private string _CrrentClassName;
- /// <summary>
- /// 质检单主键ID,用于记录主表选中行的主键信息。
- /// 目前由于 加载控件不能传递具有参数的函数,所以临时使用全局变量。
- /// ToDo:后续修改优化加载控件的实现方式,支持传递具有参数的函数。
- /// 孙亚龙 舍弃于2020年9月7日
- /// </summary>
- //string InspectionId = string.Empty;
- /// <summary>
- /// 用于控制明细表数据的加载时机。
- /// 由于主表DataGridView数据加载时,会默认触发选中项更改事件。这时候加载明细表数据会发生异常。
- /// 使用全局变量,控制明细表的数据的加载时机,只能在主表数据全部初始化完成后,并且选中了一行主表数据的时候。
- /// </summary>
- bool isControlInspectionDtlShow = false;
- /// <summary>
- /// 定义委托
- /// 用于执行刷新页面数据的函数
- /// </summary>
- public delegate void dlgRefreshFrmHost();
- /// <summary>
- /// 定义委托变量
- /// 用于绑定刷新页面数据的函数
- /// </summary>
- public static dlgRefreshFrmHost RefreshFrmHost;
-
- #endregion
- #region 初始化数据
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void frmWmsQaInspection_Load(object sender, EventArgs e)
- {
- #region 获取主、明细表的显示列信息
- //获取质检单主表数据源配置
- var result = ConfigServices.configService.GetDataViewOrderList(new ClientFieldOrderCondition { SourceCode = $"{_CrrentClassName}" });
- if (result.Status == OperateStatus.Success)
- {
- _clientFieldOrderList = result.Data;
- }
- //获取质检单明细表表数据源配置
- var resultDtl = ConfigServices.configService.GetDataViewOrderList(new ClientFieldOrderCondition { SourceCode = $"{_CrrentClassName}_Dtl" });
- if (resultDtl.Status == OperateStatus.Success)
- {
- _clientFieldOrderDtlList = resultDtl.Data;
- }
- #endregion
- InitComboBoxItemData();
- kdtp_startCreateTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
- kdtp_endCreateTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
- kdtp_startCreateTime.Checked = false;
- kdtp_endCreateTime.Checked = false;
- kdtp_startInspectionTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
- kdtp_endInspectionTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
- kdtp_startInspectionTime.Checked = false;
- kdtp_endInspectionTime.Checked = false;
-
- RefreshFrmHost = new dlgRefreshFrmHost(RefreshInspectionSearchData);
-
- }
- /// <summary>
- /// 初始化下拉列表数据
- /// </summary>
- private void InitComboBoxItemData()
- {
- /*
- ToDo:后续把下拉列表转为 后台获取数据,目前是写死的。 1:内部质检;2:外部质检;
- */
- List<BasDictionaryResult> results = new List<BasDictionaryResult>();
- #region 单据类型
- results = BasDictionaryUtil.basDictionaryResultLst.FindAll(x => x.DICTIONARY_CODE == "InspectionTypeDesc");
- if (results.Count > 0)
- {
- kcmb_inspectionType.Items.Clear();
- kcmb_inspectionType.Items.Add(new ListItem
- {
- Value = "",
- Text = "请选择",
- });
- foreach (var item in results)
- {
- kcmb_inspectionType.Items.Add(new ListItem
- {
- Value = item.DICTIONARY_ITEM_CODE,
- Text = item.DICTIONARY_ITEM_NAME,
- });
- }
- kcmb_inspectionType.SelectedIndex = 0;
- }
- else
- {
- KryptonMessageBox.Show("未找到质检单类型的字典项数据!");
- }
- #endregion
- #region 单据状态
- results = BasDictionaryUtil.basDictionaryResultLst.FindAll(x => x.DICTIONARY_CODE == "InspectionDtlStatusDesc");
- if (results.Count > 0)
- {
- kcmb_inspectionDtlStatus.Items.Clear();
- kcmb_inspectionDtlStatus.Items.Add(new ListItem
- {
- Value = "",
- Text = "请选择",
- });
- foreach (var item in results)
- {
- kcmb_inspectionDtlStatus.Items.Add(new ListItem
- {
- Value = item.DICTIONARY_ITEM_CODE,
- Text = item.DICTIONARY_ITEM_NAME,
- });
- }
- kcmb_inspectionDtlStatus.SelectedIndex = 0;
- }
- else
- {
- KryptonMessageBox.Show("未找到质检单明细状态的字典项数据!");
- }
- #endregion
- #region 供应商信息
- var result = BaseServices.supplierService.GetList(new SupplierSearchCondition
- {
- IsUsed = true,
- PageIndex = 1,
- PageSize = 10000
- });
- if (result.Status == OperateStatus.Success)
- {
- kcmb_supplierMsg.Items.Clear();
- kcmb_supplierMsg.Items.Add(new ListItem
- {
- Value = "",
- Text = "请选择",
- });
- foreach (SupplierResult item in result.Data.RowData.ToList())
- {
- kcmb_supplierMsg.Items.Add(new ListItem
- {
- Value = item.SUPPLIER_CODE,
- Text = item.SUPPLIER_NAME,
- });
- }
- kcmb_supplierMsg.SelectedIndex = 0;
- }
- else
- {
- kcmb_supplierMsg.Items.Clear();
- KryptonMessageBox.Show(result.Message);
- }
- //kcmb_supplierMsg.Items.Clear();
- //kcmb_supplierMsg.Items.Add(new ListItem
- //{
- // Value = "",
- // Text = "请选择",
- //});
- //kcmb_supplierMsg.Items.Add(new ListItem
- //{
- // Value = "WX_NXZB_001",
- // Text = "无锡南兴装备",
- //});
- //kcmb_supplierMsg.Items.Add(new ListItem
- //{
- // Value = "WX_NXZB_002",
- // Text = "东莞南兴装备",
- //});
- //kcmb_supplierMsg.SelectedIndex = 0;
- #endregion
- #region 库区
- var regionResult = BaseServices.regionService.GetList(new RegionSearchCondition { IsUsed = true, ItemSQL = "REGION_CODE,REGION_NAME,AREA_NAME,AREA_CODE,WAREHOUSE_CODE,WAREHOUSE_NAME" });
- if (regionResult.Status == OperateStatus.Success)
- {
- kcmb_regionMsg.Items.Clear();
- kcmb_regionMsg.Items.Add(new ListItem
- {
- Value = "",
- Text = "请选择",
- });
- foreach (RegionResult item in regionResult.Data.RowData.ToList())
- {
- kcmb_regionMsg.Items.Add(new ListItem
- {
- Value = item.REGION_CODE,
- Text = item.REGION_NAME,
- });
- }
- kcmb_regionMsg.SelectedIndex = 0;
- }
- else
- {
- kcmb_regionMsg.Items.Clear();
- KryptonMessageBox.Show(regionResult.Message);
- }
- //kcmb_regionMsg.Items.Add(new ListItem
- //{
- // Value = "Region01",
- // Text = "库区1",
- //});
- //kcmb_regionMsg.Items.Add(new ListItem
- //{
- // Value = "Region02",
- // Text = "库区2",
- //});
- //kcmb_regionMsg.SelectedIndex = 0;
- #endregion
- #region 物料类型
- var materielTypeResult = BaseServices.materielTypeService.GetList(new MaterielTypeSearchCondition { IsUsed = true, ItemSQL = "MATERIEL_TYPE_CODE,MATERIEL_TYPE_NAME" });
- if (materielTypeResult.Status == OperateStatus.Success)
- {
- kcmb_materielTypeMsg.Items.Clear();
- kcmb_materielTypeMsg.Items.Add(new ListItem
- {
- Value = "",
- Text = "请选择",
- });
- foreach (var item in materielTypeResult.Data.RowData.ToList())
- {
- kcmb_materielTypeMsg.Items.Add(new ListItem
- {
- Value = item.MATERIEL_TYPE_CODE,
- Text = item.MATERIEL_TYPE_NAME,
- });
- }
- kcmb_materielTypeMsg.SelectedIndex = 0;
- }
- else
- {
- kcmb_materielTypeMsg.Items.Clear();
- KryptonMessageBox.Show(materielTypeResult.Message);
- }
- //kcmb_materielTypeMsg.Items.Add(new ListItem
- //{
- // Value = "TestMaterielType001",
- // Text = "测试物料类型1",
- //});
- //kcmb_materielTypeMsg.Items.Add(new ListItem
- //{
- // Value = "TestMaterielType002",
- // Text = "测试物料类型2",
- //});
- //kcmb_materielTypeMsg.Items.Add(new ListItem
- //{
- // Value = "TestMaterielType003",
- // Text = "测试物料类型3",
- //});
- //kcmb_materielTypeMsg.Items.Add(new ListItem
- //{
- // Value = "TestMaterielType004",
- // Text = "测试物料类型4",
- //});
- //kcmb_materielTypeMsg.SelectedIndex = 0;
- #endregion
- #region 质检结果
- results = BasDictionaryUtil.basDictionaryResultLst.FindAll(x => x.DICTIONARY_CODE == "InspectionResultDesc");
- if (results.Count > 0)
- {
- kcmb_inspectionResultMsg.Items.Clear();
- kcmb_inspectionResultMsg.Items.Add(new ListItem
- {
- Value = "",
- Text = "请选择",
- });
- foreach (var item in results)
- {
- kcmb_inspectionResultMsg.Items.Add(new ListItem
- {
- Value = item.DICTIONARY_ITEM_CODE,
- Text = item.DICTIONARY_ITEM_NAME,
- });
- }
- kcmb_inspectionResultMsg.SelectedIndex = 0;
- }
- else
- {
- KryptonMessageBox.Show("未找到质检结果的字典项数据!");
- }
- #endregion
- }
-
- #endregion
- #region 查询质检单数据
- /// <summary>
- /// 查询质检单数据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void kbtnSearch_Click(object sender, EventArgs e)
- {
- var loadfrm = new frmLoading();
- loadfrm.Show();
- var message = loadfrm.EventCalExec(LoadWmsQaInspectionData);
-
- }
- /// <summary>
- /// 刷新质检单的查询数据
- /// </summary>
- private void RefreshInspectionSearchData()
- {
- var loadfrm = new frmLoading();
- loadfrm.Show();
- var message = loadfrm.EventCalExec(LoadWmsQaInspectionData);
- if (!string.IsNullOrWhiteSpace(message))
- {
- KryptonMessageBox.Show($"查询失败!\r\n{message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- /// <summary>
- /// 调用服务端接口,请求质检单主表数据
- /// </summary>
- /// <returns></returns>
- private string LoadWmsQaInspectionData()
- {
- var result = WmsInspectionService.wmsQaInspectionService.GetWmsQaInspectionListForPage(new WmsQaInspectionSearchMd
- {
- InspectionNoMsg = ktb_inspectionNo.Text,
- BillNoMsg = ktb_sourceNo.Text,
- PalletNoMsg = ktb_palletNoMsg.Text,
- MaterielMsg = ktb_materielMsg.Text,
- RegionNoMsg = ((ListItem)kcmb_regionMsg.SelectedItem).Value,
- BinNoMsg = ktb_binMsg.Text,
- InspectionResultMsg = ((ListItem)kcmb_inspectionResultMsg.SelectedItem).Value,
- MaterielTypeMsg = ((ListItem)kcmb_materielTypeMsg.SelectedItem).Value,
- InspectionTypeMsg = ((ListItem)kcmb_inspectionType.SelectedItem).Value,
- InspectionStatusMsg = ((ListItem)kcmb_inspectionDtlStatus.SelectedItem).Value,
- SupplierMsg = ((ListItem)kcmb_supplierMsg.SelectedItem).Value,
- StartCreateMsg = kdtp_startCreateTime.Checked ? kdtp_startCreateTime.Value.ToString() : null,
- EndCreateMsg = kdtp_endCreateTime.Checked ? kdtp_endCreateTime.Value.ToString() : null,
- StartInspectionTimeMsg = kdtp_startInspectionTime.Checked ? kdtp_startInspectionTime.Value.ToString() : null,
- EndInspectionTimeMsg = kdtp_endInspectionTime.Checked ? kdtp_endInspectionTime.Value.ToString() : null,
- PageNum = this.pageToolbar1.PageIndex,
- EveryPageQty = this.pageToolbar1.PageSize,
- }); ; ;
- if (result.Status == OperateStatus.Success)
- {
- kdgv_WmsQaInspection.Columns.Clear();
- kdgv_WmsQaInspectionDtl.DataSource = null;
- //InspectionId = string.Empty;
- isControlInspectionDtlShow = false;
- kdgv_WmsQaInspection.DataSource = result.Data;
- kdgv_WmsQaInspection.BuildDataGridView(_clientFieldOrderList.GetFieldOrderDic());
- kdgv_WmsQaInspection.ClearSelection();
- isControlInspectionDtlShow = true;
- SetStatusCellBackColor(kdgv_WmsQaInspection, "INSPECTION_STATUS");
- this.pageToolbar1.DataCount = result.DataCount;
- ktb_inspectionNo.Focus();
- return string.Empty;
- }
- else
- {
- ktb_inspectionNo.Focus();
- return result.Message;
- }
- }
- #endregion
- #region 查询质检单明细表数据
- /// <summary>
- /// 质检单主表选中行事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void kdgv_WmsQaInspection_SelectionChanged(object sender, EventArgs e)
- {
- if (kdgv_WmsQaInspection.SelectedRows.Count > 0 && isControlInspectionDtlShow)
- {
- //InspectionId = kdgv_WmsQaInspection.SelectedRows[0].Cells[1].Value.ToString();
- int mainTableId = Convert.ToInt32(kdgv_WmsQaInspection.SelectedRows[0].Cells[1].Value);
- var loadfrm = new frmLoading();
- loadfrm.Show();
- var message = loadfrm.EventCalExecExt1(LoadWmsQaInspectionDtlData, mainTableId);
- if (!string.IsNullOrWhiteSpace(message))
- {
- KryptonMessageBox.Show($"查询失败!\r\n{message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- }
- /// <summary>
- /// 调用服务端接口,请求质检单明细表数据
- /// </summary>
- /// <returns></returns>
- private string LoadWmsQaInspectionDtlData(int mainTableId)
- {
- //if (string.IsNullOrEmpty(InspectionId))
- //{
- // return "请选择记录!";
- //}
- var result = WmsInspectionService.wmsQaInspectionService.GetWmsQaInspectionDtlListForId(new WmsQaInspectionResult { INSPECTION_ID = Convert.ToInt32(mainTableId), REMARKS1 = "查询已删除明细数据" });
- if (result.Status == OperateStatus.Success)
- {
- kdgv_WmsQaInspectionDtl.Columns.Clear();
- kdgv_WmsQaInspectionDtl.DataSource = result.Data.WmsQaInspectionDtlList;
- kdgv_WmsQaInspectionDtl.BuildDataGridView(_clientFieldOrderDtlList.GetFieldOrderDic(), true, false);
- kdgv_WmsQaInspectionDtl.ClearSelection();
- SetStatusCellBackColor(kdgv_WmsQaInspectionDtl, "INSPECTION_DTL_STATUS");
- return string.Empty;
- }
- else
- {
- return result.Message;
- }
- }
- #endregion
- #region 质检单增、删、改、强制完成、质检审核等操作
- /// <summary>
- /// 质检审核
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void kbtn_InspectionCheck_Click(object sender, EventArgs e)
- {
- int rowsSelectedNum = 0;
- string inspectionId = string.Empty;
- int rowSelectIndex = 0;
- foreach (DataGridViewRow item in kdgv_WmsQaInspection.Rows)
- {
- DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)item.Cells[0];
- object obj = checkCell.EditedFormattedValue;
- if (Convert.ToBoolean(obj))
- {
- rowsSelectedNum++;
- inspectionId = item.Cells[1].Value.ToString();
- rowSelectIndex = item.Index;
- }
- }
- if (rowsSelectedNum > 0)
- {
- if (rowsSelectedNum == 1)
- {
- int inspectionStatus = Convert.ToInt32(kdgv_WmsQaInspection.Rows[rowSelectIndex].Cells["INSPECTION_STATUS"].Value);
- if (inspectionStatus == (int)InspectionStatus.初始创建)
- {
- frmChildInspectionCheck frm = new frmChildInspectionCheck();
- frm.InspectionId = inspectionId;
- frm.ShowDialog();
- }
- else if (inspectionStatus < (int)InspectionStatus.质检完成)
- {
- KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单不处于【初始创建】状态,无法再次进行质检审核!");
- }
- else if (inspectionStatus == (int)InspectionStatus.强制完成)
- {
- KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单已被【强制完成】,无法再次进行质检审核!");
- }
- else if (inspectionStatus == (int)InspectionStatus.已删除)
- {
- KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单【已被删除】,无法再次进行质检审核!");
- }
- else if (inspectionStatus == (int)InspectionStatus.质检完成)
- {
- KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单【已完成】,无法再次进行质检审核!");
- }
- else
- {
- KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单状态【{inspectionStatus}】是未知的,无法进行质检审核!");
- }
- }
- else
- {
- KryptonMessageBox.Show("不能对勾选的多行数据进行质检审核,请重新勾选一行数据!");
- }
- }
- else
- {
- KryptonMessageBox.Show("请勾选要质检审核的数据行!");
- }
- }
- /// <summary>
- /// 新增质检单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void kbtnAdd_Click(object sender, EventArgs e)
- {
- frmChildAddWmsQaInspection frm = new frmChildAddWmsQaInspection();
- frm.ShowDialog();
- }
- /// <summary>
- /// 编辑质检单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void kbtnEdit_Click(object sender, EventArgs e)
- {
- int rowsSelectedNum = 0;
- string inspectionId = string.Empty;
- int rowSelectIndex = 0;
- foreach (DataGridViewRow item in kdgv_WmsQaInspection.Rows)
- {
- DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)item.Cells[0];
- object obj = checkCell.EditedFormattedValue;
- if (Convert.ToBoolean(obj))
- {
- rowsSelectedNum++;
- inspectionId = item.Cells[1].Value.ToString();
- rowSelectIndex = item.Index;
- }
- }
- if (rowsSelectedNum > 0)
- {
- if (rowsSelectedNum == 1)
- {
- int inspectionStatus = Convert.ToInt32(kdgv_WmsQaInspection.Rows[rowSelectIndex].Cells["INSPECTION_STATUS"].Value);
- if (inspectionStatus == (int)InspectionStatus.初始创建)
- {
- frmChildEditWmsQaInspection frm = new frmChildEditWmsQaInspection();
- frm.InspectionId = inspectionId;
- frm.ShowDialog();
- }
- else if (inspectionStatus < (int)InspectionStatus.质检完成)
- {
- KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单不处于【初始创建】状态,无法再次进行编辑!");
- }
- else if (inspectionStatus == (int)InspectionStatus.强制完成)
- {
- KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单已被【强制完成】,无法再次进行编辑!");
- }
- else if (inspectionStatus == (int)InspectionStatus.已删除)
- {
- KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单【已被删除】,无法再次进行编辑!");
- }
- else if (inspectionStatus == (int)InspectionStatus.质检完成)
- {
- KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单【已完成】,无法再次进行编辑!");
- }
- else
- {
- KryptonMessageBox.Show($"第【{rowSelectIndex + 1}】行的质检单状态【{inspectionStatus}】是未知的,无法进行编辑!");
- }
- }
- else
- {
- KryptonMessageBox.Show("不能对勾选的多行数据进行编辑,请重新勾选一行数据!");
- }
- }
- else
- {
- KryptonMessageBox.Show("请勾选要编辑的数据行!");
- }
- }
- /// <summary>
- /// 删除质检单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void kbtnRemove_Click(object sender, EventArgs e)
- {
- }
- /// <summary>
- /// 强制完成质检单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void kbtn_ForceFinish_Click(object sender, EventArgs e)
- {
- }
- #endregion
- #region 导入、导出、打印、重置条件质检单数据
- /// <summary>
- /// 重置质检单查询条件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void kbtnReset_Click(object sender, EventArgs e)
- {
- ktb_inspectionNo.Text = "";
- ktb_sourceNo.Text = "";
- ktb_materielMsg.Text = "";
- ktb_binMsg.Text = "";
- ktb_palletNoMsg.Text = "";
- kcmb_inspectionType.SelectedIndex = 0;
- kcmb_inspectionDtlStatus.SelectedIndex = 0;
- kcmb_supplierMsg.SelectedIndex = 0;
- kcmb_inspectionResultMsg.SelectedIndex = 0;
- kcmb_materielTypeMsg.SelectedIndex = 0;
- kcmb_regionMsg.SelectedIndex = 0;
- kdtp_startCreateTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
- kdtp_startCreateTime.Checked = false;
- kdtp_endCreateTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
- kdtp_endCreateTime.Checked = false;
- kdtp_startInspectionTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
- kdtp_startInspectionTime.Checked = false;
- kdtp_endInspectionTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
- kdtp_endInspectionTime.Checked = false;
- }
- /// <summary>
- /// 导出质检单数据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void kbtnExport_Click(object sender, EventArgs e)
- {
- List<string> inspectionIdList = new List<string>();
- foreach (DataGridViewRow item in kdgv_WmsQaInspection.Rows)
- {
- DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)item.Cells[0];
- object obj = checkCell.EditedFormattedValue;
- if (Convert.ToBoolean(obj))
- {
- inspectionIdList.Add(item.Cells[1].Value.ToString());
- }
- }
- if (inspectionIdList.Count > 0)
- {
- List<WmsQaInspectionResult> wmsQaInspectionList = new List<WmsQaInspectionResult>();
- foreach (string item in inspectionIdList)
- {
- var result = WmsInspectionService.wmsQaInspectionService.GetWmsQaInspectionDtlListForId(new WmsQaInspectionResult { INSPECTION_ID = Convert.ToInt32(item) });
- if (result.Status == OperateStatus.Success)
- {
- wmsQaInspectionList.Add(result.Data);
- }
- }
- NxExcelHelper.ExportToExcel(GetWmsInspectionExportExcelData(wmsQaInspectionList), "质检单数据");
- }
- else
- {
- KryptonMessageBox.Show("请勾选要导出的数据行!");
- }
- }
- private DataTable GetWmsInspectionExportExcelData(List<WmsQaInspectionResult> wmsQaInspectionList)
- {
- DataTable dt = new DataTable();
- #region 准备导出列名
- DataColumn dc = new DataColumn("质检单号");
- dt.Columns.Add(dc);
- dc = new DataColumn("质检单类型");
- dt.Columns.Add(dc);
- dc = new DataColumn("质检方式");
- dt.Columns.Add(dc);
- dc = new DataColumn("质检人");
- dt.Columns.Add(dc);
- dc = new DataColumn("质检时间");
- dt.Columns.Add(dc);
- dc = new DataColumn("物料类型编码");
- dt.Columns.Add(dc);
- dc = new DataColumn("物料类型名称");
- dt.Columns.Add(dc);
- dc = new DataColumn("物料编码");
- dt.Columns.Add(dc);
- dc = new DataColumn("物料名称");
- dt.Columns.Add(dc);
- dc = new DataColumn("物料条码");
- dt.Columns.Add(dc);
- dc = new DataColumn("规格");
- dt.Columns.Add(dc);
- dc = new DataColumn("单位");
- dt.Columns.Add(dc);
- dc = new DataColumn("批次号");
- dt.Columns.Add(dc);
- dc = new DataColumn("包装");
- dt.Columns.Add(dc);
- dc = new DataColumn("供应商编码");
- dt.Columns.Add(dc);
- dc = new DataColumn("供应商名称");
- dt.Columns.Add(dc);
- dc = new DataColumn("生产日期");
- dt.Columns.Add(dc);
- dc = new DataColumn("失效日期");
- dt.Columns.Add(dc);
- dc = new DataColumn("质检单明细状态");
- dt.Columns.Add(dc);
- dc = new DataColumn("质检结果");
- dt.Columns.Add(dc);
- dc = new DataColumn("物品状态");
- dt.Columns.Add(dc);
- #endregion
- foreach (WmsQaInspectionResult retreatMd in wmsQaInspectionList)
- {
- foreach (WmsQaInspectionDtlResult retreatDtlMd in retreatMd.WmsQaInspectionDtlList)
- {
- DataRow dr = dt.NewRow();
- dr["质检单号"] = retreatMd.INSPECTION_NO;
- dr["质检单类型"] = retreatMd.INSPECTION_TYPE_NAME;
- dr["质检方式"] = retreatMd.INSPECTION_WAY_NAME;
- dr["质检人"] = retreatMd.INSPECTION_USER;
- dr["质检时间"] = retreatMd.INSPECTION_TIME;
- dr["物料类型编码"] = retreatDtlMd.MATERIEL_TYPE_CODE;
- dr["物料类型名称"] = retreatDtlMd.MATERIEL_TYPE_NAME;
- dr["物料编码"] = retreatDtlMd.MATERIEL_CODE;
- dr["物料名称"] = retreatDtlMd.MATERIEL_NAME;
- dr["物料条码"] = retreatDtlMd.MATERIEL_BARCODE;
- dr["规格"] = retreatDtlMd.MATERIEL_SPEC;
- dr["单位"] = retreatDtlMd.UNIT_CODE;
- dr["批次号"] = retreatDtlMd.BATCH_NO;
- dr["包装"] = retreatDtlMd.PACKAGE_CODE;
- dr["供应商编码"] = retreatDtlMd.SUPPLIER_CODE;
- dr["供应商名称"] = retreatDtlMd.SUPPLIER_NAME;
- dr["生产日期"] = retreatDtlMd.PRODUCT_DATE;
- dr["失效日期"] = retreatDtlMd.EXP_DATE;
- dr["质检单明细状态"] = retreatDtlMd.INSPECTION_DTL_STATUS_NAME;
- dr["质检结果"] = retreatDtlMd.INSPECTION_RESULT_NAME;
- dr["物品状态"] = retreatDtlMd.ITEM_STATUS_NAME;
- dt.Rows.Add(dr);
- }
- }
- return dt;
- }
- private void kbtnImport_Click(object sender, EventArgs e)
- {
- }
- private void kbtnPrint_Click(object sender, EventArgs e)
- {
- }
- #endregion
- #region DataGridView 相关事件
- /// <summary>
- /// 设置DatatGridView的第一列复选框的背景色
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void kdgv_WmsQaInspection_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.ColumnIndex == 0)
- {
- DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)kdgv_WmsQaInspection.CurrentCell;
- if (Convert.ToBoolean(checkCell.EditedFormattedValue))
- {
- kdgv_WmsQaInspection.CurrentCell.Style.BackColor = Color.FromArgb(51, 153, 255);
- }
- else
- {
- kdgv_WmsQaInspection.CurrentCell.Style.BackColor = Color.Transparent;
- }
- }
- }
- /// <summary>
- /// 设置状态列的背景色
- /// </summary>
- /// <param name="dataGridView">dataGridView控件</param>
- /// <param name="columnName">状态列的列名称</param>
- private void SetStatusCellBackColor(KryptonDataGridView dataGridView, string columnName)
- {
- foreach (DataGridViewRow item in dataGridView.Rows)
- {
- string inspectionDtlStatus = item.Cells[columnName].Value.ToString();
- switch (Enum.Parse(typeof(InspectionStatus), inspectionDtlStatus))
- {
- case InspectionStatus.初始创建:
- //item.Cells[columnName].Style.ForeColor = Color.White;
- item.Cells[columnName].Style.BackColor = Color.FromArgb(214, 228, 243);
- break;
- case InspectionStatus.质检审核:
- //item.Cells[columnName].Style.ForeColor = Color.White;
- item.Cells[columnName].Style.BackColor = Color.LightYellow;
- break;
- case InspectionStatus.质检中:
- //item.Cells[columnName].Style.ForeColor = Color.White;
- item.Cells[columnName].Style.BackColor = Color.LightGreen;
- break;
- case InspectionStatus.结果确认完成:
- //item.Cells[columnName].Style.ForeColor = Color.White;
- item.Cells[columnName].Style.BackColor = Color.LightBlue;
- break;
- case InspectionStatus.质检完成:
- //item.Cells[columnName].Style.ForeColor = Color.White;
- item.Cells[columnName].Style.BackColor = Color.LightGray;
- break;
- case InspectionStatus.强制完成:
- //item.Cells[columnName].Style.ForeColor = Color.White;
- item.Cells[columnName].Style.BackColor = Color.DarkGray;
- break;
- case InspectionStatus.已删除:
- //item.Cells[columnName].Style.ForeColor = Color.White;
- item.Cells[columnName].Style.BackColor = Color.FromArgb(255, 69, 0);
- break;
- default:
- break;
- }
- }
- }
- private void kdgv_WmsQaInspection_DataError(object sender, DataGridViewDataErrorEventArgs e)
- {
- }
- private void kdgv_WmsQaInspectionDtl_DataError(object sender, DataGridViewDataErrorEventArgs e)
- {
- }
- #endregion
- #region 鼠标右键单击事件
- /// <summary>
- /// 刷新明细表数据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void 刷新ToolStripMenuItem1_Click(object sender, EventArgs e)
- {
- if (kdgv_WmsQaInspectionDtl.Rows.Count > 0)
- {
- if (kdgv_WmsQaInspection.SelectedRows.Count > 0 && isControlInspectionDtlShow)
- {
- //InspectionId = kdgv_WmsQaInspection.SelectedRows[0].Cells[1].Value.ToString();
- int mainTableId = Convert.ToInt32(kdgv_WmsQaInspection.SelectedRows[0].Cells[1].Value);
- var loadfrm = new frmLoading();
- loadfrm.Show();
- var message = loadfrm.EventCalExecExt1(LoadWmsQaInspectionDtlData, mainTableId);
- if (!string.IsNullOrWhiteSpace(message))
- {
- KryptonMessageBox.Show($"查询失败!\r\n{message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- }
- }
- /// <summary>
- /// 刷新主表数据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void 刷新ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (kdgv_WmsQaInspection.Rows.Count > 0)
- {
- RefreshInspectionSearchData();
- }
- }
- #endregion
- private void pageToolbar1_OnPageChange(int PageIndex, int PageSzie)
- {
- this.kbtnSearch_Click(null, null);
- }
- }
- }
|