if (loginUser.GetUserInfo(this.txtUserName.Text,this.txtPassWord.Text)==true && loginUser.UserPassed==true )
{
//登录成功
lblCheckInfo.Text=loginUser.RealName +"登录成功!";
Session["username"]=this.txtUserName.Text;
Session["password"]=this.txtPassWord.Text;
loginUser.UserIP="登陆IP:"+this.Request.UserHostAddress+" 机器信息:"+this.Request.Browser.Platform.ToString()+" "+this.Request.Browser.Browser+" "+this.Request.Browser.Version;
loginUser.LoginCount=loginUser.LoginCount+1;
loginUser.LastLoginTime=DateTime.Now.ToShortDateString()+" "+DateTime.Now.ToLongTimeString();
Response.Redirect("admin.aspx");
}
//返回登录失败信息
else
{
Response.Write("<script>alert('登录失败,可能是账号密码错误!')</script>");

}
public bool GetUserInfo(string txtUserName, string txtPassWord)
{
try
{
txtUserName=checkRequest(txtUserName);
txtPassWord=checkRequest(txtPassWord);
String strsql;
strsql="select * from vw_user_info where Username='"+ txtUserName +"'and password='"+ txtPassWord + "'";
DataSet myDs;
myDs=ExecuteSql4Ds(strsql);
if (myDs.Tables[0].Rows.Count == 0)
{
return false;
}
else
{
if (myDs.Tables[0].Rows[0]["Real_name"] != null)
{
this.strId=myDs.Tables[0].Rows[0]["User_ID"].ToString();
this.strLastLoginTime=myDs.Tables[0].Rows[0]["Last_login_time"].ToString();
this.isLeader=(bool)myDs.Tables[0].Rows[0]["Is_leader"];
this.isUserpassed=(bool)myDs.Tables[0].Rows[0]["Is_User_passed"];
this.strAddress=myDs.Tables[0].Rows[0]["Address"].ToString();
this.strDepartment=myDs.Tables[0].Rows[0]["Department_Name"].ToString();
this.strEmail=myDs.Tables[0].Rows[0]["Email"].ToString();
this.strLastLoginTime=myDs.Tables[0].Rows[0]["Last_login_time"].ToString();
this.strPassword=myDs.Tables[0].Rows[0]["Password"].ToString();
this.strPostalcode=myDs.Tables[0].Rows[0]["Postalcode"].ToString();
this.strRealName=myDs.Tables[0].Rows[0]["Real_name"].ToString();
this.strTel=myDs.Tables[0].Rows[0]["Tel"].ToString();
this.strUserIP=myDs.Tables[0].Rows[0]["User_IP"].ToString();
this.strUsername=myDs.Tables[0].Rows[0]["Username"].ToString();
this.strUserType=myDs.Tables[0].Rows[0]["User_type"].ToString();
this.strDepartmentID=myDs.Tables[0].Rows[0]["Department_ID"].ToString();
this.intlogincount=(int)myDs.Tables[0].Rows[0]["Login_count"]; }
return true;
}
}
catch
{
return false;
}

}