123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- using ComponentFactory.Krypton.Toolkit;
- using NXWMS.Client.Model.AppModels.Condition.SysSettings;
- using NXWMS.Client.Model.AppModels.Result;
- using NXWMS.Client.Model.CoreModels;
- using NXWMS.Client.String.Enums;
- using NXWMS.Commons;
- 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.SysSettings.ChildFrm
- {
- public partial class FrmParameterEdit : KryptonForm
- {
- private int id;
- private EnumOperation _operation;
-
- public FrmParameterEdit()
- {
- InitializeComponent();
- }
- public int Id { get => id; set => id = value; }
- public EnumOperation Operation { get => _operation; set => _operation = value; }
- /// <summary>
- /// 控件初始化
- /// </summary>
- public void InitControl()
- {
- CheckForIllegalCrossThreadCalls = false;
-
- var fieldList = new List<FieldValue>().GetFieldValueCodeList<ParameterType>();
-
- cmbParameterType.DataSource = fieldList;
- cmbParameterType.DisplayMember = "Name";
- cmbParameterType.ValueMember = "Code";
- cmbParameterType.SelectedIndex = -1;
- fieldList = new List<FieldValue>().GetFieldValueIdList<AllowEditFlagType>();
-
- chkAllowEditFlag.DataSource = fieldList;
- chkAllowEditFlag.DisplayMember = "Name";
- chkAllowEditFlag.ValueMember = "Id";
- chkAllowEditFlag.SelectedIndex = -1;
-
- }
- private void btnSave_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrWhiteSpace(txtParameterCode.Text))
- {
- KryptonMessageBox.Show($"请输入参数编码。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (string.IsNullOrWhiteSpace(txtParameterName.Text))
- {
- KryptonMessageBox.Show($"请输入参数名称。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (string.IsNullOrWhiteSpace(txtParameterValue.Text))
- {
- KryptonMessageBox.Show($"请输入参数值。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (string.IsNullOrWhiteSpace(cmbParameterType.Text))
- {
- KryptonMessageBox.Show($"请选择参数类型。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (string.IsNullOrWhiteSpace(chkAllowEditFlag.Text))
- {
- KryptonMessageBox.Show($"请选择是否允许修改。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (KryptonMessageBox.Show("是否保存", "提示信息", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
- {
- return;
- }
- switch (Operation)
- {
- case EnumOperation.Add:
- var addResult = SysSettingsServices.parameterService.Add(new ParameterCondition
- {
- OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
- IsUsed = chkUse.Checked ? false : true,
- ParameterCode = txtParameterCode.Text,
- ParameterName = txtParameterName.Text,
- ParameterType = cmbParameterType.SelectedValue.ToString(),
- AllowEditFlag = Convert.ToInt32(chkAllowEditFlag.SelectedValue.ToString()),
- ParameterValue = txtParameterValue.Text,
- Describe = richDescibe.Text,
- IsShow = chkShow.Checked ? false : true
- });
- if (addResult.Status == OperateStatus.Success)
- {
- KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
-
- this.DialogResult = DialogResult.OK;
- }
- else
- {
- KryptonMessageBox.Show($"操作失败!\r\n{addResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- break;
- case EnumOperation.Edit:
- var editResult = SysSettingsServices.parameterService.Edit(new ParameterCondition
- {
- OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
- IsUsed = chkUse.Checked,
- ParameterCode = txtParameterCode.Text,
- ParameterName = txtParameterName.Text,
- ParameterType = cmbParameterType.SelectedValue.ToString(),
- AllowEditFlag = Convert.ToInt32(chkAllowEditFlag.SelectedValue.ToString()),
- ParameterValue = txtParameterValue.Text,
- Describe = richDescibe.Text,
- IsShow = chkShow.Checked,
- ParameterId = Id,
- });
- if (editResult.Status == OperateStatus.Success)
- {
- KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
-
- this.DialogResult = DialogResult.OK;
- }
- else
- {
- KryptonMessageBox.Show($"操作失败!\r\n{editResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- break;
- }
- }
- private void btnExit_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- this.Close();
- }
- }
- }
|