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

📄 statusmanage.cs

📁 学生管理(包括学生成绩 档案和课程) 学生可以录入数据
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace StudentManager
{
    public partial class StatusManage : Form
    {
        private SqlConnection conn1 = null;
        private string commandstr = null;
        private SqlCommand command1 = null;
        private SqlDataReader DataReader = null;
        public StatusManage()
        {
            InitializeComponent();
            conn1 = new SqlConnection(DataLevel.Connection.ConnString);   
            commandstr = "Select * from Student";
            command1 = new SqlCommand();
            command1.CommandText = commandstr;
            command1.Connection = conn1;
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnApply_Click(object sender, EventArgs e)
        {
            if (conn1.State == ConnectionState.Closed)
                conn1.Open();
            this.commandstr="Select * from Student where StudentID='"+textBoxID.Text+"'";
            this.command1.CommandText=this.commandstr;
       //     DataReader.Close();
            DataReader=this.command1.ExecuteReader();
            if(DataReader.Read())
            {
                System.DateTime InTime;
                this.textBoxDepartment.Text=this.DataReader["Department"].ToString();
                this.textBoxClass.Text=this.DataReader["Class"].ToString();
                this.textBoxName.Text=this.DataReader["StudentName"].ToString();
                this.textBoxSex.Text=this.DataReader["Sex"].ToString();
                this.textBoxAge.Text=this.DataReader["Age"].ToString();
                this.textBoxNation.Text=this.DataReader["Nation"].ToString();
                this.textBoxNativeplace.Text=this.DataReader["NativePlace"].ToString();
                this.textBoxPower.Text=this.DataReader["Status"].ToString();
                InTime =Convert.ToDateTime(this.DataReader["InDate"].ToString());
                this.textBoxTime.Text = InTime.ToShortDateString().ToString();
                this.pictureBox1.Image=Image.FromFile(this.DataReader["Picture"].ToString());
               
            }
            this.conn1.Close();
            this.DataReader.Close();
        }
        public void Combo_Fill()
        {
            conn1.Open();
            commandstr = "Select DepartmentName from Department";
            command1.CommandText = commandstr;
            DataReader.Close();
            DataReader = command1.ExecuteReader();
            while (DataReader.Read())
            {
                combodapartment.Items.Add(DataReader["DepartmentName"].ToString());
            }
            DataReader.Close();
            conn1.Close();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            Combo_Fill();
        }

        private void combodapartment_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboclass.Items.Clear();
            comboclass.Text = "";
            if (conn1.State == ConnectionState.Closed)
                conn1.Open();
            commandstr = "Select ClassName from class where DepartmentName=" + "'" + combodapartment.Text + "'";
            command1.CommandText = commandstr;
            DataReader = command1.ExecuteReader();
            while (DataReader.Read())
            {
                comboclass.Items.Add(DataReader["ClassName"].ToString());
            }
            DataReader.Close();
            conn1.Close();
        }

        private void btnApply3_Click(object sender, EventArgs e)
        {
            if (combodapartment.Text == "" | comboclass.Text == "" | dateTimePicker1.Text == "")
            {
                MessageBox.Show("调入学院代码 班级名称 和 时间不能为空 !");
                return;
            }
            string originDep=textBoxDepartment.Text;
            string originCls=textBoxClass.Text;
            DateTime  MoveTime=Convert.ToDateTime(this.dateTimePicker1.Text);
            string data=MoveTime.ToShortDateString().ToString();
            BusinessRule.StatusManage manage=new StudentManager.BusinessRule.StatusManage ();
            if (manage.StuMove_Insert(textBoxID.Text, originDep, originCls, this.combodapartment.Text, this.comboclass.Text, data))
            {
                if (manage.Student_Move(textBoxID.Text, this.combodapartment.Text, this.comboclass.Text))
                {
                    MessageBox.Show("调转成功 !");
                    textBoxDepartment.Text=combodapartment.Text;
                    textBoxClass.Text=comboclass.Text;
                }
            }

        }

        private void btnAply2_Click(object sender, EventArgs e)
        {
            if (this.comboLeavekind.Text == "")
            {
                MessageBox.Show("离校状态不能为空 !");
                return;
            }
            DateTime MoveTime = Convert.ToDateTime(this.dateTimePicker2.Text);
            string data = MoveTime.ToShortDateString().ToString();
            BusinessRule.StatusManage manage=new StudentManager.BusinessRule.StatusManage ();
            if (MessageBox.Show("此同学真的确认离校吗?", "确认离校", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
            {
                if (manage.studentleave_Insert(textBoxID.Text, textBoxDepartment.Text, textBoxClass.Text, comboLeavekind.Text, data))
                {
                    if (manage.student_leave(textBoxID.Text))
                    {
                        MessageBox.Show("该学生记录删除成功!");
                        Info_Clear();
                    }
                }
            }

        }
        public void Info_Clear()
        {
            textBoxID.Text = "";
            textBoxAge.Text = "";
            textBoxClass.Text = "";
            textBoxDepartment.Text = "";
            textBoxName.Text = "";
            textBoxNation.Text = "";
            textBoxNativeplace.Text = "";
            textBoxPower.Text = "";
            textBoxSex.Text = "";
            textBoxTime.Text = "";
            pictureBox1.Image.Dispose();
            pictureBox1.Image = null;
        }

   
    }
}

⌨️ 快捷键说明

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