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

📄 exam.cs

📁 学生成绩管理系统
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.Common;
using TeachHelper.DataAccessLayer;

namespace TeachHelper.BusinessLogicLayer
{
    /// <summary>
    /// Summary description for Exam
    /// </summary>
    public class Exam
    {
        public Exam()
        {
        }

        public static DataSet GetCollect()
        {
            Database db = DatabaseFactory.CreateDatabase();
            string sqlCommand = "usp_SelectTeachHelper_Exam";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
            return db.ExecuteDataSet(dbCommand);
        }

        public static DataSet GetCollectByTeacher(string teacher)
        {            
            Database db = DatabaseFactory.CreateDatabase();
            string sqlCommand = "usp_SelectTeachHelper_ExamByTeacher";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
            db.AddInParameter(dbCommand, "Teacher", DbType.String, teacher);
            return db.ExecuteDataSet(dbCommand);
        }

        public static DataSet GetCollectByDepartmentIdGradeMajorIdClassTime(int departmentId, int grade, int majorId, int classes, DateTime beginDate, DateTime endDate)
        {
            Database db = DatabaseFactory.CreateDatabase();
            string sqlCommand = "usp_SelectTeachHelper_ExamByDepartmentIdGradeMajorIdClassTime";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
            db.AddInParameter(dbCommand, "DepartmentId", DbType.Int32, departmentId);
            db.AddInParameter(dbCommand, "Grade", DbType.Int32, grade);
            db.AddInParameter(dbCommand, "MajorId", DbType.Int32, majorId);
            db.AddInParameter(dbCommand, "Class", DbType.Int32, classes);
            db.AddInParameter(dbCommand, "BeginDate", DbType.DateTime, beginDate);
            db.AddInParameter(dbCommand, "EndDate", DbType.DateTime, endDate);
            return db.ExecuteDataSet(dbCommand);
        }

        public static bool Create(string name, string teacher, int departmentId, int grade, 
            int majorId, int classes, int subjectId, int examTypeId, DateTime time, string description)
        {
            Database db = DatabaseFactory.CreateDatabase();

            string sqlCommand = "usp_InsertTeachHelper_Exam";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "Name", DbType.String, name);
            db.AddInParameter(dbCommand, "Teacher", DbType.String, teacher);
            db.AddInParameter(dbCommand, "DepartmentId", DbType.Int32, departmentId);
            db.AddInParameter(dbCommand, "Grade", DbType.Int32, grade);
            db.AddInParameter(dbCommand, "MajorId", DbType.Int32, majorId);
            db.AddInParameter(dbCommand, "Class", DbType.Int32, classes);
            db.AddInParameter(dbCommand, "SubjectId", DbType.Int32, subjectId);
            db.AddInParameter(dbCommand, "ExamTypeId", DbType.Int32, examTypeId);
            db.AddInParameter(dbCommand, "Time", DbType.DateTime, time);
            db.AddInParameter(dbCommand, "Description", DbType.String, description);

            int result = db.ExecuteNonQuery(dbCommand);

            if (result == 1)
                return true;
            else
                return false;
        }

        public static void Update(int id, string name, string teacher, int departmentId, int grade, 
            int majorId, int classes, int subjectId, int examTypeId, DateTime time)
        {
            Database db = DatabaseFactory.CreateDatabase();

            string sqlCommand = "usp_UpdateTeachHelper_Exam";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "Id", DbType.Int32, id);
            db.AddInParameter(dbCommand, "Name", DbType.String, name);
            db.AddInParameter(dbCommand, "Teacher", DbType.String, teacher);
            db.AddInParameter(dbCommand, "DepartmentId", DbType.Int32, departmentId);
            db.AddInParameter(dbCommand, "Grade", DbType.Int32, grade);
            db.AddInParameter(dbCommand, "MajorId", DbType.Int32, majorId);
            db.AddInParameter(dbCommand, "Class", DbType.Int32, classes);
            db.AddInParameter(dbCommand, "SubjectId", DbType.Int32, subjectId);
            db.AddInParameter(dbCommand, "ExamTypeId", DbType.Int32, examTypeId);
            db.AddInParameter(dbCommand, "Time", DbType.DateTime, time);

            int result = db.ExecuteNonQuery(dbCommand);

        }
    }
}

⌨️ 快捷键说明

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