namespace _07老师和学生登录
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//--------------------------------------------------------------------------------
//最开始,通过判断哪个radioButton1.Checked被选中进行判断
private void button1_Click(object sender, EventArgs e)
{
//先做里面的if,根据需求再加这个外层if
if (radioButton1.Checked == true || radioButton2.Checked == true)
{
if (radioButton1.Checked == true)
{
if (textBox1.Text == "student" && textBox2.Text == "student")
MessageBox.Show("学生登录成功");
else
{
MessageBox.Show("登录失败");
textBox1.Clear();
textBox2.Clear();
textBox1.Focus();
}
}
else
{
if (textBox1.Text == "teacher" && textBox2.Text == "teacher")
MessageBox.Show("老师登录成功");
else
{
MessageBox.Show("登录失败");
textBox1.Clear();
textBox2.Clear();
textBox1.Focus();
}
}
}
else
{
MessageBox.Show("请首先选择一个身份!");
}
}
}
}
MDI窗体