123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- 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<RegionResult> _regionList;
- private int id;
- private EnumOperation _operation;
- private string _selectWarehouseCode;
- private string _selectAreaCode;
- private string _selectRegionCode;
- public FrmBinEdit()
- {
- InitializeComponent();
-
- }
-
- public List<RegionResult> 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<FieldValue>().GetFieldValueIdList<BinType>();
-
- cmbBinType.DataSource = fieldList;
- cmbBinType.DisplayMember = "Name";
- cmbBinType.ValueMember = "Id";
- cmbBinType.SelectedIndex = -1;
- //TODO 这是一个字典表,需要改
- fieldList = new List<FieldValue>();
- 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();
- }
- }
- }
|