7.WinFor练习--用户登录

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了7.WinFor练习--用户登录相关的知识,希望对你有一定的参考价值。

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练习--用户登录的主要内容,如果未能解决你的问题,请参考以下文章

Python练习,模拟用户登录接口

ajax讲解:“创建用户”和“用户登录”练习

Python练习-有点儿意思的用户登录

python文件调用小练习——用户登录及锁定

Spring练习,使用注解的方式,完成模拟用户的正常登录。要求如下: 使用注解方式开发模拟用户的正常登录。

练习-用户登录