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

📄 seeresult.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.IO;
using System.Net;
using System.Text;
using System.ComponentModel;
using System.Web.SessionState;   

public partial class seeResult : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["stuId"] == null)
        {
            Response.Redirect("Default.aspx");
        }
        else
        {
            if (!Page.IsPostBack)
            {
                string courseId = Convert.ToString(Session["courseId"]);
                string stuId = Convert.ToString(Session["stuId"]);
                string stuName = (new projClass()).getUserName(stuId);
                string courseName = (new projClass()).getCourseNameAsCourseId(courseId);
                lbl_stuId.Text = stuId;
                lbl_stuName.Text = stuName;
                lbl_courseName.Text = courseName;
                InitData();
            }
        }
    }

    public void InitData()
    {
        Hashtable htsingle = (Hashtable)Session["htsing"];
        DataSet ds1 = (new projClass()).getTestDanXuan(Session["courseId"].ToString());
        GridView1.DataSource = ds1;
        GridView1.DataBind();
        CheckSingle(htsingle);//检查单选题       
        ((Label)GridView1.HeaderRow.FindControl("Label5")).Text = ((Label)GridView1.Rows[0].FindControl("Label31")).Text;


        Hashtable htMulit = (Hashtable)Session["htMulit"];
        DataSet ds2 = (new projClass()).getTestDuoXuan(Session["courseId"].ToString());
        GridView2.DataSource = ds2;
        GridView2.DataBind();
        CheckMulit(htMulit);//检查多选题
        ((Label)GridView2.HeaderRow.FindControl("Label10")).Text = ((Label)GridView2.Rows[0].FindControl("Label32")).Text;


        Hashtable htJudge = (Hashtable)Session["htjudge"];
        DataSet ds3 = (new projClass()).getTestIf(Session["courseId"].ToString());
        GridView3.DataSource = ds3;
        GridView3.DataBind();
        CheckJudge(htJudge);//检查判断题
        ((Label)GridView3.HeaderRow.FindControl("Label11")).Text = ((Label)GridView3.Rows[0].FindControl("Label33")).Text;


        Hashtable htfill = (Hashtable)Session["htfill"];
        DataSet ds4 = (new projClass()).getTianKong(Session["courseId"].ToString());
        GridView4.DataSource = ds4;
        GridView4.DataBind();
        CheckFill(htfill);//检查填空题
        ((Label)GridView4.HeaderRow.FindControl("Label12")).Text = ((Label)GridView4.Rows[0].FindControl("Label34")).Text;

        Hashtable htquestions = (Hashtable)Session["htquestions"];
        DataSet ds5 = (new projClass()).getWenDa(Session["courseId"].ToString());
        GridView5.DataSource = ds5;
        GridView5.DataBind();
        CheckQuestion(htquestions);//检查问答题
        ((Label)GridView5.HeaderRow.FindControl("Label13")).Text = ((Label)GridView5.Rows[0].FindControl("Label35")).Text;
    }
    //检查单选题
    public void CheckSingle(Hashtable htsing)
    {
        //  htsing[0].ToString();
        //string Qanswer= ((Label)GridView1.Rows[0].FindControl("Label4")).Text;
        foreach (GridViewRow dr in GridView1.Rows)//对单选题每题进行判断用户选择答案
        {
            string Qanswer = ((Label)GridView1.Rows[dr.RowIndex].FindControl("Label4")).Text;
            if (htsing[dr.RowIndex].ToString() != Qanswer)
            {
                if (htsing[dr.RowIndex].ToString() == "1")
                {
                    ((RadioButton)dr.FindControl("RadioButton1")).Checked = true;
                }
                else if (htsing[dr.RowIndex].ToString() == "2")
                {
                    ((RadioButton)dr.FindControl("RadioButton2")).Checked = true;
                }
                else if (htsing[dr.RowIndex].ToString() == "3")
                {
                    ((RadioButton)dr.FindControl("RadioButton3")).Checked = true;
                }
                else if (htsing[dr.RowIndex].ToString() == "4")
                {
                    ((RadioButton)dr.FindControl("RadioButton4")).Checked = true;
                }
                ((Label)GridView1.Rows[dr.RowIndex].FindControl("Label4")).Visible = true;

            }
            else
            {
                if (htsing[dr.RowIndex].ToString() == "1")
                {
                    ((RadioButton)dr.FindControl("RadioButton1")).Checked = true;
                }
                else if (htsing[dr.RowIndex].ToString() == "2")
                {
                    ((RadioButton)dr.FindControl("RadioButton2")).Checked = true;
                }
                else if (htsing[dr.RowIndex].ToString() == "3")
                {
                    ((RadioButton)dr.FindControl("RadioButton3")).Checked = true;
                }
                else if (htsing[dr.RowIndex].ToString() == "4")
                {
                    ((RadioButton)dr.FindControl("RadioButton4")).Checked = true;
                }
            }


        }
    }

    //检查多选题
    public void CheckMulit(Hashtable htMulit)
    {
        foreach (GridViewRow dr in GridView2.Rows)//对单选题每题进行判断用户选择答案
        {
            string Qanswer = ((Label)GridView2.Rows[dr.RowIndex].FindControl("Label16")).Text;
            if (htMulit[dr.RowIndex].ToString() != Qanswer)
            {

                if (htMulit[dr.RowIndex].ToString().Contains("A"))
                {
                    ((CheckBox)dr.FindControl("CheckBox1")).Checked = true;
                    if (htMulit[dr.RowIndex].ToString().Contains("B"))
                    {
                        ((CheckBox)dr.FindControl("CheckBox3")).Checked = true;
                        if (htMulit[dr.RowIndex].ToString().Contains("C"))
                        {
                            ((CheckBox)dr.FindControl("CheckBox2")).Checked = true;
                            if (htMulit[dr.RowIndex].ToString().Contains("D"))
                            {
                                ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                            }
                        }
                        else if (htMulit[dr.RowIndex].ToString().Contains("D"))
                        {
                            ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                        }
                    }
                    else if (htMulit[dr.RowIndex].ToString().Contains("C"))
                    {

                        ((CheckBox)dr.FindControl("CheckBox2")).Checked = true;
                        if (htMulit[dr.RowIndex].ToString().Contains("D"))
                        {
                            ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                        }

                    }
                    else if (htMulit[dr.RowIndex].ToString().Contains("D"))
                    {
                        ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                    }
                }
                else if (htMulit[dr.RowIndex].ToString().Contains("B"))
                {
                    ((CheckBox)dr.FindControl("CheckBox3")).Checked = true;
                    if (htMulit[dr.RowIndex].ToString().Contains("C"))
                    {
                        ((CheckBox)dr.FindControl("CheckBox2")).Checked = true;
                        if (htMulit[dr.RowIndex].ToString().Contains("D"))
                        {
                            ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                        }
                    }
                    else if (htMulit[dr.RowIndex].ToString().Contains("D"))
                    {
                        ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                    }

                }
                else if (htMulit[dr.RowIndex].ToString().Contains("C"))
                {
                    ((CheckBox)dr.FindControl("CheckBox2")).Checked = true;
                    if (htMulit[dr.RowIndex].ToString().Contains("D"))
                    {
                        ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                    }
                }
                else if (htMulit[dr.RowIndex].ToString().Contains("D"))
                {
                    ((CheckBox)dr.FindControl("CheckBox4")).Checked = true;
                }



                ((Label)GridView2.Rows[dr.RowIndex].FindControl("Label16")).Visible = true;

            }
            else if (htMulit[dr.RowIndex].ToString() == Qanswer)
            {
                if (htMulit[dr.RowIndex].ToString().Contains("A"))
                {
                    ((CheckBox)dr.FindControl("CheckBox1")).Checked = true;
                    if (htMulit[dr.RowIndex].ToString().Contains("B"))

⌨️ 快捷键说明

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