?? testadd.aspx.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 + -