FrmCustomerEdit.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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.Services;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Windows.Forms;
  14. namespace NXWMS.Forms.Base.ChildFrm
  15. {
  16. public partial class FrmCustomerEdit : KryptonForm
  17. {
  18. public int Id { get; set; }
  19. public EnumOperation operation { get; set; }
  20. public FrmCustomerEdit()
  21. {
  22. InitializeComponent();
  23. }
  24. private void btnExit_Click(object sender, EventArgs e)
  25. {
  26. this.DialogResult = DialogResult.Cancel;
  27. this.Close();
  28. }
  29. private void btnSave_Click(object sender, EventArgs e)
  30. {
  31. if (string.IsNullOrWhiteSpace(txtCustomerCode.Text))
  32. {
  33. KryptonMessageBox.Show($"请输入客户编码!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  34. return;
  35. }
  36. if (string.IsNullOrWhiteSpace(cmbCustomerType.Text))
  37. {
  38. KryptonMessageBox.Show($"请选择客户类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  39. return;
  40. }
  41. switch (operation)
  42. {
  43. case EnumOperation.Add:
  44. var addResult = BaseServices.customerService.Add(new CustomerCondition
  45. {
  46. OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  47. IsUsed = chkUse.Checked,
  48. CustomerType = cmbCustomerType.SelectedValue == null ? "" :
  49. cmbCustomerType.SelectedValue.ToString(),
  50. DefaultDistributionRule = txtDistributionRule.Text,
  51. DefaultPutShelfRule = txtPutRule.Text,
  52. Describe = richDescibe.Text,
  53. Address = txtAddress.Text,
  54. Area = cmbArea.Text,
  55. City = cmbCity.Text,
  56. Contract = txtContract.Text,
  57. ContractPhone = txtContractPhone.Text,
  58. CustomerCode = txtCustomerCode.Text,
  59. CustomerName = txtCustomerName.Text,
  60. PostalCode = txtPostalCode.Text,
  61. Province = cmbProvince.Text,
  62. Route = txtRoute.Text,
  63. Street = cmbStreet.Text,
  64. });
  65. if (addResult.Status == OperateStatus.Success)
  66. {
  67. KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  68. InitControl();
  69. groupOperation.Visible = false;
  70. this.DialogResult = DialogResult.OK;
  71. }
  72. else
  73. {
  74. KryptonMessageBox.Show($"操作失败!\r\n{addResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  75. }
  76. break;
  77. case EnumOperation.Edit:
  78. var editResult = BaseServices.customerService.Edit(new CustomerCondition
  79. {
  80. OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
  81. IsUsed = chkUse.Checked,
  82. CustomerType = cmbCustomerType.SelectedValue == null ? "" :
  83. cmbCustomerType.SelectedValue.ToString(),
  84. DefaultDistributionRule = txtDistributionRule.Text,
  85. DefaultPutShelfRule = txtPutRule.Text,
  86. Describe = richDescibe.Text,
  87. Address = txtAddress.Text,
  88. Area = cmbArea.Text,
  89. City = cmbCity.Text,
  90. Contract = txtContract.Text,
  91. ContractPhone = txtContractPhone.Text,
  92. CustomerCode = txtCustomerCode.Text,
  93. CustomerName = txtCustomerName.Text,
  94. PostalCode = txtPostalCode.Text,
  95. Province = cmbProvince.Text,
  96. Route = txtRoute.Text,
  97. Street = cmbStreet.Text,
  98. Id = this.Id,
  99. });
  100. if (editResult.Status == OperateStatus.Success)
  101. {
  102. KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  103. InitControl();
  104. groupOperation.Visible = false;
  105. this.DialogResult = DialogResult.OK;
  106. }
  107. else
  108. {
  109. KryptonMessageBox.Show($"操作失败!\r\n{editResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  110. }
  111. break;
  112. }
  113. }
  114. public void InitControl()
  115. {
  116. var fieldList = new List<FieldValue>();
  117. fieldList.Add(new FieldValue { Code = "Common", Name = "普通客户" });
  118. cmbCustomerType.DataSource = fieldList;
  119. cmbCustomerType.DisplayMember = "Name";
  120. cmbCustomerType.ValueMember = "Code";
  121. cmbCustomerType.SelectedIndex = -1;
  122. fieldList = new List<FieldValue>();
  123. fieldList.Add(new FieldValue { Code = "江苏省", Name = "江苏省" });
  124. cmbProvince.DataSource = fieldList;
  125. cmbProvince.DisplayMember = "Name";
  126. cmbProvince.ValueMember = "Code";
  127. cmbProvince.SelectedIndex = -1;
  128. fieldList = new List<FieldValue>();
  129. fieldList.Add(new FieldValue { Code = "无锡市", Name = "无锡市" });
  130. cmbCity.DataSource = fieldList;
  131. cmbCity.DisplayMember = "Name";
  132. cmbCity.ValueMember = "Code";
  133. cmbCity.SelectedIndex = -1;
  134. fieldList = new List<FieldValue>();
  135. fieldList.Add(new FieldValue { Code = "锡山区", Name = "锡山区" });
  136. cmbArea.DataSource = fieldList;
  137. cmbArea.DisplayMember = "Name";
  138. cmbArea.ValueMember = "Code";
  139. cmbArea.SelectedIndex = -1;
  140. }
  141. private void FrmCustomerEdit_Shown(object sender, EventArgs e)
  142. {
  143. }
  144. }
  145. }