C# Winfrom学生管理系统

 

1.界面控件展示C# Winfrom学生管理系统_第1张图片

2.登录界面展示

C# Winfrom学生管理系统_第2张图片

 

C# Winfrom学生管理系统_第3张图片

C# Winfrom学生管理系统_第4张图片

C# Winfrom学生管理系统_第5张图片C# Winfrom学生管理系统_第6张图片

登录页面代码

​
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 = "123456", tpwd = "qwer";
        const string sid = "654321", spwd = "asdf";

        private void button1_Click(object sender, EventArgs e)
        {
            string id = maskedTextBox1.Text;
            string pwd = textBox2.Text;
            if (id == "" || pwd == "")
            {
                MessageBox.Show("请输入必填项");
                return;
            }
            string p = comboBox1.SelectedItem.ToString();
            switch (p)
            {
                case "老师":
                default:
                    if (tid.Equals(id)&&tpwd.Equals(pwd))
                    {
                        //实例化
                        main main = new main();
                        main.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("登陆失败");
                    }
                    break;
                case "学生":
                    if (sid.Equals(id)&&spwd.Equals(pwd))
                    {
                        main main2 = new main();
                        main2.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("登陆失败");
                    }
                    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 main : Form
    {
        public main()
        {
            InitializeComponent();
        }

        private void main_Load(object sender, EventArgs e)
        {
            this.Text = "教师管理页面";
            groupBox1.Visible = false;
            groupBox2.Visible = false;
            groupBox3.Visible = false;
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
          //  Image image = pictureBox1.Image = ImageLayout.Stretch;
            foreach (TreeNode item in treeView1.Nodes)
            {
                // MessageBox.Show(((TreeNode)item).Text);
                comboBox1.Items.Add(item.Text);
            }
            comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBox1.SelectedIndex = 0;
            comboBox2.SelectedIndex = 0;
            comboBox2.DropDownStyle = ComboBoxStyle.DropDownList;
            treeView1.Visible = false;
            treeView2.Visible = false;
            pictureBox1.Visible = false;
            treeView2.Visible = false;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            toolStripStatusLabel4.Text = DateTime.Now.ToString();
        }

        private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            groupBox1.Visible = true;
            groupBox2.Visible = false;
            groupBox3.Visible = false;
            treeView1.Visible = false;
            pictureBox1.Visible = false;
            treeView2.Visible = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string oldpwd = textBox1.Text;
            string newpwd = textBox2.Text;
            string pwd = textBox3.Text;
            if (oldpwd==""||newpwd==""||pwd=="")
            {
                MessageBox.Show("请填写必填项");
                return;
            }
            if (oldpwd.Equals("qwer"))
            {
                if (newpwd.Equals(pwd))
                {
                    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)
        {
            groupBox2.Visible = true;
            groupBox1.Visible = false;
            groupBox3.Visible = false;
            treeView1.Visible = true;
            pictureBox1.Visible = false;
            treeView2.Visible = false;

        }

        private void button2_Click(object sender, EventArgs e)
        {
            string name = textBox5.Text;
            if (name=="")
            {
                MessageBox.Show("请输入姓名");
                return;
            }
            string cname = comboBox1.SelectedItem.ToString();
            foreach (TreeNode item in treeView1.Nodes)
            {
                if (item.Text==cname)
                {
                    item.Nodes.Add(name);
                    textBox5.Text = "";
                }

            }
        }

        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 toolStripButton5_Click(object sender, EventArgs e)
        {
            groupBox1.Visible = false;
            groupBox2.Visible = false;
            groupBox3.Visible = false;
            treeView1.Visible = false;
            pictureBox1.Visible = false;
            treeView2.Visible = false;
        }

        private void 黑色ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.BackColor = Color.Black;
        }

        private void 蓝色ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.BackColor = Color.CadetBlue;
        }

        private void 红色ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.BackColor = Color.MediumVioletRed;
        }

        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;
            treeView1.Visible = false;
            pictureBox1.Visible = false;
            treeView2.Visible = false;
        }

        private void 添加李旦ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            pictureBox1.Visible = true;
            groupBox3.Visible = false;
            groupBox1.Visible = false;
            groupBox2.Visible = false;
            treeView1.Visible = false;
            treeView2.Visible = false;
        }

        private void 删除老师ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            treeView2.Visible = true;
            pictureBox1.Visible = false ;
            groupBox3.Visible = false;
            groupBox1.Visible = false;
            groupBox2.Visible = false;
            treeView1.Visible = false;
        }

   
    }
}

 

你可能感兴趣的:(C#,Winfrom,C#管理系统)