码迷,mamicode.com
首页 > Windows程序 > 详细

7.WinFor练习--用户登录

时间:2019-05-21 22:39:44      阅读:192      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!