2021-06-05 14:17:30 +08:00
|
|
|
|
using CleanMachineHMI.forms;
|
|
|
|
|
|
using CleanMachineHMI.FrmUserControl;
|
|
|
|
|
|
using CleanMachineHMI.Utils;
|
2021-12-26 21:30:02 +08:00
|
|
|
|
using Krypton.Toolkit;
|
2021-06-05 14:17:30 +08:00
|
|
|
|
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;
|
2021-12-27 09:51:57 +08:00
|
|
|
|
|
2021-06-05 14:17:30 +08:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
|
|
namespace CleanMachineHMI.frmChild
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class frmAddUser : KryptonForm
|
|
|
|
|
|
{
|
|
|
|
|
|
public frmAddUser()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
_ComboBoxLanguageTextList = this.GetInfoLanguageText(GlobalHelper.LanguageCode, "KryptonComboBox");
|
|
|
|
|
|
_InfoLanguageTextList = this.GetInfoLanguageText(GlobalHelper.LanguageCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
private DataTable _ComboBoxLanguageTextList;
|
|
|
|
|
|
private DataTable _InfoLanguageTextList;
|
|
|
|
|
|
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 frmAddUser_Load(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
InitControlEvent();
|
2022-03-18 19:06:26 +08:00
|
|
|
|
this.SetFormControlText();
|
2021-06-05 14:17:30 +08:00
|
|
|
|
if (GlobalHelper.LanguageCode == "English")
|
|
|
|
|
|
{
|
|
|
|
|
|
cmbGender.Items.Clear();
|
|
|
|
|
|
foreach (DataRow item in _ComboBoxLanguageTextList.GetComBoboxItemArr(cmbGender.Name, "KryptonComboBox"))
|
|
|
|
|
|
{
|
|
|
|
|
|
cmbGender.Items.Add(item["CONTROL_NAME"].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
string sql = $"SELECT ROLE_ID,ROLE_CODE,ROLE_NAME FROM SYS_ROLE ";
|
|
|
|
|
|
DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
|
2021-12-31 19:53:53 +08:00
|
|
|
|
kcmb_Role.DisplayMember = "Text";
|
|
|
|
|
|
kcmb_Role.DisplayMember = "Text";
|
2021-06-05 14:17:30 +08:00
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
kcmb_Role.Items.Clear();
|
|
|
|
|
|
kcmb_Role.Items.Add(new ListItem
|
|
|
|
|
|
{
|
|
|
|
|
|
Value = "0",
|
|
|
|
|
|
Text = "Please Select",
|
|
|
|
|
|
});
|
|
|
|
|
|
foreach (DataRow item in dt.Rows)
|
|
|
|
|
|
{
|
|
|
|
|
|
kcmb_Role.Items.Add(new ListItem
|
|
|
|
|
|
{
|
|
|
|
|
|
Value = item["ROLE_ID"].ToString(),
|
|
|
|
|
|
Text = item["ROLE_CODE"].ToString(),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
kcmb_Role.SelectedIndex = 0;
|
|
|
|
|
|
cmbGender.SelectedIndex = 0;
|
|
|
|
|
|
kryptonPanel1.Focus();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(txtAccount.Text))
|
|
|
|
|
|
{
|
2022-03-18 19:06:26 +08:00
|
|
|
|
KryptonMessageBox.Show(this.GetInfoText("请输入用户编码!", "EnterUserCodeInfo"));
|
2021-06-05 14:17:30 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (string.IsNullOrEmpty(txtName.Text))
|
|
|
|
|
|
{
|
2022-03-18 19:06:26 +08:00
|
|
|
|
KryptonMessageBox.Show(this.GetInfoText("请输入用户名称!", "EnterUserNameInfo"));
|
2021-06-05 14:17:30 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (string.IsNullOrEmpty(txtPS.Text))
|
|
|
|
|
|
{
|
|
|
|
|
|
//KryptonMessageBox.Show("请输入用户密码!");
|
2022-03-18 19:06:26 +08:00
|
|
|
|
KryptonMessageBox.Show(this.GetInfoText("请输入用户密码!", "EnterUserPasswordInfo"));
|
2021-06-05 14:17:30 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (string.IsNullOrEmpty(txtPS1.Text))
|
|
|
|
|
|
{
|
|
|
|
|
|
//KryptonMessageBox.Show("请确认用户密码!");
|
2022-03-18 19:06:26 +08:00
|
|
|
|
KryptonMessageBox.Show(this.GetInfoText("请确认用户密码!", "ConfirmUserPasswordInfo"));
|
2021-06-05 14:17:30 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (cmbGender.SelectedIndex == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
//KryptonMessageBox.Show("请选择性别!");
|
2022-03-18 19:06:26 +08:00
|
|
|
|
KryptonMessageBox.Show(this.GetInfoText("请选择性别!", "SelectUserGenderInfo"));
|
2021-06-05 14:17:30 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (kcmb_Role.SelectedIndex == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
//KryptonMessageBox.Show("请选择所属角色!");
|
2022-03-18 19:06:26 +08:00
|
|
|
|
KryptonMessageBox.Show(this.GetInfoText("请选择所属角色!", "SelectUserRoleInfo"));
|
2021-06-05 14:17:30 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (txtPS1.Text != txtPS.Text)
|
|
|
|
|
|
{
|
|
|
|
|
|
//KryptonMessageBox.Show("两次输入的密码不同,请重新输入!");
|
2022-03-18 19:06:26 +08:00
|
|
|
|
KryptonMessageBox.Show(this.GetInfoText("两次输入的密码不同,请重新输入!", "ConfirmUserPasswordErrInfo"));
|
2021-06-05 14:17:30 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
string sqlIsExistCode = $@"SELECT 1 FROM SYS_USER WHERE USER_CODE = '{txtAccount.Text}'";
|
|
|
|
|
|
DataTable dtIsExistCode = LeadDbHelperSQLite.Query(sqlIsExistCode).Tables[0];
|
|
|
|
|
|
if (dtIsExistCode != null && dtIsExistCode.Rows.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
//KryptonMessageBox.Show($"用户名:【{txtAccount.Text}】已经存在,请重新输入!");
|
|
|
|
|
|
KryptonMessageBox.Show($"User name 【{txtAccount.Text}】already exist, please re-enter!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string sql = $@"
|
|
|
|
|
|
INSERT INTO SYS_USER (
|
|
|
|
|
|
USER_CODE,
|
|
|
|
|
|
USER_NAME,
|
|
|
|
|
|
PASSWORD,
|
|
|
|
|
|
GENDER,
|
|
|
|
|
|
SCHEDULE_CODE,
|
|
|
|
|
|
ROLE_ID,
|
|
|
|
|
|
USED_FLAG,
|
|
|
|
|
|
DEL_FLAG,
|
|
|
|
|
|
CREATE_BY,
|
|
|
|
|
|
CREATE_TIME,
|
|
|
|
|
|
UPDATE_BY,
|
|
|
|
|
|
UPDATE_TIME,
|
|
|
|
|
|
DATA_VERSION,
|
|
|
|
|
|
REMARKS1,
|
|
|
|
|
|
REMARKS2,
|
|
|
|
|
|
REMARKS3,
|
|
|
|
|
|
REMARKS4,
|
|
|
|
|
|
REMARKS5
|
|
|
|
|
|
)
|
|
|
|
|
|
VALUES
|
|
|
|
|
|
(
|
|
|
|
|
|
'{txtAccount.Text}',
|
|
|
|
|
|
'{txtName.Text}',
|
|
|
|
|
|
'{txtPS1.Text}',
|
|
|
|
|
|
'{cmbGender.SelectedIndex}',
|
|
|
|
|
|
'1',
|
|
|
|
|
|
'{((ListItem)kcmb_Role.SelectedItem).Value}',
|
|
|
|
|
|
1,
|
|
|
|
|
|
0,
|
2021-12-31 16:27:14 +08:00
|
|
|
|
'{GlobalHelper.UserInfo.UserId}',
|
2021-06-05 14:17:30 +08:00
|
|
|
|
datetime('now', 'localtime'),
|
2021-12-31 16:27:14 +08:00
|
|
|
|
'{GlobalHelper.UserInfo.UserId}',
|
2021-06-05 14:17:30 +08:00
|
|
|
|
datetime('now', 'localtime'),
|
|
|
|
|
|
0,
|
|
|
|
|
|
NULL,
|
|
|
|
|
|
NULL,
|
|
|
|
|
|
NULL,
|
|
|
|
|
|
NULL,
|
|
|
|
|
|
NULL
|
|
|
|
|
|
);
|
|
|
|
|
|
";
|
|
|
|
|
|
int row = LeadDbHelperSQLite.ExecuteSql(sql);
|
|
|
|
|
|
if (row > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
//KryptonMessageBox.Show("新增用户数据成功!");
|
2022-03-18 19:06:26 +08:00
|
|
|
|
KryptonMessageBox.Show(this.GetInfoText("新增用户数据成功!", "AddSuccessInfo"));
|
2021-06-05 14:17:30 +08:00
|
|
|
|
frmUser.RefreshFrmHost();
|
|
|
|
|
|
this.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
//KryptonMessageBox.Show("新增用户数据失败!");
|
2022-03-18 19:06:26 +08:00
|
|
|
|
KryptonMessageBox.Show(this.GetInfoText("新增用户数据失败!", "AddFailInfo"));
|
2021-06-05 14:17:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
2022-03-18 19:06:26 +08:00
|
|
|
|
KryptonMessageBox.Show(this.GetInfoText("新增用户数据发生异常", "AddUserDataExp") + $":【{ex.Message}】!");
|
2021-06-05 14:17:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|