添加项目文件。
This commit is contained in:
209
CleanMachineHMI/frmChild/frmAddUser.cs
Normal file
209
CleanMachineHMI/frmChild/frmAddUser.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
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 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();
|
||||
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 sql = $"SELECT ROLE_ID,ROLE_CODE,ROLE_NAME FROM SYS_ROLE ";
|
||||
DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
|
||||
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))
|
||||
{
|
||||
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 (kcmb_Role.SelectedIndex == 0)
|
||||
{
|
||||
//KryptonMessageBox.Show("请选择所属角色!");
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请选择所属角色!", "SelectUserRoleInfo"));
|
||||
return;
|
||||
}
|
||||
if (txtPS1.Text != txtPS.Text)
|
||||
{
|
||||
//KryptonMessageBox.Show("两次输入的密码不同,请重新输入!");
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("两次输入的密码不同,请重新输入!", "ConfirmUserPasswordErrInfo"));
|
||||
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,
|
||||
'{GlobalHelper.UserInfo.USER_ID}',
|
||||
datetime('now', 'localtime'),
|
||||
'{GlobalHelper.UserInfo.USER_ID}',
|
||||
datetime('now', 'localtime'),
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
";
|
||||
int row = LeadDbHelperSQLite.ExecuteSql(sql);
|
||||
if (row > 0)
|
||||
{
|
||||
//KryptonMessageBox.Show("新增用户数据成功!");
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("新增用户数据成功!", "AddSuccessInfo"));
|
||||
frmUser.RefreshFrmHost();
|
||||
this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
//KryptonMessageBox.Show("新增用户数据失败!");
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("新增用户数据失败!", "AddFailInfo"));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("新增用户数据发生异常", "AddUserDataExp") + $":【{ex.Message}】!");
|
||||
}
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user