//初始化试卷,从数据库中将试题取出 protected void InitData() { DataBase DB = new DataBase(); int paperID = Convert.ToInt32(Request.QueryString["PaperID"].ToString()); SqlParameter[] Params1 = new SqlParameter[2]; Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选题"); //题目类型 DataSet ds1 = DB.GetDataSet("Proc_PaperDetail", Params1); GridView11.DataSource = ds1; GridView11.DataBind(); if (ds1.Tables[0].Rows.Count > 0) { ((Label)GridView11.HeaderRow.FindControl("Labelt2")).Text = ((Label)GridView11.Rows[0].FindControl("Labelm1")).Text; } SqlParameter[] Params2 = new SqlParameter[2]; Params2[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params2[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "多选题"); //题目类型 DataSet ds2 = DB.GetDataSet("Proc_PaperDetail", Params2); GridView2.DataSource = ds2; GridView2.DataBind(); if (ds2.Tables[0].Rows.Count > 0) { ((Label)GridView2.HeaderRow.FindControl("Labelt5")).Text = ((Label)GridView2.Rows[0].FindControl("Labelm2")).Text; } SqlParameter[] Params3 = new SqlParameter[2]; Params3[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params3[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "判断题"); //题目类型 DataSet ds3 = DB.GetDataSet("Proc_PaperDetail", Params3); GridView3.DataSource = ds3; GridView3.DataBind(); if (ds3.Tables[0].Rows.Count > 0) { ((Label)GridView3.HeaderRow.FindControl("Labelt8")).Text = ((Label)GridView3.Rows[0].FindControl("Labelm3")).Text; } SqlParameter[] Params4 = new SqlParameter[2]; Params4[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params4[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "填空题"); //题目类型 DataSet ds4 = DB.GetDataSet("Proc_PaperDetail", Params4); GridView4.DataSource = ds4; GridView4.DataBind(); if (ds4.Tables[0].Rows.Count > 0) { ((Label)GridView4.HeaderRow.FindControl("Labelt11")).Text = ((Label)GridView4.Rows[0].FindControl("Labelm4")).Text; } SqlParameter[] Params5 = new SqlParameter[2]; Params5[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params5[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "问答题"); //题目类型 DataSet ds5 = DB.GetDataSet("Proc_PaperDetail", Params5); GridView5.DataSource = ds5; GridView5.DataBind(); if (ds5.Tables[0].Rows.Count > 0) { ((Label)GridView5.HeaderRow.FindControl("Labelt14")).Text = ((Label)GridView5.Rows[0].FindControl("Labelm5")).Text; } }
//查询所用试卷科目 //不需要参数 public DataSet QueryDiff() { DataBase DB = new DataBase(); return DB.GetDataSet("Proc_DiffList"); }
//��ѯ�ʴ��� //�γ̱�� 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); }
//������Ŀ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; } }
//根据题目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; } }
//初始化试卷,从数据库中将试题取出 protected void PaperData() { string userid = Request.QueryString["UserID"].ToString(); paperid = int.Parse(Request.QueryString["PaperID"].ToString()); DataBase DB = new DataBase(); DataSet ds = DB.GetDataSetSql("select * from [UserAnswertb] where UserID='" + userid + "'"); DataRow[] row = ds.Tables[0].Select(); foreach (DataRow rs in row) { lblExamtime.Text = rs["ExamTime"].ToString(); } SqlParameter[] Params1 = new SqlParameter[3]; Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选题"); Params1[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds1 = DB.GetDataSet("Proc_UserAnswertb", Params1); if (ds1.Tables[0].Rows.Count > 0) { GridView11.DataSource = ds1; GridView11.DataBind(); ((Label)GridView11.HeaderRow.FindControl("Label27")).Text = ((Label)GridView11.Rows[0].FindControl("Label4")).Text; } SqlParameter[] Params2 = new SqlParameter[3]; Params2[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params2[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "多选题"); Params2[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds2 = DB.GetDataSet("Proc_UserAnswertb", Params2); if (ds2.Tables[0].Rows.Count > 0) { GridView2.DataSource = ds2; GridView2.DataBind(); ((Label)GridView2.HeaderRow.FindControl("Label28")).Text = ((Label)GridView2.Rows[0].FindControl("Label8")).Text; } SqlParameter[] Params3 = new SqlParameter[3]; Params3[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params3[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "判断题"); Params3[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds3 = DB.GetDataSet("Proc_UserAnswertb", Params3); if (ds3.Tables[0].Rows.Count > 0) { GridView3.DataSource = ds3; GridView3.DataBind(); ((Label)GridView3.HeaderRow.FindControl("Label29")).Text = ((Label)GridView3.Rows[0].FindControl("Label12")).Text; } SqlParameter[] Params4 = new SqlParameter[3]; Params4[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params4[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "填空题"); Params4[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds4 = DB.GetDataSet("Proc_UserAnswertb", Params4); if (ds4.Tables[0].Rows.Count > 0) { GridView4.DataSource = ds4; GridView4.DataBind(); ((Label)GridView4.HeaderRow.FindControl("Label30")).Text = ((Label)GridView4.Rows[0].FindControl("Label17")).Text; } SqlParameter[] Params5 = new SqlParameter[3]; Params5[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params5[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "问答题"); Params5[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds5 = DB.GetDataSet("Proc_UserAnswertb", Params5); if (ds5.Tables[0].Rows.Count > 0) { GridView5.DataSource = ds5; GridView5.DataBind(); ((Label)GridView5.HeaderRow.FindControl("Label31")).Text = ((Label)GridView5.Rows[0].FindControl("Label21")).Text; } if (GridView11.Rows.Count > 0) { int score1 = 0; int singlemark = int.Parse(((Label)GridView11.Rows[0].FindControl("Label4")).Text);//取出单选题的每题分值 foreach (GridViewRow dr in GridView11.Rows) { if (((Label)dr.FindControl("Label3")).Text.Trim() == "A") { ((RadioButton)dr.FindControl("RadioButton1")).Checked = true; } else if (((Label)dr.FindControl("Label3")).Text.Trim() == "B") { ((RadioButton)dr.FindControl("RadioButton2")).Checked = true; } else if (((Label)dr.FindControl("Label3")).Text.Trim() == "C") { ((RadioButton)dr.FindControl("RadioButton3")).Checked = true; } else if (((Label)dr.FindControl("Label3")).Text.Trim() == "D") { ((RadioButton)dr.FindControl("RadioButton4")).Checked = true; } if (((Label)dr.FindControl("Label3")).Text.Trim() == ((Label)dr.FindControl("Label23")).Text.Trim()) { score1 = score1 + singlemark; sinScore.Text = Convert.ToString(score1); } } } if (GridView2.Rows.Count > 0) { int score2 = 0; int multimark = int.Parse(((Label)GridView2.Rows[0].FindControl("Label8")).Text);//取出多选题每题分值 foreach (GridViewRow dr in GridView2.Rows) { if (((Label)dr.FindControl("Label7")).Text.Trim() == "A") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "B") { ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "C") { ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "D") { ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "AB") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "AC") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "AD") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "BC") { ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "BD") { ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "CD") { ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "ABC") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "ABD") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "ACD") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "ABCD") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == ((Label)dr.FindControl("Label27")).Text.Trim()) { score2 = score2 + multimark; mulScore.Text = Convert.ToString(score2); } } } if (GridView3.Rows.Count > 0) { int score3 = 0; int judgemark = int.Parse(((Label)GridView3.Rows[0].FindControl("Label12")).Text);//取出判断题每题分值 foreach (GridViewRow dr in GridView3.Rows)//对判断题每题进行判断用户选择答案 { try { if (bool.Parse(((Label)dr.FindControl("Label11")).Text.Trim())) { ((CheckBox)dr.FindControl("CheckBox5")).Checked = true; } else { ((CheckBox)dr.FindControl("CheckBox6")).Checked = true; } } catch { ((CheckBox)dr.FindControl("CheckBox5")).Checked = false; ((CheckBox)dr.FindControl("CheckBox6")).Checked = false; } if (((Label)dr.FindControl("Label11")).Text.Trim() == ((Label)dr.FindControl("Label41")).Text.Trim()) { score3 = score3 + judgemark; judScore.Text = Convert.ToString(score3); } } } //取出填空题每题分值 if (GridView4.Rows.Count > 0) { int score4 = 0; int fillmark = int.Parse(((Label)GridView4.Rows[0].FindControl("Label17")).Text); foreach (GridViewRow dr in GridView4.Rows)//对填空题每题进行判断用户选择答案 { string str = ""; str = ((TextBox)dr.FindControl("TextBox1")).Text.Trim(); if (str == ((Label)dr.FindControl("Label26")).Text.Trim()) { score4 = score4 + fillmark; filScore.Text = Convert.ToString(score4); } } } }
//初始化试卷,从数据库中将试题取出 protected void InitData() { DataBase DB = new DataBase(); int paperID = int.Parse(Session["PaperID"].ToString()); SqlParameter[] Params1 = new SqlParameter[2]; Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选题"); //题目类型 DataSet ds1 = DB.GetDataSet("Proc_PaperDetail", Params1); if (ds1.Tables[0].Rows.Count > 0)//判断下是否有单选题 { GridView11.DataSource = ds1; GridView11.DataBind(); ((Label)GridView11.HeaderRow.FindControl("Label27")).Text = ((Label)GridView11.Rows[0].FindControl("Label4")).Text; } SqlParameter[] Params2 = new SqlParameter[2]; Params2[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params2[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "多选题"); //题目类型 DataSet ds2 = DB.GetDataSet("Proc_PaperDetail", Params2); if (ds2.Tables[0].Rows.Count > 0) { GridView2.DataSource = ds2; GridView2.DataBind(); ((Label)GridView2.HeaderRow.FindControl("Label28")).Text = ((Label)GridView2.Rows[0].FindControl("Label8")).Text; } SqlParameter[] Params3 = new SqlParameter[2]; Params3[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params3[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "判断题"); //题目类型 DataSet ds3 = DB.GetDataSet("Proc_PaperDetail", Params3); if (ds3.Tables[0].Rows.Count > 0) { GridView3.DataSource = ds3; GridView3.DataBind(); ((Label)GridView3.HeaderRow.FindControl("Label29")).Text = ((Label)GridView3.Rows[0].FindControl("Label12")).Text; } SqlParameter[] Params4 = new SqlParameter[2]; Params4[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params4[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "填空题"); //题目类型 DataSet ds4 = DB.GetDataSet("Proc_PaperDetail", Params4); if (ds4.Tables[0].Rows.Count > 0) { GridView4.DataSource = ds4; GridView4.DataBind(); ((Label)GridView4.HeaderRow.FindControl("Label45")).Text = ((Label)GridView4.Rows[0].FindControl("Label17")).Text; } SqlParameter[] Params5 = new SqlParameter[2]; Params5[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params5[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "问答题"); //题目类型 DataSet ds5 = DB.GetDataSet("Proc_PaperDetail", Params5); if (ds5.Tables[0].Rows.Count > 0) { GridView5.DataSource = ds5; GridView5.DataBind(); ((Label)GridView5.HeaderRow.FindControl("Label31")).Text = ((Label)GridView5.Rows[0].FindControl("Label37")).Text; } }
public DataSet QueryRoleNoAdminandUser() { DataBase DB = new DataBase(); return DB.GetDataSet("Proc_RoleListNo2"); }
//查询所用成绩 //不需要参数 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); }
//查询单选题 //课程编号 public DataSet QueryFillBlankProblem(int TCourseID) { SqlParameter[] Params = new SqlParameter[1]; DataBase DB = new DataBase(); Params[0] = DB.MakeInParam("@CourseID", SqlDbType.Int, 4, TCourseID); //题目编号 return DB.GetDataSet("Proc_FillBlankProblemList", Params); }
//初始化试卷,从数据库中将试题取出 protected void InitData() { DataBase DB = new DataBase(); string userid = Session["UserID"].ToString(); paperid = int.Parse(Session["PaperID"].ToString()); DataSet ds = DB.GetDataSetSql("select * from UserAnswertb where UserID='" + userid + "' and PaperID='" + paperid + "'"); if (ds.Tables[0].Rows.Count>0) { sum = right = error = noDone = 0;//初始化变量 SqlParameter[] Params1 = new SqlParameter[3]; Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选题"); Params1[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds1 = DB.GetDataSet("Proc_UserAnswertb", Params1); if (ds1.Tables[0].Rows.Count > 0) { GridView11.DataSource = ds1; GridView11.DataBind(); ((Label)GridView11.HeaderRow.FindControl("Label27")).Text = ((Label)GridView11.Rows[0].FindControl("Label4")).Text; } SqlParameter[] Params2 = new SqlParameter[3]; Params2[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params2[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "多选题"); Params2[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds2 = DB.GetDataSet("Proc_UserAnswertb", Params2); if (ds2.Tables[0].Rows.Count > 0) { GridView2.DataSource = ds2; GridView2.DataBind(); ((Label)GridView2.HeaderRow.FindControl("Label28")).Text = ((Label)GridView2.Rows[0].FindControl("Label8")).Text; } SqlParameter[] Params3 = new SqlParameter[3]; Params3[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params3[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "判断题"); Params3[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds3 = DB.GetDataSet("Proc_UserAnswertb", Params3); if (ds3.Tables[0].Rows.Count > 0) { GridView3.DataSource = ds3; GridView3.DataBind(); ((Label)GridView3.HeaderRow.FindControl("Label29")).Text = ((Label)GridView3.Rows[0].FindControl("Label12")).Text; } SqlParameter[] Params4 = new SqlParameter[3]; Params4[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params4[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "填空题"); Params4[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds4 = DB.GetDataSet("Proc_UserAnswertb", Params4); if (ds4.Tables[0].Rows.Count > 0) { GridView4.DataSource = ds4; GridView4.DataBind(); ((Label)GridView4.HeaderRow.FindControl("Label30")).Text = ((Label)GridView4.Rows[0].FindControl("Label17")).Text; } SqlParameter[] Params5 = new SqlParameter[3]; Params5[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params5[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "问答题"); Params5[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds5 = DB.GetDataSet("Proc_UserAnswertb", Params5); if (ds5.Tables[0].Rows.Count > 0) { GridView5.DataSource = ds5; GridView5.DataBind(); ((Label)GridView5.HeaderRow.FindControl("Label31")).Text = ((Label)GridView5.Rows[0].FindControl("Label21")).Text; } //得到题目总数 sum = GridView11.Rows.Count + GridView2.Rows.Count + GridView3.Rows.Count + GridView4.Rows.Count ; if (GridView11.Rows.Count > 0) { foreach (GridViewRow dr in GridView11.Rows) { if (((Label)dr.FindControl("Label3")).Text.Trim() == "A") { ((RadioButton)dr.FindControl("RadioButton1")).Checked = true; } else if (((Label)dr.FindControl("Label3")).Text.Trim() == "B") { ((RadioButton)dr.FindControl("RadioButton2")).Checked = true; } else if (((Label)dr.FindControl("Label3")).Text.Trim() == "C") { ((RadioButton)dr.FindControl("RadioButton3")).Checked = true; } else if (((Label)dr.FindControl("Label3")).Text.Trim() == "D") { ((RadioButton)dr.FindControl("RadioButton4")).Checked = true; } if (((Label)dr.FindControl("Label3")).Text.Trim() == ((Label)dr.FindControl("lbSingleAnswer")).Text.Trim()) { right++; } else { if(((Label)dr.FindControl("Label3")).Text.Trim()=="") { noDone++; } else { dr.BackColor = System.Drawing.Color.LightPink;//错题以红色背景显示 error++; } } } } if (GridView2.Rows.Count > 0) { foreach (GridViewRow dr in GridView2.Rows) { if (((Label)dr.FindControl("Label7")).Text.Trim() == "A") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "B") { ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "C") { ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "D") { ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "AB") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "AC") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "AD") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "BC") { ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "BD") { ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "CD") { ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "ABC") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "ABD") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "ACD") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "ABCD") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == ((Label)dr.FindControl("lbMultiAnswer")).Text.Trim()) { right++; } else { if(((Label)dr.FindControl("Label7")).Text.Trim()=="") { noDone++; } else { dr.BackColor = System.Drawing.Color.LightPink;//错题以红色背景显示 error++; } } } } if (GridView3.Rows.Count > 0) { foreach (GridViewRow dr in GridView3.Rows)//对判断题每题进行判断用户选择答案 { try { if (bool.Parse(((Label)dr.FindControl("Label11")).Text.Trim())) { ((CheckBox)dr.FindControl("RadioButton5")).Checked = true; } else { ((CheckBox)dr.FindControl("RadioButton6")).Checked = true; } } catch { ((CheckBox)dr.FindControl("RadioButton5")).Checked = false; ((CheckBox)dr.FindControl("RadioButton6")).Checked = false; } if (((Label)dr.FindControl("Label11")).Text.Trim() == ((Label)dr.FindControl("lbJudgeAnswer")).Text.Trim()) { right++; } else { if(((Label)dr.FindControl("Label11")).Text.Trim()=="") { noDone++; } else { dr.BackColor = System.Drawing.Color.LightPink;//错题以红色背景显示 error++; } } } } //取出填空题每题分值 if (GridView4.Rows.Count > 0) { int score4 = 0; int fillmark = int.Parse(((Label)GridView4.Rows[0].FindControl("Label17")).Text); foreach (GridViewRow dr in GridView4.Rows)//对填空题每题进行判断用户选择答案 { string str = ""; str = ((TextBox)dr.FindControl("TextBox1")).Text.Trim(); if (str == ((Label)dr.FindControl("Label26")).Text.Trim()) { right++; } else { if (str == "") { noDone++; } else { dr.BackColor = System.Drawing.Color.LightPink;//错题以红色背景显示 error++; } } } } lbSumUp.Text = "除问答题外,共"+sum.ToString()+"道客观题,其中正确"+right.ToString()+"道题,错误"+error.ToString()+"道题,"+noDone.ToString()+"没做!"; } else { int paperID = paperid; lbSumUp.Text = "没有记录!"; SqlParameter[] Params1 = new SqlParameter[2]; Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选题"); //题目类型 DataSet ds1 = DB.GetDataSet("Proc_PaperDetail", Params1); if (ds1.Tables[0].Rows.Count > 0)//判断下是否有单选题 { GridView11.DataSource = ds1; GridView11.DataBind(); ((Label)GridView11.HeaderRow.FindControl("Label27")).Text = ((Label)GridView11.Rows[0].FindControl("Label4")).Text; } SqlParameter[] Params2 = new SqlParameter[2]; Params2[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params2[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "多选题"); //题目类型 DataSet ds2 = DB.GetDataSet("Proc_PaperDetail", Params2); if (ds2.Tables[0].Rows.Count > 0) { GridView2.DataSource = ds2; GridView2.DataBind(); ((Label)GridView2.HeaderRow.FindControl("Label28")).Text = ((Label)GridView2.Rows[0].FindControl("Label8")).Text; } SqlParameter[] Params3 = new SqlParameter[2]; Params3[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params3[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "判断题"); //题目类型 DataSet ds3 = DB.GetDataSet("Proc_PaperDetail", Params3); if (ds3.Tables[0].Rows.Count > 0) { GridView3.DataSource = ds3; GridView3.DataBind(); ((Label)GridView3.HeaderRow.FindControl("Label29")).Text = ((Label)GridView3.Rows[0].FindControl("Label12")).Text; } SqlParameter[] Params4 = new SqlParameter[2]; Params4[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params4[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "填空题"); //题目类型 DataSet ds4 = DB.GetDataSet("Proc_PaperDetail", Params4); if (ds4.Tables[0].Rows.Count > 0) { GridView4.DataSource = ds4; GridView4.DataBind(); ((Label)GridView4.HeaderRow.FindControl("Label30")).Text = ((Label)GridView4.Rows[0].FindControl("Label17")).Text; } SqlParameter[] Params5 = new SqlParameter[2]; Params5[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 Params5[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "问答题"); //题目类型 DataSet ds5 = DB.GetDataSet("Proc_PaperDetail", Params5); if (ds5.Tables[0].Rows.Count > 0) { GridView5.DataSource = ds5; GridView5.DataBind(); ((Label)GridView5.HeaderRow.FindControl("Label31")).Text = ((Label)GridView5.Rows[0].FindControl("Label21")).Text; } } }
//查询所有用户试卷的试卷 public DataSet QueryUserPaperList() { DataBase DB = new DataBase(); return DB.GetDataSet("Proc_UserPaperList"); //return DB.GetDataSetSql("SELECT distinct [dbo].[Users].[UserID],[dbo].[Users].[UserName],[dbo].[UserAnswertb].[UserID], [dbo].[UserAnswertb].[PaperID],[dbo].[UserAnswertb].[ExamTime],[dbo].[UserAnswertb].[state],[dbo].[Paper].[PaperName] FROM [dbo].[Users],[dbo].[UserAnswertb],[dbo].[Paper] where Users.UserID=UserAnswertb.UserID and UserAnswertb.PaperID=Paper.PaperID and Paper.NeedTime!=0 "); }
//查询所用可用试卷 //不需要参数 public DataSet QueryPaper() { DataBase DB = new DataBase(); SqlParameter[] Params = new SqlParameter[1]; Params[0] = DB.MakeInParam("@PaperState", SqlDbType.Bit, 1, "true"); //题目编号 return DB.GetDataSet("Proc_PaperUseList", Params); }
//查询所用试卷 //不需要参数 public DataSet QueryAllPaper() { DataBase DB = new DataBase(); return DB.GetDataSet("Proc_PaperList"); }
//根据用户 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; } }
//初始化试卷,从数据库中将试题取出 protected void PaperData() { string userid = Request.QueryString["UserID"].ToString(); paperid = int.Parse(Request.QueryString["PaperID"].ToString()); DataBase DB = new DataBase(); DataSet ds = DB.GetDataSetSql("select PaperName,ExamTime from [UserAnswertb],[Paper] where[UserAnswertb].PaperID=[Paper].PaperID and UserID='" + userid + "' and [UserAnswertb].PaperID='" + paperid + "'"); DataRow[] row = ds.Tables[0].Select(); //获取试卷基本信息 lblExamtime.Text = row[0]["ExamTime"].ToString(); lblExamname.Text = row[0]["PaperName"].ToString(); //获取总分 ds = DB.GetDataSetSql("select Score from Scoretb where UserID='" + userid + "' and PaperID='" + paperid + "'"); DataRow[] rowSum = ds.Tables[0].Select(); sumScore.Text = rowSum[0]["Score"].ToString(); SqlParameter[] Params1 = new SqlParameter[3]; Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选题"); Params1[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds1 = DB.GetDataSet("Proc_UserAnswertb", Params1); if (ds1.Tables[0].Rows.Count > 0) { GridView11.DataSource = ds1; GridView11.DataBind(); ((Label)GridView11.HeaderRow.FindControl("Label27")).Text = ((Label)GridView11.Rows[0].FindControl("Label4")).Text; } SqlParameter[] Params2 = new SqlParameter[3]; Params2[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params2[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "多选题"); Params2[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds2 = DB.GetDataSet("Proc_UserAnswertb", Params2); if (ds2.Tables[0].Rows.Count > 0) { GridView2.DataSource = ds2; GridView2.DataBind(); ((Label)GridView2.HeaderRow.FindControl("Label28")).Text = ((Label)GridView2.Rows[0].FindControl("Label8")).Text; } SqlParameter[] Params3 = new SqlParameter[3]; Params3[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params3[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "判断题"); Params3[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds3 = DB.GetDataSet("Proc_UserAnswertb", Params3); if (ds3.Tables[0].Rows.Count > 0) { GridView3.DataSource = ds3; GridView3.DataBind(); ((Label)GridView3.HeaderRow.FindControl("Label29")).Text = ((Label)GridView3.Rows[0].FindControl("Label12")).Text; } SqlParameter[] Params4 = new SqlParameter[3]; Params4[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params4[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "填空题"); Params4[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds4 = DB.GetDataSet("Proc_UserAnswertb", Params4); if (ds4.Tables[0].Rows.Count > 0) { GridView4.DataSource = ds4; GridView4.DataBind(); ((Label)GridView4.HeaderRow.FindControl("Label30")).Text = ((Label)GridView4.Rows[0].FindControl("Label17")).Text; } SqlParameter[] Params5 = new SqlParameter[3]; Params5[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperid); Params5[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "问答题"); Params5[2] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, userid); DataSet ds5 = DB.GetDataSet("Proc_UserAnswertb", Params5); if (ds5.Tables[0].Rows.Count > 0) { GridView5.DataSource = ds5; GridView5.DataBind(); ((Label)GridView5.HeaderRow.FindControl("Label31")).Text = ((Label)GridView5.Rows[0].FindControl("Label21")).Text; } if (GridView11.Rows.Count > 0) { int score1 = 0; int singlemark = int.Parse(((Label)GridView11.Rows[0].FindControl("Label4")).Text);//取出单选题的每题分值 foreach (GridViewRow dr in GridView11.Rows) { if (((Label)dr.FindControl("Label3")).Text.Trim() == "A") { ((RadioButton)dr.FindControl("RadioButton1")).Checked = true; } else if (((Label)dr.FindControl("Label3")).Text.Trim() == "B") { ((RadioButton)dr.FindControl("RadioButton2")).Checked = true; } else if (((Label)dr.FindControl("Label3")).Text.Trim() == "C") { ((RadioButton)dr.FindControl("RadioButton3")).Checked = true; } else if (((Label)dr.FindControl("Label3")).Text.Trim() == "D") { ((RadioButton)dr.FindControl("RadioButton4")).Checked = true; } if (((Label)dr.FindControl("Label3")).Text.Trim() == ((Label)dr.FindControl("Label23")).Text.Trim()) { score1 = score1 + singlemark; sinScore.Text = Convert.ToString(score1); //dr.Visible = false;//单选题 } else { dr.BackColor = System.Drawing.Color.LightPink;//错题以红色背景显示 } } } if (GridView2.Rows.Count > 0) { int score2 = 0; int multimark = int.Parse(((Label)GridView2.Rows[0].FindControl("Label8")).Text);//取出多选题每题分值 foreach (GridViewRow dr in GridView2.Rows) { if (((Label)dr.FindControl("Label7")).Text.Trim() == "A") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "B") { ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "C") { ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "D") { ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "AB") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "AC") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "AD") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "BC") { ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "BD") { ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "CD") { ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "ABC") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "ABD") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "ACD") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == "ABCD") { ((CheckBox)dr.FindControl("CheckBox1")).Checked = true; ((CheckBox)dr.FindControl("CheckBox2")).Checked = true; ((CheckBox)dr.FindControl("CheckBox3")).Checked = true; ((CheckBox)dr.FindControl("CheckBox4")).Checked = true; } if (((Label)dr.FindControl("Label7")).Text.Trim() == ((Label)dr.FindControl("Label27")).Text.Trim()) { score2 = score2 + multimark; mulScore.Text = Convert.ToString(score2); } else { dr.BackColor = System.Drawing.Color.LightPink;//错题以红色背景显示 } } } if (GridView3.Rows.Count > 0) { int score3 = 0; int judgemark = int.Parse(((Label)GridView3.Rows[0].FindControl("Label12")).Text);//取出判断题每题分值 foreach (GridViewRow dr in GridView3.Rows)//对判断题每题进行判断用户选择答案 { try { if (bool.Parse(((Label)dr.FindControl("Label11")).Text.Trim())) { ((CheckBox)dr.FindControl("CheckBox5")).Checked = true; } else { ((CheckBox)dr.FindControl("CheckBox6")).Checked = true; } } catch { ((CheckBox)dr.FindControl("CheckBox5")).Checked = false; ((CheckBox)dr.FindControl("CheckBox6")).Checked = false; } if (((Label)dr.FindControl("Label11")).Text.Trim() == ((Label)dr.FindControl("Label41")).Text.Trim()) { score3 = score3 + judgemark; judScore.Text = Convert.ToString(score3); } else { dr.BackColor = System.Drawing.Color.LightPink;//错题以红色背景显示 } } } //计算总分 }
//查询所用试卷科目 //不需要参数 public DataSet QueryCourse() { DataBase DB = new DataBase(); return DB.GetDataSet("Proc_CourseList"); }
//��ѯ���н�ɫ //����Ҫ���� public DataSet QueryRole() { DataBase DB = new DataBase(); return DB.GetDataSet("Proc_RoleList"); }