练习:WinForm(教师、学生系统登录)

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 学生教师登录
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void rdoStudent_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (rdoStudent.Checked || rdoTeacher.Checked)
            {
                string name = txtName.Text.Trim();
                string pwd = txtPWD.Text;
                //选择学生
                if (rdoStudent.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();
                        txtName.Focus();
                    }
                }
            }

            else 
            {
                MessageBox.Show("请首先选择登录身份");
            }
        }
    }
}

 

posted @ 2016-06-30 15:35  庚xiao午  阅读(477)  评论(0编辑  收藏  举报