C#简略管理系统

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

简略的学生管理系统 有不足之处,请大佬指教**

登录界面

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 = "10086", tpwd = "1314";
        const string sid = "110", spwd = "120";

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //获取输入文本框的值
            string tm= maskedTextBox1.Text;
            string tp = textBox1.Text;
            string js = comboBox1.SelectedItem.ToString();
            if (tm==""||tp=="")
            {
                MessageBox.Show("请输入必填项");
                return;
            }
            switch (js)
            {
                case "老师":
                    if (tm.Equals(tid)&&tp.Equals(tpwd))
                    {
                        Main m = new Main();

                        m.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("登录失败");
                    }
                    break;
                case "学生":
                    if (tm.Equals(sid) && tp.Equals(spwd))
                    {
                        MessageBox.Show("登录成功");
                    }
                    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 修改密码ToolStripMenuItem_Click(object sender, EventArgs e)
        {
           
        }


        private void Main_Load(object sender, EventArgs e)
        {
            groupBox2.Visible = false;
            //遍历treeView1里面的节点
            foreach (TreeNode item in treeView1.Nodes)
            {
                //将节点里面文本内容添加到下拉框里面
                comboBox1.Items.Add(item.Text);
            }
            //将其设为只读的
            comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            //默认选项为第一个
            comboBox1.SelectedIndex = 0;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string opwd = textBox1.Text;
            string npwd = textBox2.Text;
            string cpwd = textBox3.Text;
            if (opwd==""||npwd==""||cpwd=="")
            {
                MessageBox.Show("请填写必填项");
                return;
            }
            // 判断旧密码是否与输入的登录密码一致
            if (opwd.Equals("1314"))
            {
                //判断输入的新密码是否与确认密码一致
                if (npwd.Equals(cpwd))
                {
                    DialogResult re = MessageBox.Show("修改成功", "提示", 
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (re==DialogResult.OK)
                        {
                         groupBox1.Visible = false;
                        }
                }
                else
                {
                    MessageBox.Show("请保持重复密码与新密码一致");
                }
            }
            else
            {
                MessageBox.Show("输入错误");
                return;
            }
        }

        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);
                }
            }
        }
        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 ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            groupBox1.Visible = true;
            groupBox2.Visible = false;
        }

        private void 添加学生ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            groupBox2.Visible = true;
            groupBox1.Visible = false;
        }

        private void 设置样式ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form1 f = new Form1();
            f.Show();
            this.Hide();
        }

        private void 设置主题淹死ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

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

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

        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;
        }
    }
}

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值