📄 testduoxuanupdate.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 testDuoXuanUpdate : 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()).getTestDuoXuanInfoAsId(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"]);
tbx_ans1.Text = Convert.ToString(dataRow["testAns1"]);
tbx_ans2.Text = Convert.ToString(dataRow["testAns2"]);
tbx_ans3.Text = Convert.ToString(dataRow["testAns3"]);
tbx_ans4.Text = Convert.ToString(dataRow["testAns4"]);
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;
string rightAns =(String) dataRow["rightAns"];
int numrightAns;
for (int i = 0; i < rightAns.Length;i++ ) {
string irightAns = rightAns.Substring(i, 1);
if (irightAns.Equals("A"))
{
numrightAns = 1;
}
else if (irightAns.Equals("B"))
{
numrightAns = 2;
}
else if (irightAns.Equals("C"))
{
numrightAns =3;
}
else{
numrightAns = 4;
}
switch ( numrightAns)
{
case 1:this.CheckBoxList1.Items[0].Selected= true; break;
case 2: this.CheckBoxList1.Items[1].Selected = true; break;
case 3: this.CheckBoxList1.Items[2].Selected = true; break;
case 4: this.CheckBoxList1.Items[3].Selected = true; break;
}
}
}
}
//确定事件
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (tbx_content.Text.Trim() != "")
{
int count;
string testId = Session["testId"].ToString();
string courseId = Session["courseId"].ToString();
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();
string rightAns = "";
int score;
int pub;
if (cbx_isPub.Checked)
pub = 1;
else pub = 0;
score = Convert.ToInt32(tbx_score.Text);
if (this.CheckBoxList1.Items[0].Selected)
rightAns += "A";
if (this.CheckBoxList1.Items[1].Selected)
rightAns += "B";
if (this.CheckBoxList1.Items[2].Selected)
rightAns += "C";
if (this.CheckBoxList1.Items[3].Selected)
rightAns += "D";
count = (new projClass()).updateTestDuoXuanInfo(testId, content, ans1, ans2, ans3, ans4, rightAns, pub, courseId, score);
if (count == 0)
Response.Write("<script>alert(\"更新失败!\");</script>");
else
{
Response.Redirect("showDuoXuan.aspx");
//Response.Write("<script>alert('"+courseId+"');</script>");
}
}
else Response.Write("<script>alert(\"请输入完整题目!\");</script>");
}
//取消事件
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("showDuoXuan.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -