FrmPalletEdit.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using ComponentFactory.Krypton.Toolkit;
  2. using NXWMS.Client.Model.AppModels.Condition.Base;
  3. using NXWMS.Client.Model.AppModels.Result.Base;
  4. using NXWMS.Client.Model.CoreModels;
  5. using NXWMS.Client.String.Enums;
  6. using NXWMS.Services;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. namespace NXWMS.Forms.Base.ChildFrm
  16. {
  17. public partial class FrmPalletEdit : KryptonForm
  18. {
  19. private int _id;
  20. public EnumOperation operation { get; set; }
  21. private List<PalletTypeResult> _palletTypeList;
  22. public int Id { get => _id; set => _id = value; }
  23. public List<PalletTypeResult> PalletTypeList { get => _palletTypeList; set => _palletTypeList = value; }
  24. public FrmPalletEdit()
  25. {
  26. InitializeComponent();
  27. }
  28. public void InitControl()
  29. {
  30. cmbPalletType.DataSource = _palletTypeList;
  31. cmbPalletType.DisplayMember = "PALLET_TYPE_NAME";
  32. cmbPalletType.ValueMember = "PALLET_TYPE_CODE";
  33. cmbPalletType.SelectedIndex = -1;
  34. }
  35. private void FrmPalletEdit_Shown(object sender, EventArgs e)
  36. {
  37. InitControl();
  38. }
  39. private void btnSave_Click(object sender, EventArgs e)
  40. {
  41. if (string.IsNullOrWhiteSpace(txtPalletCode.Text))
  42. {
  43. KryptonMessageBox.Show($"请输入托盘编码!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  44. return;
  45. }
  46. if (string.IsNullOrWhiteSpace(txtPalletName.Text))
  47. {
  48. KryptonMessageBox.Show($"请输入托盘名称!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  49. return;
  50. }
  51. if (string.IsNullOrWhiteSpace(cmbPalletType.Text))
  52. {
  53. KryptonMessageBox.Show($"请选择托盘类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  54. return;
  55. }
  56. switch (operation)
  57. {
  58. case EnumOperation.Add:
  59. var addResult = BaseServices.palletService.Add(new PalletCondition
  60. {
  61. OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  62. IsUsed = chkUse.Checked,
  63. Describe = richDescibe.Text,
  64. PalletCode = txtPalletCode.Text,
  65. PalletName = txtPalletName.Text,
  66. PalletType = cmbPalletType.SelectedValue == null ? "" :
  67. cmbPalletType.SelectedValue.ToString(),
  68. }); ;
  69. if (addResult.Status == OperateStatus.Success)
  70. {
  71. KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  72. InitControl();
  73. groupOperation.Visible = false;
  74. this.DialogResult = DialogResult.OK;
  75. }
  76. else
  77. {
  78. KryptonMessageBox.Show($"操作失败!\r\n{addResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  79. }
  80. break;
  81. case EnumOperation.Edit:
  82. var editResult = BaseServices.palletService.Edit(new PalletCondition
  83. {
  84. OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  85. IsUsed = chkUse.Checked,
  86. Describe = richDescibe.Text,
  87. PalletCode = txtPalletCode.Text,
  88. PalletName = txtPalletName.Text,
  89. PalletType = cmbPalletType.SelectedValue == null ? "" :
  90. cmbPalletType.SelectedValue.ToString(),
  91. Id = Id
  92. });
  93. if (editResult.Status == OperateStatus.Success)
  94. {
  95. KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  96. InitControl();
  97. groupOperation.Visible = false;
  98. this.DialogResult = DialogResult.OK;
  99. }
  100. else
  101. {
  102. KryptonMessageBox.Show($"操作失败!\r\n{editResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  103. }
  104. break;
  105. }
  106. }
  107. private void btnExit_Click(object sender, EventArgs e)
  108. {
  109. this.DialogResult = DialogResult.Cancel;
  110. }
  111. }
  112. }