ASP.NET 在线考试系统实现步骤

一、版本页面

VS2010+SqlServer2008R2
登陆页面
数据库页面

二、实现功能

1.  用户注册登录
2.  两种身份:管理员(普通管理员与超级管理员)和考生
3.  普通管理员能够修改学生与查看考试信息
4. 超级管理馆能够更改考试信息
5.  读者查看自己的信息,参加考试

三、主要页面展示

1.登陆页面
登陆页面
2.考生进入
考生进入
3.考生考试考生考试
4.成绩查询
成绩查询
5.错题查看
错题查看
6.管理员页面(分超级管理员与普通管理员,权限不同)
管理员页面
7.学生添加
学生添加
8.题库添加
题库添加
9.试卷生成与管理
试卷生成与管理
10.成绩管理
成绩管理

四、简单代码

1.登陆

 if (cx.Text.ToString().Trim() == "管理员")
        {
            sql = "select * from allusers where username='" + TextBox1.Text.ToString().Trim() + "' and pwd='" + TextBox2.Text.ToString().Trim() + "'";
        }
        if (cx.Text.ToString().Trim() == "学生")
        {
            sql = "select * from xueshengxinxi where xuehao='" + TextBox1.Text.ToString().Trim() + "' and mima='" + TextBox2.Text.ToString().Trim() + "' ";
        }
        DataSet result = new DataSet();
        result = new Class1().hsggetdata(sql);
        // result = new TestOnline.Class1().hsggetdata(sql);
        if (result != null)
        {
            if (result.Tables[0].Rows.Count > 0)
            {
                Session["username"] = TextBox1.Text.ToString().Trim();

                if (cx.Text.ToString().Trim() == "管理员")
                {
                    Session["cx"] = result.Tables[0].Rows[0]["cx"].ToString().Trim();
                }
                else
                {
                    Session["cx"] = cx.Text.ToString().Trim();
                    Session["xm"] = result.Tables[0].Rows[0]["xingming"].ToString().Trim();
                    Session["bj"] = result.Tables[0].Rows[0]["banji"].ToString().Trim();
                }


                Response.Redirect("main.aspx");
            }
            else
            {
                Response.Write("<script>javascript:alert('对不起,用户名或密码不正确!');history.back();</script>");
            }
        }

2.在线考试

  if (result != null)
            {
                if (result.Tables[0].Rows.Count > 0)
                {

                    nshijuanbianhao = result.Tables[0].Rows[0]["shijuanbianhao"].ToString().Trim();
                    nxuanzetishu = result.Tables[0].Rows[0]["xuanzetishu"].ToString().Trim();
                    nxuanzetifenzhi = result.Tables[0].Rows[0]["xuanzetifenzhi"].ToString().Trim();
                    nxuanzeti = result.Tables[0].Rows[0]["xuanzeti"].ToString().Trim();
                    npanduantishu = result.Tables[0].Rows[0]["panduantishu"].ToString().Trim();
                    npanduantifenzhi = result.Tables[0].Rows[0]["panduantifenzhi"].ToString().Trim();
                    npanduanti = result.Tables[0].Rows[0]["panduanti"].ToString().Trim();
                    ntiankongtishu = result.Tables[0].Rows[0]["tiankongtishu"].ToString().Trim();
                    ntiankongtifenzhi = result.Tables[0].Rows[0]["tiankongtifenzhi"].ToString().Trim();
                    ntiankongti = result.Tables[0].Rows[0]["tiankongti"].ToString().Trim();
                }
            }

            sql = "select * from xuanzeti where id in (" + nxuanzeti + ") ";
            //DataSet result = new DataSet();
            result = new Class1().hsggetdata(sql);
            if (result != null)
            {
                if (result.Tables[0].Rows.Count > 0)
                {

                    DataList1.DataSource = result.Tables[0];
                    DataList1.DataBind();

                }
                else
                {
                    DataList1.DataSource = null;
                    DataList1.DataBind();
                }
            }

            sql = "select * from panduanti where id in (" + npanduanti + ") ";
            //DataSet result = new DataSet();
            result = new Class1().hsggetdata(sql);
            if (result != null)
            {
                if (result.Tables[0].Rows.Count > 0)
                {

                    DataList2.DataSource = result.Tables[0];
                    DataList2.DataBind();

                }
                else
                {
                    DataList2.DataSource = null;
                    DataList2.DataBind();
                }
            }

3.成绩查询(简单绑定)

if (!IsPostBack)
        {
            string sql;
            sql = "select * from chengji where xh='" + Session["username"].ToString().Trim()+ "' order by id desc";
            getdata(sql);
        }

五、总结

已经做了很多的项目了,这个考试系统比较完善,对数据的增删改查都比较到位,需要直接加我(不白给)1076396021
直接跳转

原文地址:https://www.cnblogs.com/LJF111/p/12304841.html