⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jiaoshiguanli.cs

📁 data structure c 学校管理系统
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace schoolManager
{
    public partial class jiaoshiguanli : Form
    {
        public jiaoshiguanli()
        {
            InitializeComponent();
        }
        private DataTable datsource;
        private teacher currentT;
        private void jiaoshiguanli_Load(object sender, EventArgs e)
        {
            loadxianzhen();            
        }
        private void loadxianzhen()
        {
            string xiangzhenname = "select xiangzhenmingcheng from xiangzhen";
            DataMessager data = new DataMessager(Application.StartupPath);
            DataTable mytable = data.query(xiangzhenname, "xiangzhen");
            for (int i = 0; i<mytable.Rows.Count;i++ )
            {
                this.comboBox4.Items.Add(mytable.Rows[i].ItemArray[0].ToString());
            }
        }

        private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.comboBox5.Items.Clear();
            string xiangzhenname = "select xuexiaomingcheng from xuexiaobiao where xiangzhen='"+comboBox4.SelectedItem.ToString()+"'";
            DataMessager data = new DataMessager(Application.StartupPath);
            DataTable mytable = data.query(xiangzhenname, "xuexiaobiao");
            for (int i = 0; i < mytable.Rows.Count; i++)
            {
                this.comboBox5.Items.Add(mytable.Rows[i].ItemArray[0].ToString());
            }
        }

        private void comboBox5_SelectedValueChanged(object sender, EventArgs e)
        {
            string xiangzhenname = "select xuexiaodaima from xuexiaobiao where xuexiaomingcheng='" + comboBox5.SelectedItem.ToString() + "'";
            DataMessager data = new DataMessager(Application.StartupPath);
            DataTable mytable = data.query(xiangzhenname, "xuexiaobiao");
            this.textBox7.Text = mytable.Rows[0].ItemArray[0].ToString();
        }
        private void getTeacher()
        {
            try
            {
                currentT = new teacher();
                currentT.beizhu = textBox10.Text;
                currentT.biyiexuexiao0 = textBox1.Text;
                currentT.biyiexuexiao1 = textBox6.Text;
                currentT.canjiagongzuoshijian = dateTimePicker2.Value.ToShortDateString();
                currentT.chushengriqi = dateTimePicker1.Value.ToShortDateString();
                currentT.danrenkecheng = comboBox10.SelectedItem.ToString();
                currentT.dianhua = textBox5.Text;
                currentT.jiaoshizigezhenghao = textBox12.Text;
                currentT.minzu = comboBox7.SelectedItem.ToString();
                currentT.nianling = Convert.ToInt32(textBox11.Text.Trim());
                currentT.rushanshijian = dateTimePicker3.Value.ToShortDateString();
                currentT.shenfenzhenghao = textBox8.Text;
                currentT.xiangzhen = comboBox4.SelectedItem.ToString();
                currentT.xingbie = comboBox1.SelectedItem.ToString();
                currentT.xingming = textBox2.Text;
                currentT.xueli0 = comboBox2.SelectedItem.ToString();
                currentT.xueli1 = comboBox3.SelectedItem.ToString();
                currentT.xuexiao = comboBox5.SelectedItem.ToString();
                currentT.xuexiaodaima = textBox7.Text;
                currentT.xuexiaoleixing = comboBox6.SelectedItem.ToString();
                currentT.yibaohao = textBox14.Text;
                currentT.yinghangzhanghao = textBox13.Text;
                currentT.zhengzhimianmao = comboBox11.SelectedItem.ToString();
                currentT.zhicheng = comboBox9.SelectedItem.ToString();
                currentT.zhiwu = comboBox8.SelectedItem.ToString();
                currentT.zhuzhi = textBox3.Text;
            }
            catch(Exception ex)
            {
                MessageBox.Show("必要选项没有选择,无法完成所需操作!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
        }
        private void button8_Click(object sender, EventArgs e)
        {
            //add
            getTeacher();
            try
            {
                DataMessager add = new DataMessager(Application.StartupPath);
                string sql = "insert into jiaoshibiao values('"+currentT.xiangzhen+"','"+currentT.xuexiao+"','"+currentT.xuexiaodaima+"','"+currentT.xuexiaoleixing+"','"+currentT.xingming+"','"+
                    currentT.xingbie + "','" + currentT.minzu + "','" + currentT.chushengriqi + "','" + currentT.nianling + "','" + currentT.shenfenzhenghao + "','" + currentT.xueli0 + "','" + currentT.xueli1+ "','"+
                    currentT.biyiexuexiao0+"','"+currentT.biyiexuexiao1+"','"+currentT.canjiagongzuoshijian+"','"+currentT.zhengzhimianmao+"','"+currentT.zhiwu+"','"+currentT.zhicheng+"','"+
                    currentT.danrenkecheng+"','"+currentT.zhuzhi+"','"+currentT.rushanshijian+"','"+currentT.jiaoshizigezhenghao+"','"+currentT.yinghangzhanghao+"','"+currentT.yibaohao+"','"+
                    currentT.dianhua+"','"+currentT.beizhu+"')";
                if (add.modify(sql))
                {
                    MessageBox.Show("数据增加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("数据增加失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch(Exception exx)
            {
                MessageBox.Show("由于"+exx.Message.ToString()+"系统出错!");
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            //del
            getTeacher();
            try
            {
                DataMessager del = new DataMessager(Application.StartupPath);
                string sql = "delte from jiaoshibiao where xiangzhen='"+currentT.xiangzhen+"' and xuexiao='"+currentT.xuexiao+"' and xingming='"+currentT.xingming+"' and xingbie='"+currentT.xingbie+"'";
                if (del.modify("jiaoshibiao"))
                {
                    MessageBox.Show("数据增加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("数据增加失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch(Exception exx)
            {
            MessageBox.Show("由于"+exx.Message.ToString()+"系统出错!");
            }
        }

        private void button9_Click(object sender, EventArgs e)
        {
            //query
            getTeacher();
            try
            {
                DataMessager getdat = new DataMessager(Application.StartupPath);
                string sql = "select * from jiaoshibiao where xiangzhen='" + currentT.xiangzhen + "' and xuexiao='" + currentT.xuexiao + "' and xingming='" + currentT.xingming + "' and xingbie='" + currentT.xingbie + "'";
                datsource = getdat.query(sql,"jiaoshibiao");
                searchResult search = new searchResult();
                this.dataGridView1.DataSource = datsource;
            }
            catch (Exception exx)
            {
                MessageBox.Show("由于" + exx.Message.ToString() + "系统出错!");
            }
        }
    }
}

⌨️ 快捷键说明

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