protected void BtnUpdate_Click(object sender, EventArgs e) { if (Request.QueryString["id"] != null) { int id = int.Parse(Request.QueryString["id"]); string username = txtUserName.Text.Trim(); var model = bllAdmin.GetModel(p => p.ID != id && p.UserName.Equals(username)); if (model != null) { PageFunc.AjaxAlert(this.Page, "用户名已存在!"); return; } modelAdmin = bllAdmin.GetModel(int.Parse(Request.QueryString["id"])); modelAdmin.UserName = username; if (txtPwd.Text != "重新设置密码") { modelAdmin.UserPwd = PageFunc.Encrypt(txtPwd.Text, 1); } modelAdmin.Enabled = chbIsEnabled.Checked; modelAdmin.UserType = ddlUserType.SelectedValue; modelAdmin.Remark = txtRemark.Text.Trim(); modelAdmin.TbAccount = ddlAccount.SelectedValue; bllAdmin.Update(modelAdmin); Response.Write(PageFunc.ShowMsgJumpE("更新成功!", "AdminList.aspx")); } }
protected void BtnSubmit_Click(object sender, EventArgs e) { var loginModel = Session[sessionAdminModel] as Model.AdminInfo; modelAdmin = bllAdmin.GetModel(loginModel.ID); modelAdmin.UserPwd = PageFunc.Encrypt(txtPwd.Text, 1); bllAdmin.Update(modelAdmin); Response.Write(PageFunc.ShowMsgJumpE("更新成功!", "ChangePwd.aspx")); }
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 = ""; } }
protected void BtnSubmit_Click(object sender, EventArgs e) { string username = txtUserName.Text.Trim(); var model = bllAdmin.GetModel(p => p.UserName.Equals(username)); if (model != null) { PageFunc.AjaxAlert(this.Page, "用户名已存在!"); return; } modelAdmin.UserName = username; modelAdmin.UserPwd = PageFunc.Encrypt(txtPwd.Text, 1); modelAdmin.AddTime = DateTime.Now; modelAdmin.Enabled = chbIsEnabled.Checked; modelAdmin.UserType = ddlUserType.SelectedValue; modelAdmin.Remark = txtRemark.Text.Trim(); modelAdmin.TbAccount = ddlAccount.SelectedValue; bllAdmin.Add(modelAdmin); Response.Write(PageFunc.ShowMsgJumpE("添加成功!", "AdminList.aspx")); }