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; } /// /// 控件初始化 /// public void InitControl() { CheckForIllegalCrossThreadCalls = false; var fieldList = new List().GetFieldValueCodeList(); cmbParameterType.DataSource = fieldList; cmbParameterType.DisplayMember = "Name"; cmbParameterType.ValueMember = "Code"; cmbParameterType.SelectedIndex = -1; fieldList = new List().GetFieldValueIdList(); 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(); } } }