protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string    id        = Request.QueryString["dethi"].ToString();
            string    sql_dethi = "select Tende from DETHI where Made='" + id + "'";
            DataTable tb_dethi  = ketnoi.getData(sql_dethi);
            txt_dethi.Text  = tb_dethi.Rows[0][0].ToString().ToUpper();
            txt_dethi2.Text = tb_dethi.Rows[0][0].ToString().ToUpper();



            string sql_Phutnghe = "select * from DONGHO where IDDongho='03'";
            rpt_dongho.DataSource = ketnoi.getData(sql_Phutnghe);
            rpt_dongho.DataBind();

            string sql_hinhanh = "select A.IDCauhoi,C.IDNoidungchitiet, A.Phancauhoi, RTRIM(B.Tenfile)as Tenfile,A.Noidung from CAUHOI A, FILES B, CHITIETNOIDUNG C where A.IDNoidung='Photographs' and C.IDNoidungchitiet=A.IDNoidung and A.IDFile=B.IDFile and A.Made='" + id + "'order by A.IDCauhoi ASC";
            Rpt_nghe_hinhanh.DataSource = ketnoi.getData(sql_hinhanh);
            Rpt_nghe_hinhanh.DataBind();

            for (int i = 0; i < Rpt_nghe_hinhanh.Items.Count; i++)
            {
                Label  a   = (Label)Rpt_nghe_hinhanh.Items[i].FindControl("A");
                Label  b   = (Label)Rpt_nghe_hinhanh.Items[i].FindControl("B");
                Label  c   = (Label)Rpt_nghe_hinhanh.Items[i].FindControl("C");
                Label  d   = (Label)Rpt_nghe_hinhanh.Items[i].FindControl("D");
                string sql = "select * from DAPAN where IDCauhoi ='1_Pho_" + (i + 1) + "'";
                try
                {
                    DataTable tb = ketnoi.getData(sql);
                    a.Text = tb.Rows[0]["NDDA"].ToString();
                    b.Text = tb.Rows[1]["NDDA"].ToString();
                    c.Text = tb.Rows[2]["NDDA"].ToString();
                    d.Text = tb.Rows[3]["NDDA"].ToString();
                }
                catch { }
            }

            try
            {
                string    sql_filenghe = "select * from FILES where IDFile='Nghe_Photo_" + id.Substring(0, 2) + "'";
                DataTable tb_filenghe  = ketnoi.getData(sql_filenghe);
                filenghe = tb_filenghe.Rows[0]["Tenfile"].ToString();
            }
            catch { }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string id = Request.QueryString["dethi"];
            try
            {
                sodiemdoc    = Double.Parse(Session["diemdoc"].ToString());
                sodiemnghe   = Double.Parse(Session["diemnghe"].ToString());
                tongdiem     = Double.Parse(Session["diemdoc"] + Session["diemnghe"].ToString());
                sodiem       = ((Double.Parse(Session["diemdoc"].ToString()) + Double.Parse(Session["diemnghe"].ToString())) * 0.1) + 1;
                tongdiemdoc  = (Double.Parse(Session["diemdoc"].ToString()) * 0.2) + 1;
                tongdiemnghe = (Double.Parse(Session["diemnghe"].ToString()) * 0.2) + 1;
            }
            catch { }
            try
            {
                string sql_filenghe = "select * from FILES where IDFile='Nghe_" + id + "'";
                Repeater1.DataSource = ketnoi.getData(sql_filenghe);
                Repeater1.DataBind();
            }
            catch { }

            diemthi.Visible = false;


            string sql_Phutnghe = "select * from DONGHO where IDDongho='02'";
            rpt_donghonghe.DataSource = ketnoi.getData(sql_Phutnghe);
            rpt_donghonghe.DataBind();

            string sql_Phutdoc = "select * from DONGHO where IDDongho='01'";
            rpt_donghodoc.DataSource = ketnoi.getData(sql_Phutdoc);
            rpt_donghodoc.DataBind();

            phandoc.Visible    = false;
            phannghe.Visible   = false;
            btn_Nopbai.Visible = false;
            string    sql_mathoigian = "select IDThoigian from THOIGIAN Order by IDThoigian DESC";
            DataTable tb_mathoigian  = ketnoi.getData(sql_mathoigian);
            if (tb_mathoigian.Rows.Count < 1)
            {
                stt = 1;
            }
            else
            {
                stt = Int32.Parse(tb_mathoigian.Rows[0][0].ToString()) + 1;
            }


            string thoigian = "insert into Thoigian(IDThoigian) values('" + stt + "')";
            ketnoi.executeQuery(thoigian);


            //Phần nghe
            string sql_hinhanh = "select A.IDCauhoi,C.IDNoidungchitiet, A.Phancauhoi, RTRIM(B.Tenfile)as Tenfile,A.Noidung from CAUHOI A, FILES B, CHITIETNOIDUNG C where A.IDNoidung='Photographstest' and C.IDNoidungchitiet=A.IDNoidung and A.IDFile=B.IDFile and Made='" + id + "' order by A.IDCauhoi ASC";
            Rpt_nghe_hinhanh.DataSource = ketnoi.getData(sql_hinhanh);
            Rpt_nghe_hinhanh.DataBind();

            for (int i = 0; i < Rpt_nghe_hinhanh.Items.Count; i++)
            {
                Label     a   = (Label)Rpt_nghe_hinhanh.Items[i].FindControl("A");
                Label     b   = (Label)Rpt_nghe_hinhanh.Items[i].FindControl("B");
                Label     c   = (Label)Rpt_nghe_hinhanh.Items[i].FindControl("C");
                Label     d   = (Label)Rpt_nghe_hinhanh.Items[i].FindControl("D");
                string    sql = "select * from DAPAN where IDCauhoi ='1_" + (i + 1) + "'";
                DataTable tb  = ketnoi.getData(sql);
                a.Text = tb.Rows[0]["NDDA"].ToString();
                b.Text = tb.Rows[1]["NDDA"].ToString();
                c.Text = tb.Rows[2]["NDDA"].ToString();
                d.Text = tb.Rows[3]["NDDA"].ToString();
            }

            string sql_cauhoi = "select C.IDNoidungchitiet, A.Phancauhoi, RTRIM(B.Tenfile)as Tenfile,A.Noidung from CAUHOI A, FILES B, CHITIETNOIDUNG C where A.IDNoidung='Questiontest' and C.IDNoidungchitiet=A.IDNoidung and A.IDFile=B.IDFile and Made='" + id + "' order by A.IDCauhoi ASC";
            rpt_nghe_cauhoi.DataSource = ketnoi.getData(sql_cauhoi);
            rpt_nghe_cauhoi.DataBind();
            for (int i = 0; i < rpt_nghe_cauhoi.Items.Count; i++)
            {
                Label     a   = (Label)rpt_nghe_cauhoi.Items[i].FindControl("A");
                Label     b   = (Label)rpt_nghe_cauhoi.Items[i].FindControl("B");
                Label     c   = (Label)rpt_nghe_cauhoi.Items[i].FindControl("C");
                string    sql = "select * from DAPAN where IDCauhoi ='1_" + (11 + i) + "'";
                DataTable tb  = ketnoi.getData(sql);
                a.Text = tb.Rows[0]["NDDA"].ToString();
                b.Text = tb.Rows[1]["NDDA"].ToString();
                c.Text = tb.Rows[2]["NDDA"].ToString();
            }


            string sql_hoithoai = "select C.IDNoidungchitiet, A.Phancauhoi, RTRIM(B.Tenfile)as Tenfile,A.Noidung from CAUHOI A, FILES B, CHITIETNOIDUNG C where A.IDNoidung='Conversationtest' and C.IDNoidungchitiet=A.IDNoidung and A.IDFile=B.IDFile and Made='" + id + "' order by A.IDCauhoi ASC";
            rpt_nghehoithoai.DataSource = ketnoi.getData(sql_hoithoai);
            rpt_nghehoithoai.DataBind();
            for (int i = 0; i < rpt_nghehoithoai.Items.Count; i++)
            {
                Label     a   = (Label)rpt_nghehoithoai.Items[i].FindControl("A");
                Label     b   = (Label)rpt_nghehoithoai.Items[i].FindControl("B");
                Label     c   = (Label)rpt_nghehoithoai.Items[i].FindControl("C");
                Label     d   = (Label)rpt_nghehoithoai.Items[i].FindControl("D");
                string    sql = "select * from DAPAN where IDCauhoi ='1_" + (41 + i) + "'";
                DataTable tb  = ketnoi.getData(sql);
                a.Text = tb.Rows[0]["NDDA"].ToString();
                b.Text = tb.Rows[1]["NDDA"].ToString();
                c.Text = tb.Rows[2]["NDDA"].ToString();
            }

            string sql_doanvan = "select C.IDNoidungchitiet, A.Phancauhoi, RTRIM(B.Tenfile)as Tenfile,A.Noidung from CAUHOI A, FILES B, CHITIETNOIDUNG C where A.IDNoidung='Talktest' and C.IDNoidungchitiet=A.IDNoidung and A.IDFile=B.IDFile and Made='" + id + "' order by A.IDCauhoi ASC";
            rpt_nghedoanvan.DataSource = ketnoi.getData(sql_doanvan);
            rpt_nghedoanvan.DataBind();
            for (int i = 0; i < rpt_nghedoanvan.Items.Count; i++)
            {
                Label     a   = (Label)rpt_nghedoanvan.Items[i].FindControl("A");
                Label     b   = (Label)rpt_nghedoanvan.Items[i].FindControl("B");
                Label     c   = (Label)rpt_nghedoanvan.Items[i].FindControl("C");
                Label     d   = (Label)rpt_nghedoanvan.Items[i].FindControl("D");
                string    sql = "select * from DAPAN where IDCauhoi ='1_" + (71 + i) + "'";
                DataTable tb  = ketnoi.getData(sql);
                a.Text = tb.Rows[0]["NDDA"].ToString();
                b.Text = tb.Rows[1]["NDDA"].ToString();
                c.Text = tb.Rows[2]["NDDA"].ToString();
            }
            //Phần đọc

            string sql_doc = "select * from CAUHOI where IDNoidung='Sentencestest' and Made='" + id + "'";
            rpt_phandoc.DataSource = ketnoi.getData(sql_doc);
            rpt_phandoc.DataBind();
            for (int i = 0; i < rpt_phandoc.Items.Count; i++)
            {
                Label     a   = (Label)rpt_phandoc.Items[i].FindControl("A");
                Label     b   = (Label)rpt_phandoc.Items[i].FindControl("B");
                Label     c   = (Label)rpt_phandoc.Items[i].FindControl("C");
                Label     d   = (Label)rpt_phandoc.Items[i].FindControl("D");
                string    sql = "select * from DAPAN where IDCauhoi ='1_" + (101 + i) + "'";
                DataTable tb  = ketnoi.getData(sql);
                a.Text = tb.Rows[0]["NDDA"].ToString();
                b.Text = tb.Rows[1]["NDDA"].ToString();
                c.Text = tb.Rows[2]["NDDA"].ToString();
                d.Text = tb.Rows[3]["NDDA"].ToString();
            }
            string sql_docdientu = "select * from CAUHOI where IDNoidung='TextCompletiontest' and Made='" + id + "'";
            rpt_docdientu.DataSource = ketnoi.getData(sql_docdientu);
            rpt_docdientu.DataBind();
            for (int i = 0; i < rpt_docdientu.Items.Count; i++)
            {
                Label a = (Label)rpt_docdientu.Items[i].FindControl("A");
                Label b = (Label)rpt_docdientu.Items[i].FindControl("B");
                Label c = (Label)rpt_docdientu.Items[i].FindControl("C");
                Label d = (Label)rpt_docdientu.Items[i].FindControl("D");
                try
                {
                    string    sql = "select * from DAPAN where IDCauhoi ='1_14" + (i + 1) + "'";
                    DataTable tb  = ketnoi.getData(sql);
                    a.Text = tb.Rows[0]["NDDA"].ToString();
                    b.Text = tb.Rows[1]["NDDA"].ToString();
                    c.Text = tb.Rows[2]["NDDA"].ToString();
                    d.Text = tb.Rows[3]["NDDA"].ToString();
                }
                catch { }
            }

            string sql_docdoanvan = "select * from CAUHOI where IDNoidung='SinglePassagetest' and Made='" + id + "'";
            rpt_docdoanvan.DataSource = ketnoi.getData(sql_docdoanvan);
            rpt_docdoanvan.DataBind();
            for (int i = 0; i < rpt_docdoanvan.Items.Count; i++)
            {
                Label a = (Label)rpt_docdoanvan.Items[i].FindControl("A");
                Label b = (Label)rpt_docdoanvan.Items[i].FindControl("B");
                Label c = (Label)rpt_docdoanvan.Items[i].FindControl("C");
                Label d = (Label)rpt_docdoanvan.Items[i].FindControl("D");
                try
                {
                    string    sql = "select * from DAPAN where IDCauhoi ='1_" + (153 + i) + "' and Made='" + id + "'";
                    DataTable tb  = ketnoi.getData(sql);
                    a.Text = tb.Rows[0]["NDDA"].ToString();
                    b.Text = tb.Rows[1]["NDDA"].ToString();
                    c.Text = tb.Rows[2]["NDDA"].ToString();
                    d.Text = tb.Rows[3]["NDDA"].ToString();
                }
                catch { }
            }
            string sql_docdoanvan1 = "select * from CAUHOI where IDNoidung='DoublePassagetest' and Made='" + id + "'";
            rpt_docdoanvan.DataSource = ketnoi.getData(sql_docdoanvan1);
            rpt_docdoanvan.DataBind();
            for (int i = 0; i < rpt_docdoanvan.Items.Count; i++)
            {
                Label a = (Label)rpt_docdoanvan.Items[i].FindControl("A");
                Label b = (Label)rpt_docdoanvan.Items[i].FindControl("B");
                Label c = (Label)rpt_docdoanvan.Items[i].FindControl("C");
                Label d = (Label)rpt_docdoanvan.Items[i].FindControl("D");
                try
                {
                    string    sql = "select * from DAPAN where IDCauhoi ='1_" + (153 + i) + "' and Made='" + id + "'";
                    DataTable tb  = ketnoi.getData(sql);
                    a.Text = tb.Rows[0]["NDDA"].ToString();
                    b.Text = tb.Rows[1]["NDDA"].ToString();
                    c.Text = tb.Rows[2]["NDDA"].ToString();
                    d.Text = tb.Rows[3]["NDDA"].ToString();
                }
                catch { }
            }
        }
    }