web页面的用户登录界面
我写了一段代码,用来判断用户登录的,但是执行时不管怎么输都显示 "对不起,您输入的用户名错误!",程序代码如下,请高手指教
private void Button1_Click(object sender, System.EventArgs e)
{
if (this.username .Text =="")
{
this.RegisterStartupScript("提示", " <script language=\"javascript\"> alert('请输入用户名!'); </script> ");
return;
}
string SqlConn=System.Configuration.ConfigurationSettings.AppSettings["ConnString"];
SqlConnection Conn=new SqlConnection(SqlConn);
Conn.Open();
string SqlStr0="select username,logid,pwd,qx,sfjh from [zy_user] where logid='"+this.username.Text+"' and sfzx='0'";
SqlCommand Comm0=new SqlCommand(SqlStr0,Conn);
SqlDataReader read0=Comm0.ExecuteReader();
if(read0.Read())
{
string sfjh=read0["sfjh"].ToString();
if (sfjh=="0")
{
this.err.Text="对不起,您是第一次登录必须修改密码!";
return;
}
string pwd=read0["pwd"].ToString();
if (!new Encode().DecodePassword(ref pwd,128))
{
}
if (pwd != this.pwd.Text)
{
this.err.Text="对不起,您输入的用户名或密码错误!";
this.pwd.Text="";
return;
}
else
{
Session["S_username"]=this.username.Text;
Session["S_qx"]=read0["qx"].ToString();
Session["S_username1"]=read0["username"].ToString();
Session.Timeout=500;
Response.Redirect("main.aspx");
read0.Close();
Conn.Close();
}
}
else
{
read0.Close();
Conn.Close();
this.err.Text="对不起,您输入的用户名或密码错误!";
this.username.Text="";
this.pwd.Text="";
}
}