FrmBinEdit.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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.Commons;
  7. using NXWMS.Services;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.ComponentModel;
  11. using System.Data;
  12. using System.Drawing;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Windows.Forms;
  16. namespace NXWMS.Forms.Base.ChildFrm
  17. {
  18. public partial class FrmBinEdit : KryptonForm
  19. {
  20. private List<RegionResult> _regionList;
  21. private int id;
  22. private EnumOperation _operation;
  23. private string _selectWarehouseCode;
  24. private string _selectAreaCode;
  25. private string _selectRegionCode;
  26. public FrmBinEdit()
  27. {
  28. InitializeComponent();
  29. }
  30. public List<RegionResult> RegionList { get => _regionList; set => _regionList = value; }
  31. public int Id { get => id; set => id = value; }
  32. public EnumOperation Operation { get => _operation; set => _operation = value; }
  33. private void btnSave_Click(object sender, EventArgs e)
  34. {
  35. if (string.IsNullOrWhiteSpace(cmbRegionCode.Text))
  36. {
  37. KryptonMessageBox.Show($"请选择库区!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  38. return;
  39. }
  40. if (string.IsNullOrWhiteSpace(txtBinCode.Text))
  41. {
  42. KryptonMessageBox.Show($"请输入库位编码!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  43. return;
  44. }
  45. if (string.IsNullOrWhiteSpace(txtBinName.Text))
  46. {
  47. KryptonMessageBox.Show($"请输入库位名称!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  48. return;
  49. }
  50. if (string.IsNullOrWhiteSpace(cmbBinType.Text))
  51. {
  52. KryptonMessageBox.Show($"请选择库位类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  53. return;
  54. }
  55. switch (Operation)
  56. {
  57. case EnumOperation.Add:
  58. var addResult = BaseServices.binService.Add(new BinCondition
  59. {
  60. OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  61. IsUsed = chkUse.Checked,
  62. RegionCode = cmbRegionCode.SelectedValue == null ? "" :
  63. cmbRegionCode.SelectedValue.ToString(),
  64. DownShelfOrder = Convert.ToInt32(numDownShelfOrder.Value),
  65. BinCode = txtBinCode.Text,
  66. BinColumn = Convert.ToInt32(numBinColumn.Value),
  67. BinLayer = Convert.ToInt32(numBinLayer.Value),
  68. BinName = txtBinName.Text,
  69. BinRow = Convert.ToInt32(numBinRow.Value),
  70. BinType = cmbBinType.SelectedValue == null ? "" :
  71. cmbBinType.SelectedValue.ToString(),
  72. Height = numHeight.Value,
  73. IsBlendBatch = chkBlendBatch.Checked,
  74. IsBlendProduct = chkBlendProduct.Checked,
  75. Length = numLength.Value,
  76. NumberLimit = numNumberLimit.Value,
  77. PutShelfOrder = Convert.ToInt32(numPutShelfOrder.Value),
  78. ShelfCode = cmbShelf.SelectedValue == null ? "" : cmbShelf.SelectedValue.ToString(),
  79. TrarLimit = numTrarLimit.Value,
  80. VolumnLimit = numVolumeLimit.Value,
  81. WeightLimit = numWeightLimit.Value,
  82. Wide = numWide.Value,
  83. Describe = richDescibe.Text,
  84. WarehouseCode = _selectWarehouseCode,
  85. AreaCode = _selectAreaCode,
  86. });
  87. if (addResult.Status == OperateStatus.Success)
  88. {
  89. KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  90. this.DialogResult = DialogResult.OK;
  91. }
  92. else
  93. {
  94. KryptonMessageBox.Show($"操作失败!\r\n{addResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  95. }
  96. break;
  97. case EnumOperation.Edit:
  98. var editResult = BaseServices.binService.Edit(new BinCondition
  99. {
  100. OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  101. IsUsed = chkUse.Checked,
  102. RegionCode = cmbRegionCode.SelectedValue == null ? "" :
  103. cmbRegionCode.SelectedValue.ToString(),
  104. DownShelfOrder = Convert.ToInt32(numDownShelfOrder.Value),
  105. BinCode = txtBinCode.Text,
  106. BinColumn = Convert.ToInt32(numBinColumn.Value),
  107. BinLayer = Convert.ToInt32(numBinLayer.Value),
  108. BinName = txtBinName.Text,
  109. BinRow = Convert.ToInt32(numBinRow.Value),
  110. BinType = cmbBinType.SelectedValue == null ? "" :
  111. cmbBinType.SelectedValue.ToString(),
  112. Height = numHeight.Value,
  113. IsBlendBatch = chkBlendBatch.Checked,
  114. IsBlendProduct = chkBlendProduct.Checked,
  115. Length = numLength.Value,
  116. NumberLimit = numNumberLimit.Value,
  117. PutShelfOrder = Convert.ToInt32(numPutShelfOrder.Value),
  118. ShelfCode = cmbShelf.SelectedValue == null ? "" :
  119. cmbShelf.SelectedValue.ToString(),
  120. TrarLimit = numTrarLimit.Value,
  121. VolumnLimit = numVolumeLimit.Value,
  122. WeightLimit = numWeightLimit.Value,
  123. Wide = numWide.Value,
  124. Describe = richDescibe.Text,
  125. WarehouseCode = _selectWarehouseCode,
  126. AreaCode = _selectAreaCode,
  127. Id = Id,
  128. });
  129. if (editResult.Status == OperateStatus.Success)
  130. {
  131. KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  132. this.DialogResult = DialogResult.OK;
  133. }
  134. else
  135. {
  136. KryptonMessageBox.Show($"操作失败!\r\n{editResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  137. }
  138. break;
  139. }
  140. }
  141. public void InitControl()
  142. {
  143. CheckForIllegalCrossThreadCalls = false;
  144. cmbRegionCode.DataSource = _regionList;
  145. cmbRegionCode.DisplayMember = "REGION_NAME";
  146. cmbRegionCode.ValueMember = "REGION_CODE";
  147. cmbRegionCode.SelectedIndex = -1;
  148. var fieldList = new List<FieldValue>().GetFieldValueIdList<BinType>();
  149. cmbBinType.DataSource = fieldList;
  150. cmbBinType.DisplayMember = "Name";
  151. cmbBinType.ValueMember = "Id";
  152. cmbBinType.SelectedIndex = -1;
  153. //TODO 这是一个字典表,需要改
  154. fieldList = new List<FieldValue>();
  155. fieldList.Add(new FieldValue { Code = "Common", Name = "临时货架排" });
  156. cmbShelf.DataSource = fieldList;
  157. cmbShelf.DisplayMember = "Name";
  158. cmbShelf.ValueMember = "Code";
  159. cmbShelf.SelectedIndex = -1;
  160. //_pageIndex = 1;
  161. //_pageSize = 20;
  162. }
  163. private void cmbRegionCode_SelectedIndexChanged(object sender, EventArgs e)
  164. {
  165. if (cmbRegionCode.SelectedValue != null)
  166. {
  167. var regionInfo = _regionList.Where(s => s.REGION_CODE == cmbRegionCode.SelectedValue.ToString()).FirstOrDefault();
  168. if (regionInfo != null)
  169. {
  170. _selectAreaCode = regionInfo.AREA_CODE;
  171. _selectWarehouseCode = regionInfo.WAREHOUSE_CODE;
  172. lbWarehouse.Text = regionInfo.AREA_NAME;
  173. _selectRegionCode = regionInfo.REGION_CODE;
  174. lbRegion.Text = regionInfo.AREA_NAME;
  175. }
  176. }
  177. }
  178. private void FrmBinEdit_Shown(object sender, EventArgs e)
  179. {
  180. }
  181. private void btnExit_Click(object sender, EventArgs e)
  182. {
  183. DialogResult = DialogResult.Cancel;
  184. this.Close();
  185. }
  186. }
  187. }