69 lines
2.6 KiB
C#
69 lines
2.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using DeiNiu.wms.Logical;
|
|
|
|
public partial class login : System.Web.UI.Page
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
txtUserName.Focus();
|
|
}
|
|
protected void lklogin_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (Session["checkcode"] == null) Session["checkcode"] = new Random().Next(2, 4);
|
|
LEmployee lem = new LEmployee();
|
|
|
|
DeiNiu.RequestLog logobj = new DeiNiu.RequestLog();
|
|
logobj.LoginLog(txtUserName.Text , " trying to login ");
|
|
string CheckCode = this.txtCheck.Text.ToUpper();
|
|
bool paswdpassed = lem.Login(txtUserName.Text, txtPasswd.Text);
|
|
bool loginPassed = paswdpassed
|
|
&& Session["checkcode"].ToString().Equals(CheckCode);
|
|
|
|
if (paswdpassed) logobj.LoginLog(txtUserName.Text," passwd passed"); else logobj.LoginLog(txtUserName.Text ," passwd failed");
|
|
if (!loginPassed)
|
|
{
|
|
txtPasswd.Text = string.Empty;
|
|
lblResult.Text = "<font color=red><b>用户登录信息错误,请重新输入</b></font>";
|
|
logobj.LoginLog(txtUserName.Text, " login failed ");
|
|
|
|
}
|
|
else
|
|
{
|
|
lblResult.Text = "<font color=red><b>Passed</b></font>";
|
|
|
|
if (((ArrayList) Application["userlst"]).Contains(lem.GetEmployee.em_account))
|
|
{
|
|
lblResult.Text = "<font color=red><b>" + lem.GetEmployee.em_account + "用户已在线,不可重复登录。</b></font>";
|
|
// return;
|
|
}
|
|
else //系统在线人数
|
|
{
|
|
|
|
Application["usercnt"] = Convert.ToInt32(Application["usercnt"].ToString()) + 1;
|
|
|
|
((ArrayList) Application["userlst"]).Add(lem.GetEmployee.em_account);
|
|
|
|
}
|
|
DeiNiu.Utils. LoginInfo.UserId = lem.GetEmployee.ID;
|
|
|
|
lem.GetEmployee.em_isOnline = true;
|
|
lem.GetEmployee.Update();
|
|
|
|
|
|
|
|
Session["CurrentUserId"] = lem.GetEmployee.ID;
|
|
Session["CurrentUserAccount"] = lem.GetEmployee.em_account;
|
|
Session["CurrentUser"] = lem;
|
|
logobj.LoginLog(txtUserName.Text, " login succeed");
|
|
Response.Redirect("desktop.aspx");
|
|
}
|
|
}
|
|
|
|
protected void btnCancelLogin_Click(object sender, EventArgs e)
|
|
{
|
|
Response.Redirect("index.aspx");
|
|
}
|
|
}
|