日期:2014-05-17  浏览次数:20523 次

一个登录界面需要大家帮忙
一个登录界面,需要输入用户名和密码,下面还有三个单选框,分别为学生,老师,管理员!
根据用户输入的姓名和密码,还有选择的单选框内的内容
(点击登录)第一步先在数据库中查姓名和密码是否正确,第二部根据选择的项跳转到相应的页面!
这个怎么做??
查找我会了,关键是如何根据单选款的内容跳转到相应的页面
(这两个步骤结合在一起该怎么做)
谢谢各位大侠!!!!!!!!!!!!!!!!

------解决方案--------------------
以前winForm端写的登陆,原理差不多,代码贴给你,研究下就会的

private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show("账号或用户名不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
if (comboBox1.Text == "学生登录") //学生登录
{
SqlConnection conn = new SqlConnection(connectString);
conn.Open();
string str = "select * from userInformation where userName='" + textBox1.Text + "'and userId='" + textBox2.Text + "'";
SqlCommand cmd = new SqlCommand(str, conn);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Form2 f2 = new Form2();
f2.Show(this);
this.Visible = false;
}
else
{
MessageBox.Show("不存在当前学生用户或者用户名或密码错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
dr.Close();
conn.Close();
}
else if (comboBox1.Text == "教师登录") //教师登录
{
SqlConnection conn1 = new SqlConnection(connectString);
conn1.Open();
string str1="select * from teacherInformation where teacherName='"+textBox1.Text+"'and teacherPassword='"+textBox2.Text+"'";
SqlCommand cmd1=new SqlCommand(str1,conn1);
SqlDataReader dr1=cmd1.ExecuteReader();
if(dr1.Read())
{
Form3 f3=new Form3();
f3.Show(this);
this.Visible = false;
}
else
{
MessageBox.Show("不存在当前教师用户或者用户名或密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
dr1.Close();
conn1.Close();
}
else if (comboBox1.Text == "管理员登录") //管理员登录
{
SqlConnection conn2 = new SqlConnection(connectString);
conn2.Open();
string str2 = "select * from adminInformation where adminName='" + textBox1.Text + "'and adminPassword='" + textBox2.Text + "'";
SqlCommand cmd2 = new SqlCommand(str2, conn2);
SqlDataReader dr2 = cmd2.ExecuteReader();
if (dr2.Read())
{
Form4 f4 = new Form4();
f4.Show(this);
this.Visible = false;
}
else
{
MessageBox.Show("不存在当前管理员用户或者用户名或密码错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
dr2.Close();
conn2