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

📄 st_questionadd.aspx.cs

📁 数据库:Microsoft SQL Server 2000。 技术平台:Microsoft .NET Framework 2.0.0.0版本。 IIS:Internet Informati
💻 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 STGROUP.ST_WebExam.ST_Admin
{
	/// <summary>
	/// ST_QuestionAdd 的摘要说明。
	/// </summary>
	public partial class ST_QuestionAdd : System.Web.UI.Page
	{
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			Response.Cache.SetCacheability(HttpCacheability.NoCache);//去掉页面缓存
			if(!IsPostBack)
			{
				//初始化科目信息,如果没有提示错误
				ST_ExamBiz.ST_Course st_course = new STGROUP.ST_ExamBiz.ST_Course();
				DataSet ds = st_course.ST_GetAllCourseInfo();
				ddlCourse.DataSource = st_course.ST_GetAllCourseInfo();
				ddlCourse.DataBind();
				if(ddlCourse.Items.Count==0)
				{
					Response.Write("<script language>alert('没有科目信息,请先添加科目!');window.close();</script>");
					Response.End();
				}
				

				//绑定题目信息
				ST_ExamBiz.ST_Question st_Question = new STGROUP.ST_ExamBiz.ST_Question();
				if(Request["Action"]=="edit" && Request["id"]!=null)
				{
					ds = st_Question.ST_GetQuestionInfo(int.Parse(Request["id"]));
					txtNumber.Text = ds.Tables[0].Rows[0]["ST_QuestionID"].ToString();
					txtDes.Text = ds.Tables[0].Rows[0]["ST_QuestionDes"].ToString();
					txtA.Text = ds.Tables[0].Rows[0]["ST_Answer1"].ToString();
					txtB.Text = ds.Tables[0].Rows[0]["ST_Answer2"].ToString();
					txtC.Text = ds.Tables[0].Rows[0]["ST_Answer3"].ToString();
					txtD.Text = ds.Tables[0].Rows[0]["ST_Answer4"].ToString();
					rblAnswer.SelectedIndex = rblAnswer.Items.IndexOf(rblAnswer.Items.FindByValue(ds.Tables[0].Rows[0]["ST_RightAnswer"].ToString()));
					ddlCourse.SelectedIndex = ddlCourse.Items.IndexOf(ddlCourse.Items.FindByValue(ds.Tables[0].Rows[0]["ST_CourseID"].ToString()));
				}
			}
		}

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

		}
		#endregion

		protected void btnOK_Click(object sender, System.EventArgs e)
		{
			ST_ExamBiz.ST_Question st_Question = new STGROUP.ST_ExamBiz.ST_Question();
			if(Request["Action"]=="add")//添加题目
			{
				st_Question.ST_InsertQuestionInfo(txtDes.Text.Trim(), txtA.Text.Trim(), txtB.Text.Trim(), txtC.Text.Trim(), txtD.Text.Trim(), rblAnswer.SelectedValue, int.Parse(ddlCourse.SelectedValue));
			}
			else//更新题目
			{
				st_Question.ST_UpdateQuestionInfo(txtDes.Text.Trim(), txtA.Text.Trim(), txtB.Text.Trim(), txtC.Text.Trim(), txtD.Text.Trim(), rblAnswer.SelectedValue, int.Parse(ddlCourse.SelectedValue),int.Parse(txtNumber.Text));
			}

			string str = "<script language=javascript>window.dialogArguments.document.location.href='ST_Question.aspx';window.close();</script>"; 
			Response.Write(str);
		
		}
	}
}

⌨️ 快捷键说明

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