addusers.cs

来自「一个简单的考生答题系统」· CS 代码 · 共 67 行

CS
67
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Myschool
{
    public partial class AddUsers : Form
    {
        public AddUsers()
        {
            InitializeComponent();
        }

        private void btnsure_Click(object sender, EventArgs e)
        {
            //获得前台数据
            string name = txtname.Text;
            string pwd1 = txtpwd1.Text;
            string pwd2 = txtpwd2.Text;
            //数据效验
            if ("" == name) {
                MessageBox.Show("请输入用户名!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
                txtname.Focus();
                return;
            } if ("" == pwd1) {
                MessageBox.Show("请输入密码!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
                txtpwd1.Focus();
                return;
            }if(""==pwd2){
            MessageBox.Show("请输入确认密码!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
            txtpwd2.Focus();
                return;
            }if(pwd1!=pwd2){
            MessageBox.Show("两次密码输入不同,请确认后重新输入!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
            txtpwd1.Focus();
            return;
            }
            bool b = AddSubject.AddStudent(name,pwd1);
            if (b)
            {
                MessageBox.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else {
                MessageBox.Show("添加失败","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
            }
        }

        private void AddUsers_Load(object sender, EventArgs e)
        {
            comtype.SelectedIndex = 0;
        }

        private void btngiveup_Click(object sender, EventArgs e)
        {
            txtname.Text = "";
            txtpwd1.Text = "";
            txtpwd2.Text = "";
            comtype.SelectedIndex = 0;
        }

   
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?