123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- using ComponentFactory.Krypton.Toolkit;
- using NXWMS.Client.Model.AppModels.Condition.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 FrmCustomerEdit : KryptonForm
- {
- public int Id { get; set; }
- public EnumOperation operation { get; set; }
- public FrmCustomerEdit()
- {
- InitializeComponent();
-
- }
- private void btnExit_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- this.Close();
- }
- private void btnSave_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrWhiteSpace(txtCustomerCode.Text))
- {
- KryptonMessageBox.Show($"请输入客户编码!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (string.IsNullOrWhiteSpace(cmbCustomerType.Text))
- {
- KryptonMessageBox.Show($"请选择客户类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- switch (operation)
- {
- case EnumOperation.Add:
- var addResult = BaseServices.customerService.Add(new CustomerCondition
- {
- OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
- IsUsed = chkUse.Checked,
- CustomerType = cmbCustomerType.SelectedValue == null ? "" :
- cmbCustomerType.SelectedValue.ToString(),
- DefaultDistributionRule = txtDistributionRule.Text,
- DefaultPutShelfRule = txtPutRule.Text,
- Describe = richDescibe.Text,
- Address = txtAddress.Text,
- Area = cmbArea.Text,
- City = cmbCity.Text,
- Contract = txtContract.Text,
- ContractPhone = txtContractPhone.Text,
- CustomerCode = txtCustomerCode.Text,
- CustomerName = txtCustomerName.Text,
- PostalCode = txtPostalCode.Text,
- Province = cmbProvince.Text,
- Route = txtRoute.Text,
- Street = cmbStreet.Text,
- });
- 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.customerService.Edit(new CustomerCondition
- {
- OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
- IsUsed = chkUse.Checked,
- CustomerType = cmbCustomerType.SelectedValue == null ? "" :
- cmbCustomerType.SelectedValue.ToString(),
- DefaultDistributionRule = txtDistributionRule.Text,
- DefaultPutShelfRule = txtPutRule.Text,
- Describe = richDescibe.Text,
- Address = txtAddress.Text,
- Area = cmbArea.Text,
- City = cmbCity.Text,
- Contract = txtContract.Text,
- ContractPhone = txtContractPhone.Text,
- CustomerCode = txtCustomerCode.Text,
- CustomerName = txtCustomerName.Text,
- PostalCode = txtPostalCode.Text,
- Province = cmbProvince.Text,
- Route = txtRoute.Text,
- Street = cmbStreet.Text,
- Id = this.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;
- }
- }
- public void InitControl()
- {
- var fieldList = new List<FieldValue>();
- fieldList.Add(new FieldValue { Code = "Common", Name = "普通客户" });
- cmbCustomerType.DataSource = fieldList;
- cmbCustomerType.DisplayMember = "Name";
- cmbCustomerType.ValueMember = "Code";
- cmbCustomerType.SelectedIndex = -1;
- fieldList = new List<FieldValue>();
- fieldList.Add(new FieldValue { Code = "江苏省", Name = "江苏省" });
- cmbProvince.DataSource = fieldList;
- cmbProvince.DisplayMember = "Name";
- cmbProvince.ValueMember = "Code";
- cmbProvince.SelectedIndex = -1;
- fieldList = new List<FieldValue>();
- fieldList.Add(new FieldValue { Code = "无锡市", Name = "无锡市" });
- cmbCity.DataSource = fieldList;
- cmbCity.DisplayMember = "Name";
- cmbCity.ValueMember = "Code";
- cmbCity.SelectedIndex = -1;
- fieldList = new List<FieldValue>();
- fieldList.Add(new FieldValue { Code = "锡山区", Name = "锡山区" });
- cmbArea.DataSource = fieldList;
- cmbArea.DisplayMember = "Name";
- cmbArea.ValueMember = "Code";
- cmbArea.SelectedIndex = -1;
- }
- private void FrmCustomerEdit_Shown(object sender, EventArgs e)
- {
-
- }
- }
- }
|