FrmSupplierEdit.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using ComponentFactory.Krypton.Toolkit;
  2. using NXWMS.Client.Model.AppModels.Condition.Base;
  3. using NXWMS.Client.Model.CoreModels;
  4. using NXWMS.Client.String.Enums;
  5. using NXWMS.Commons;
  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 FrmSupplierEdit : KryptonForm
  18. {
  19. private int _id;
  20. public EnumOperation operation { get; set; }
  21. public int Id { get => _id; set => _id = value; }
  22. public FrmSupplierEdit()
  23. {
  24. InitializeComponent();
  25. }
  26. public void InitControl()
  27. {
  28. //TODO 0805 以下所有配置都需要从数据库或者其它地方读取,这里暂时写死,后期加上配置表,联动查询
  29. var fieldList = new List<FieldValue>().GetFieldValueCodeList<SupplierType>();
  30. cmbSupplierType.DataSource = fieldList;
  31. cmbSupplierType.DisplayMember = "Name";
  32. cmbSupplierType.ValueMember = "Code";
  33. cmbSupplierType.SelectedIndex = -1;
  34. fieldList = new List<FieldValue>();
  35. fieldList.Add(new FieldValue { Code = "江苏省", Name = "江苏省" });
  36. cmbProvince.DataSource = fieldList;
  37. cmbProvince.DisplayMember = "Name";
  38. cmbProvince.ValueMember = "Code";
  39. cmbProvince.SelectedIndex = -1;
  40. fieldList = new List<FieldValue>();
  41. fieldList.Add(new FieldValue { Code = "无锡市", Name = "无锡市" });
  42. cmbCity.DataSource = fieldList;
  43. cmbCity.DisplayMember = "Name";
  44. cmbCity.ValueMember = "Code";
  45. cmbCity.SelectedIndex = -1;
  46. fieldList = new List<FieldValue>();
  47. fieldList.Add(new FieldValue { Code = "锡山区", Name = "锡山区" });
  48. cmbArea.DataSource = fieldList;
  49. cmbArea.DisplayMember = "Name";
  50. cmbArea.ValueMember = "Code";
  51. cmbArea.SelectedIndex = -1;
  52. }
  53. private void FrmSupplierEdit_Shown(object sender, EventArgs e)
  54. {
  55. }
  56. private void btnSave_Click(object sender, EventArgs e)
  57. {
  58. if (string.IsNullOrWhiteSpace(txtSupplierCode.Text))
  59. {
  60. KryptonMessageBox.Show($"请输入客户编码!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  61. return;
  62. }
  63. switch (operation)
  64. {
  65. case EnumOperation.Add:
  66. var addResult = BaseServices.supplierService.Add(new SupplierCondition
  67. {
  68. OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  69. IsUsed = chkUse.Checked,
  70. SupplierType = cmbSupplierType.SelectedValue == null ? "" :
  71. cmbSupplierType.SelectedValue.ToString(),
  72. Describe = richDescibe.Text,
  73. Address = txtAddress.Text,
  74. Area = cmbArea.Text,
  75. City = cmbCity.Text,
  76. Contract = txtContract.Text,
  77. ContractPhone = txtContractPhone.Text,
  78. SupplierCode = txtSupplierCode.Text,
  79. SupplierName = txtSupplierName.Text,
  80. PostalCode = txtPostalCode.Text,
  81. Province = cmbProvince.Text,
  82. Route = txtRoute.Text,
  83. Street = cmbStreet.Text,
  84. });
  85. if (addResult.Status == OperateStatus.Success)
  86. {
  87. KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  88. InitControl();
  89. groupOperation.Visible = false;
  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.supplierService.Edit(new SupplierCondition
  99. {
  100. OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  101. IsUsed = chkUse.Checked,
  102. SupplierType = cmbSupplierType.SelectedValue == null ? "" :
  103. cmbSupplierType.SelectedValue.ToString(),
  104. Describe = richDescibe.Text,
  105. Address = txtAddress.Text,
  106. Area = cmbArea.Text,
  107. City = cmbCity.Text,
  108. Contract = txtContract.Text,
  109. ContractPhone = txtContractPhone.Text,
  110. SupplierCode = txtSupplierCode.Text,
  111. SupplierName = txtSupplierName.Text,
  112. PostalCode = txtPostalCode.Text,
  113. Province = cmbProvince.Text,
  114. Route = txtRoute.Text,
  115. Street = cmbStreet.Text,
  116. Id = Id
  117. }); ;
  118. if (editResult.Status == OperateStatus.Success)
  119. {
  120. KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  121. InitControl();
  122. groupOperation.Visible = false;
  123. this.DialogResult = DialogResult.OK;
  124. }
  125. else
  126. {
  127. KryptonMessageBox.Show($"操作失败!\r\n{editResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  128. }
  129. break;
  130. }
  131. }
  132. private void btnExit_Click(object sender, EventArgs e)
  133. {
  134. this.DialogResult = DialogResult.Cancel;
  135. }
  136. }
  137. }