protected override void OnInit(EventArgs e) { //BLL.Admin bllAdmin = new BLL.Admin(); //var u = bllAdmin.GetModel(1); //Model.AdminInfo uModel = new Model.AdminInfo //{ // ID = u.ID, // UserName = u.UserName, // UserType = Codes.AdminRole.管理员, // TbAccount = "S1" //}; //Session[sessionAdminModel] = uModel; if (Request.QueryString["zhanghaoid"] != null) { Response.Cookies["zhanghaoid"].Value = Request.QueryString["zhanghaoid"].ToString(); } string urls = "tljlist.aspx|tljdo.aspx|change.aspx|appkeylist.aspx|appkeydo.aspx|changepwd.aspx|collectgoodslist.aspx|orderslist.aspx|plansdo.aspx|planslist.aspx|productstat.aspx|tljstat.aspx"; string currentPage = System.IO.Path.GetFileName(Request.PhysicalPath).ToLower(); if (Session[sessionAdminModel] == null && urls.IndexOf(currentPage) != -1) { if (Request.QueryString["zhanghao"] != null && Request.QueryString["mima"] != null) { string username = Request.QueryString["zhanghao"]; string userpwd = Request.QueryString["mima"]; BLL.Admin bllAdmin = new BLL.Admin(); var uModel = bllAdmin.AdminLogin(username, PageFunc.Encrypt(userpwd, 1)); if (uModel != null) { Session[sessionAdminModel] = uModel; Response.Redirect(Request.Url.ToString()); } else { Response.Write("<script language='Javascript'>alert('帐号无效!');window.parent.location='login.aspx';</script>"); Response.End(); } } } if (Session[sessionAdminModel] == null) { Response.Write("<script language='Javascript'>alert('登录超时!');window.parent.location='login.aspx';</script>"); Response.End(); } }
protected void BtnLogin_Click(object sender, EventArgs e) { BLL.Admin bllAdmin = new BLL.Admin(); if (Session["SSVC"] != null) { if (this.txtCode.Text.Trim().ToLower() != Session["SSVC"].ToString().ToLower()) { PageFunc.AjaxAlert(this.Page, "错误的验证码,请重新输入!"); this.txtCode.Text = ""; } else { var uModel = bllAdmin.AdminLogin(this.txtUserName.Text.Trim(), PageFunc.Encrypt(this.txtPassWd.Text, 1)); if (uModel != null) { if (!uModel.Enabled) { PageFunc.AjaxAlert(this.Page, "该帐号已被停用!"); this.txtCode.Text = ""; } else { AdminPage basePage = new AdminPage(); Session[basePage.sessionAdminModel] = uModel; Response.Redirect("TljList.aspx"); } } else { PageFunc.AjaxAlert(this.Page, "用户名或密码有误!"); this.txtCode.Text = ""; } } } else { PageFunc.AjaxAlert(this.Page, "验证码无效,请重新刷新!"); this.txtCode.Text = ""; } }