添加项目文件。
This commit is contained in:
143
CleanMachineHMI/frmLogin.cs
Normal file
143
CleanMachineHMI/frmLogin.cs
Normal file
@@ -0,0 +1,143 @@
|
||||
using CleanMachineHMI.Domain.Enums;
|
||||
using CleanMachineHMI.Utils;
|
||||
using ComponentFactory.Krypton.Toolkit;
|
||||
using LeadDataBaseUtility;
|
||||
using NX_LogUtility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CleanMachineHMI
|
||||
{
|
||||
[FormType(EnumFormType.Login)]
|
||||
public partial class frmLogin : KryptonForm
|
||||
{
|
||||
/// <summary>
|
||||
/// 页面信息语言文本列表
|
||||
/// </summary>
|
||||
private readonly DataTable _InfoLanguageTextList;
|
||||
|
||||
public frmLogin()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_InfoLanguageTextList = this.GetInfoLanguageText(GlobalHelper.LanguageCode);
|
||||
this.SetFormControlText(GlobalHelper.LanguageCode);
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
//txtAccount.Text = "";
|
||||
txtPs.Text = "";
|
||||
}
|
||||
|
||||
private void btnExit_Click(object sender, EventArgs e)
|
||||
{
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
private void btnLogin_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(txtAccount.Text))
|
||||
{
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请输入登陆账号!", "PleaseInputAccount"), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(txtPs.Text))
|
||||
{
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请输入登陆密码!", "PleaseInputPassword"), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
|
||||
var sql = $@"SELECT A.USER_ID,A.USER_CODE,A.USER_NAME,A.SCHEDULE_CODE,A.USED_FLAG,A.DEL_FLAG,A.PASSWORD,B.ROLE_ID,B.ROLE_GRADE FROM SYS_USER A LEFT JOIN SYS_ROLE B ON A.ROLE_ID = B.ROLE_ID WHERE A.USER_CODE= '{txtAccount.Text}'";
|
||||
DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
var data = dt.Rows[0];
|
||||
if (data["USED_FLAG"].ToString() == "0")
|
||||
{
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("用户已被停用!", "UserStop"), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
if (data["DEL_FLAG"].ToString() == "1")
|
||||
{
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("用户已被删除!", "UserDeleted"), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
if (data["PASSWORD"].ToString().ToLower() != txtPs.Text.ToLower())
|
||||
{
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("输入密码错误!", "PasswordFail"), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
AppConfigHelper.Update("LastTimeUserCode",txtAccount.Text.Trim());
|
||||
//登陆成功
|
||||
Init();
|
||||
|
||||
//获取基础配置
|
||||
sql = "select * from SYS_PARAMETER where used_flag=1 and del_flag=0";
|
||||
DataTable dtTemp = LeadDbHelperSQLite.Query(sql).Tables[0];
|
||||
GlobalHelper.ParameterList = dtTemp;
|
||||
|
||||
GlobalHelper.UserInfo = new Domain.Models.ViewModels.UserInfo
|
||||
{
|
||||
GENDER = Convert.ToInt32(data["USED_FLAG"].ToString()),
|
||||
SCHEDULE_CODE = data["SCHEDULE_CODE"] == null ? "" : data["SCHEDULE_CODE"].ToString(),
|
||||
USER_CODE = data["USER_CODE"].ToString(),
|
||||
USER_ID = Convert.ToInt32(data["USER_ID"].ToString()),
|
||||
USER_NAME = data["USER_NAME"].ToString(),
|
||||
ROLE_ID = Convert.ToInt32(data["ROLE_ID"].ToString()),
|
||||
ROLE_GRADE = Convert.ToInt32(data["ROLE_GRADE"].ToString()),
|
||||
};
|
||||
this.Hide();
|
||||
|
||||
LogHelper.WriteLog($"用户:【{GlobalHelper.UserInfo.USER_NAME}】登录系统成功!",LogTypeEum.Run);
|
||||
sql = $@"SELECT A.ROLE_ID,A.ROLE_CODE,A.ROLE_NAME,B.MENU_ID,C.MENU_CODE,C.MENU_NAME,C.MENU_URL,C.MENU_PID FROM SYS_ROLE A LEFT JOIN SYS_ROLE_MENU_PERMISSION B on A.ROLE_ID = B.ROLE_ID LEFT JOIN SYS_MENU C on B.MENU_ID = C.MENU_ID WHERE A.ROLE_ID = '{GlobalHelper.UserInfo.ROLE_ID}'";
|
||||
|
||||
GlobalHelper.RoleMenuPermission = LeadDbHelperSQLite.Query(sql).Tables[0];
|
||||
GlobalHelper.MainFormNew = new frmMainNew();
|
||||
GlobalHelper.MainFormNew.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
KryptonMessageBox.Show(_InfoLanguageTextList.GetInfoText("请输入正确的登陆账号!", "PleaseCorrectAccount"), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void frmLogin_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
txtAccount.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
|
||||
txtAccount.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
|
||||
|
||||
txtPs.GotFocus += new EventHandler(txt_GotFocus); //获取焦点前发生事件
|
||||
txtPs.LostFocus += new EventHandler(txt_LostFocus); //失去焦点后发生事件
|
||||
|
||||
txtAccount.Text = AppConfigHelper.Get("LastTimeUserCode");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
KryptonMessageBox.Show(ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
private void txt_GotFocus(object sender, EventArgs e)
|
||||
{
|
||||
KeyboardAutoPopUp.ShowInputPanel();
|
||||
}
|
||||
private void txt_LostFocus(object sender, EventArgs e)
|
||||
{
|
||||
KeyboardAutoPopUp.HideInputPanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user