在线考试系统毕业论文(软件工程完整版)

Label3.Visible=false; } } }

protected void Button2_Click(object sender,EventArgs e) {

txtStuID.Text=\; txtStuName.Text=\; txtStuPwd.Text=\; txtStuFPwd.Text=\; txtQuePwd.Text=\; txtAnsPwd.Text=\; txtStuID.Focus(); }

protected void Button3_Click(object sender,EventArgs e) {

Response.Redirect(\); }

protected void Button1_ Click(object sender,EventArgs e) {

//调用公共类中的eccom,执行SQL语句命令 dataconn.eccom(\

tb_student+\(ID.namespace,PWD,question,answer,Sex,profession)\values(\,\,\t+\,\,\,\addProfession.SelectedValue)+\)\

//如果添加成功,弹出添加成功对话框

Label1.Visible=true; }

protected void Button1_Click1(object sender,EventArges e) {

SqlDataReader read=dataconn.ExceRead(\ID=\+this.txtStuID.Text+\); read.Read();

if(read.HashRows) {

if(this.txtStuID.Text==read[\].toString()) {

Label2.Visible=true; }

read.Close(); }}

24

6.3.3考生在线考试模块

该页面中考生首先阅读考试规则,在同意规则后,选择考试试题和套题

代码为:

using System.Data.SqlClient;

public partial class QianUser_StartExamfra:System.Web.UI.Page {

Datacon dataconn=new Datacon();

static int int_row1=0;//单选题号索引 static int int_row2=0;//多选题号索引 static int int_row1Point=0;//单选题分数 static int int_row2Point=0;//多选题分数

//****************页面加载事件,从数据库提取题目**********// protected void Page_Load(object sender,EventArgs e) {

if(!IsPostBack) {

this.getCom(1);

this.getCom(2); } }

//***********提交试卷***********//

protected void btnSubmit_Click(object sender,EventArgs e) {

int_row1=0;//单选题号索引 int_row2=0;//多选题号索引

25

int_row1Point=0;//单选题分数 int_row2Point=0;//多选题分数 //try //{

Label3.Visible=Label4.Visible=Lable7.Visible=Lable8.Visible=Label9.Visible=Label10.Visible=true;

this.lblStuID.Text=Session[\].ToString();

this.lblSubject.Text=Session[\].ToString(); this.lblQuestion.Text=Session[\].ToString(); this.getCom(3); this.getCom(4);

this.lblTotal.Text=Covert.ToString(int_rowPoint+int_row2Point); dataconn.eccom(\

+\

+\lblStuID.Text+\+lblSubject.Text+\+int_row1Point+\+int_row2Point+\);

this.getCom(5);

Response.Write(\您确定要交卷吗?’);location='StartExamfra.aspx':\); //this.btnSubmit.Enabled=false; //}

//Response.Write(\您已经答应过该试卷’);window.close()\ //} }

//***********执行与数据库的关联操作*****// protected void getCom(int i) {

string ddl=Application[\].ToString(); string dd2=Application[\].ToString(); SqlConnection con=dataconn.getcon(); switch(i) {

//从数据库中选择单选题 case 1;

SqlDataAdapter myaddapter1=new SqlDataAdapter(\+

\单选题'and que_lessonid=\+ddl+\,con); DataSet myds1=new DateSet();

26

myaddapter1.Fill(mydsl); DataLis1.DataSource DataList.DataBind(); //生成单选题题号

for(int tID1=1;tID1<=DataList1.Item.Count;tID1++) {

Label lblSelect=(Label)DataList.Items[tID1++){

Label

lblSelect=(Label)DataList1.Items[tID1].FindControl(\); lblSelect.Text=tID1.ToString()+\、\; }

break;

//从数据库中选择多选题 case 2:

SqlDataAdapter myadapter2=new SqlDataAdapter(\

+\tb_Questions where que_type='多选题'and que_lessonid=\

+ddl+\and que_taotiid=\order by id desc\

DataSet myds2=new DataSet(); myadapter2.Fill(myds2); DataList2.DataSource=myds2; DataList2.DataBind(); //生成多选题题号 for(int

tID2=1;tID2<=DataList2.Items.Count;tID2++) {

Label

lblDselect=(Label)DataList2.Items[tID2-1].FindControl(\); lblDselect.Text=tID2.ToString()+\、\; }

break;

//核对单选题 case 3:

SqlDataAdapter myadapter3=new SqlDataAdapter(\

+\单选题'and que_lessonid=\

+ddl+\+dd2+\desc\,con);

DataSet myds3=new DataSet(); myadapter3.Fill(myds3);

27

联系客服:779662525#qq.com(#替换为@)