7.WinFor练习--用户登录

2021-06-03 13:02

阅读:854

标签:tar   不成功   成功   lse   else   用户登录   登录失败   win   string   

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("请先选择用户登录身份");
}
}
}
}

7.WinFor练习--用户登录

标签:tar   不成功   成功   lse   else   用户登录   登录失败   win   string   

原文地址:https://blog.51cto.com/12679593/2398232


评论


亲,登录后才可以留言!