namespace _7用户登录
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//点击登录时进行判断
private void btnLoging_Click(object sender, EventArgs e)
{
if (radStudent.Checked || radTeacher.Checked)
{
//取得输入用户名和密码
string name = txtName.Text.Trim();
string pwd = txtPwd.Text;
//判断学生登录还是老师登录
if (radStudent.Checked)
{
if (name == "student" && pwd == "student")
{
MessageBox.Show("学生登录成功");
}
else
{
MessageBox.Show("学生登录失败");
txtName.Clear();
txtPwd.Clear();
txtName.Focus();
}
}
else
{
if (name == "teacher" && pwd == "teacher")
{
MessageBox.Show("老师登录成功");
}
else
{
MessageBox.Show("老师登录不成功");
txtName.Clear();
txtPwd.Clear();
}
}
}
else
{
MessageBox.Show("请先选择用户登录身份");
}
}
}
}