日期:2014-05-19  浏览次数:20661 次

C#菜鸟问题
C#菜鸟问题:我做了一个登陆框,当输入用户名和密码时,到数据库(SQL   Server2000)中查询,正确则显示 "登陆成功 ",错误则显示 "登陆失败 ",请问怎么实现?

------解决方案--------------------
if(this.textBox1.Text.Trim()!=string.Empty)//用户名不为空
{
if(this.textBox2.Text.Trim()!=string.Empty)//密码不为空
{
user user=new user(conn);
if(user.IsHaveUser(textBox1.Text.Trim()))//存在该用户
{
if(user.IsHavePopedom(textBox1.Text.Trim()))//该用户存在权限
{
if(user.IsPassword(textBox1.Text,textBox2.Text))//用户密码正确
{
this.DialogResult=DialogResult.OK;//返回状态
}
else
{
MessageBox.Show( "密码不正确! ");
return;
}

}
else
{
MessageBox.Show( "该用户没有权限! ");
return;
}

}
else
{
MessageBox.Show( "不存在该用户名! ");
return;
}

}
else
{
MessageBox.Show( "密码不能为空! ");
return;
}

}
else
{
MessageBox.Show( "用户名不能为空! ");
return;
}