首页面
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 管理系统
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//默认选项为第一个
comboBox1.SelectedIndex = 0;
//只读
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
}
const string teacherid = "123456", teacherpwd = "123abc";
const string studentid = "654321", studentpwd = "321abc";
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
//登录按钮
private void button1_Click(object sender, EventArgs e)
{
//接收密码
string id = maskedTextBox1.Text;
string pwd = textBox1.Text;
if (id==""||pwd=="")
{
MessageBox.Show("请输入必填项");
return;
}
//选择框
string Checkbox = comboBox1.SelectedItem.ToString();
//判断登录
switch (Checkbox)
{
case "老师":
if (teacherid==id&&teacherpwd==pwd)
{
Form2 sheet = new Form2();
sheet.Show();
this.Hide();
}
else
{
MessageBox.Show("登陆失败");
}
break;
case "学生":
if (studentid == id && studentpwd == pwd)
{
Form3 sheet = new Form3();
sheet.Show();
this.Hide();
}
else
{
MessageBox.Show("登陆失败");
}
break;
default:
break;
}
}
}
}
学生页面
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
usi