/// <summary> /// 修改密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { SP.BLL.members bll = new SP.BLL.members(); //判断两次密码输入是否一致,如果不一致,则弹出提示信息,并返回 if (TextBox1.Text == TextBox2.Text) { //根据用户编号和原密码得到用户信息 DataSet ds = bll.GetList(" lname=" + Session["lname"].ToString() + " and pass='******'"); //判断原密码是否正确 if (ds.Tables[0].Rows.Count > 0) { //更新新密码 SP.Model.members model = new SP.Model.members(); model.pass = Md5Hash(TextBox1.Text); model.lname = Session["lname"].ToString(); bll.Update(model); Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('修改成功!');</script>"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('原密码不正确!');</script>"); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('两次密码输入不一致!');</script>"); } }
/// <summary> /// 注册 /// </summary> protected void btnSave_Click(object sender, EventArgs e) { SP.BLL.members bll = new SP.BLL.members(); //验证是否已经存在 if (bll.Exists(txt_lname.Text)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('该登录名已存在,请重新输入!');</script>"); return; } if (txt_pass.Text != txt_pass2.Text) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('两次密码输入不一致,请重新输入!');</script>"); return; } string addrpic = ""; if (fppic.HasFile) { string name = this.fppic.PostedFile.FileName; int i = name.LastIndexOf('.'); string extname = name.Substring(i); string filename = DateTime.Now.ToString("yyyyMMddhhmmssfff"); string path = filename + extname; string savePath = Server.MapPath(@"uploads\" + filename + extname); fppic.PostedFile.SaveAs(savePath); addrpic = path; } string lname = txt_lname.Text; string pass = Md5Hash(txt_pass.Text); string mname = txt_mname.Text; string sex = rtsex.SelectedValue; string tel = txt_tel.Text; string mpic = addrpic; DateTime regtime = DateTime.Now; SP.Model.members model = new SP.Model.members(); model.lname = lname; model.pass = pass; model.mname = mname; model.sex = sex; model.tel = tel; model.mpic = mpic; model.regtime = regtime; bll.Add(model); Session["lname"] = txt_lname.Text; Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('恭喜您注册成功!');location.href='default.aspx';</script>"); }
//初始化 private void ShowInfo() { if (Request.QueryString["id"] != null) { SP.BLL.members bll = new SP.BLL.members(); SP.Model.members model = bll.GetModel(Request.QueryString["id"]); this.lbllname.Text = model.lname; this.lblpass.Text = model.pass; this.lblmname.Text = model.mname; this.lblsex.Text = model.sex; this.lbltel.Text = model.tel; imgpic.ImageUrl = "../../uploads/" + model.mpic; this.lblregtime.Text = model.regtime.ToString(); } }
/// <summary> /// 编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { string addrpic = Labelpic.Text; if (fppic.HasFile) { string name = this.fppic.PostedFile.FileName; int i = name.LastIndexOf('.'); string extname = name.Substring(i); string filename = DateTime.Now.ToString("yyyyMMddhhmmssfff"); string path = filename + extname; string savePath = Server.MapPath(@"..\..\uploads\" + filename + extname); fppic.PostedFile.SaveAs(savePath); addrpic = path; } string lname = txt_lname.Text; //string pass = Md5Hash(txt_pass.Text); string mname = txt_mname.Text; string sex = rtsex.SelectedValue; string tel = txt_tel.Text; string mpic = addrpic; SP.Model.members model = new SP.Model.members(); model.lname = lname; // model.pass = pass; model.mname = mname; model.sex = sex; model.tel = tel; model.mpic = mpic; bll.Update(model); Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('操作成功,请返回!');location.href='Default.aspx';</script>"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(SP.Model.members model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(SP.Model.members model) { return(dal.Add(model)); }