C#、。net程序,用户代码未处理formatexception 30
三层架构写的登陆页面,单独登陆时没问题,登陆文本框为空时就会出现这个错误,放了必填验证控件没有用protectedvoidbtnLogin_Click(objectsen...
三层架构写的登陆页面,单独登陆时没问题,登陆文本框为空时就会出现这个错误,放了必填验证控件没有用
protected void btnLogin_Click(object sender, EventArgs e)
{
SolderBusiness sb = new SolderBusiness();
int i = sb.IsUserExist(Convert.ToInt32( txtSno.Text.Trim()), txtPWD.Text.Trim());
if (i > 0)
{
if (txtV.Text.Trim() == lblV.Text.Trim())
{
Session["sno"] = txtSno.Text.Trim();
Response.Redirect("BusinessOrder.aspx");
}
else
{
Response.Write("<script>alert('验证码输入错误')</script>");
lblV.Text = RndNum(4);
}
}
else
{
Response.Write("<script>alert('账号或密码输入错误')</script>");
}
}
public int IsUserExist(int sno,string spwd)
{
string sqlText = "select count(*) from SellerTable where sno=@sno and spwd=@spwd";
string[] paraNames = { "@sno","@spwd"};
object[] paraValues = { sno ,spwd };
int i = Convert.ToInt32(DA.GetOneData(sqlText, CommandType.Text, paraNames, paraValues));
return i;
} 展开
protected void btnLogin_Click(object sender, EventArgs e)
{
SolderBusiness sb = new SolderBusiness();
int i = sb.IsUserExist(Convert.ToInt32( txtSno.Text.Trim()), txtPWD.Text.Trim());
if (i > 0)
{
if (txtV.Text.Trim() == lblV.Text.Trim())
{
Session["sno"] = txtSno.Text.Trim();
Response.Redirect("BusinessOrder.aspx");
}
else
{
Response.Write("<script>alert('验证码输入错误')</script>");
lblV.Text = RndNum(4);
}
}
else
{
Response.Write("<script>alert('账号或密码输入错误')</script>");
}
}
public int IsUserExist(int sno,string spwd)
{
string sqlText = "select count(*) from SellerTable where sno=@sno and spwd=@spwd";
string[] paraNames = { "@sno","@spwd"};
object[] paraValues = { sno ,spwd };
int i = Convert.ToInt32(DA.GetOneData(sqlText, CommandType.Text, paraNames, paraValues));
return i;
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询