195 lines
8.0 KiB
C#
195 lines
8.0 KiB
C#
using CleanMachineHMI.Domain.Enums;
|
|
using CleanMachineHMI.Utils;
|
|
using 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
|
|
{
|
|
|
|
public frmLogin()
|
|
{
|
|
InitializeComponent();
|
|
this.SetFormControlText();
|
|
}
|
|
|
|
|
|
|
|
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(this.T("请输入登陆账号!", "PleaseInputAccount"), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
if (string.IsNullOrWhiteSpace(txtPs.Text))
|
|
{
|
|
KryptonMessageBox.Show(this.T("请输入登陆密码!", "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];
|
|
var _user = new CleanMachine.BLL.SYS.UserBLL().GetModel(txtAccount.Text);
|
|
if (_user != null)
|
|
{
|
|
if (_user.UsedFlag == 0 || _user.DelFlag == 1)
|
|
{
|
|
KryptonMessageBox.Show(this.T("用户已被停用!", "UserStop"), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
if (_user.Password.ToLower() != _user.Password.ToLower())
|
|
{
|
|
KryptonMessageBox.Show(this.T("输入密码错误!", "PasswordFail"));
|
|
return;
|
|
}
|
|
|
|
|
|
txtPs.Text = "";
|
|
|
|
|
|
Global.UserInfo = new Domain.Models.ViewModels.UserInfo
|
|
{
|
|
Gender = _user.Gender,
|
|
ScheduleCode = _user.ScheduleCode,
|
|
UserCode = _user.UserCode,
|
|
UserId = _user.UserId,
|
|
UserName = _user.UserName,
|
|
RoleId = _user.RoleId,
|
|
RoleGrade = _user.RoleGrade,
|
|
};
|
|
|
|
|
|
//获取基础配置
|
|
//var sql = "select * from SYS_PARAMETER where used_flag=1 and del_flag=0";
|
|
//DataTable dtTemp = LeadDbHelperSQLite.Query(sql).Tables[0];
|
|
//GlobalHelper.ParameterList = dtTemp;
|
|
|
|
Global.ParameterList = new CleanMachine.BLL.SYS.ParameterBLL().GetList("").ToList();
|
|
|
|
//
|
|
|
|
this.Hide();
|
|
|
|
LogHelper.WriteLog($"用户:【{Global.UserInfo.UserName}】登录系统成功!", LogTypeEum.Run);
|
|
// var 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.RoleId}'";
|
|
|
|
// GlobalHelper.RoleMenuPermission = LeadDbHelperSQLite.Query(sql).Tables[0];
|
|
Global.RoleMenuPermission = new CleanMachine.BLL.SYS.RoleMenuPermissionBLL().GetList(_user.RoleId).ToList();
|
|
Global.MainFormNew = new frmMainNew();
|
|
Global.MainFormNew.Show();
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
KryptonMessageBox.Show(this.T("请输入正确的登陆账号!", "PleaseCorrectAccount"), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
|
|
//if (dt.Rows.Count > 0)
|
|
//{
|
|
// var data = dt.Rows[0];
|
|
// if (data["USED_FLAG"].ToString() == "0")
|
|
// {
|
|
// KryptonMessageBox.Show(this.T("用户已被停用!", "UserStop"), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
// return;
|
|
// }
|
|
// if (data["DEL_FLAG"].ToString() == "1")
|
|
// {
|
|
// KryptonMessageBox.Show(this.T("用户已被删除!", "UserDeleted"), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
// return;
|
|
// }
|
|
// if (data["PASSWORD"].ToString().ToLower() != txtPs.Text.ToLower())
|
|
// {
|
|
// KryptonMessageBox.Show(this.T("输入密码错误!", "PasswordFail"));
|
|
// 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()),
|
|
// ScheduleCode = data["SCHEDULE_CODE"] == null ? "" : data["SCHEDULE_CODE"].ToString(),
|
|
// UserCode = data["USER_CODE"].ToString(),
|
|
// UserId = Convert.ToInt32(data["USER_ID"].ToString()),
|
|
// UserName = data["USER_NAME"].ToString(),
|
|
// RoleId = Convert.ToInt32(data["ROLE_ID"].ToString()),
|
|
// RoleGrade = Convert.ToInt32(data["ROLE_GRADE"].ToString()),
|
|
// };
|
|
// this.Hide();
|
|
|
|
// LogHelper.WriteLog($"用户:【{GlobalHelper.UserInfo.UserName}】登录系统成功!",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.RoleId}'";
|
|
|
|
// GlobalHelper.RoleMenuPermission = LeadDbHelperSQLite.Query(sql).Tables[0];
|
|
// GlobalHelper.MainFormNew = new frmMainNew();
|
|
// GlobalHelper.MainFormNew.Show();
|
|
//}
|
|
//else
|
|
//{
|
|
// KryptonMessageBox.Show(this.T("请输入正确的登陆账号!", "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();
|
|
}
|
|
}
|
|
}
|