using ComponentFactory.Krypton.Toolkit; using NXWMS.Client.FrmCustom; using NXWMS.Client.Model.AppModels.Condition.Instock; using NXWMS.Client.Model.AppModels.Result.Common; using NXWMS.Client.Model.AppModels.Result.Instock; using NXWMS.Client.Model.CoreModels; using NXWMS.Commons; 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.Web.UI.WebControls; using System.Windows.Forms; using static NXWMS.Client.FrmCustom.CustomEventMsg; namespace NXWMS.Forms.Instock.frmInstockChild { /// /// 新增上架单 /// public partial class frmChildAddWmsInPutAway : KryptonForm { /// /// 窗体构造函数 /// public frmChildAddWmsInPutAway() { InitializeComponent(); } #region 全局变量 private string CurrSourceNo { get; set; } private string CurrTrayCode { get; set; } #endregion #region 初始化数据 /// /// 窗体加载函数 /// /// /// private void frmChildAddWmsInPutAway_Load(object sender, EventArgs e) { InitComboBoxItemData(); InitCusPalletNoCmbMsg(); } /// /// 初始化下拉列表数据 /// private void InitComboBoxItemData() { /* ToDo:后续把下拉列表转为 后台获取数据,目前是写死的。 1:收货组盘自动上架;2:退料组盘自动上架;3:WMS端手动上架;4:手持端入库上架;5:质检入库上架;6:盘点入库上架 */ List results = new List(); #region 单据类型 results = BasDictionaryUtil.basDictionaryResultLst.FindAll(x => x.DICTIONARY_CODE == "PutAwayTypeDesc"); if (results.Count > 0) { kcmb_PutAwayType.Items.Clear(); foreach (var item in results) { kcmb_PutAwayType.Items.Add(new ListItem { Value = item.DICTIONARY_ITEM_CODE, Text = item.DICTIONARY_ITEM_NAME, }); } kcmb_PutAwayType.SelectedIndex = 0; } else { KryptonMessageBox.Show("未找到上架单类型的字典项数据!"); } #endregion } /// /// 自定义到货通知单下拉列表的数据行选择事件 /// /// /// void CusPalletNo_AfterSelector(object sender, AfterSelectorEventArgs e) { try { DataGridViewRow row = e.Value as DataGridViewRow; DataRowView dataRow = row.DataBoundItem as DataRowView; string palletNoMsg = dataRow["托盘号"].ToString().Trim(); string billNoMsg = dataRow["单据号"].ToString().Trim(); string billTypeMsg = dataRow["单据类型"].ToString().Trim(); kdgv_PutAwayDtlData.Rows.Clear(); if (billTypeMsg == "收货单") { var result = WmsInstockService.wmsInReceiptService.GetWmsInReceiptRecordListForPage(new WmsInReceiptRecordSearchMd { ReceiptNoMsg = billNoMsg, PalletNoMsg = palletNoMsg, ReceiptRecordStatus = "0", PageNum = 1, EveryPageQty =100 }); if (result.Status == OperateStatus.Success) { CurrSourceNo = result.Data[0].RECEIPT_NO; CurrTrayCode = result.Data[0].TRAY_CODE; foreach (WmsInReceiptRecordResult item in result.Data) { int index = kdgv_PutAwayDtlData.Rows.Add(); kdgv_PutAwayDtlData.Rows[index].Cells[0].Value = index + 1; kdgv_PutAwayDtlData.Rows[index].Cells[1].Value = item.MATERIEL_CODE; kdgv_PutAwayDtlData.Rows[index].Cells[2].Value = item.MATERIEL_NAME; kdgv_PutAwayDtlData.Rows[index].Cells[3].Value = item.MATERIEL_BARCODE; kdgv_PutAwayDtlData.Rows[index].Cells[4].Value = item.MATERIEL_SPEC; kdgv_PutAwayDtlData.Rows[index].Cells[5].Value = item.BATCH_NO; kdgv_PutAwayDtlData.Rows[index].Cells[6].Value = item.RECEIPT_QTY; kdgv_PutAwayDtlData.Rows[index].Cells[7].Value = item.UNIT_CODE; kdgv_PutAwayDtlData.Rows[index].Cells[8].Value = item.PACKAGE_CODE; kdgv_PutAwayDtlData.Rows[index].Cells[9].Value = item.SUPPLIER_CODE; kdgv_PutAwayDtlData.Rows[index].Cells[10].Value = item.SUPPLIER_NAME; kdgv_PutAwayDtlData.Rows[index].Cells[11].Value = item.PRODUCT_DATE; kdgv_PutAwayDtlData.Rows[index].Cells[12].Value = item.EXP_DATE; kdgv_PutAwayDtlData.Rows[index].Cells[13].Value = item.INSPECTION_RESULT_NAME; kdgv_PutAwayDtlData.Rows[index].Cells[14].Value = item.ITEM_STATUS_NAME; kdgv_PutAwayDtlData.Rows[index].Cells[15].Value = item.RECEIPT_RECORD_ID; kdgv_PutAwayDtlData.Rows[index].Cells[16].Value = item.INSPECTION_RESULT; kdgv_PutAwayDtlData.Rows[index].Cells[17].Value = item.ITEM_STATUS; } kcmb_PutAwayType.SelectedItem = new ListItem { Value = "1", Text = "收货组盘自动上架", }; } } else { var result = WmsInstockService.wmsInRetreatService.GetWmsInRetreatRecordListForPage(new WmsInRetreatRecordSearchMd { RetreatNoMsg = billNoMsg, PalletNoMsg = palletNoMsg, RetreatRecordStatus = "0", PageNum = 1, EveryPageQty = 100, }); if (result.Status == OperateStatus.Success) { CurrSourceNo = result.Data[0].RETREAT_NO; CurrTrayCode = result.Data[0].TRAY_CODE; foreach (WmsInRetreatRecordResult item in result.Data) { int index = kdgv_PutAwayDtlData.Rows.Add(); kdgv_PutAwayDtlData.Rows[index].Cells[0].Value = index + 1; kdgv_PutAwayDtlData.Rows[index].Cells[1].Value = item.MATERIEL_CODE; kdgv_PutAwayDtlData.Rows[index].Cells[2].Value = item.MATERIEL_NAME; kdgv_PutAwayDtlData.Rows[index].Cells[3].Value = item.MATERIEL_BARCODE; kdgv_PutAwayDtlData.Rows[index].Cells[4].Value = item.MATERIEL_SPEC; kdgv_PutAwayDtlData.Rows[index].Cells[5].Value = item.BATCH_NO; kdgv_PutAwayDtlData.Rows[index].Cells[6].Value = item.RETREAT_QTY; kdgv_PutAwayDtlData.Rows[index].Cells[7].Value = item.UNIT_CODE; kdgv_PutAwayDtlData.Rows[index].Cells[8].Value = item.PACKAGE_CODE; kdgv_PutAwayDtlData.Rows[index].Cells[9].Value = item.SUPPLIER_CODE; kdgv_PutAwayDtlData.Rows[index].Cells[10].Value = item.SUPPLIER_NAME; kdgv_PutAwayDtlData.Rows[index].Cells[11].Value = item.PRODUCT_DATE; kdgv_PutAwayDtlData.Rows[index].Cells[12].Value = item.EXP_DATE; kdgv_PutAwayDtlData.Rows[index].Cells[13].Value = item.INSPECTION_RESULT_NAME; kdgv_PutAwayDtlData.Rows[index].Cells[14].Value = item.ITEM_STATUS_NAME; kdgv_PutAwayDtlData.Rows[index].Cells[15].Value = item.RETREAT_RECORD_ID; kdgv_PutAwayDtlData.Rows[index].Cells[16].Value = item.INSPECTION_RESULT; kdgv_PutAwayDtlData.Rows[index].Cells[17].Value = item.ITEM_STATUS; } kcmb_PutAwayType.SelectedItem = new ListItem { Value = "2", Text = "退料组盘自动上架", }; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// /// 初始化自定义到货通知单下拉列表的数据 /// private void InitCusPalletNoCmbMsg() { cmb_CusPalletNo.sDisplayField = "托盘号,单据类型,单据号"; cmb_CusPalletNo.DisplayMember = "托盘号"; cmb_CusPalletNo.sKeyWords = "托盘号"; cmb_CusPalletNo.DataSource = CreateCusPalletNoTable(); cmb_CusPalletNo.RowFilterVisible = true; cmb_CusPalletNo.AfterSelector += new AfterSelectorEventHandler(CusPalletNo_AfterSelector); ; } /// /// 创建数据源表格 /// /// private DataTable CreateCusPalletNoTable() { DataTable dt = new DataTable(); DataColumn dc = new DataColumn("托盘号"); dt.Columns.Add(dc); dc = new DataColumn("单据类型"); dt.Columns.Add(dc); dc = new DataColumn("单据号"); dt.Columns.Add(dc); var result = WmsInstockService.wmsInPutAwayService.GetPutAwayPalletMsgList(); if (result.Status == OperateStatus.Success) { DataRow dr1 = dt.NewRow(); foreach (WmsInPutAwayPalletMsgResult item in result.Data) { DataRow dr = dt.NewRow(); dr["托盘号"] = item.PALLET_CODE; dr["单据类型"] = item.BillType; dr["单据号"] = item.BillNo; dt.Rows.Add(dr); } } return dt; } #endregion #region 按钮事件 /// /// 确认按钮事件 /// 提交添加完成的上架单数据 /// /// /// private void btnConfirm_Click(object sender, EventArgs e) { /* * ToDo: 后续增加托盘校验: 是否已经存在上架单信息。 */ WmsInPutAwayResult wmsInPutAwayResult = new WmsInPutAwayResult(); wmsInPutAwayResult.SOURCE_NO = CurrSourceNo; wmsInPutAwayResult.TRAY_CODE = CurrTrayCode; wmsInPutAwayResult.PALLET_CODE = cmb_CusPalletNo.Text; wmsInPutAwayResult.PUTAWAY_TYPE = Convert.ToInt32(((ListItem)kcmb_PutAwayType.SelectedItem).Value); wmsInPutAwayResult.PUTAWAY_PRIORITY = Convert.ToInt32(knud_PutAwayPriority.Value); wmsInPutAwayResult.EBIN_CODE = ktb_EbinNo.Text; wmsInPutAwayResult.DESCRIBE = ktb_Describe.Text; wmsInPutAwayResult.CREATE_BY = AppConfig.UserLoginResult.UserInfo.UserId; wmsInPutAwayResult.UPDATE_BY = AppConfig.UserLoginResult.UserInfo.UserId; List wmsInPutAwayDtlList = new List(); foreach (DataGridViewRow item in kdgv_PutAwayDtlData.Rows) { wmsInPutAwayDtlList.Add(new WmsInPutAwayDtlResult { MATERIEL_CODE = item.Cells[1].Value.ToString(), MATERIEL_NAME = item.Cells[2].Value.ToString(), MATERIEL_BARCODE = item.Cells[3].Value == null ? null : item.Cells[3].Value.ToString(), MATERIEL_SPEC = item.Cells[4].Value == null ? null : item.Cells[4].Value.ToString(), BATCH_NO = item.Cells[5].Value.ToString(), PUTAWAY_QTY = Convert.ToDecimal(item.Cells[6].Value), UNIT_CODE = item.Cells[7].Value.ToString(), PACKAGE_CODE = item.Cells[8].Value == null ? null: item.Cells[8].Value.ToString(), SUPPLIER_CODE = item.Cells[9].Value == null ? null : item.Cells[9].Value.ToString(), SUPPLIER_NAME = item.Cells[10].Value == null ? null : item.Cells[10].Value.ToString(), PRODUCT_DATE = Convert.ToDateTime(item.Cells[11].Value), EXP_DATE = Convert.ToDateTime(item.Cells[12].Value), INSPECTION_RESULT = item.Cells[16].Value.ToString(), ITEM_STATUS = Convert.ToInt32(item.Cells[17].Value), CREATE_BY = AppConfig.UserLoginResult.UserInfo.UserId, UPDATE_BY = AppConfig.UserLoginResult.UserInfo.UserId }); } wmsInPutAwayResult.WmsInPutAwayDtlList = wmsInPutAwayDtlList; var result = WmsInstockService.wmsInPutAwayService.AddWmsInPutAwayData(wmsInPutAwayResult); if (result.Status == OperateStatus.Success) { KryptonMessageBox.Show(result.Message); frmWmsInPutAway.RefreshFrmHost(); this.Close(); } else { KryptonMessageBox.Show(result.Message); } } /// /// 取消按钮事件 /// 退出新增界面 /// /// /// private void btnCancel_Click(object sender, EventArgs e) { this.Close(); } #endregion #region DataGridView相关事件 private void kdgv_PutAwayDtlData_DataError(object sender, DataGridViewDataErrorEventArgs e) { } #endregion } }