Example #1
0
        protected void Button_text_Click(object sender, EventArgs e)
        {
            List <Questdata> Qdata = new List <Questdata>();

            TestID = DropDownList1.SelectedValue;
            SqlCommand    cmd;
            SqlConnection AllData_Connection = null;
            SqlDataReader DataBase_Reader;                                                                                         //資料庫讀取

            AllData_Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DataBaseConnection"].ConnectionString); //宣告一個資料庫連結
            #region 取得ID
            AllData_Connection.Open();                                                                                             //開啟AllData資料庫
            DataBase_Language = "Select * from SelectedData where TextID= '" + TestID.Trim() + "'";                                //資料庫語法
            cmd             = new SqlCommand(DataBase_Language, AllData_Connection);                                               //使用SQL
            DataBase_Reader = cmd.ExecuteReader();

            while (DataBase_Reader.Read())
            {
                string doNumber = (string)DataBase_Reader["doNumber"];
                int    way      = (int)DataBase_Reader["Way"];
                Qdata.Add(new Questdata(doNumber, 0, 0, 0, 0, way));
            }
            DataBase_Reader.Close();
            AllData_Connection.Close();//close AllData資料庫
            #endregion
            #region 取得答題狀況
            AllData_Connection.Open();                                                           //開啟AllData資料庫
            DataBase_Language = "Select * from FloatData where TestID= '" + TestID.Trim() + "'"; //資料庫語法
            cmd             = new SqlCommand(DataBase_Language, AllData_Connection);             //使用SQL
            DataBase_Reader = cmd.ExecuteReader();

            while (DataBase_Reader.Read())
            {
                string Reply;
                string doNumber = (string)DataBase_Reader["QuestionID"];
                if (DataBase_Reader["Reply"] == DBNull.Value)
                {
                    Reply = "X";
                }
                else
                {
                    Reply = (string)DataBase_Reader["Reply"];
                }
                //  Reply = (string)DataBase_Reader["Reply"]==DBNull.Value? "X" : (string)DataBase_Reader["Reply"];
                for (int u = 0; u < Qdata.Count; u++)
                {
                    if (doNumber.Trim() == Qdata[u].testid.Trim())
                    {
                        if (Reply == "A")
                        {
                            Qdata[u].optiontotal[0]++;
                        }
                        if (Reply == "B")
                        {
                            Qdata[u].optiontotal[1]++;
                        }
                        if (Reply == "C")
                        {
                            Qdata[u].optiontotal[2]++;
                        }
                        if (Reply == "D")
                        {
                            Qdata[u].optiontotal[3]++;
                        }
                    }
                }
            }
            DataBase_Reader.Close();
            AllData_Connection.Close();//close AllData資料庫
            #endregion
            for (int u = 0; u < Qdata.Count; u++)
            {
                int total = Qdata[u].optiontotal[0] + Qdata[u].optiontotal[1] + Qdata[u].optiontotal[2] + Qdata[u].optiontotal[3];
                if (total != 0)
                {
                    #region 畫圖
                    if (Qdata[u].way == 1)
                    {
                        Panel_onImage.Controls.Add(new Label()
                        {
                            Text = "第" + (u + 1) + "題" + Qdata[u].testid.Trim() + "(必選)"
                        });
                    }
                    else
                    {
                        Panel_onImage.Controls.Add(new Label()
                        {
                            Text = "第" + (u + 1) + "題" + Qdata[u].testid.Trim() + "(隨機)"
                        });
                    }

                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "<br>"
                    });
                    Panel_onImage.Controls.Add(new System.Web.UI.WebControls.Image()
                    {
                        ImageUrl = "~/Images/Adaptive/" + Qdata[u].testid.Trim() + "Q.png", Width = 500
                    });
                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "<br><HR color=#E6E8EA size=1 >"
                    });
                    Label label = new Label();
                    label.Text      = "正確解答<br>";
                    label.BackColor = System.Drawing.Color.GreenYellow;
                    label.Font.Size = 16;
                    Panel_onImage.Controls.Add(label);
                    Panel_onImage.Controls.Add(new System.Web.UI.WebControls.Image()
                    {
                        ImageUrl = "~/Images/Adaptive/" + Qdata[u].testid.Trim() + "A.png", Width = 200
                    });
                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "<br>選正解人數:" + Qdata[u].optiontotal[0] + "人(" + (Qdata[u].optiontotal[0] * 100 / total) + "%)<HR color=#E6E8EA size=1 >"
                    });
                    Label label2 = new Label();
                    label2.Text      = "<br>其他選項<br>";
                    label2.BackColor = System.Drawing.Color.MediumVioletRed;
                    label2.Font.Size = 14;
                    Panel_onImage.Controls.Add(label2);

                    Panel_onImage.Controls.Add(new System.Web.UI.WebControls.Image()
                    {
                        ImageUrl = "~/Images/Adaptive/" + Qdata[u].testid.Trim() + "B.png", Width = 200
                    });
                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "<br>人數:" + Qdata[u].optiontotal[1] + "人(" + (Qdata[u].optiontotal[1] * 100 / total) + "%)<br><HR color=#E6E8EA size=1 >"
                    });
                    Panel_onImage.Controls.Add(new System.Web.UI.WebControls.Image()
                    {
                        ImageUrl = "~/Images/Adaptive/" + Qdata[u].testid.Trim() + "C.png", Width = 200
                    });
                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "<br>人數:" + Qdata[u].optiontotal[2] + "人(" + (Qdata[u].optiontotal[2] * 100 / total) + "%)<br><HR color=#E6E8EA size=1 >"
                    });
                    Panel_onImage.Controls.Add(new System.Web.UI.WebControls.Image()
                    {
                        ImageUrl = "~/Images/Adaptive/" + Qdata[u].testid.Trim() + "D.png", Width = 200
                    });
                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "<br>人數:" + Qdata[u].optiontotal[3] + "人(" + (Qdata[u].optiontotal[3] * 100 / total) + "%)<br><HR color=#E6E8EA size=1 >"
                    });
                    Panel_onImage.Controls.Add(new Button()
                    {
                        Text = "查看答題情況"
                    });
                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "<HR color=#00FF00 size=10 >"
                    });
                    #endregion 畫圖
                }
                else
                {
                    #region 畫圖
                    if (Qdata[u].way == 1)
                    {
                        Panel_onImage.Controls.Add(new Label()
                        {
                            Text = "第" + (u + 1) + "題(必選)(無人作答)"
                        });
                    }
                    else
                    {
                        Panel_onImage.Controls.Add(new Label()
                        {
                            Text = "第" + (u + 1) + "題(隨機)(無人作答)"
                        });
                    }
                    //Panel_onImage.Controls.Add(new Label() { Text = "第" + (u + 1) + "題(無人作答)"});
                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "<br>"
                    });
                    Panel_onImage.Controls.Add(new System.Web.UI.WebControls.Image()
                    {
                        ImageUrl = "~/Images/Adaptive/" + Qdata[u].testid.Trim() + "Q.png", Width = 500
                    });
                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "<br>"
                    });
                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "正確解答<br>"
                    });
                    Panel_onImage.Controls.Add(new System.Web.UI.WebControls.Image()
                    {
                        ImageUrl = "~/Images/Adaptive/" + Qdata[u].testid.Trim() + "A.png", Width = 200
                    });
                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "<br>其他選項<br>"
                    });
                    Panel_onImage.Controls.Add(new System.Web.UI.WebControls.Image()
                    {
                        ImageUrl = "~/Images/Adaptive/" + Qdata[u].testid.Trim() + "B.png", Width = 200
                    });
                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "<br>"
                    });
                    Panel_onImage.Controls.Add(new System.Web.UI.WebControls.Image()
                    {
                        ImageUrl = "~/Images/Adaptive/" + Qdata[u].testid.Trim() + "C.png", Width = 200
                    });
                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "<br>"
                    });
                    Panel_onImage.Controls.Add(new System.Web.UI.WebControls.Image()
                    {
                        ImageUrl = "~/Images/Adaptive/" + Qdata[u].testid.Trim() + "D.png", Width = 200
                    });
                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "<br>"
                    });
                    Panel_onImage.Controls.Add(new Button()
                    {
                        Text = "查看答題情況"
                    });
                    Panel_onImage.Controls.Add(new Label()
                    {
                        Text = "<br>--------------------------------------------------------------------------------------------------------------------------------<br>"
                    });
                    #endregion 畫圖
                }
            }
            //-----------------------------------------------------------------------
            List <ChapterCount> chapterlist = new List <ChapterCount>();
            AllData_Connection.Open();                                                     //開啟AllData資料庫
            DataBase_Language = "Select * from FloatData where  TestID ='" + TestID + "'"; //資料庫語法
            cmd             = new SqlCommand(DataBase_Language, AllData_Connection);       //使用SQL
            DataBase_Reader = cmd.ExecuteReader();
            Boolean getCH = false;
            #region 曲線取值
            while (DataBase_Reader.Read())
            {
                try {
                    getCH = true;

                    string tempChapter = (string)DataBase_Reader["Chapter"];
                    int    skills      = (int)DataBase_Reader["SkillsUnit"];
                    string Reply       = "X";
                    if (!DataBase_Reader.IsDBNull(DataBase_Reader.GetOrdinal("Reply")))
                    {
                        Reply = (string)DataBase_Reader["Reply"];
                    }
                    for (int tc = 0; tc < chapterlist.Count; tc++)
                    {
                        if (tempChapter.Trim() == chapterlist[tc].chapter)
                        {
                            getCH = false;
                            while (skills != 0)
                            {
                                int ab = skills % 10;
                                if (Reply.Trim() == "A")//2
                                {
                                    chapterlist[tc].abilityYes[ab - 1]++;
                                }
                                chapterlist[tc].abilityTotal[ab - 1]++;
                                skills = skills / 10;
                            }
                        }
                    }
                    //-------------沒有章節情況下
                    if (getCH == true)
                    {
                        ChapterCount tempCC = new ChapterCount(tempChapter.Trim());

                        while (skills != 0)
                        {
                            int ab = skills % 10;
                            if (Reply.Trim() == "A")//2
                            {
                                tempCC.abilityYes[ab - 1]++;
                            }
                            tempCC.abilityTotal[ab - 1]++;
                            skills = skills / 10;
                        }
                        chapterlist.Add(tempCC);
                    }
                }
                catch
                { }
            }
            AllData_Connection.Close();//開啟AllData資料庫
            #endregion
            // Label2.Text = tempSelected;
            #region 資料讀取-屬性能力名稱
            for (int tc = 0; tc < chapterlist.Count; tc++)
            {
                AllData_Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DataBaseConnection"].ConnectionString); //宣告一個資料庫連結
                AllData_Connection.Open();                                                                                             //開啟AllData資料庫
                DataBase_Language = " Select * from Ability";                                                                          //資料庫語法
                cmd             = new SqlCommand(DataBase_Language, AllData_Connection);                                               //使用SQL
                DataBase_Reader = cmd.ExecuteReader();

                int tempIndex = 0;
                while (DataBase_Reader.Read())
                {
                    try
                    {
                        string TestDataNumber = (string)DataBase_Reader[chapterlist[tc].chapter.Trim()];
                        chapterlist[tc].abilityName[tempIndex] = TestDataNumber;
                        tempIndex++;
                    }
                    catch { }
                }
                AllData_Connection.Close();//開啟AllData資料庫
            }
            #endregion
            #region 畫圖
            for (int tc = 0; tc < chapterlist.Count; tc++)
            {
                Chart Chart1 = new Chart();
                Chart1.Width  = 500;
                Chart1.Height = 300;
                Chart1.Series.Add("Series1");
                Chart1.ChartAreas.Add("ChartArea1");
                Chart1.Series["Series1"].ChartType           = SeriesChartType.Bar; //橫條圖
                Chart1.Series["Series1"].IsValueShownAsLabel = true;

                //----------
                Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D    = true;                 //3D效果
                Chart1.ChartAreas["ChartArea1"].Area3DStyle.IsClustered = true;                 //並排顯示
                Chart1.ChartAreas["ChartArea1"].Area3DStyle.Rotation    = 40;                   //垂直角度
                Chart1.ChartAreas["ChartArea1"].Area3DStyle.Inclination = 50;                   //水平角度
                Chart1.ChartAreas["ChartArea1"].Area3DStyle.PointDepth  = 30;                   //數據條深度
                Chart1.ChartAreas["ChartArea1"].Area3DStyle.WallWidth   = 0;                    //外牆寬度
                Chart1.ChartAreas["ChartArea1"].Area3DStyle.LightStyle  = LightStyle.Realistic; //光源
                Chart1.ChartAreas["ChartArea1"].BackColor = Color.FromArgb(240, 240, 240);      //背景色
                Chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineColor = Color.FromArgb(150, 150, 150);
                //X 軸線顏色
                Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineColor = Color.FromArgb(150, 150, 150);
                //Y 軸線顏色
                Chart1.Series["Series1"].MarkerSize            = 16;
                Chart1.ChartAreas["ChartArea1"].AxisX.Title    = "答題率(%)";
                Chart1.ChartAreas["ChartArea1"].AxisY.Title    = "屬性";
                Chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1;
                //------
                Title title = new Title();
                title.Text = "[" + chapterlist[tc].chapter + "] 能力答題率";
                title.Font = new System.Drawing.Font("Trebuchet MS", 14F, FontStyle.Bold);
                Chart1.Titles.Add(title);

                for (int U = 0; U < chapterlist[tc].abilityTotal.Length; U++)
                {
                    if (chapterlist[tc].abilityTotal[U] != 0)
                    {
                        Chart1.Series["Series1"].Points.AddXY(U + 1, chapterlist[tc].abilityYes[U] * 100 / chapterlist[tc].abilityTotal[U]);
                    }
                }
                //Chart1.Series["Series1"].IsValueShownAsLabel = true;
                for (int i = 0; i < Chart1.Series["Series1"].Points.Count; i++)
                {
                    Chart1.Series["Series1"].Points[i].Label = "#VALX." + chapterlist[tc].abilityName[Convert.ToInt16(Chart1.Series["Series1"].Points[i].XValue) - 1] + "(#VALY %," + chapterlist[tc].abilityYes[Convert.ToInt16(Chart1.Series["Series1"].Points[i].XValue) - 1] + "/" + chapterlist[tc].abilityTotal[Convert.ToInt16(Chart1.Series["Series1"].Points[i].XValue) - 1] + ")";

                    if (Chart1.Series["Series1"].Points[i].YValues[0] > 60)
                    {
                        Chart1.Series["Series1"].Points[i].Color = Color.Green;
                    }
                    else
                    {
                        Chart1.Series["Series1"].Points[i].Color = Color.Red;
                    }
                    ;
                }
                //  Chart1.DataBind();
                //Chart1.Series["Series1"]["BarLabelStyle"]="Top";
                Panel_chart.Controls.Add(Chart1);
            }
            #endregion
            int[] Score     = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            int   nottest   = 0;
            int   totaltest = 0;
            AllData_Connection.Open();                                                           //開啟AllData資料庫
            DataBase_Language = "Select * from ExamsList where TestID= '" + TestID.Trim() + "'"; //資料庫語法
            cmd             = new SqlCommand(DataBase_Language, AllData_Connection);             //使用SQL
            DataBase_Reader = cmd.ExecuteReader();

            while (DataBase_Reader.Read())
            {
                totaltest++;
                int Sc = (int)DataBase_Reader["Score"];
                if (Sc >= 0)
                {
                    Score[(Sc / 10)]++;
                }
                else
                {
                    nottest++;
                }
            }
            DataBase_Reader.Close();
            AllData_Connection.Close();//close AllData資料庫

            for (int U = 0; U < Score.Length; U++)
            {
                string name = "";
                if (U == 0)
                {
                    name = "10以下";
                }
                else if (U == (Score.Length - 1))
                {
                    name = "滿分";
                }
                else
                {
                    name = (U * 10) + "~" + ((U + 1) * 10 - 1);
                }
                Chart_Score.Series["Series1"].Points.AddXY(name, Score[U]);
            }
            Chart_Score.Series["Series1"].Points.AddXY("未考", nottest);

            #region 畫圖成績
            Chart_Score.Series["Series1"].ChartType                        = SeriesChartType.Bar; //橫條圖
            Chart_Score.ChartAreas["ChartArea1"].AxisX.Title               = "分數";
            Chart_Score.ChartAreas["ChartArea1"].AxisY.Title               = "人數";
            Chart_Score.ChartAreas["ChartArea1"].Area3DStyle.Enable3D      = true;                          //3D效果
            Chart_Score.ChartAreas["ChartArea1"].Area3DStyle.IsClustered   = true;                          //並排顯示
            Chart_Score.ChartAreas["ChartArea1"].Area3DStyle.Rotation      = 40;                            //垂直角度
            Chart_Score.ChartAreas["ChartArea1"].Area3DStyle.Inclination   = 50;                            //水平角度
            Chart_Score.ChartAreas["ChartArea1"].Area3DStyle.PointDepth    = 30;                            //數據條深度
            Chart_Score.ChartAreas["ChartArea1"].Area3DStyle.WallWidth     = 0;                             //外牆寬度
            Chart_Score.Series["Series1"].IsValueShownAsLabel              = true;
            Chart_Score.ChartAreas["ChartArea1"].BackColor                 = Color.FromArgb(240, 240, 240); //背景色
            Chart_Score.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineColor = Color.FromArgb(150, 150, 150);
            //X 軸線顏色
            Chart_Score.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineColor = Color.FromArgb(150, 150, 150);
            //Y 軸線顏色
            Chart_Score.Series["Series1"].MarkerSize = 16;
            Title title1 = new Title();
            title1.Text = "成績分布圖";
            title1.Font = new System.Drawing.Font("Trebuchet MS", 18F, FontStyle.Bold);
            Chart_Score.Titles.Add(title1);
            for (int i = 0; i < Chart_Score.Series["Series1"].Points.Count; i++)
            {
                Chart_Score.Series["Series1"].Points[i].Label = "#VALX(#VALY人," + (Chart_Score.Series["Series1"].Points[i].YValues[0] * 100 / totaltest).ToString("0.00") + "%)";
            }
            #endregion
            // this.GridView_Test.Columns[3].Visible = false;
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {    //初始化
            if (!IsPostBack)
            {
                string     TestID      = "";
                string     studentID   = "";
                int        QuestionSet = 0;
                HttpCookie mycookie    = Request.Cookies["CCMATHTEST"];
                if (mycookie != null)
                {
                    Label_ID.Text      = mycookie.Values["SID"];
                    studentID          = mycookie.Values["SID"];
                    Label_class.Text   = HttpUtility.UrlDecode(mycookie.Values["Name"]);
                    Label_textId.Text  = mycookie.Values["textID"];
                    TestID             = HttpUtility.UrlDecode(mycookie.Values["textID"]);
                    Label_context.Text = HttpUtility.UrlDecode(mycookie.Values["Context"]);

                    //Label_Qnum.Text = mycookie.Values["totalNumber"];
                    // QuestionSet = Convert.ToInt16(Label_Qnum.Text.Trim());
                }
                else
                {
                    Server.Transfer("~/WebPage/TestQuestion.aspx");
                }
                //------------------------------------
                #region 題目設定
                if (TestID != string.Empty)
                {
                    SqlConnection AllData_Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DataBaseConnection"].ConnectionString); //宣告一個資料庫連結
                    SqlCommand    cmd;
                    SqlDataReader DataBase_Reader;
                    AllData_Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DataBaseConnection"].ConnectionString); //宣告一個資料庫連結
                    AllData_Connection.Open();                                                                                             //開啟AllData資料庫



                    #region 刪除
                    /*刪除*/
                    DataBase_Language = string.Format("DELETE FROM FloatData WHERE StudentID = '{0}' AND TestID='{1}'", studentID, TestID);
                    cmd = new SqlCommand(DataBase_Language, AllData_Connection);//使用SQL

                    cmd.Connection = AllData_Connection;
                    cmd.ExecuteNonQuery();
                    #endregion
                    /*---*/
                    #region 找題目
                    /*找題目*/
                    Response.Write("ID:" + TestID);
                    // TestID = TestID.Trim();
                    DataBase_Language = "Select * from SelectedData where TextID = '" + TestID.Trim() + "'"; //資料庫語法
                    cmd             = new SqlCommand(DataBase_Language, AllData_Connection);                 //使用SQL
                    DataBase_Reader = cmd.ExecuteReader();
                    List <string> TestData = new List <string>();
                    List <string> RandData = new List <string>();
                    //初始化
                    TestData.Clear();
                    RandData.Clear();
                    while (DataBase_Reader.Read())
                    {
                        int    Way      = (int)DataBase_Reader["Way"];
                        string doNumber = (string)DataBase_Reader["doNumber"];
                        switch (Way)
                        {
                        case 1:    //必出題目
                            TestData.Add(doNumber);
                            break;

                        case 2:    //隨機選擇
                            RandData.Add(doNumber);
                            break;
                        }
                    }
                    DataBase_Reader.Close();
                    #endregion

                    int    index      = 0;
                    string temp       = "";
                    int    RandCount  = 0;
                    int    TotalCount = 0;


                    try
                    {
                        //隨機打亂
                        for (int i = 0; i < RandData.Count; i++)
                        {
                            index = rand.Next(0, RandData.Count - 1);
                            if (index != i)
                            {
                                temp            = RandData[i];
                                RandData[i]     = RandData[index];
                                RandData[index] = temp;
                            }
                        }

                        DataBase_Language = "Select * from TestTimeData where TestID= '" + TestID.Trim() + "'"; //資料庫語法
                        cmd             = new SqlCommand(DataBase_Language, AllData_Connection);                //使用SQL
                        DataBase_Reader = cmd.ExecuteReader();

                        while (DataBase_Reader.Read())
                        {
                            RandCount   = (int)DataBase_Reader["RandCount"];
                            TotalCount  = (int)DataBase_Reader["TotalCount"];
                            QuestionSet = TotalCount;
                        }
                        DataBase_Reader.Close();
                        //加入隨機選題目
                        for (int tempRandCount = 0; tempRandCount < RandCount; tempRandCount++)
                        {
                            if (TestData.Count < QuestionSet)
                            {
                                TestData.Add(RandData[tempRandCount].Trim());
                            }
                        }
                        //一一把題目匯入
                        string[] option_set     = { "C", "B", "D", "A" }; // 選項
                        string   OptionSet      = "";                     //打亂後存入選項
                        int      diff           = 0;                      //困難度
                        string   TestDataNumber = "";
                        int      SKill          = 0;
                        //每一題設定
                        for (int Ques = 1; Ques <= TestData.Count; Ques++)
                        {
                            //選項打亂
                            for (int t = 0; t < option_set.Length; t++)
                            {
                                int    A      = t;
                                int    B      = rand.Next(option_set.Length);
                                string temp_S = option_set[A];
                                option_set[A] = option_set[B];
                                option_set[B] = temp_S;
                            }
                            OptionSet         = option_set[0] + option_set[1] + option_set[2] + option_set[3];
                            TestDataNumber    = TestData[Ques - 1];                                               //實際作答題號
                            DataBase_Language = "Select * from ExerciseData where ID = '" + TestDataNumber + "'"; //資料庫語法
                            cmd             = new SqlCommand(DataBase_Language, AllData_Connection);              //使用SQL
                            DataBase_Reader = cmd.ExecuteReader();
                            string Chapter = "";
                            while (DataBase_Reader.Read())
                            {
                                SKill   = (int)DataBase_Reader["SkillsUnit"];
                                Chapter = (string)DataBase_Reader["Chapter"];
                                diff    = (int)DataBase_Reader["Difficulty"];
                            }

                            DataBase_Reader.Close();                                                                                                                                                                                                                                                                                //停用上一個CMD用法
                                                                                                                                                                                                                                                                                                                                    //
                                                                                                                                                                                                                                                                                                                                    //載入到浮動資料
                            char   Reply  = 'X';
                            string AddNew = string.Format("INSERT INTO FloatData(StudentID, QuestionID,SaveOption,NumberQ,TestType,Chapter,TestID,SkillsUnit,Difficulty,Reply) VALUES('{0}','{1}','{2}',{3},{4},'{5}','{6}','{7}','{8}','{9}')", studentID, TestDataNumber, OptionSet, Ques, 1, Chapter, TestID, SKill, diff, 'X'); //要改
                            cmd            = new SqlCommand(AddNew, AllData_Connection);                                                                                                                                                                                                                                            //使用SQL
                            cmd.Connection = AllData_Connection;
                            cmd.ExecuteNonQuery();
                            DataBase_Reader.Close();
                        }


                        //cookie 更新.
                        HttpCookie CCcookie = new HttpCookie("CCMATHTESTTN");

                        CCcookie.Values.Add("TN", TestData.Count.ToString());
                        CCcookie.Expires = DateTime.Now.AddDays(5);
                        // Response.Cookies["CCMATHTESTTN"].Domain = "";
                        Response.Cookies.Add(CCcookie);
                        Response.AppendCookie(CCcookie);
                        // Response.Redirect("~/WebPage/Exam_Page.aspx");
                        // Response.Cookies["CCMATHTEST"].Values["totalNumber"] = TestData.Count.ToString();
                        // mycookie.Values[]= TestData.Count.ToString();
                        Label_Qnum.Text = CCcookie.Values["TN"];
                    }
                    catch
                    {
                    }
                    AllData_Connection.Close();//開啟AllData資料庫
                }
                else
                {
                    Server.Transfer("~/WebPage/AdaptiveOption.aspx");
                }

                #endregion
            }
        }