注塑喷涂
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.
 
 
 
 
 

109 lines
3.7 KiB

using MESClassLibrary.BLL.Log;
using MESClassLibrary.BLL.User;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MESWebSite
{
public partial class Login : System.Web.UI.Page
{
UserBLL userclass = new UserBLL();
UserModel md = new UserModel();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
/// <summary>
/// 登录按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnLogin_Click(object sender, EventArgs e)
{
try
{
string _loginName = this.LoginName.Text.Trim();
string _loginpassword = this.LoginPassword.Text.Trim();
UserNameLogin(_loginName, _loginpassword);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
}
}
/// <summary>
/// 登录方法
/// </summary>
/// <param name="_loginName"></param>
/// <param name="_loginpassword"></param>
public void UserNameLogin(string _loginName, string _loginpassword)
{
try
{
md.Username = _loginName;
md.Password = _loginpassword;
if (userclass.Login(md))
{
DataTable dt_user = new DataTable();
dt_user = userclass.SearchUserInfoByUserName(md.Username);
HttpCookie cookie = new HttpCookie("LoginUserInfo");
cookie["UserID"] = dt_user.Rows[0]["UserID"].ToString().Trim();
cookie["UserName"] = _loginName;
cookie["PassWord"] = _loginpassword;
cookie["RealName"] = HttpUtility.UrlEncode(dt_user.Rows[0]["RealName"].ToString().Trim(), System.Text.Encoding.UTF8);
//cookie.Expires = DateTime.Now.AddDays(14);
Response.Cookies.Add(cookie);
Response.Redirect("Manage/index.aspx", false);
}
else
{
ClientScript.RegisterStartupScript(ClientScript.GetType(), "错误", "<script>alert('用户名或密码错误,请重新输入');</script>");
}
#region 注销
//if (userclass.Login(md))
//{
// #region 下次自动登录-暂时注销
// //if (AutoLogin.Checked)
// //{
// // HttpCookie cookie = new HttpCookie("LoginUserInfo");
// // cookie["UserName"] = _loginName;
// // cookie["PassWord"] = _loginpassword;
// // cookie.Expires = DateTime.Now.AddDays(14);
// // Response.Cookies.Add(cookie);
// //}
// //Session.Add("LoginUserInfo", md);
// #endregion
// Response.Redirect("Manage/index.aspx", false);
//}
//else
//{
// ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>alert('用户名或密码错误,请重新输入');</script>");
//}
#endregion
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
}
}
}
}