/// <summary> /// 登录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnLogin_Click(object sender, EventArgs e) { SP.BLL.members bll = new SP.BLL.members(); //根据用户名和密码得到用户信息 DataSet ds = bll.GetList(" lname='" + txt_lname.Text + "' and pass='******'"); //判断用户是否存在 if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; //把用户信息存入到Session Session["lname"] = dr["lname"].ToString(); //跳转 Response.Redirect("default.aspx"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('用户名或密码错误!');</script>"); return; } }
/// <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> private void bind() { string where = " 1=1 "; if (txt_lname.Text != "") { where += " and lname like '%" + txt_lname.Text + "%' "; } GridView1.DataSource = bll.GetList(where + " order by regtime desc"); GridView1.DataBind(); }
/// <summary> /// 初始化 /// </summary> protected void chushi() { //根据编号得到相应的记录 DataSet ds = bll.GetList(" lname='" + Session["lname"] + "'"); if (ds.Tables[0].Rows.Count > 0) { txt_lname.Text = ds.Tables[0].Rows[0]["lname"].ToString(); // txt_pass.Text = ds.Tables[0].Rows[0]["pass"].ToString(); txt_mname.Text = ds.Tables[0].Rows[0]["mname"].ToString(); rtsex.SelectedValue = ds.Tables[0].Rows[0]["sex"].ToString(); txt_tel.Text = ds.Tables[0].Rows[0]["tel"].ToString(); Labelpic.Text = ds.Tables[0].Rows[0]["mpic"].ToString(); if (Labelpic.Text != "" && Labelpic.Text.Length > 3) { Imagepic.ImageUrl = "../../uploads/" + Labelpic.Text; Imagepic.Visible = true; } } }