protected void btnUpdate_Click(object sender, EventArgs e) { if (Session["Users"] != null) { Maticsoft.Model.Admin users = (Maticsoft.Model.Admin)Session["Users"]; if (users.Pwd != txtOldPwd.Value.Trim()) { txtOldPwd.Focus(); this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('旧密码错误!');</script>"); return; } else { Maticsoft.BLL.Admin UsersBLL = new Maticsoft.BLL.Admin(); users.Pwd = txtNewPwd.Value.Trim(); if (UsersBLL.Update(users)) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改密码成功!\\n新密码为:" + txtNewPwd.Value.Trim() + "');location=location;</script>"); return; } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改密码失败!');</script>"); return; } } } }
/// <summary> /// 用户登录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BtnLogin_Click(object sender, EventArgs e) { Maticsoft.Model.Admin Admin = new Maticsoft.Model.Admin(); Maticsoft.BLL.Admin admin = new Maticsoft.BLL.Admin(); DataSet ds = admin.GetList(" Name='" + this.txtU_Name.Value.Trim() + "' and Pwd='" + this.txtU_Pass.Value.Trim() + "'"); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { Admin.Name = this.txtU_Name.Value.Trim(); Admin.Pwd = this.txtU_Pass.Value.Trim(); Admin.ID = Convert.ToInt32(dt.Rows[0]["ID"]); Session["Users"] = Admin; Response.Redirect("Index.aspx"); } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('用户名或者密码错误!');</script>"); return; } }