您目前尚未登陆,请选择【登陆】或【注册
首页->行政办公->多功能在线考试系统源码>>Web/UserTest.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:多功能在线考试系统源码
当前文件:文件类型 OnLineExam/Web/UserTest.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using MyOnLineExam.DataAccessLayer; 12using System.Data.SqlClient; 13using MyOnLineExam.BusinessLogicLayer; 14 15//该源码下载自www.51aspx.com(51aspx.com) 16public partial class Web_UserTest : System.Web.UI.Page 17{ 18 protected void Page_Load(object sender, EventArgs e) 19 { 20 if (!IsPostBack) 21 { 22 lblPaperName.Text = Session["PaperName"].ToString(); 23 InitData(); 24 } 25 } 26 //初始化试卷,从数据库中将试题取出 27 protected void InitData() 28 { 29 //Response.Write(Session["PaperID"].ToString()); 30 //Response.End(); 31 32 SqlParameter[] Params1 = new SqlParameter[2]; 33 DataBase DB = new DataBase(); 34 int paperID = int.Parse(Session["PaperID"].ToString()); 35 Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 36 Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选题"); //题目类型 37 DataSet ds1 = DB.GetDataSet("Proc_PaperDetail",Params1); 38 GridView1.DataSource = ds1; 39 GridView1.DataBind(); 40 41 ((Label)GridView1.HeaderRow.FindControl("Label27")).Text = ((Label)GridView1.Rows[0].FindControl("Label4")).Text; 42 43 SqlParameter[] Params2 = new SqlParameter[2]; 44 Params2[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 45 Params2[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "多选题"); //题目类型 46 DataSet ds2 = DB.GetDataSet("Proc_PaperDetail", Params2); 47 GridView2.DataSource = ds2; 48 GridView2.DataBind(); 49 ((Label)GridView2.HeaderRow.FindControl("Label28")).Text = ((Label)GridView2.Rows[0].FindControl("Label8")).Text; 50 51 SqlParameter[] Params3 = new SqlParameter[2]; 52 Params3[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 53 Params3[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "判断题"); //题目类型 54 DataSet ds3 = DB.GetDataSet("Proc_PaperDetail", Params3); 55 GridView3.DataSource = ds3; 56 GridView3.DataBind(); 57 ((Label)GridView3.HeaderRow.FindControl("Label29")).Text = ((Label)GridView3.Rows[0].FindControl("Label12")).Text; 58 59 SqlParameter[] Params4 = new SqlParameter[2]; 60 Params4[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID); //试卷编号 61 Params4[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "填空题"); //题目类型 62 DataSet ds4 = DB.GetDataSet("Proc_PaperDetail", Params4); 63 GridView4.DataSource = ds4; 64 GridView4.DataBind(); 65 ((Label)GridView4.HeaderRow.FindControl("Label30")).Text = ((Label)GridView4.Rows[0].FindControl("Label17")).Text; 66 } 67 //提交试卷,生成成绩 68 protected void imgBtnSubmit_Click(object sender, ImageClickEventArgs e) 69 { 70 int score = 0; 71 int singlemark = int.Parse(((Label)GridView1.Rows[0].FindControl("Label4")).Text);//取出单选题的每题分值 72 foreach (GridViewRow dr in GridView1.Rows)//对单选题每题进行判断用户选择答案 73 { 74 string str = ""; 75 if (((RadioButton)dr.FindControl("RadioButton1")).Checked) 76 { 77 str = "A"; 78 } 79 else if (((RadioButton)dr.FindControl("RadioButton2")).Checked) 80 { 81 str = "B"; 82 } 83 else if (((RadioButton)dr.FindControl("RadioButton3")).Checked) 84 { 85 str = "C"; 86 } 87 else if (((RadioButton)dr.FindControl("RadioButton4")).Checked) 88 { 89 str = "D"; 90 } 91 if (((Label)dr.FindControl("Label3")).Text.Trim() == str)//将用户选择结果和答案进行比较 92 { 93 score = score + singlemark; 94 } 95 } 96 int multimark = int.Parse(((Label)GridView2.Rows[0].FindControl("Label8")).Text);//取出多选题每题分值 97 foreach (GridViewRow dr in GridView2.Rows)//对多选题每题进行判断用户选择答案 98 { 99 string str = ""; 100 if (((CheckBox)dr.FindControl("CheckBox1")).Checked) 101 { 102 str += "A"; 103 } 104 if (((CheckBox)dr.FindControl("CheckBox2")).Checked) 105 { 106 str += "B"; 107 } 108 if (((CheckBox)dr.FindControl("CheckBox3")).Checked) 109 { 110 str += "C"; 111 } 112 if (((CheckBox)dr.FindControl("CheckBox4")).Checked) 113 { 114 str += "D"; 115 } 116 if (((Label)dr.FindControl("Label7")).Text.Trim() == str)//将用户选择结果和答案进行比较 117 { 118 score = score + multimark; 119 } 120 } 121 int judgemark = int.Parse(((Label)GridView3.Rows[0].FindControl("Label12")).Text);//取出判断题每题分值 122 foreach (GridViewRow dr in GridView3.Rows)//对判断题每题进行判断用户选择答案 123 { 124 bool j = false; 125 if (((CheckBox)dr.FindControl("CheckBox5")).Checked) 126 { 127 j = true; 128 } 129 if (j == bool.Parse(((Label)dr.FindControl("Label11")).Text.Trim())) 130 { 131 score = score + judgemark; 132 } 133 } 134 int fillmark = int.Parse(((Label)GridView4.Rows[0].FindControl("Label17")).Text);//取出填空题每题分值 135 foreach (GridViewRow dr in GridView4.Rows) 136 { 137 string str = ""; 138 str = ((TextBox)dr.FindControl("TextBox1")).Text.Trim(); 139 if (str == ((Label)dr.FindControl("Label16")).Text.Trim()) 140 { 141 score = score + fillmark; 142 } 143 } 144 Scores insertScore = new Scores(); //创建Scores类对象 145 insertScore.UserID = Session["userID"].ToString();//设置Scores对象的属性 146 insertScore.PaperID=int.Parse(Session["PaperID"].ToString()); 147 insertScore.Score = score; 148 if (insertScore.InsertByProc())//调用InsertByProc方法向数据库中插入成绩 149 { 150 if (score >= 80)//根据成绩给出相应提示 151 { 152 Response.Write("<script language=javascript>alert('您太棒了!您的成绩为:"+score+"分!')</script>"); 153 } 154 else if (score >= 60) 155 { 156 Response.Write("<script language=javascript>alert('合格!您的成绩为:"+score+"分!')</script>"); 157 } 158 else 159 { 160 Response.Write("<script language=javascript>alert('需要努力了!您的成绩为:"+score+"分!')</script>"); 161 } 162 Panel1.Visible = true; 163 } 164 } 165 protected void imgBtnAnswer_Click(object sender, ImageClickEventArgs e) 166 { 167 Response.Redirect("TestAnswer.aspx"); 168 } 169} 170
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:多功能在线考试系统源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号