添加项目文件。
This commit is contained in:
168
CleanMachineHMI/frmChild/frmEditUser.cs
Normal file
168
CleanMachineHMI/frmChild/frmEditUser.cs
Normal file
@@ -0,0 +1,168 @@
|
||||
using CleanMachineHMI.forms;
|
||||
using CleanMachineHMI.FrmUserControl;
|
||||
using CleanMachineHMI.Utils;
|
||||
using ComponentFactory.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.Web.UI.WebControls;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CleanMachineHMI.frmChild
|
||||
{
|
||||
public partial class frmEditUser : KryptonForm
|
||||
{
|
||||
public frmEditUser()
|
||||
{
|
||||
InitializeComponent();
|
||||
_ComboBoxLanguageTextList = this.GetInfoLanguageText(GlobalHelper.LanguageCode, "KryptonComboBox");
|
||||
_InfoLanguageTextList = this.GetInfoLanguageText(GlobalHelper.LanguageCode);
|
||||
}
|
||||
private DataTable _ComboBoxLanguageTextList;
|
||||
private DataTable _InfoLanguageTextList;
|
||||
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(GlobalHelper.LanguageCode);
|
||||
if (GlobalHelper.LanguageCode == "English")
|
||||
{
|
||||
cmbGender.Items.Clear();
|
||||
foreach (DataRow item in _ComboBoxLanguageTextList.GetComBoboxItemArr(cmbGender.Name, "KryptonComboBox"))
|
||||
{
|
||||
cmbGender.Items.Add(item["CONTROL_NAME"].ToString());
|
||||
}
|
||||
}
|
||||
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(_InfoLanguageTextList.GetInfoText("编辑用户数据界面加载异常", "LoadEditFrmExp") + $":【{ex.Message}】!");
|
||||
}
|
||||
}
|
||||
|
||||
private void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(txtAccount.Text))
|
||||
{
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请输入用户编码!", "EnterUserCodeInfo"));
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(txtName.Text))
|
||||
{
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请输入用户名称!", "EnterUserNameInfo"));
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(txtPS.Text))
|
||||
{
|
||||
//KryptonMessageBox.Show("请输入用户密码!");
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请输入用户密码!", "EnterUserPasswordInfo"));
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(txtPS1.Text))
|
||||
{
|
||||
//KryptonMessageBox.Show("请确认用户密码!");
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请确认用户密码!", "ConfirmUserPasswordInfo"));
|
||||
return;
|
||||
}
|
||||
if (cmbGender.SelectedIndex == 0)
|
||||
{
|
||||
//KryptonMessageBox.Show("请选择性别!");
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请选择性别!", "SelectUserGenderInfo"));
|
||||
return;
|
||||
}
|
||||
if (txtPS1.Text != txtPS.Text)
|
||||
{
|
||||
//KryptonMessageBox.Show("两次输入的密码不同,请重新输入!");
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("两次输入的密码不同,请重新输入!", "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 = '{GlobalHelper.UserInfo.USER_ID}',UPDATE_TIME = datetime('now', 'localtime') where USER_ID = '{UserId}'";
|
||||
int row = LeadDbHelperSQLite.ExecuteSql(sql);
|
||||
if (row > 0)
|
||||
{
|
||||
//KryptonMessageBox.Show("修改用户数据成功!");
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("修改用户数据成功!", "EditSuccessInfo"));
|
||||
frmUser.RefreshFrmHost();
|
||||
this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
//KryptonMessageBox.Show("修改用户数据失败!");
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("修改用户数据失败!", "EditFailInfo"));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("编辑用户数据发生异常", "EditUserDataExp") + $":【{ex.Message}】!");
|
||||
}
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user