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

📄 testadd.aspx.cs

📁 考试系统,测试帐号:学生ID:012003021314
💻 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>
	/// testAdd 的摘要说明。
	/// </summary>
	public partial class testAdd : System.Web.UI.Page
	{
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(Session["adminId"]==null)
			{
					Response.Redirect("login.aspx");
			}else
			if(!Page.IsPostBack)
			{
				if(Session["courseId"]!=null)
				{
				 string courseId=Convert.ToString(Session["courseId"]);
			     lbl_courseName.Text=(new projClass()).getCourseNameAsCourseId(courseId); 	
				}
				else
				{
					Response.Write("<script>alert(\"没有获取到科目ID\");</script>");
					Response.Redirect("showTest.aspx");
				}
			}
		}

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

		}
		#endregion

		private void Ibtn_ok_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			if(tbx_content.Text.Trim()!="")
			{
				int count;
				string courseId=Convert.ToString(Session["courseId"]);
				string content=tbx_content.Text.Trim();
				string ans1=tbx_ans1.Text.Trim();
				string ans2=tbx_ans2.Text.Trim();
				string ans3=tbx_ans3.Text.Trim();
				string ans4=tbx_ans4.Text.Trim();
				int rightAns=1;
				int score;
				int pub;
				if(cbx_isPub.Checked)
					pub=1;
				else pub=0;
				score=Convert.ToInt32(tbx_score.Text);
				if(rbtn1.Checked)
					rightAns=1;
				else if(rbtn2.Checked)
					rightAns=2;
				else if(rbtn3.Checked)
					rightAns=3;
				else if(rbtn4.Checked)
					rightAns=4;
				count=(new projClass()).insertTest(content,ans1,ans2,ans3,ans4,rightAns,pub,score,courseId);
                tbx_content.Text="";
				tbx_ans1.Text="";
				tbx_ans2.Text="";
				tbx_ans3.Text="";
				tbx_ans4.Text="";
                if(count==0)
					Response.Write("<script>alert(\"添加失败!\");</script>");
				
			}
			else  Response.Write("<script>alert(\"请输入完整题目!\");</script>");
			if(!cbx_continue.Checked)
			{
					Response.Redirect("showTest.aspx");
				
			}
		}

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

⌨️ 快捷键说明

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