毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 报告 >> 正文

ASP.NET调试在线考试系统的实现

更新时间:2007-10-4:  来源:毕业论文

ASP.NET调试在线考试系统的实现|上机实验实习报告|计算机上机实习报告|习题10-6需求一和需求二任选一

实验目的

二、实验要求:

1:自学第十章

2:调试在线考试系统的实现

3:改进该系统,既习题10-6需求一和需求二任选一,画流程图、编程、调试、运行结果截图

、实验步骤:

程序设计:

 流程图:

<Script runat="server">

void Page_Load(Object Src, EventArgs E) {

       string No = "";

       string Name = "";

       string Lesson = "";

       string Msg = "";

       if (IsPostBack) {//页面被提交的时候执行

              No = Request["txtNo"];

              Name = Request["txtName"];

              Lesson = Request["Lesson"];

              string SQL = "Select * From 成绩单 ";

              SQL = SQL + "Where 学号=" + "'" + No + "'" + " And 姓名='" + Name + "'";

              OleDbConnection Conn;

              Conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"+

                     "Data Source="+Server.MapPath("test.mdb"));

              Conn.Open();

        //Response.Write(SQL);

              OleDbCommand Comm=new OleDbCommand(SQL,Conn);

              OleDbDataReader dr=Comm.ExecuteReader();

              if (dr.Read())         {

                     if (dr[Lesson].ToString() != "-1") {

                            Msg = "你已经考过本科目了!";

                     }

                     else{

                     Conn.Close();

                     Response.Redirect("TEST.ASPX?Lesson="+Lesson+"&Name="+Name+"&No="+No);

                     }

              }

              else{

                     Msg = "你不是合法考生!";

 

              }

              Message.Text = Msg;

              Conn.Close();

       }

 

}

</Script>

<HTML>

       <BODY BGCOLOR=BEIGE>

       <H1 ALIGN="CENTER">在线考试系统</H1>

       <HR>

<FORM METHOD="POST" RUNAT="SERVER">

       <asp:DropDownList ID="Lesson" RUNAT="server">

      <asp:ListItem value="ASP" selected="true">ASP</asp:ListItem>

      <asp:ListItem value="XML">XML</asp:ListItem>

   </asp:DropDownList>

       <P>姓名:<asp:textbox id="txtName" runat="server" /></P>

       <P>学号:<asp:textbox id="txtNo" runat="server" /></P>

       <P><asp:button text="开始考试" runat="server" /></P>

       </FORM>      <HR>

              <asp:label id="Message" runat="server" />

       </BODY>

</HTML>                  

 

<% @ Page Language="C#" %>

<%@ Import Namespace="System.Data" %>

<%@ Import Namespace="System.Data.OleDb" %>

<Script runat="server">

string Lesson;

string No;

string Name;

OleDbDataReader dr;

void Page_Load(Object Src, EventArgs E) {

       Lesson = Request["Lesson"];

       No =  Request["No"];

       Name = Request["Name"];

       string SQL = "Select * From " + Lesson + " Order By 题号";

       OleDbConnection Conn;

       Conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"+

              "Data Source="+Server.MapPath("test.mdb"));

       Conn.Open();

    //Response.Write(SQL);

       OleDbCommand Comm = new OleDbCommand(SQL,Conn);

       dr = Comm.ExecuteReader();

}

</Script>

<HTML>

       <BODY BGCOLOR=BEIGE>

       <CENTER>

       <H1><FONT COLOR=#6699DD>在线考试系统</FONT></H1>

       </CENTER>

       <H2>考试科目 -- <%=Lesson%><HR></H2>

       <FORM Action="Score.aspx" Method="GET">

       <INPUT Type="Hidden" Name="Lesson" Value=<%=Lesson%>>

       <INPUT Type="Hidden" Name="No" Value=<%=No%>>

       <INPUT Type="Hidden" Name="Name" Value=<%=Name%>>

<%

string TestType = "";

while (dr.Read()){

       Response.Write("<B>" + dr["题号"].ToString() + "."

              + Server.HtmlEncode(dr["题目"].ToString())

              + dr["类型"].ToString() + ":" + dr["分数"].ToString() + ")</B>");

       Response.Write("<div>");

       for (int i=1; i<5; i++)     {

              if (dr["类型"].ToString() == "单选")    {

                     TestType = "Radio";

              }    

              else  {

                     TestType = "CheckBox";

              }

              Response.Write("<INPUT Type=" + TestType

                     + " Name=No" + dr["题号"].ToString()

                     + " Value=" + i +">"

                     + Server.HtmlEncode(dr["选项" + i].ToString()) + "<BR>");

       }

       Response.Write("</div>");

}

%>

<INPUT Type=Submit Value="    ">

</FORM><HR></BODY>

</HTML>

 

                                                                                                  

<% @ Page Language="C#" %>

<%@ Import Namespace="System.Data" %>

<%@ Import Namespace="System.Data.OleDb" %>

<Script runat="server">

string Lesson;

string No;

string Name;

OleDbDataReader dr;

string SQL;

OleDbConnection Conn;

OleDbCommand Comm;

void Page_Load(Object Src, EventArgs E) {

       Lesson = Request["Lesson"];

       No = Request["No"];

       Name = Request["Name"];

       Conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"+

              "Data Source="+Server.MapPath("test.mdb"));

       Conn.Open();

       SQL = "Select * from " + Lesson;

    //Response.Write(SQL);

       Comm = new OleDbCommand(SQL,Conn);

       dr = Comm.ExecuteReader();

}

//如果<60分,显示为红色

string TestResult(string inputScore){

       int Score = Convert.ToInt32(inputScore);

       if (-1 == Score)     {

              return "你还没有考试";

       }

       else if(Score < 60)  {

              return "<FONT Color=Red>" + Score + "</FONT>";

       }

       else  {

              return Score.ToString();

       }

}

 

</Script>

<HTML>

       <BODY BGCOLOR="BEIGE">

       <H2>成绩单<HR></H2>

<%

       int Score = 0;

       while (dr.Read())    {

              if (Request["No" + dr["题号"].ToString()] != null)      {

                     string Sel = Request["No" + dr["题号"].ToString()];

                     string Ans = dr["解答"].ToString();

                     //Response.Write(Sel + Ans + "<br>");

                     if (Ans == Sel)

                     {

                            Score = Score + Convert.ToInt32(dr["分数"].ToString());

                //Response.Write( "OK" + Score);

                     }

              }

       }

       //重新建立DataReader对象,需要重新打开Connection对象

       Conn.Close();

       Conn.Open();

       SQL = "Select * From 成绩单 ";

       SQL = SQL + "Where 学号=" + "'" + No + "'" + " And 姓名='" + Name + "'";

       Comm = new OleDbCommand(SQL,Conn);

       OleDbDataReader drScore = Comm.ExecuteReader();

       if(drScore.Read()){

              if (drScore[Lesson].ToString() == "-1")      {

              SQL = "update 成绩单 set " + Lesson + " = "  + Score.ToString()

                            + " where 学号=" + "'" + No + "'"

                            + " And 姓名='" + Name + "'";

              Conn.Close();

              Conn.Open();

              Comm = new OleDbCommand(SQL,Conn);

              Comm.ExecuteNonQuery();

       }

       else  {

              Response.Write ("<script>{alert('你已经考过了')}</script>");

              }

       }

%>

       <%=Name%>同志你好,你的考试成绩统计为:<BR>

       <CENTER>

         <TABLE BORDER=2 BGCOLOR="#F1F1F1" WIDTH=80%>

         <TR BGCOLOR="#DDDDDD"><TD>你参加的科目</TD><TD>你的分数</TD></TR>

<%//重新读取成绩

       Conn.Close();

       Conn.Open();

       SQL = "Select * From 成绩单 ";

       SQL = SQL + "Where 学号=" + "'" + No + "'" + " And 姓名='" + Name + "'";

       Comm = new OleDbCommand(SQL,Conn);

       drScore = Comm.ExecuteReader();

       if(drScore.Read()){

       %>

         <TR><TD>ASP</TD><TD Align=Right><%=TestResult(drScore["ASP"].ToString())%></TD></TR>

         <TR><TD>XML</TD><TD Align=Right><%=TestResult(drScore["XML"].ToString())%></TD></TR>

       <%  }     %>

         </TABLE></center>

       <HR>

       <A HREF="login.aspx?txtNo=<%=No%>&txtName=<%=Name%>">参加其他科目考试</A>

       </BODY>

</HTML>

四、试验运行结果:

若图片无法显示请联系站长QQ752018766

ASP.NET调试在线考试系统的实现下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©lwfree.cn 六维论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。