//删除科目 //输入: // 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_DeleteChapter", Params); if (Count > 0) return true; else return false; }
//向Course表中添加考试科目信息 //输出: // 插入成功:返回True; // 插入失败:返回False; public bool InsertByProc(string courseName) { SqlParameter[] Params = new SqlParameter[2]; DataBase DB = new DataBase(); Params[0] = DB.MakeInParam("@name", SqlDbType.VarChar, 50, Name); //考试科目名称 Params[1] = new SqlParameter("@courseName", courseName); int Count = -1; Count = DB.RunProc("Proc_AddChapter", Params); if (Count > 0) return true; else return false; }
//根据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; } }
//查询单选题 public DataSet QuerySingleProblem(int ChapterID) { SqlParameter[] Params = new SqlParameter[1]; DataBase DB = new DataBase(); Params[0] = new SqlParameter("@chapterID", ChapterID); //题目编号 return DB.GetDataSet("Proc_SingleProblemList",Params); }
//根据题目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_SingleProblemDetail", 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, "ChapterID"); //科目编号 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"); //答案 return true; } else { return false; } }
//删除题目 //输入: // 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_FillBlankProblemDelete", Params); if (Count > 0) return true; else return false; }
//根据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; } }
//更新试卷信息 public bool UpdateByProc(int PID) { SqlParameter[] Params = new SqlParameter[2]; DataBase DB = new DataBase(); Params[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, PID); //试卷编号 Params[1] = DB.MakeInParam("@PaperState", SqlDbType.Bit, 1, PaperState); //试卷状态 int Count = -1; Count = DB.RunProc("Proc_PaperModify", Params); if (Count > 0) return true; else return false; }
//查询所用试卷 //不需要参数 public DataSet QueryAllPaper(string courseName) { SqlParameter[] Params = new SqlParameter[1]; DataBase DB = new DataBase(); Params[0] = new SqlParameter("@courseName", courseName); return DB.GetDataSet("Proc_PaperList", Params); }
//向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,50, UserPwd); //用户密码 Params[3] = DB.MakeInParam("@UserPower", SqlDbType.Int,4, UserPower); //用户权限 int Count = -1; Count = DB.RunProc("Proc_UsersAdd", Params); if (Count > 0) return true; else return false; }
//向Score表中添加成绩 //输出: // 插入成功:返回True; // 插入失败:返回False; public bool InsertByProc() { SqlParameter[] Params = new SqlParameter[3]; DataBase DB = new DataBase(); Params[0] = DB.MakeInParam("@UserID", SqlDbType.NVarChar, 50, UserID); //用户编号 Params[1] = DB.MakeInParam("@PaperID", SqlDbType.Int,4, PaperID); //用户密码 Params[2] = DB.MakeInParam("@Score", SqlDbType.Int,4, Score); //用户权限 int Count = -1; Count = DB.RunProc("Proc_ScoreAdd", Params); if (Count > 0) return true; else return false; }
//更新科目的信息 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_ModifyChapter", Params); if (Count > 0) return true; else return false; }
//更新用户的信息 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("@UserPower", SqlDbType.SmallInt, 2, UserPower); //用户权限 int Count = -1; Count = DB.RunProc("Proc_UsersModify", Params); if (Count > 0) return true; else return false; }
//查询用户 //查询所用用户 //不需要参数 public DataSet QueryUsers() { DataBase DB = new DataBase(); return DB.GetDataSet("Proc_UsersList"); }
//修改用户的密码 //输入: // XUserID - 用户编号; //输出: // 修改成功:返回True; // 修改失败:返回False; public bool ModifyPassword(string XUserID) { SqlParameter[] Params = new SqlParameter[2]; DataBase DB = new DataBase(); Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, XUserID); //用户编号 Params[1] = DB.MakeInParam("@UserPwd", SqlDbType.VarChar, 50, UserPwd); //用户密码 int Count = -1; Count = DB.RunProc("Proc_UsersPasswordModify", Params); if (Count > 0) return true; else return false; }
//根据用户 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._userPower = GetSafeData.ValidateDataRow_N(DR, "UserPower"); //用户权限 this._userName = GetSafeData.ValidateDataRow_S(DR, "UserName"); //用户姓名 return true; } else { return false; } }
//更新单选题试题信息 public bool UpdateByProc(int TID, int ChapterID) { SqlParameter[] Params = new SqlParameter[8]; DataBase DB = new DataBase(); Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, TID); //题目编号 Params[1] = new SqlParameter("@chapterID", ChapterID); //科目编号 Params[2] = DB.MakeInParam("@Title", SqlDbType.NVarChar, 200, Title); //题目 Params[3] = DB.MakeInParam("@AnswerA", SqlDbType.NVarChar, 50, AnswerA); //答案A Params[4] = DB.MakeInParam("@AnswerB", SqlDbType.NVarChar, 50, AnswerB); //答案B Params[5] = DB.MakeInParam("@AnswerC", SqlDbType.NVarChar, 50, AnswerC); //答案C Params[6] = DB.MakeInParam("@AnswerD", SqlDbType.NVarChar, 50, AnswerD); //答案D Params[7] = DB.MakeInParam("@Answer", SqlDbType.VarChar, 4, Answer); //答案 int Count = -1; Count = DB.RunProc("Proc_SingleProblemModify", Params); if (Count > 0) return true; else return false; }
//胡媛媛添加,按学生ID查询成绩,2010-4-12 //输入: // UserID - 用户编号; //输出: // 删除成功:返回True; // 删除失败:返回False; public bool QueryScoreByUserId(string UID) { String sqlstr = "select * from Score where UserID=" + UID; DataBase DB = new DataBase(); bool flag = DB.GetRecord(sqlstr); return flag; }
//胡媛媛添加,按学生ID删除成绩,2010-4-12 //输入: // UserID - 用户编号; //输出: // 删除成功:返回True; // 删除失败:返回False; public bool DeleteByUserId(string UID) { SqlParameter[] Params = new SqlParameter[1]; DataBase DB = new DataBase(); Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 20, UID); //成绩编号 int Count = -1; Count = DB.RunProc("Proc_ScoreDeleteByUserId", Params); if (Count > 0) return true; else return false; }
//删除用户 //输入: // 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; }
//胡媛媛添加,按学生ID删除成绩,2010-4-12 //查询所用成绩 //不需要参数 public DataSet QueryScore(string courseName) { DataBase DB = new DataBase(); SqlParameter[] Param = new SqlParameter[1]; Param[0] = new SqlParameter("@courseName", courseName); return DB.GetDataSet("Proc_ScoreList", Param); }
//查询所用考试章节 public DataSet QueryCourse(string courseName) { DataBase DB = new DataBase(); SqlParameter[] Params = new SqlParameter[1]; Params[0] = new SqlParameter("@courseName", courseName); return DB.GetDataSet("Proc_GetChapterList", Params); }
//向Paper表中添加试卷信息(采用存储过程) //输出: // 插入成功:返回True; // 插入失败:返回False; public bool InsertByProc(int ChapterID) { SqlParameter[] Params = new SqlParameter[3]; DataBase DB = new DataBase(); Params[0] = new SqlParameter("@chapterID", ChapterID); //科目编号 Params[1] = DB.MakeInParam("@PaperName", SqlDbType.NVarChar, 50, PaperName); //试卷名称 Params[2] = DB.MakeInParam("@PaperState", SqlDbType.Bit,1, PaperState); //试卷状态 int Count = -1; Count = DB.RunProc("Proc_PaperAdd", Params); if (Count > 0) return true; else return false; }
//根据题目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_FillBlankProblemDetail", 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, "ChapterID"); //科目编号 this._FrontTitle = GetSafeData.ValidateDataRow_S(DR, "FrontTitle"); //题目前部分 this._BackTitle = GetSafeData.ValidateDataRow_S(DR, "BackTitle"); //题目后部分 this._Answer = GetSafeData.ValidateDataRow_S(DR, "Answer"); //答案 return true; } else { return false; } }
//查询所用可用试卷 //不需要参数 public DataSet QueryPaper(string courseName) { DataBase DB = new DataBase(); SqlParameter[] Params = new SqlParameter[2]; Params[0] = DB.MakeInParam("@PaperState", SqlDbType.Bit,1, "true"); //题目编号 Params[1] = new SqlParameter("@courseName", courseName); return DB.GetDataSet("Proc_PaperUseList",Params); }
//更新填空题的信息 public bool UpdateByProc(int TID, int ChapterID) { SqlParameter[] Params = new SqlParameter[5]; DataBase DB = new DataBase(); Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, TID); //题目编号 Params[1] = new SqlParameter("@chapterID", ChapterID); //科目编号 Params[2] = DB.MakeInParam("@FrontTitle", SqlDbType.NVarChar, 200, FrontTitle); //题目前部分 Params[3] = DB.MakeInParam("@BackTitle", SqlDbType.NVarChar, 200, BackTitle); //题名后部分 Params[4] = DB.MakeInParam("@Answer", SqlDbType.NVarChar, 100, Answer); //答案 int Count = -1; Count = DB.RunProc("Proc_FillBlankProblemModify", Params); if (Count > 0) return true; else return false; }
//删除题目 //输入: // TID - 题目编号; //输出: // 删除成功:返回True; // 删除失败:返回False; public bool DeleteByProc(int PID) { SqlParameter[] Params = new SqlParameter[1]; DataBase DB = new DataBase(); //胡媛媛修改,将参数@ID改为@PaperID,2010-4-13 Params[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, PID); //题目编号 //胡媛媛修改,将参数@ID改为@PaperID,2010-4-13 int Count = -1; Count = DB.RunProc("Proc_PaperDelete", Params); if (Count > 0) return true; else return false; }
//更新判断题的信息 public bool UpdateByProc(int TID, int ChapterID) { SqlParameter[] Params = new SqlParameter[4]; DataBase DB = new DataBase(); Params[0] = DB.MakeInParam("@ID", SqlDbType.Int, 4, TID); //题目编号 Params[1] = new SqlParameter("@chapterID", ChapterID); //科目编号 Params[2] = DB.MakeInParam("@Title", SqlDbType.NVarChar, 200, Title); //题目 Params[3] = DB.MakeInParam("@Answer", SqlDbType.Bit, 1, Answer); //答案 int Count = -1; Count = DB.RunProc("Proc_JudgeProblemModify", Params); if (Count > 0) return true; else return false; }