⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 result.aspx.cs

📁 在线考试系统...asp.net
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace TestOnline
{
	/// <summary>
	/// result 的摘要说明。
	/// </summary>
	public class result : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.ImageButton ImageButton1;
		protected System.Web.UI.WebControls.Label lbl_score;
		protected System.Web.UI.WebControls.Label lbl_stuId;
		protected System.Web.UI.WebControls.Label lbl_stuName;
		protected System.Web.UI.WebControls.Label lbl_courseName;
		protected System.Web.UI.WebControls.ImageButton ImageButton3;
		protected System.Web.UI.WebControls.ImageButton ImageButton2;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!IsPostBack)
			{
			
				if(Session["stuId"]!=null)
				{
					//以下是获取学生和科目的相关信息.
					string stuId=Convert.ToString(Session["stuId"]);
					string courseId=Convert.ToString(Session["courseId"]);
					string stuName=(new projClass()).getUserName(stuId);
					string courseName=(new projClass()).getCourseNameAsCourseId(courseId);
					lbl_stuId.Text=stuId;
					lbl_stuName.Text=stuName;
					lbl_courseName.Text=courseName;

					
					Hashtable ht_rightAnswer,ht_stuAnswer;
					ht_rightAnswer=(Hashtable)Session["rightAnswer"];
					ht_stuAnswer=(Hashtable)Session["stuAnswer"];
					if(Session["stuAnswer"]==null||Session["rightAnswer"]==null)
						Response.Write("<script>alert(\"session没有获取!\");</script>");
			
					int score=0;
					//给每一题验证答案
					for(int i=1;i<=50;i++)
					{
						if(ht_stuAnswer.Contains(i.ToString())&&ht_rightAnswer.Contains(i.ToString()))
						if(ht_stuAnswer[i.ToString()].ToString().Equals(ht_rightAnswer[i.ToString()].ToString()))
						{
							score=score+2;
						}
					}
					lbl_score.Text=Convert.ToString(score);
					int count=(new projClass()).updateScore(stuId,courseId,1,score);
					int count1=(new projClass()).updateStuStatus(stuId,"",0);
					if(count==0||count1==0)
						Response.Write("<script>alert(\"更新状态错误!\");</script>");
				}
					//没有获取到学生的学号,退出到登录页面
				else Response.Redirect("login.aspx");
			}
	}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);
			this.ImageButton3.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton3_Click);
			this.ImageButton2.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton2_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void ImageButton2_Click(object sender, System.Web.UI.ImageClickEventArgs e)
          //退出按钮
		{
			Response.Redirect("login.aspx");
		}

		private void ImageButton3_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			Response.Redirect("userInfo.aspx");
		}

		private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			Response.Redirect("seeResult.aspx");
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -