using ComponentFactory.Krypton.Toolkit; using NXWMS.Client.Model.AppModels.Condition.Base; using NXWMS.Client.Model.AppModels.Result.Base; using NXWMS.Client.Model.CoreModels; using NXWMS.Client.String.Enums; 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.Windows.Forms; namespace NXWMS.Forms.Base.ChildFrm { public partial class FrmBinEdit : KryptonForm { private List _regionList; private int id; private EnumOperation _operation; private string _selectWarehouseCode; private string _selectAreaCode; private string _selectRegionCode; public FrmBinEdit() { InitializeComponent(); } public List RegionList { get => _regionList; set => _regionList = value; } public int Id { get => id; set => id = value; } public EnumOperation Operation { get => _operation; set => _operation = value; } private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(cmbRegionCode.Text)) { KryptonMessageBox.Show($"请选择库区!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrWhiteSpace(txtBinCode.Text)) { KryptonMessageBox.Show($"请输入库位编码!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrWhiteSpace(txtBinName.Text)) { KryptonMessageBox.Show($"请输入库位名称!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrWhiteSpace(cmbBinType.Text)) { KryptonMessageBox.Show($"请选择库位类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } switch (Operation) { case EnumOperation.Add: var addResult = BaseServices.binService.Add(new BinCondition { OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId, IsUsed = chkUse.Checked, RegionCode = cmbRegionCode.SelectedValue == null ? "" : cmbRegionCode.SelectedValue.ToString(), DownShelfOrder = Convert.ToInt32(numDownShelfOrder.Value), BinCode = txtBinCode.Text, BinColumn = Convert.ToInt32(numBinColumn.Value), BinLayer = Convert.ToInt32(numBinLayer.Value), BinName = txtBinName.Text, BinRow = Convert.ToInt32(numBinRow.Value), BinType = cmbBinType.SelectedValue == null ? "" : cmbBinType.SelectedValue.ToString(), Height = numHeight.Value, IsBlendBatch = chkBlendBatch.Checked, IsBlendProduct = chkBlendProduct.Checked, Length = numLength.Value, NumberLimit = numNumberLimit.Value, PutShelfOrder = Convert.ToInt32(numPutShelfOrder.Value), ShelfCode = cmbShelf.SelectedValue == null ? "" : cmbShelf.SelectedValue.ToString(), TrarLimit = numTrarLimit.Value, VolumnLimit = numVolumeLimit.Value, WeightLimit = numWeightLimit.Value, Wide = numWide.Value, Describe = richDescibe.Text, WarehouseCode = _selectWarehouseCode, AreaCode = _selectAreaCode, }); if (addResult.Status == OperateStatus.Success) { KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; } else { KryptonMessageBox.Show($"操作失败!\r\n{addResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case EnumOperation.Edit: var editResult = BaseServices.binService.Edit(new BinCondition { OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId, IsUsed = chkUse.Checked, RegionCode = cmbRegionCode.SelectedValue == null ? "" : cmbRegionCode.SelectedValue.ToString(), DownShelfOrder = Convert.ToInt32(numDownShelfOrder.Value), BinCode = txtBinCode.Text, BinColumn = Convert.ToInt32(numBinColumn.Value), BinLayer = Convert.ToInt32(numBinLayer.Value), BinName = txtBinName.Text, BinRow = Convert.ToInt32(numBinRow.Value), BinType = cmbBinType.SelectedValue == null ? "" : cmbBinType.SelectedValue.ToString(), Height = numHeight.Value, IsBlendBatch = chkBlendBatch.Checked, IsBlendProduct = chkBlendProduct.Checked, Length = numLength.Value, NumberLimit = numNumberLimit.Value, PutShelfOrder = Convert.ToInt32(numPutShelfOrder.Value), ShelfCode = cmbShelf.SelectedValue == null ? "" : cmbShelf.SelectedValue.ToString(), TrarLimit = numTrarLimit.Value, VolumnLimit = numVolumeLimit.Value, WeightLimit = numWeightLimit.Value, Wide = numWide.Value, Describe = richDescibe.Text, WarehouseCode = _selectWarehouseCode, AreaCode = _selectAreaCode, Id = Id, }); if (editResult.Status == OperateStatus.Success) { KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; } else { KryptonMessageBox.Show($"操作失败!\r\n{editResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; } } public void InitControl() { CheckForIllegalCrossThreadCalls = false; cmbRegionCode.DataSource = _regionList; cmbRegionCode.DisplayMember = "REGION_NAME"; cmbRegionCode.ValueMember = "REGION_CODE"; cmbRegionCode.SelectedIndex = -1; var fieldList = new List().GetFieldValueIdList(); cmbBinType.DataSource = fieldList; cmbBinType.DisplayMember = "Name"; cmbBinType.ValueMember = "Id"; cmbBinType.SelectedIndex = -1; //TODO 这是一个字典表,需要改 fieldList = new List(); fieldList.Add(new FieldValue { Code = "Common", Name = "临时货架排" }); cmbShelf.DataSource = fieldList; cmbShelf.DisplayMember = "Name"; cmbShelf.ValueMember = "Code"; cmbShelf.SelectedIndex = -1; //_pageIndex = 1; //_pageSize = 20; } private void cmbRegionCode_SelectedIndexChanged(object sender, EventArgs e) { if (cmbRegionCode.SelectedValue != null) { var regionInfo = _regionList.Where(s => s.REGION_CODE == cmbRegionCode.SelectedValue.ToString()).FirstOrDefault(); if (regionInfo != null) { _selectAreaCode = regionInfo.AREA_CODE; _selectWarehouseCode = regionInfo.WAREHOUSE_CODE; lbWarehouse.Text = regionInfo.AREA_NAME; _selectRegionCode = regionInfo.REGION_CODE; lbRegion.Text = regionInfo.AREA_NAME; } } } private void FrmBinEdit_Shown(object sender, EventArgs e) { } private void btnExit_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; this.Close(); } } }