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

📄 testpaper1.aspx.cs

📁 本系统实现了网上考试的目的
💻 CS
📖 第 1 页 / 共 2 页
字号:
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;
using System.Data.SqlClient;
using System.Data.SqlTypes;

public partial class TestPaper1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserID"] == null)
        {
            Response.Redirect("Default.aspx");
        }
        else
        {
            //Ibtn_submit.Attributes.Add("OnClick", "return confirm('你的确要交卷吗?交卷后将不能再考试!');");

            string courseId = Convert.ToString(Session["ClassifyID"]);
            string stuId = Convert.ToString(Session["UserID"]);
            string stuName = Convert.ToString(Session["UserName"]);
            string courseName = Convert.ToString(Session["ClassifyName"]);
            lbl_stuId.Text = stuId;
            lbl_stuName.Text = stuName;
            lbl_courseName.Text = courseName;



            int XZnum = 1;
            SqlDataReader readerXZ = (new UserDB()).selectXZastestpaper(stuId, courseId);
            Hashtable ht_XZRightAnswer = new Hashtable();
            Hashtable ht_XZStuTest = new Hashtable();
            while (readerXZ.Read())
            {
                string testId = readerXZ["testID"].ToString();


                SqlDataReader readerXZ1 = (new UserDB()).getXZInfoAsXZId1(testId);

                while (readerXZ1.Read())
                {
                    Literal lit_XZContent = new Literal();
                    RadioButtonList rbtnList_XZ = new RadioButtonList();
                    rbtnList_XZ.ID = "rbtnList_XZ" + XZnum.ToString();
                    lit_XZContent.Text = "<br>" + XZnum.ToString() + "、" + Server.HtmlEncode(readerXZ1["XZName"].ToString()) + "<br>";
                    rbtnList_XZ.Items.Add("A. " + Server.HtmlEncode(readerXZ1["A"].ToString()));
                    rbtnList_XZ.Items.Add("B. " + Server.HtmlEncode(readerXZ1["B"].ToString()));
                    rbtnList_XZ.Items.Add("C. " + Server.HtmlEncode(readerXZ1["C"].ToString()));
                    rbtnList_XZ.Items.Add("D. " + Server.HtmlEncode(readerXZ1["D"].ToString()));
                    // string XZID = readerXZ["XZID"].ToString();
                    ht_XZStuTest.Add(XZnum.ToString(), testId.ToString());
                    int XZRightAns = (new UserDB()).getXZRightAnsAsXZId(testId);
                    ht_XZRightAnswer.Add(XZnum.ToString(), XZRightAns);
                    for (int j = 1; j <= 4; j++)
                    {
                        rbtnList_XZ.Items[j - 1].Value = j.ToString();
                    }
                    if (XZnum <= 35)
                    {
                        Panel1.Controls.Add(lit_XZContent);
                        Panel1.Controls.Add(rbtnList_XZ);
                    }
                    else
                    {
                        Panel2.Controls.Add(lit_XZContent);
                        Panel2.Controls.Add(rbtnList_XZ);
                    }
                }
                string xz = "xz";
                int stuanswer = (new UserDB()).getstuanswer(stuId, courseId, xz, XZnum);
                RadioButtonList XZlist;
                if (XZnum <= 35)
                {
                    XZlist = (RadioButtonList)Panel1.FindControl("rbtnList_XZ" + XZnum.ToString());
                }
                else
                {
                    XZlist = (RadioButtonList)Panel2.FindControl("rbtnList_XZ" + XZnum.ToString());
                }
                switch (stuanswer)
                {
                    case 1:
                        XZlist.Items[0].Selected = true;
                        break;
                    case 2:
                        XZlist.Items[1].Selected = true;
                        break;
                    case 3:
                        XZlist.Items[2].Selected = true;
                        break;
                    case 4:
                        XZlist.Items[3].Selected = true;
                        break;
                    default:
                        break;
                }
                XZnum++;
            }
            Session["XZRightAnswer"] = ht_XZRightAnswer;
            Session["XZStuTest"] = ht_XZStuTest;
            SqlDataReader readerWX3 = (new UserDB()).selectWXastestpaper(stuId, courseId);
            Hashtable ht_WXRightAnswer = new Hashtable();
            Hashtable ht_WXStuTest = new Hashtable();
            while (readerWX3.Read())
            {
                string testId = readerWX3["testID"].ToString();
                SqlDataReader readerWX1 = (new UserDB()).getWXInfoAsWXId1(testId);
                while (readerWX1.Read())
                {
                    string WXID2 = readerWX1["WXID"].ToString();
                    string WXTKID = readerWX1["WXTKID"].ToString();
                    Session["WXID"] = WXID2;
                    Literal lit_WXContent = new Literal();
                    lit_WXContent.Text = "<br>" + Server.HtmlEncode(readerWX1["WXName"].ToString()) + "<br>";
                    Hashtable ht_WXContent = new Hashtable();
                    ht_WXContent.Add(1, WXTKID.ToString());
                    Panel3.Controls.Add(lit_WXContent);
                    Session["WXContent"] = ht_WXContent;
                }
                string WXID1 = Convert.ToString(Session["WXID"]);
                SqlDataReader readerWXDetail = (new UserDB()).getWXTKDetailAsWXId(WXID1);
                int WXnum = 1;
                while (readerWXDetail.Read())
                {

                    Literal lit_WXDeltail = new Literal();
                    RadioButtonList rbtnList_WX = new RadioButtonList();
                    rbtnList_WX.ID = "rbtnList_WX" + WXnum.ToString();
                    rbtnList_WX.RepeatColumns = 4;
                    lit_WXDeltail.Text = "<br>" + WXnum.ToString() + "、" + "<br>";
                    rbtnList_WX.Items.Add("A. " + Server.HtmlEncode(readerWXDetail["A"].ToString()));
                    rbtnList_WX.Items.Add("B. " + Server.HtmlEncode(readerWXDetail["B"].ToString()));
                    rbtnList_WX.Items.Add("C. " + Server.HtmlEncode(readerWXDetail["C"].ToString()));
                    rbtnList_WX.Items.Add("D. " + Server.HtmlEncode(readerWXDetail["D"].ToString()));
                    string WXID = readerWXDetail["WXNumber"].ToString();
                    ht_WXStuTest.Add(WXnum.ToString(), WXID.ToString());
                    int WXRightAns = (new UserDB()).getWXRightAnsAsWXId(WXID);
                    ht_WXRightAnswer.Add(WXnum.ToString(), WXRightAns);
                    for (int j = 1; j <= 4; j++)
                    {
                        rbtnList_WX.Items[j - 1].Value = j.ToString();
                    }
                    Panel3.Controls.Add(lit_WXDeltail);
                    Panel3.Controls.Add(rbtnList_WX);
                    string wxdetail = "wxdetail";
                    int stuanswer = (new UserDB()).getstuanswer(stuId, courseId, wxdetail, WXnum);
                    RadioButtonList WXlist;
                    WXlist = (RadioButtonList)Panel3.FindControl("rbtnList_WX" + WXnum.ToString());
                    switch (stuanswer)
                    {
                        case 1:
                            WXlist.Items[0].Selected = true;
                            break;
                        case 2:
                            WXlist.Items[1].Selected = true;
                            break;
                        case 3:
                            WXlist.Items[2].Selected = true;
                            break;
                        case 4:
                            WXlist.Items[3].Selected = true;
                            break;
                        default:
                            break;
                    }
                    WXnum++;
                }

            }
            Session["WXRightAnswer"] = ht_WXRightAnswer;
            Session["WXStuTest"] = ht_WXStuTest;
            SqlDataReader readerYD3 = (new UserDB()).selectYDastestpaper(stuId, courseId);
            Hashtable ht_YDRightAnswer = new Hashtable();
            Hashtable ht_YDStuTest = new Hashtable();
            while (readerYD3.Read())
            {
                string testId = readerYD3["testID"].ToString();
                SqlDataReader readerYD1 = (new UserDB()).getYDInfoAsYDId1(testId);
                while (readerYD1.Read())
                {
                    string YD2 = readerYD1["YDID"].ToString();
                    string YDID = readerYD1["YUEDUID"].ToString();
                    Session["YDID"] = YD2;

⌨️ 快捷键说明

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