123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- 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 FrmPalletEdit : KryptonForm
- {
- private int _id;
- public EnumOperation operation { get; set; }
- private List<PalletTypeResult> _palletTypeList;
-
- public int Id { get => _id; set => _id = value; }
- public List<PalletTypeResult> PalletTypeList { get => _palletTypeList; set => _palletTypeList = value; }
- public FrmPalletEdit()
- {
- InitializeComponent();
- }
- public void InitControl()
- {
-
- cmbPalletType.DataSource = _palletTypeList;
- cmbPalletType.DisplayMember = "PALLET_TYPE_NAME";
- cmbPalletType.ValueMember = "PALLET_TYPE_CODE";
- cmbPalletType.SelectedIndex = -1;
-
- }
- private void FrmPalletEdit_Shown(object sender, EventArgs e)
- {
- InitControl();
- }
- private void btnSave_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrWhiteSpace(txtPalletCode.Text))
- {
- KryptonMessageBox.Show($"请输入托盘编码!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (string.IsNullOrWhiteSpace(txtPalletName.Text))
- {
- KryptonMessageBox.Show($"请输入托盘名称!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (string.IsNullOrWhiteSpace(cmbPalletType.Text))
- {
- KryptonMessageBox.Show($"请选择托盘类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- switch (operation)
- {
- case EnumOperation.Add:
- var addResult = BaseServices.palletService.Add(new PalletCondition
- {
- OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
- IsUsed = chkUse.Checked,
- Describe = richDescibe.Text,
- PalletCode = txtPalletCode.Text,
- PalletName = txtPalletName.Text,
- PalletType = cmbPalletType.SelectedValue == null ? "" :
- cmbPalletType.SelectedValue.ToString(),
- }); ;
- if (addResult.Status == OperateStatus.Success)
- {
- KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- InitControl();
- groupOperation.Visible = false;
- this.DialogResult = DialogResult.OK;
- }
- else
- {
- KryptonMessageBox.Show($"操作失败!\r\n{addResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- break;
- case EnumOperation.Edit:
- var editResult = BaseServices.palletService.Edit(new PalletCondition
- {
- OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
- IsUsed = chkUse.Checked,
- Describe = richDescibe.Text,
- PalletCode = txtPalletCode.Text,
- PalletName = txtPalletName.Text,
- PalletType = cmbPalletType.SelectedValue == null ? "" :
- cmbPalletType.SelectedValue.ToString(),
- Id = Id
- });
- if (editResult.Status == OperateStatus.Success)
- {
- KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- InitControl();
- groupOperation.Visible = false;
- this.DialogResult = DialogResult.OK;
- }
- else
- {
- KryptonMessageBox.Show($"操作失败!\r\n{editResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- break;
- }
- }
- private void btnExit_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- }
- }
- }
|