예제 #1
1
        //删除用户
        //输入:
        //      XUserID - 用户编号;
        //输出:
        //      删除成功:返回True;
        //      删除失败:返回False;
        public bool DeleteByProc(string XUserID)
        {
            SqlParameter[] Params = new SqlParameter[1];

            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, XUserID);               //用户编号

            int Count = -1;
            Count = DB.RunProc("Proc_UsersDelete", Params);
            if (Count > 0)
                return true;
            else return false;
        }
예제 #2
0
        //删除科目
        //输入:
        //      CID - 科目编号;
        //输出:
        //      删除成功:返回True;
        //      删除失败:返回False;
        public bool DeleteByProc(int CID)
        {
            SqlParameter[] Params = new SqlParameter[1];

            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@ID", SqlDbType.Int,4, CID);               //科目编号

            int Count = -1;
            Count = DB.RunProc("Proc_CourseDelete", Params);
            if (Count > 0)
                return true;
            else return false;
        }
예제 #3
0
        //向Course表中添加试卷科目信息
        //输出:
        //      插入成功:返回True;
        //      插入失败:返回False;
        public bool InsertByProc()
        {
            SqlParameter[] Params = new SqlParameter[1];

            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@Name", SqlDbType.VarChar, 50, Name);               //试卷科目名称

            int Count = -1;
            Count = DB.RunProc("Proc_CourseAdd", Params);
            if (Count > 0)
                return true;
            else return false;
        }
예제 #4
0
        public bool CheckExist(string UserID, int PaperID)
        {
            SqlParameter[] Params = new SqlParameter[2];
            DataBase DB = new DataBase();
            string strsql = " SELECT * FROM TempExam WHERE UserID =@UserID and PaperID= @PaperID";
            Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 20, UserID);
            Params[1] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, PaperID);

            SqlDataReader DR = DB.RunStrGetReader(strsql, Params);
            if (!DR.HasRows)//DR.Read())
            {

                return false;
            }
            else
            {
                return true;
            }
        }
예제 #5
0
        //判断是否已经考试
        public bool IsTest(string UserID, int PaperID)
        {
            SqlParameter[] Params = new SqlParameter[2];

            DataBase DB = new DataBase();
            string strsql = "SELECT * FROM UserAnswertb WHERE UserID=@UserID AND PaperID=@PaperID";
            Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 20, UserID);
            Params[1] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, PaperID);

            SqlDataReader DR = DB.RunStrGetReader(strsql, Params);
            if (!DR.Read())
            {
                return false;
            }
            else
            {
                return true;
            }
        }
예제 #6
0
        //向Users表中添加用户信息(采用存储过程)
        //输出:
        //      插入成功:返回True;
        //      插入失败:返回False;
        public bool InsertByProc()
        {
            SqlParameter[] Params = new SqlParameter[4];

            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, UserID);               //用户编号
            Params[1] = DB.MakeInParam("@UserName", SqlDbType.VarChar, 50, UserName);           //用户姓名
            Params[2] = DB.MakeInParam("@UserPwd", SqlDbType.VarChar,64, UserPwd);    //用户密码
            Params[3] = DB.MakeInParam("@RoleId", SqlDbType.Int, 4,RoleId);    //角色

            int Count = -1;
            Count = DB.RunProc("Proc_UsersAdd", Params);
            if (Count > 0)
                return true;
            else return false;
        }
예제 #7
0
        //向SingleProblem表中添加题目信息(采用存储过程)
        //输出:
        //      插入成功:返回True;
        //      插入失败:返回False;
        public bool InsertByProc()
        {
            SqlParameter[] Params = new SqlParameter[4];

            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@CourseID", SqlDbType.Int, 4, CourseID);                 //科目编号
            Params[1] = DB.MakeInParam("@Title", SqlDbType.VarChar, 1000, Title);                //题目
            Params[2] = DB.MakeInParam("@DiffID", SqlDbType.Int, 4, DiffID);      //难度系数
            Params[3] = DB.MakeInParam("@Answer", SqlDbType.Bit, 1, Answer);                      //答案A

            int Count = -1;
            Count = DB.RunProc("Proc_JudgeProblemAdd", Params);
            if (Count > 0)
                return true;
            else return false;
        }
예제 #8
0
        //更新科目的信息
        public bool UpdateByProc(int CID)
        {
            SqlParameter[] Params = new SqlParameter[2];

            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, CID);               //用户编号
            Params[1] = DB.MakeInParam("@Name", SqlDbType.VarChar, 200, Name);      //用户权限

            int Count = -1;
            Count = DB.RunProc("Proc_CourseModify", Params);
            if (Count > 0)
                return true;
            else return false;
        }
예제 #9
0
        public bool GetBeginTime(string UserID, int PaperID)
        {
            SqlParameter[] Params = new SqlParameter[2];

            DataBase DB = new DataBase();
            string strsql = "SELECT BeginTime FROM TempExam WHERE PaperID=@PaperID and UserID=@UserID";
            Params[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, PaperID);
            Params[1] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 20, UserID);

            SqlDataReader DR = DB.RunStrGetReader(strsql, Params);
            if (!DR.Read())
            {
                return false;
            }
            else
            {
                this.BeginTime = (DateTime)DR[0];//获取考试开始的时间
                return true;
            }
        }
예제 #10
0
 //查询用户
 //查询所用用户
 //不需要参数
 public DataSet QueryUsers()
 {
     DataBase DB = new DataBase();
     string sql = "SELECT [Users].[UserID],[Users].[UserName],[Role].[RoleName]FROM [Users],[Role] WHERE [Users].[RoleId]=[Role].[RoleId] and [Users].[UserID]!='admin'";
     return DB.GetDataSetSql(sql);//DB.GetDataSet("Proc_UsersList");
 }
예제 #11
0
        //ɾ����Ŀ
        //���룺
        //      TID - ��Ŀ��ţ�
        //�����
        //      ɾ���ɹ�������True��
        //      ɾ��ʧ�ܣ�����False��
        public bool DeleteByProc(int TID)
        {
            SqlParameter[] Params = new SqlParameter[1];

            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, TID);               //��Ŀ���

            int Count = -1;
            Count = DB.RunProc("Proc_QuestionProblemDelete", Params);
            if (Count > 0)
                return true;
            else return false;
        }
예제 #12
0
        //�����ж������Ϣ
        public bool UpdateByProc(int TID)
        {
            SqlParameter[] Params = new SqlParameter[5];

            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, TID);                           //��Ŀ���
            Params[1] = DB.MakeInParam("@CourseID", SqlDbType.Int, 4, CourseID);                //��Ŀ���
            Params[2] = DB.MakeInParam("@Title", SqlDbType.VarChar, 1000, Title);               //��Ŀ
            Params[3] = DB.MakeInParam("@DiffID", SqlDbType.Int, 4, DiffID);      //�Ѷ�ϵ��
            Params[4] = DB.MakeInParam("@Answer", SqlDbType.VarChar, 1000, Answer);                      //��A

            int Count = -1;
            Count = DB.RunProc("Proc_QuestionProblemModify", Params);
            if (Count > 0)
                return true;
            else return false;
        }
예제 #13
0
        //��ѯ�ʴ���
        //�γ̱��
        public DataSet QueryQuestionProblem(int TCourseID)
        {
            SqlParameter[] Params = new SqlParameter[1];

            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@CourseID", SqlDbType.Int, 4, TCourseID);               //��Ŀ���
            return DB.GetDataSet("Proc_QuestionProblemList", Params);
        }
예제 #14
0
        //������ĿID ��ʼ����Ŀ
        //���룺
        //      TID - ��Ŀ��ţ�
        //�����
        //      ��Ŀ���ڣ�����True��
        //      ��Ŀ���ڣ�����False��
        public bool LoadData(int TID)
        {
            SqlParameter[] Params = new SqlParameter[1];
            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, TID);                  //�û����

            DataSet ds = DB.GetDataSet("Proc_QuestionProblemDetail", Params);
            ds.CaseSensitive = false;
            DataRow DR;
            if (ds.Tables[0].Rows.Count > 0)
            {
                DR = ds.Tables[0].Rows[0];
                this._CourseID = GetSafeData.ValidateDataRow_N(DR, "CourseID");                   //��Ŀ���
                this._Title = GetSafeData.ValidateDataRow_S(DR, "Title");                         //��Ŀ
                this._Answer = GetSafeData.ValidateDataRow_S(DR, "Answer");                     //��
                this._DiffID = GetSafeData.ValidateDataRow_N(DR, "DiffID");            //�Ѷ�ϵ��
                return true;
            }
            else
            {
                return false;
            }
        }
예제 #15
0
 public bool isReduplicated(string title)
 {
     SqlParameter[] Params = new SqlParameter[1];
     DataBase DB = new DataBase();
     Params[0] = DB.MakeInParam("@Title", SqlDbType.VarChar, 1000, title);               //��Ŀ
     if (DB.GetRecordCount("select count(*) from QuestionProblem where Title='" + title + "' ") != 0)
         return true;
     else
         return false;
 }
예제 #16
0
        //更新多选题的信息
        public bool UpdateByProc(int TID)
        {
            SqlParameter[] Params = new SqlParameter[9];

            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, TID);                           //题目编号
            Params[1] = DB.MakeInParam("@CourseID", SqlDbType.Int, 4, CourseID);                //科目编号
            Params[2] = DB.MakeInParam("@Title", SqlDbType.VarChar, 1000, Title);               //题目
            Params[3] = DB.MakeInParam("@AnswerA", SqlDbType.VarChar, 500, AnswerA);            //答案A
            Params[4] = DB.MakeInParam("@AnswerB", SqlDbType.VarChar, 500, AnswerB);            //答案B
            Params[5] = DB.MakeInParam("@AnswerC", SqlDbType.VarChar, 500, AnswerC);            //答案C
            Params[6] = DB.MakeInParam("@AnswerD", SqlDbType.VarChar, 500, AnswerD);            //答案D
            Params[7] = DB.MakeInParam("@DiffID", SqlDbType.Int, 4, DiffID);      //难度系数
            Params[8] = DB.MakeInParam("@Answer", SqlDbType.VarChar, 50, Answer);               //参考答案

            int Count = -1;
            Count = DB.RunProc("Proc_MultiProblemModify", Params);
            if (Count > 0)
                return true;
            else return false;
        }
예제 #17
0
        //根据题目ID 初始化题目
        //输入:
        //      TID - 题目编号;
        //输出:
        //      题目存在:返回True;
        //      题目不在:返回False;
        public bool LoadData(int TID)
        {
            SqlParameter[] Params = new SqlParameter[1];
            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, TID);                  //用户编号

            DataSet ds = DB.GetDataSet("Proc_MultiProblemDetail", Params);
            ds.CaseSensitive = false;
            DataRow DR;
            if (ds.Tables[0].Rows.Count > 0)
            {
                DR = ds.Tables[0].Rows[0];
                this._CourseID = GetSafeData.ValidateDataRow_N(DR, "CourseID");                   //科目编号
                this._Title = GetSafeData.ValidateDataRow_S(DR, "Title");                         //题目
                this._AnswerA = GetSafeData.ValidateDataRow_S(DR, "AnswerA");                     //答案A
                this._AnswerB = GetSafeData.ValidateDataRow_S(DR, "AnswerB");                     //答案B
                this._AnswerC = GetSafeData.ValidateDataRow_S(DR, "AnswerC");                     //答案C
                this._AnswerD = GetSafeData.ValidateDataRow_S(DR, "AnswerD");                     //答案D
                this._Answer = GetSafeData.ValidateDataRow_S(DR, "Answer");                       //答案
                this._DiffID = GetSafeData.ValidateDataRow_N(DR, "DiffID");            //难度系数
                return true;
            }
            else
            {
                return false;
            }
        }
예제 #18
0
        //根据用户 UserID 初始化该用户
        //输入:
        //      XUserID - 用户编号;
        //输出:
        //      用户存在:返回True;
        //      用户不在:返回False;
        public bool LoadData(string XUserID)
        {
            SqlParameter[] Params = new SqlParameter[1];
            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, XUserID);                  //用户编号

            DataSet ds = DB.GetDataSet("Proc_UsersDetail", Params);
            ds.CaseSensitive = false;
            DataRow DR;
            if (ds.Tables[0].Rows.Count > 0)
            {
                DR= ds.Tables[0].Rows[0];
                this._userID = GetSafeData.ValidateDataRow_S(DR, "UserID");                         //用户编号
                this._userName = GetSafeData.ValidateDataRow_S(DR, "UserName");                     //用户姓名
                this._userPwd = GetSafeData.ValidateDataRow_S(DR, "UserPwd");                   //用户密码
                this._roleid = GetSafeData.ValidateDataRow_N(DR, "RoleId");                     //用户权限
                this._rolename = GetSafeData.ValidateDataRow_S(DR, "RoleName");                     //用户权限

                //获取权限集合
                string colName = "";
                for (int i = 0; i < DR.ItemArray.Length; i++)
                {
                    colName = DR.Table.Columns[i].ColumnName;
                    if (colName.StartsWith("HasDuty_") && GetSafeData.ValidateDataRow_N(DR, colName) == 1)
                    {
                        this._duties.Add(DR.Table.Columns[i].ColumnName.Substring(8));	//去掉前缀“HasDuty_”
                    }
                }
                return true;
            }
            else
            {
                return false;
            }
        }
예제 #19
0
        //修改用户的密码
        //输入:
        //      XUserID - 用户编号;
        //输出:
        //      修改成功:返回True;
        //      修改失败:返回False;
        public bool ModifyPassword(string XUserID)
        {
            SqlParameter[] Params = new SqlParameter[2];

            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 20, XUserID);               //用户编号
            Params[1] = DB.MakeInParam("@UserPwd", SqlDbType.VarChar, 64, UserPwd);    //用户密码

            int Count = -1;
            Count = DB.RunProc("Proc_UserPwdModify", Params);
            if (Count > 0)
                return true;
            else return false;
        }
예제 #20
0
 //查询所用试卷科目
 //不需要参数
 public DataSet QueryDiff()
 {
     DataBase DB = new DataBase();
     return DB.GetDataSet("Proc_DiffList");
 }
예제 #21
0
        //更新用户的信息
        public bool UpdateByProc(string XUserID)
        {
            SqlParameter[] Params = new SqlParameter[3];

            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, XUserID);               //用户编号
            Params[1] = DB.MakeInParam("@UserName", SqlDbType.VarChar, 50, UserName);           //用户姓名
            Params[2] = DB.MakeInParam("@RoleId", SqlDbType.Int, 4, RoleId);                    //角色
            //Params[3] = DB.MakeInParam("@UserPwd", SqlDbType.NVarChar, 64, UserPwd);           //角色

            int Count = -1;
            Count = DB.RunProc("Proc_UsersModify1", Params);
            if (Count > 0)
                return true;
            else return false;
        }
예제 #22
0
        /// 查询用户        
        public static DataTable QueryUsers(Hashtable queryItems)
        {
            string where = SQLString.GetConditionClause(queryItems);
            string sql = "Select * From [Users],[Role] " + where;

            if (where == "")
                sql += " Where";
            else
                sql += " And";

            sql +=" [Users].RoleId=[Role].RoleId";

            DataBase DB = new DataBase();
            return DB.GetDataTable(sql);
        }
예제 #23
0
        /// <summary>
        /// 考生第一次考某卷时要向TempExam插入一些必要的信息
        /// </summary>
        /// <returns></returns>
        public bool SetExamBegin(string UserID, int PaperID)
        {
            SqlParameter[] Params = new SqlParameter[3];
            DataBase DB = new DataBase();
               // string strsql = "INSERT INTO TempExam (UserID, PaperID,BeginTime) VALUES ( @UserID,@PaperID,@BeginTime)";
            Params[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, PaperID);
            Params[1] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 20, UserID);
            Params[2] = DB.MakeInParam("@BeginTime", SqlDbType.DateTime, 8, DateTime.Now);

            int Count = -1;
            //Count = DB.ProcStr(strsql, Params);
            Count = DB.RunProc("Proc_TempExamAdd", Params);
            if (Count > 0)
                return true;
            else
                return false;
        }
예제 #24
0
        //根据UserID和UserPassword判断密码是否正确
        //输入:
        //      XUserID - 用户编号;
        //输出:
        //      用户存在:返回True;
        //      用户不在:返回False;
        public bool CheckPassword(string XUserID)
        {
            SqlParameter[] Params = new SqlParameter[1];
            DataBase DB = new DataBase();
            Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, XUserID);                  //编号

            SqlDataReader DR = DB.RunProcGetReader("Proc_UsersDetail", Params);
            if (!DR.Read())
            {
                return false;
            }
            else
            {
                this._userPwd = DR["UserPwd"].ToString();
                return true;
            }
        }
예제 #25
0
 //查询所用试卷科目
 //不需要参数
 public DataSet QueryCourse()
 {
     DataBase DB = new DataBase();
     return DB.GetDataSet("Proc_CourseList");
 }
예제 #26
0
 //查询所用成绩
 //不需要参数
 public DataSet QueryScore()
 {
     DataBase DB = new DataBase();
     string strsql = "SELECT Users.UserID,	Users.UserName,Scoretb.ID,Scoretb.Score,Scoretb.ExamTime,Scoretb.JudgeTime, Paper.PaperID,Paper.PaperName FROM Users,Scoretb,Paper where Users.UserID=Scoretb.UserID and Scoretb.PaperID=Paper.PaperID";
     //return DB.GetDataSet("Proc_ScoreList");
     return DB.GetDataSet(strsql);
 }
예제 #27
0
        //根据UserID判断该用户是否存在
        //输入:
        //      XUserID - 用户编号;
        //输出:
        //      用户存在:返回True;
        //      用户不在:返回False;
        public bool CheckUser(string XUserID)
        {
            SqlParameter[] Params = new SqlParameter[1];
            DataBase DB = new DataBase();

            Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, XUserID);                  //教工姓名

            SqlDataReader DR = DB.RunProcGetReader("Proc_UsersDetail", Params);
            if (!DR.Read())
            {
                return false;
            }
            else
            {
                return true;
            }
        }
예제 #28
0
 //查询某个用户成绩
 public DataSet QueryUserScore(string XUserID)
 {
     SqlParameter[] Params = new SqlParameter[1];
     DataBase DB = new DataBase();
     string strsql = "SELECT Users.UserID,Users.UserName,Scoretb.ID,Scoretb.Score,Scoretb.ExamTime,Scoretb.JudgeTime,Scoretb.PingYu,Paper.PaperID,Paper.PaperName FROM Users,Scoretb,Paper WHERE Users.UserID=Scoretb.UserID and Scoretb.PaperID=Paper.PaperID and Users.UserID=@UserID order by Scoretb.ExamTime";
     Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 20,XUserID);
     return DB.GetStrDataSet(strsql, Params);
 }
예제 #29
0
        /// <summary>
        /// 检测课程名是否已经存在
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public bool IsCourseNameExist(string Name)
        {
            SqlParameter[] Params = new SqlParameter[1];

            DataBase DB = new DataBase();
            string strsql = "SELECT * FROM Course WHERE Name=@Name";
            Params[0] = DB.MakeInParam("@Name", SqlDbType.VarChar, 200, Name);

            SqlDataReader DR = DB.RunStrGetReader(strsql, Params);
            if (!DR.Read())
            {
                return false;
            }
            else
            {
                return true;
            }
        }
예제 #30
0
        //向Scoretb表中添加成绩
        //输出:
        //      插入成功:返回True;
        //      插入失败:返回False;
        public bool InsertByProc()
        {
            SqlParameter[] Params = new SqlParameter[6];
            DataBase DB = new DataBase();
            //string strsql = "INSERT INTO Scoretb (UserID, PaperID,Score,ExamTime,JudgeTime,PingYu) VALUES ( @UserID,@PaperID,@Score,@ExamTime,@JudgeTime,@PingYu)";
            Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 20, UserID);
            Params[1] = DB.MakeInParam("@PaperID", SqlDbType.Int,4, PaperID);
            Params[2] = DB.MakeInParam("@Score", SqlDbType.Int,4, Score);
            Params[3] = DB.MakeInParam("@ExamTime", SqlDbType.DateTime, 8,ExamTime);
            Params[4] = DB.MakeInParam("@JudgeTime", SqlDbType.DateTime, 8, DateTime.Now);
            Params[5] = DB.MakeInParam("@PingYu", SqlDbType.VarChar, 1000, PingYu);

            int Count = -1;
            Count = DB.RunProc("Proc_ScoreAdd", Params);
            if (Count > 0)
                return true;
            else return false;
        }