当前位置:首页 > 在线考试系统实验报告
河南工程小学院
1. 用户信息表(User)包括的数据项有: 用户名、密码、性别、身份证号码、电子邮箱、角色编号等。(如表4-1所示)
表4-1用户信息表
2. 角色表(Role)中的字段有角色编号、角色名。(如表4-2所示)
表4-2 2. 角色表
3. (Course)中的字段有课程编号和课程名以及两个备用字段。(如图4-3所示)
表4-3 课程表角色表
4. 试题表(question)中的字段有题号、课程编号、题干、A答案、B答案、C答案、D答案、正确答案。(如表4-4所示)
表4-4 角色表
9
河南工程小学院
第5章 界面设计与实现
5.1 主页设计
5.1.1 实现目标
程序启动后,进入登陆窗体,用户输入用户名和密码,然后进行登录。同时可以按下取消按钮退出本系统,登录界面模块中主要实现如下功能:
(1)可进行选择用户身份,支持鼠标操作。 (2)用户名和密码验证成功后,进入主界面。 (3)用户名错误或密码错误提醒并返回输入有误。
5-1主页面
5.1.2 登录窗口
5-2 登录窗口
10
河南工程小学院
在登录过程中,系统会首先根据画面上用户输入的内容进行验证检查,相关代码如下:
string conn = ConfigurationManager.ConnectionStrings[\].ConnectionString; protected void txtRegist_Click(object sender, EventArgs e) {
Response.Redirect(\); }
protected void txtLogin_Click(object sender, EventArgs e) {
SqlConnection con = new SqlConnection(conn);
string strSql = \ + txtName.Text + \ + this.txtPassword.Text + \; SqlCommand com = new SqlCommand(strSql, con); con.Open();
int num = (int)com.ExecuteScalar(); if (num == 0) {
Response.Write(\密码错误!');\); return; }
strSql = \ + txtName.Text + \; try {
com.CommandText = strSql;
SqlDataReader sdr = com.ExecuteReader(); if (sdr.Read()) {
string s = sdr[\].ToString(); Session[\] = s;
Session[\] = txtName.Text; Session[\] = txtPassword.Text; }
sdr.Close(); }
catch (SqlException ex) {
Response.Write(ex.ToString()); } finally {
con.Close(); }
Response.Redirect(\);
11
河南工程小学院
如果验证通过,系统会连接数据库,进行数据正确性以及用户权限的检查,以上检查成功的情况下,就会进入本系统的主窗体,如果失败,跳出错误提示框。 5.1.3 注册窗口
图5-3 注册窗口
在注册过程中,系统会自动检查用户注册的信息是否合法,相关代码如下:
string conn = ConfigurationManager.ConnectionStrings[\].ConnectionString; protected void btnOK_Click(object sender, EventArgs e) {
SqlConnection con = new SqlConnection(conn);
string strSql = \ + txtName.Text + \; SqlCommand com = new SqlCommand(strSql, con); con.Open();
int num = (int)com.ExecuteScalar(); if (num > 0) {
Response.Write(\表中存在记录!');\); } else {
string name = txtName.Text;
string password = this.txtPassword.Text; string sex = \男\;
if (this.rbtnFemail.Checked) {
sex = \女\; }
string identity = txtIdentity.Text.ToString(); string email = this.txtMail.Text.ToString();
strSql = \ + name + \ + password + \ + sex + \ + identity + \ + email + \;
com = new SqlCommand(strSql, con); com.ExecuteNonQuery(); con.Close();
12
共分享92篇相关文档