第10章A SP应用系统开发—在线考试系统.pptVIP

  • 2
  • 0
  • 约3.76万字
  • 约 25页
  • 2019-12-19 发布于辽宁
  • 举报

第10章A SP应用系统开发—在线考试系统.ppt

实现代码 在后台代码的Page_Load事件中,首先调用公共类中的ecDropDownList方法,将考生姓名绑定到DropDownList控件。其代码如下: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //调用公共类中的ecDropDownList方法 dataconn.ecDropDownList(ddlProfession, select * from tb_Profession, Name, ID); Label1.Visible = false; Label2.Visible = false; Label3.Visible = false; } } ? 点击该注册页面中的”注册”按钮,催发其Click事件,将注册信息添加到数据库中。其代码如下: protected void Button1_Click(object sender, EventArgs e) { //调用公共类中的eccom,执行SQL语句命令 dataconn.eccom(insert into tb_Student + (ID,Name,PWD,question,answer,Sex,profession) + values( + this.txtStuID.Text + , + this.txtStuName.Text + , + this.txtStuPwd.Text + , + this.txtQuePwd.Text + , + this.txtAnsPwd.Text + , + this.ddlSex.Text + , + Convert.ToInt32(ddlProfession.SelectedValue) + )); //如果添加成功,弹出成功对话框 Label1.Visible = true; } 为了避免考生输入的学生证号出现重复,导致注册失败,在页面中添加了一个”检查注册号”按钮,来检查该注册的学生证号是否已经存在。 在该按钮触发的事件中,主要应用了数据库阅读器(SqlDataReader)读取数据库中数据判断注册号是否存在。事件代码如下: protected void Button1_Click1(object sender, EventArgs e) { SqlDataReader read = dataconn.ExceRead(select * from tb_Student where ID= + this.txtStuID.Text + ); read.Read(); if (read.HasRows) { if (this.txtStuID.Text == read[ID].ToString()) { Label2.Visible = true; } } else { Label3.Visible = true; } read.Close(); } * * 其实现代码如下: Datacon dataconn = new Datacon(); static int int_row1 = 0;//单选题题号索引 static int int_row2 = 0;//多选题题号索引 static int int_row1Point = 0;//单选题分数 static int int_row2Point = 0;//多选题分数 在页面加载的Page_Load事件中编写如下代码,用于从数据库中提取出相应题目。 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack)//判断页面是否是首次加载 { this.getCom(1);//从数据库中获取单选题 this.getCom(2); //从数据库中获取多选题 } } 单机”交卷”按钮,首先通过Session

文档评论(0)

1亿VIP精品文档

相关文档