📄 testifupdate.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class testIfUpdate : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["adminId"] == null)
{
Response.Redirect("Default.aspx");
}
else
if (!Page.IsPostBack)
{
string testId = Session["testId"].ToString();
DataSet ds = new DataSet();
ds = (new projClass()).getTestIfInfoAsId(testId);
DataTable dt = ds.Tables["testInfo"];
DataRow dataRow = dt.Rows[0];
string courseId = Convert.ToString(dataRow["testCourse"]);
lbl_courseName.Text = (new projClass()).getCourseNameAsCourseId(courseId);
tbx_content.Text = Convert.ToString(dataRow["testContent"]);
this.tbx_score.Text = Convert.ToString(dataRow["testScore"]);
int pub = Convert.ToInt16(dataRow["pub"]);
if (pub == 1)
cbx_isPub.Checked = true;
else cbx_isPub.Checked = false;
int rightAns;
if (dataRow["rightAns"].Equals("对"))
{
rightAns = 1;
}
else
{
rightAns = 2;
}
switch (rightAns)
{
case 1: this.RadioButtonList1.Items[0].Selected = true; break;
case 2: this.RadioButtonList1.Items[1].Selected = true; break;
}
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (tbx_content.Text.Trim() != "")
{
int count;
//string testId=Convert.ToString(Session["testId"]);
string testId = Session["testId"].ToString();
string courseId = Convert.ToString(Session["courseId"]);
string content = tbx_content.Text.Trim();
string rightAns = "";
int score;
int pub;
if (cbx_isPub.Checked)
pub = 1;
else pub = 0;
score = Convert.ToInt32(tbx_score.Text);
if (this.RadioButtonList1.Items[0].Selected)
rightAns = "对";
else if (this.RadioButtonList1.Items[1].Selected)
rightAns = "错";
count = (new projClass()).updateTestIfInfo(testId, content, rightAns, pub, score, courseId);
if (count == 0)
Response.Write("<script>alert(\"更新失败!\");</script>");
else
{
Response.Redirect("showIf.aspx");
}
}
else Response.Write("<script>alert(\"请输入完整题目!\");</script>");
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("showIf.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -