赞
踩
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebService;
namespace webTest
{
public partial class Register : BaseClass
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
registed.Visible = false;
RegisteInfo.Visible = false;
RegisteFail.Visible = false;
RegisteSuccess.Visible = false;
login.Visible = false;
if ("" != name.Text && "" != pwd.Text)
{
DataSet ds = new DataSet();
ds = GetList("*", "sys_userinfo", "user_name='" + name.Text + "'");
if (null != ds)//这儿ds 为什么不是null
{
if (0 != ds.Tables[0].Rows.Count)
{
//该账号已经被注册过了
registed.Visible = true;
return;
}
else
{
//该账号未被注册,在数据库里插入用户数据
string sql;
string msg;
sql = "insert into sys_userinfo(user_name, user_pwd, user_mbwt1," +
"user_mbda1, user_mbwt2, user_mbda2)" +
"values('" + name.Text + "', '" + pwd.Text +
"', '" + mbquestion1.Text + "','" + mb1_answer.Text +
"', '" + mbquestion2.Text + "', '" + mb2_answer.Text + "')";
if (false != ExecuteQuery(sql, out msg))
{
RegisteSuccess.Visible = true;
login.Visible = true;
//注册成功(sql执行成功),返回登录页面
}
else
{
RegisteFail.Visible = true;
//注册失败(sql执行失败)
return;
}
}
}
}
else
{
RegisteInfo.Visible = true;
//注册失败,用户信息不完整
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("login.aspx");
}
}
}
//
//
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebService;
namespace webTest
{
public partial class login :BaseClass
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if( "" != name.Text && "" != pwd.Text)
{
DataSet ds = new DataSet();
ds = GetList("*", "sys_userinfo", "user_name='" + name.Text + "'and user_pwd='" + pwd.Text + "'");
if (null != ds)
{
if (0 != ds.Tables[0].Rows.Count)
{
//正确
Response.Redirect("Succsess.aspx?user_name="+ ds.Tables[0].Rows[0]["user_name"]);
}
else
{
Label1.Visible = true;
Label1.Text = "用户信息不符";
return;
}
}
}
else
{
Label1.Visible = true;
return;
}
}
protected void Button2_Click1(object sender, EventArgs e)
{
Response.Redirect("Register.aspx");
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.Redirect("zhmm.aspx");
}
}
}
//
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebService;
namespace webTest
{
public partial class Succsess : BaseClass
{
protected void Page_Load(object sender, EventArgs e)
{
user.Text = Request.QueryString["user_name"];
}
protected void modify_mb_Click(object sender, EventArgs e)
{
//跳转到修改密保问题页面
Response.Redirect("Modify_mb.aspx?user_name=" + user.Text);
}
protected void modify_pw_Click(object sender, EventArgs e)
{
//跳转到修改密码问题页面
Response.Redirect("xgmm.aspx?user_name=" + user.Text);
}
}
}
//
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebService;
namespace webTest
{
public partial class Modify_mb : BaseClass
{
protected void Page_Load(object sender, EventArgs e)
{
user_name.Text = Request.QueryString["user_name"];
}
protected void TextBox3_TextChanged(object sender, EventArgs e)
{
}
protected void Update_mb_Click(object sender, EventArgs e)
{
Label1.Visible = false;
Label2.Visible = false;
string sql;
string msg;
sql = "update sys_userinfo set user_mbwt1='" +
mbquestion1.Text + "',user_mbda1='" + mb_answer1.Text +
"',user_mbwt2= '" + mbquestion2.Text + "',user_mbda2='" + mb_answer2.Text + "'where user_name='" + user_name.Text + "'";
if (false != ExecuteQuery(sql, out msg))
{
Label1.Visible = true;
//修改成功(sql执行成功),返回登录页面
}
else
{
Label2.Visible = true;
//修改失败(sql执行失败)
return;
}
}
}
}
//
//
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebService;
namespace Webtest
{
public partial class xgmm : BaseClass
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
login2.Visible = false;
Label3.Visible = false;
Label2.Visible = false;
Label5.Visible = false;
if ("" != ymm.Text)//输入原密码不为空
{
DataSet ds = new DataSet();
Label4.Text = Request.QueryString["user_name"];
ds = GetList("user_pwd", "sys_userinfo", "user_name ='" + Label4.Text + "'");//取database里的密码
if ((string)ds.Tables[0].Rows[0]["user_pwd"] != ymm.Text)//原密码输错
{
//贴出错误label_0
Label3.Visible = true;
// return;
}
else//原密码匹配
{
Label3.Visible = false;
if (new_pwd1.Text != new_pwd2.Text)//密码确认错误
{
//贴出错误label_1
Label5.Visible = true;
return;
}
//密码匹配正确,往下执行
Label5.Visible = false;
string sql;
string msg;
sql = "update sys_userinfo set user_pwd='" + new_pwd2.Text + "'where user_name='" + Label4.Text + "'";
if(false!=ExecuteQuery(sql, out msg))
{
//插入成功
//更新数据库里该用户的密码
Label2.Visible = true;
login2.Visible = true;
//贴出任务完成label_2
}
else
{
//插入失败
//更新数据库里该用户的密码
Label2.Visible = false;
login2.Visible = false;
return;
}
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("login.aspx");
}
}
}
然后重新登录
(旧密码失效)
(登录成功)
//
//
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。