165 lines
6.8 KiB
C#
165 lines
6.8 KiB
C#
using CleanMachineHMI.forms;
|
|
using CleanMachineHMI.FrmUserControl;
|
|
using CleanMachineHMI.Utils;
|
|
using Krypton.Toolkit;
|
|
using LeadDataBaseUtility;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
namespace CleanMachineHMI.frmChild
|
|
{
|
|
public partial class frmEditUser : KryptonForm
|
|
{
|
|
public frmEditUser()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
public string UserId { get; set; }
|
|
private void txt_GotFocus(object sender, EventArgs e)
|
|
{
|
|
KeyboardAutoPopUp.ShowInputPanel();
|
|
}
|
|
private void txt_LostFocus(object sender, EventArgs e)
|
|
{
|
|
KeyboardAutoPopUp.HideInputPanel();
|
|
}
|
|
private void InitControlEvent()
|
|
{
|
|
txtAccount.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
|
|
txtAccount.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
|
|
|
|
txtName.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
|
|
txtName.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
|
|
|
|
txtPS.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
|
|
txtPS.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
|
|
|
|
txtPS1.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
|
|
txtPS1.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
|
|
|
|
}
|
|
|
|
private void frmEditUser_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
InitControlEvent();
|
|
this.SetFormControlText();
|
|
|
|
{
|
|
cmbGender.Items.Clear();
|
|
foreach (string item in this.GetComBoboxItemArr(cmbGender.Name))
|
|
{
|
|
cmbGender.Items.Add(item);
|
|
}
|
|
}
|
|
string sql1 = $"SELECT ROLE_ID,ROLE_CODE,ROLE_NAME FROM SYS_ROLE ";
|
|
DataTable dt1 = LeadDbHelperSQLite.Query(sql1).Tables[0];
|
|
if (dt1 != null && dt1.Rows.Count > 0)
|
|
{
|
|
kcmb_Role.Items.Clear();
|
|
foreach (DataRow item in dt1.Rows)
|
|
{
|
|
kcmb_Role.Items.Add(new ListItem
|
|
{
|
|
Value = item["ROLE_ID"].ToString(),
|
|
Text = item["ROLE_CODE"].ToString(),
|
|
});
|
|
}
|
|
}
|
|
cmbGender.SelectedIndex = 0;
|
|
string sql = $@"SELECT A.USER_ID,A.USER_CODE,A.USER_NAME,A.GENDER,A.ROLE_ID,B.ROLE_CODE,B.ROLE_NAME,A.PASSWORD FROM SYS_USER A LEFT JOIN SYS_ROLE B on A.ROLE_ID = B.ROLE_ID WHERE A.USER_ID = '{UserId}'";
|
|
DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
txtAccount.Text = dt.Rows[0]["USER_CODE"].ToString();
|
|
txtAccount.Enabled = false;
|
|
txtName.Text = dt.Rows[0]["USER_NAME"].ToString();
|
|
txtPS.Text = dt.Rows[0]["PASSWORD"].ToString();
|
|
txtPS1.Text = dt.Rows[0]["PASSWORD"].ToString();
|
|
cmbGender.SelectedIndex = Convert.ToInt32(dt.Rows[0]["GENDER"]);
|
|
kcmb_Role.Text = dt.Rows[0]["ROLE_CODE"].ToString();
|
|
}
|
|
kryptonPanel1.Focus();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
KryptonMessageBox.Show(this.T("编辑用户数据界面加载异常", "LoadEditFrmExp") + $":【{ex.Message}】!");
|
|
}
|
|
}
|
|
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrEmpty(txtAccount.Text))
|
|
{
|
|
KryptonMessageBox.Show(this.T("请输入用户编码!", "EnterUserCodeInfo"));
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(txtName.Text))
|
|
{
|
|
KryptonMessageBox.Show(this.T("请输入用户名称!", "EnterUserNameInfo"));
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(txtPS.Text))
|
|
{
|
|
//KryptonMessageBox.Show("请输入用户密码!");
|
|
KryptonMessageBox.Show(this.T("请输入用户密码!", "EnterUserPasswordInfo"));
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(txtPS1.Text))
|
|
{
|
|
//KryptonMessageBox.Show("请确认用户密码!");
|
|
KryptonMessageBox.Show(this.T("请确认用户密码!", "ConfirmUserPasswordInfo"));
|
|
return;
|
|
}
|
|
if (cmbGender.SelectedIndex == 0)
|
|
{
|
|
//KryptonMessageBox.Show("请选择性别!");
|
|
KryptonMessageBox.Show(this.T("请选择性别!", "SelectUserGenderInfo"));
|
|
return;
|
|
}
|
|
if (txtPS1.Text != txtPS.Text)
|
|
{
|
|
//KryptonMessageBox.Show("两次输入的密码不同,请重新输入!");
|
|
KryptonMessageBox.Show(this.T("两次输入的密码不同,请重新输入!", "ConfirmUserPasswordErrInfo"));
|
|
return;
|
|
}
|
|
string sql = $@"update SYS_USER set USER_CODE = '{txtAccount.Text}',USER_NAME = '{txtName.Text}',PASSWORD = '{txtPS1.Text}',GENDER = '{cmbGender.SelectedIndex}',ROLE_ID = '{((ListItem)kcmb_Role.SelectedItem).Value}',UPDATE_BY = '{Global.UserInfo.UserId}',UPDATE_TIME = datetime('now', 'localtime') where USER_ID = '{UserId}'";
|
|
int row = LeadDbHelperSQLite.ExecuteSql(sql);
|
|
if (row > 0)
|
|
{
|
|
//KryptonMessageBox.Show("修改用户数据成功!");
|
|
KryptonMessageBox.Show(this.T("修改用户数据成功!", "EditSuccessInfo"));
|
|
frmUser.RefreshFrmHost();
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
//KryptonMessageBox.Show("修改用户数据失败!");
|
|
KryptonMessageBox.Show(this.T("修改用户数据失败!", "EditFailInfo"));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
KryptonMessageBox.Show(this.T("编辑用户数据发生异常", "EditUserDataExp") + $":【{ex.Message}】!");
|
|
}
|
|
}
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|