天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.5 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace QMAPP.WinForm.Forms.Common
{
public partial class frmAlertConfirm : Form
{
public frmAlertConfirm()
{
InitializeComponent();
}
public frmAlertConfirm(string message,string authority)
{
InitializeComponent();
txtMessage.Text = message;
Authority = authority;
}
private void btnConfirm_Click(object sender, EventArgs e)
{
if (txtLoginID.Text == "")
{
MessageBox.Show("用户名不能为空!");
return;
}
if (txtPassword.Text == "")
{
MessageBox.Show("密码不能为空!");
return;
}
CheckUser(txtLoginID.Text, txtPassword.Text, false);
}
public string Authority { get; set; }
private void frmAlertConfirm_Load(object sender, EventArgs e)
{
txtLoginID.Focus();
}
private void txtPassCode_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (txtLoginID.Text.StartsWith("<") && txtLoginID.Text.EndsWith(">"))
{
var passport = txtLoginID.Text.Trim('<', '>').Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
if (passport.Length == 2)
{
string userid = passport[0];
string pwd = passport[1];
txtLoginID.Text = "";
CheckUser(userid, pwd,true);
return;
}
}
txtPassword.SelectAll();
txtPassword.Focus();
e.Handled = true;
}
}
private void CheckUser(string userid, string pwd,bool decrypt)
{
if (decrypt)
{
pwd = QMFrameWork.Common.Encrypt.DESEncrypt.Decrypt(pwd);
}
//登录验证
QMAPP.ServicesAgent.LoginService.LoginServiceClient _loginClient = new ServicesAgent.LoginService.LoginServiceClient();
var loginUser = _loginClient.IsLogin(new QMAPP.ServicesAgent.LoginService.LoginInfo { LoginUserID = userid, PassWord = pwd, UserDes = "" }
, ClientContext.GetCredentialInfo());
if (loginUser == null)
{
if (decrypt)
{
MessageBox.Show("登录码不正确或已过期,请联系管理员更换!");
}
else
{
MessageBox.Show("登录失败,用户名或密码不正确!");
}
return;
}
if (loginUser.LoginUserID.ToUpper().Trim() != "ADMIN")
{
if (!loginUser.Powers.Contains(Authority))
{
MessageBox.Show("此用户无报警确认权限,请使用其他用户登录确认!");
}
}
this.Close();
}
private void txtPassword_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
this.btnConfirm_Click(this.btnConfirm, new EventArgs());
}
}
}
}