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

📄 statusmanage.cs

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

namespace StudentManager.BusinessRule
{
   
    class StatusManage
    {
        private SqlConnection conn1 = null;
        private string commandstr = null;
        private SqlCommand Command1 = null;
        public  StatusManage()
        {
            conn1 = new SqlConnection(DataLevel.Connection.ConnString);
            Command1 = new SqlCommand();
          //  this.Command1.CommandText = commandstr;
            this.Command1.Connection = conn1;
          //  this.DataReader = Command1.ExecuteReader();

        }
        public  bool Student_Move(string studentId, string department, string Class)
        {
           /* this.commandstr = "Update Student Set Dapartment='" + department + "',Class='" + Class + "'where StudentID='" + studentId + "'";
            this.Command1.CommandText = this.commandstr;*/
            this.commandstr = "update Student set Department='" + department + "',Class='" + Class + "' where StudentID='" + studentId + "'";
            this.Command1.CommandText = this.commandstr;
            try
            {
                if (conn1.State == ConnectionState.Closed)
                    conn1.Open();
                this.Command1.ExecuteNonQuery();
                return true;
            }
            catch (Exception E)
            {
                Console.WriteLine(E.ToString());

            }
            finally
            {
                this.conn1.Close();
            }
            return false;
        
        }
        public  bool StuMove_Insert(string studentId, string originDep, string originCla, string PresentDep, string PresentCla, string date)
        {
            this.commandstr = "Insert into StudentMove(StudentID,OriginDep,OriginClass,PresentDep,PresentClass,Date) values('" + studentId + "','" + originDep + "','" + originCla + "','" + PresentDep + "','" + PresentCla + "','" + date + "')";
            this.Command1.CommandText = this.commandstr;
            try
            {
                if (this.conn1.State == ConnectionState.Closed)
                    this.conn1.Open();
                this.Command1.ExecuteNonQuery();
                return true;

            }
            catch (Exception E)
            {
                Console.WriteLine(E.ToString());
            }
            finally
            {
                this.conn1.Close();
            }
            return false;
        }
        public bool student_leave(string studentID)
        {
            this.commandstr = "delete from Student where StudentID = '" + studentID + "'";
            this.Command1.CommandText = this.commandstr;
            try
            {
                if (conn1.State == ConnectionState.Closed)
                    conn1.Open();
                this.Command1.ExecuteNonQuery();
                return true;
            }
            catch (Exception E)
            {
                Console.WriteLine(E.ToString());
            }
            finally
            {
                this.conn1.Close();
            }
            return false;
        }
        public bool studentleave_Insert(string studentId, string department, string Class, string leavetype, string date)
        {
            this.commandstr = "Insert into StudentLeave(StudentID,Department,Class,LeaveType,Date) values('" + studentId + "','" + department + "','" + Class + "','" + leavetype + "','" + date + "')";
        //    this.commandstr = "Insert      StudentLeave(StudentID,Department,Class,LeaveType,Date) values('" + studentId + "','" + department + "','" + Class + "','" + leavetype + "','" + date + "')";
            this.Command1.CommandText = this.commandstr;
            try
            {
                if (this.conn1.State == ConnectionState.Closed)
                    conn1.Open();
                this.Command1.ExecuteNonQuery();
                return true;
            }
            catch (Exception E)
            {
                Console.WriteLine(E.ToString());
            }
            finally
            {
                this.conn1.Close();
            }
            return false;

        }
    }
}

⌨️ 快捷键说明

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