123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- using ComponentFactory.Krypton.Toolkit;
- using NXWMS.Client.Model.AppModels.Condition;
- using NXWMS.Client.Model.AppModels.Result;
- using NXWMS.Client.Model.AppModels.Result.SysSettings;
- 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 FrmUserEdit : KryptonForm
- {
- /// <summary>
- /// 界面最后执行操作
- /// </summary>
- private EnumOperation _LastOperation;
- private RolePermissionResult _selectRolePermission;
- private int _selectId;
- /// <summary>
- /// 客户端字段排序列表
- /// </summary>
- private List<ClientFieldOrderResult> _clientFieldOrderList;
- private int _selectMainMenuIndex;
- private int _selectMenuIndex;
- private int _selectFunctionIndex;
- /// <summary>
- /// 角色列表
- /// </summary>
- private List<RoleResult> _roleList;
- public FrmUserEdit()
- {
- InitializeComponent();
- }
- public void InitControl()
- {
- CheckForIllegalCrossThreadCalls = false;
-
- var fieldValueList = (from x in _roleList
- select new FieldValue
- {
- Code = x.ROLE_CODE,
- Name = x.ROLE_NAME
- }).ToList();
- cmbRole.DataSource = fieldValueList.Where((x, i) => fieldValueList.FindIndex(z => z.Code == x.Code) == i).ToList();
- cmbRole.DisplayMember = "Name";
- cmbRole.ValueMember = "Code";
- cmbRole.SelectedIndex = -1;
-
-
-
- cmbGender.DataSource = new List<FieldValue>().GetFieldValueIdList<GenderType>();
- cmbGender.DisplayMember = "Name";
- cmbGender.ValueMember = "Id";
- cmbGender.SelectedIndex = -1;
-
- txtUserCode.SetControlBase(50);
- txtUserName.SetControlBase(100);
- txtNickName.SetControlBase(50);
- txtIphoneNumber.SetControlBase(20);
- txtJobTitle.SetControlBase(50);
- txtEmail.SetControlBase(100);
- txtAddress.SetControlBase(200);
-
- }
- public EnumOperation Operation { get => _LastOperation; set => _LastOperation = value; }
- public int SelectId { get => _selectId; set => _selectId = value; }
- public List<RoleResult> RoleList { get => _roleList; set => _roleList = value; }
- private void btnSave_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrWhiteSpace(txtUserCode.Text))
- {
- KryptonMessageBox.Show($"请输入用户编码。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (string.IsNullOrWhiteSpace(txtUserName.Text))
- {
- KryptonMessageBox.Show($"请输入用户名称。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (string.IsNullOrWhiteSpace(cmbGender.Text))
- {
- KryptonMessageBox.Show($"请选择性别。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- switch (Operation)
- {
- case EnumOperation.Add:
- var addResult = SysSettingsServices.userService.Add(new UserCondition
- {
- JobTitle = txtJobTitle.Text,
- NickName = txtNickName.Text,
- Address = txtAddress.Text,
- PhoneNumber = txtIphoneNumber.Text,
- UserName = txtUserName.Text,
- OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
- Email = txtEmail.Text,
- Gender = cmbGender.SelectedValue.GetObjectToInt().Value,
- IsUsed = chkUse.Checked,
- RoleCode = cmbRole.SelectedValue.GetObjectToString(),
- UserCode = txtUserCode.Text,
- });
- if (addResult.Status == OperateStatus.Success)
- {
- KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- groupOperation.Visible = false;
-
- }
- else
- {
- KryptonMessageBox.Show($"操作失败!\r\n{addResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- break;
- case EnumOperation.Edit:
- var editResult = SysSettingsServices.userService.Edit(new UserCondition
- {
- JobTitle = txtJobTitle.Text.Trim(),
- NickName = txtNickName.Text,
- Address = txtAddress.Text,
- PhoneNumber = txtIphoneNumber.Text,
- UserName = txtUserName.Text,
- OperationUserId = AppConfig.UserLoginResult.UserInfo.UserId,
- Email = txtEmail.Text,
- Gender = cmbGender.SelectedValue.GetObjectToInt().Value,
- IsUsed = chkUse.Checked,
- RoleCode = cmbRole.SelectedValue.GetObjectToString(),
- UserId = SelectId,
- });
- if (editResult.Status == OperateStatus.Success)
- {
- KryptonMessageBox.Show($"操作成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- groupOperation.Visible = false;
-
- }
- else
- {
- KryptonMessageBox.Show($"操作失败!\r\n{editResult.Message}", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- break;
- }
- DialogResult = DialogResult.OK;
- }
- private void btnExit_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
|