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.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 FrmMaterielEdit : KryptonForm { private List _materielTypeList; private int _id; public EnumOperation operation { get; set; } public FrmMaterielEdit() { InitializeComponent(); } public List MaterielTypeList { get => _materielTypeList; set => _materielTypeList = value; } public int Id { get => _id; set => _id = value; } public void InitControl() { cmbMaterielType.DataSource = _materielTypeList; cmbMaterielType.DisplayMember = "MATERIEL_TYPE_Name"; cmbMaterielType.ValueMember = "MATERIEL_TYPE_CODE"; cmbMaterielType.SelectedIndex = -1; } private void FrmMaterielEdit_Shown(object sender, EventArgs e) { } private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtMaterielCode.Text)) { KryptonMessageBox.Show($"请输入物品编码!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrWhiteSpace(cmbMaterielType.Text)) { KryptonMessageBox.Show($"请选择物品类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } switch (operation) { case EnumOperation.Add: var addResult = BaseServices.materielService.Add(new MaterielCondition { OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId, IsUsed = chkUse.Checked, Describe = richDescibe.Text, DelayEffectiveTime = Convert.ToInt32(numDelayEffectiveTime.Value), EffectiveTime = dtEffectiveTime.Value, Height = Convert.ToInt32(numHeight.Value), Length = Convert.ToInt32(numLength.Value), MaterielCode = txtMaterielCode.Text, MaterielName = txtMaterielName.Text, MaterielType = cmbMaterielType.SelectedValue == null ? "" : cmbMaterielType.SelectedValue.ToString(), MaxStock = numMaxStock.Value, MinStock = numMinStock.Value, OutboundEffectiveTime = dtOutboundEffectiveTime.Value, SpecsModel = txtSpecsModel.Text, UnitCode = cmbUnit.SelectedValue == null ? "" : cmbUnit.SelectedValue.ToString(), UnitPrice = numUnitPrice.Value, Volume = Convert.ToInt32(numVolume.Value), Weight = numWeight.Value, Wide = Convert.ToInt32(numWide.Value), }); 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.materielService.Edit(new MaterielCondition { OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId, IsUsed = chkUse.Checked, Describe = richDescibe.Text, DelayEffectiveTime = Convert.ToInt32(numDelayEffectiveTime.Value), EffectiveTime = dtEffectiveTime.Value, Height = Convert.ToInt32(numHeight.Value), Length = Convert.ToInt32(numLength.Value), MaterielCode = txtMaterielCode.Text, MaterielName = txtMaterielName.Text, MaterielType = cmbMaterielType.SelectedValue == null ? "" : cmbMaterielType.SelectedValue.ToString(), MaxStock = numMaxStock.Value, MinStock = numMinStock.Value, OutboundEffectiveTime = dtOutboundEffectiveTime.Value, SpecsModel = txtSpecsModel.Text, UnitCode = cmbUnit.SelectedValue == null ? "" : cmbUnit.SelectedValue.ToString(), UnitPrice = numUnitPrice.Value, Volume = Convert.ToInt32(numVolume.Value), Weight = numWeight.Value, Wide = Convert.ToInt32(numWeight.Value), Id = Id, }); if (editResult.Status == OperateStatus.Success) { KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); InitControl(); this.DialogResult = DialogResult.OK; } else { KryptonMessageBox.Show($"操作失败!\r\n{editResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; } } private void btnExit_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; this.Close(); } } }