三个页面之间是相通的,可通过切换账号,登录其他页面
老师,学生的账号,密码我是给的固定值。
老师的账号:201966 密码:123abc
学生的账号:123456 密码:123123
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 tid = "201966",tpwd="123abc";
const string sid = "123456", spwd="123123";
private void button1_Click(object sender, EventArgs e)
{
string id = maskedTextBox1.Text;
string pwd = textBox1.Text;
if (id == ""||pwd=="")
{
MessageBox.Show("请输入必填项");
return;
}
string selecttype = comboBox1.SelectedItem.ToString();
switch (selecttype)
{
case "老师":
if (tid.Equals(id) && tpwd.Equals(pwd))
{
Form2 fr = new Form2();
fr.Show();
this.Hide();
}
else
{
MessageBox.Show("登录失败!");
}
break;
case "学生":
if (sid.Equals(id) && spwd.Equals(pwd))
{
Form3 fm = new Form3();
fm.Show();
this.Hide();
}
else
{
MessageBox.Show("登录失败!");
}
break;
default:
break;
}
}
}
}
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 Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
this.Text = "王老师";
groupBox1.Visible = false;
groupBox2.Visible = false;
groupBox3.Visible = false;
groupBox4.Visible = false;
groupBox5.Visible = false;
foreach(TreeNode item in treeView1.Nodes)
{
comboBox1.Items.Add(item.Text);
}
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
comboBox1.SelectedIndex = 0;
foreach(TreeNode it in treeView2.Nodes)
{
comboBox2.Items.Add(it.Text);
}
comboBox2.DropDownStyle = ComboBoxStyle.DropDownList;
comboBox2.SelectedIndex = 0;
foreach(TreeNode iem in treeView3.Nodes)
{
comboBox3.Items.Add(iem.Text);
}
comboBox3.DropDownStyle = ComboBoxStyle.DropDownList;
comboBox3.SelectedIndex = 0;
}
private void timer1_Tick(object sender, EventArgs e)
{
toolStripStatusLabel6.Text = DateTime.Now.ToString();
}
private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e)
{
groupBox1.Visible = true;
groupBox2.Visible = false;
groupBox3.Visible = false;
groupBox4.Visible = false;
groupBox5.Visible = false;
}
private void button1_Click(object sender, EventArgs e)
{
string oldpwd = textBox1.Text;
string newpwd = textBox2.Text;
string repwd = textBox3.Text;
if (oldpwd == "" || newpwd == "" || repwd == "")
{
MessageBox.Show("请输入必填项");
}
if (oldpwd.Equals("123abc"))
{
if (newpwd.Equals(repwd))
{
DialogResult result =MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK,MessageBoxIcon.Information);
if (result == DialogResult.OK)
{
groupBox1.Visible = false;
}
}
else
{
MessageBox.Show("重复密码与新密码不一致");
}
}
else
{
MessageBox.Show("原密码错误请联系管理员");
}
}
private void 切换账号ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form1 form = new Form1();
form.Show();
this.Hide();
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void 添加学生ToolStripMenuItem_Click(object sender, EventArgs e)
{
treeView1.Visible = true;
treeView2.Visible = false;
treeView3.Visible = false;
groupBox2.Visible = true;
groupBox1.Visible = false;
groupBox3.Visible = false;
groupBox4.Visible = false;
groupBox5.Visible = false;
}
private void button2_Click(object sender, EventArgs e)
{
string name = textBox4.Text;
if (name == "")
{
MessageBox.Show("请输入姓名!");
return;
}
textBox4.Text = "";
string cname = comboBox1.SelectedItem.ToString();
foreach(TreeNode item in treeView1.Nodes)
{
if (item.Text == cname)
{
item.Nodes.Add(name);
}
}
}
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{
TreeNode node =treeView1.SelectedNode;
foreach(TreeNode item in treeView1.Nodes)
{
if (node.Text == item.Text)
{
MessageBox.Show("不能删除班级!");
return;
}
}
node.Remove();
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
groupBox1.Visible = false;
groupBox2.Visible = false;
groupBox3.Visible = false;
groupBox4.Visible = false;
groupBox5.Visible = false;
}
private void 蓝色ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.BackColor = Color.Cyan;
}
private void 粉色ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.BackColor = Color.HotPink;
}
private void 红色ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.BackColor = Color.OrangeRed;
}
private void 自定义ToolStripMenuItem_Click(object sender, EventArgs e)
{
colorDialog1.ShowDialog();
this.BackColor = colorDialog1.Color;
}
private void 设置字体ToolStripMenuItem_Click(object sender, EventArgs e)
{
fontDialog1.ShowDialog();
this.Font = fontDialog1.Font;
}
private void 个人信息ToolStripMenuItem_Click(object sender, EventArgs e)
{
groupBox3.Visible = true;
groupBox1.Visible = false;
groupBox2.Visible = false;
groupBox4.Visible = false;
groupBox5.Visible = false;
}
private void button3_Click(object sender, EventArgs e)
{
string xm = textBox5.Text;
string old = textBox6.Text;
string num = maskedTextBox1.Text;
if (xm == "" || old == "" || num == ""||radioButton1.Checked==false&&radioButton2.Checked==false)
{
MessageBox.Show("请输入必填项");
return;
}
else
{
DialogResult res = MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (res == DialogResult.OK)
{
groupBox3.Visible = false;
}
}
}
private void 添加老师ToolStripMenuItem_Click(object sender, EventArgs e)
{
treeView1.Visible = false;
treeView2.Visible = true;
treeView3.Visible = false;
groupBox4.Visible = true;
groupBox1.Visible = false;
groupBox2.Visible = false;
groupBox3.Visible = false;
groupBox5.Visible = false;
}
private void button4_Click(object sender, EventArgs e)
{
string names = textBox7.Text;
if (names == "")
{
MessageBox.Show("请输入姓名");
return;
}
textBox7.Text = "";
string sname = comboBox2.SelectedItem.ToString();
foreach (TreeNode item in treeView2.Nodes)
{
if (item.Text == sname)
{
item.Nodes.Add(names);
}
}
}
private void 删除ToolStripMenuItem1_Click(object sender, EventArgs e)
{
TreeNode ls = treeView2.SelectedNode;
foreach (TreeNode item in treeView2.Nodes)
{
if (ls.Text == item.Text)
{
MessageBox.Show("不能删除班级!");
return;
}
}
ls.Remove();
}
private void 职务分配ToolStripMenuItem_Click(object sender, EventArgs e)
{
treeView1.Visible = false;
treeView2.Visible = false;
treeView3.Visible = true;
groupBox1.Visible = false;
groupBox2.Visible = false;
groupBox3.Visible = false;
groupBox4.Visible = false;
groupBox5.Visible = true;
}
private void button5_Click(object sender, EventArgs e)
{
string namez = textBox8.Text;
if (namez == "")
{
MessageBox.Show("请输入姓名");
return;
}
textBox8.Text = "";
string zname = comboBox3.SelectedItem.ToString();
foreach (TreeNode item in treeView3.Nodes)
{
if (item.Text == zname)
{
item.Nodes.Add(namez);
}
}
}
private void 删除ToolStripMenuItem2_Click(object sender, EventArgs e)
{
TreeNode bm = treeView3.SelectedNode;
foreach (TreeNode item in treeView3.Nodes)
{
if (bm.Text == item.Text)
{
MessageBox.Show("不能删除部门!");
return;
}
}
bm.Remove();
}
}
}
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 Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
toolStripStatusLabel6.Text = DateTime.Now.ToString();
}
private void Form3_Load(object sender, EventArgs e)
{
groupBox1.Visible = false;
groupBox2.Visible = false;
groupBox3.Visible = false;
groupBox4.Visible = false;
}
private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e)
{
groupBox1.Visible = true;
groupBox2.Visible = false;
groupBox3.Visible = false;
groupBox4.Visible = false;
}
private void button1_Click(object sender, EventArgs e)
{
string cs = textBox1.Text;
string xmm = textBox2.Text;
string qrx = textBox3.Text;
if (cs == "" || xmm == "" || qrx == "")
{
MessageBox.Show("请输入必填项");
}
if (cs.Equals("123123"))
{
if (xmm.Equals(qrx))
{
DialogResult re = MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (re == DialogResult.OK)
{
groupBox1.Visible = false;
}
}
else
{
MessageBox.Show("重复密码与新密码不一致");
}
}
else
{
MessageBox.Show("原密码错误请联系管理员");
}
}
private void 个人信息ToolStripMenuItem_Click(object sender, EventArgs e)
{
groupBox1.Visible = false;
groupBox2.Visible = true;
groupBox3.Visible = false;
groupBox4.Visible = false;
}
private void button2_Click(object sender, EventArgs e)
{
string xm = textBox4.Text;
string zy = textBox5.Text;
string xh = textBox6.Text;
string bj = textBox7.Text;
string nl = textBox8.Text;
string mz = textBox9.Text;
if (xm == "" || zy == "" || xh == "" || bj == "" || nl == "" || mz == "" || radioButton1.Checked == false || radioButton2.Checked == false)
{
MessageBox.Show("请输入必填项");
return;
}
else
{
DialogResult res = MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (res == DialogResult.OK)
{
groupBox2.Visible = false;
}
}
}
private void 切换账号ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form1 form = new Form1();
form.Show();
this.Hide();
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void 学生课表ToolStripMenuItem_Click(object sender, EventArgs e)
{
groupBox1.Visible = false;
groupBox2.Visible = false;
groupBox3.Visible = true;
groupBox4.Visible = false;
groupBox3.BackgroundImageLayout = ImageLayout.Stretch;
}
private void 学生成绩ToolStripMenuItem_Click(object sender, EventArgs e)
{
groupBox1.Visible = false;
groupBox2.Visible = false;
groupBox3.Visible = false;
groupBox4.Visible = true;
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
groupBox1.Visible = false;
groupBox2.Visible = false;
groupBox3.Visible = false;
groupBox4.Visible = false;
}
}
}