62,269
社区成员
发帖
与我相关
我的任务
分享
protected void Button1_Click(object sender, EventArgs e)
{
string userName = txtUserName.Text.Trim();
string passWord = txtPassWord.Text.Trim();
MyChatRoom.BussinessLoginLayer.User user = new User();
user.LoadData(userName); //获取用户信息
if(user.Exist) //如果是老用户
{
if(user.Password==password) {
Response.Redirect("Main.aspx");
}
else {
Response.Write("<Script Language=JavaScript>alert(\"验证失败,请重新登录!\")</Script>");
}
}
}
public string UserName
{
set
{
this._userName=value;
}
get
{
return this._userName;
}
}
public string Password
{
set
{
this._password=value;
}
get
{
return this._password;
}
}
public bool Exist
{
get
{
return this._exist;
}
}
public bool LoadData(string userName)
{
Database db = new Database(); //实例化一个Database类
string Sql="select * from [User] where UserName='"+userName+"'";
DataRow dr = db.GetDataRow(Sql); //利用Database类里的GetDataRow方法查询数据库
if (dr != null)
{
this._userName = dr["UserName"].ToString();
this._passWord = dr["PassWord"].ToString();
return true;
}
else
return false;
}
if (user.LoadData(userName)) //获取用户信息
{
Response.Redirect("Main.aspx");
}
if (this._Exist)
{
Response.Redirect("Main.aspx");
}
if (user.Exist)
{
Response.Redirect("Main.aspx");
}
if (user._Exist)
{
Response.Redirect("Main.aspx");
}