protected void Page_Load(object sender, EventArgs e)
    {
        if (Convert.ToString(Session["TenDangNhap"]) == "")
        {
            Response.Redirect("~/dangnhap.aspx");
        }
        choilbangDAL = new clsCauHoi_LoaiBang_DAL();
        choilbangDTO = new clsCauHoi_LoaiBang_DTO();

        lbangDAL = new clsLoaiBanglai_DAL();
        lbangDTO = new clsLoaiBanglai_DTO();

        choiDAL = new clsCauHoi_DAL();
        choiDTO = new clsCauHoi_DTO();


        cmn = new clsCommon();
        if (!IsPostBack || !IsCallback)
        {
        }
        if (!Page.IsPostBack)
        {
        }
        loadMasterData();

        if (cboLoaiBang.Value != null)
        {
            gvCauHoiLoaiBang.DataSource = loadDataToUI();
            gvCauHoiLoaiBang.DataBind();
        }
    }
    protected void Page_Load(object sender, EventArgs e)

    {
        if (Convert.ToString(Session["TenDangNhap"]) == "")
        {
            Response.Redirect("~/dangnhap.aspx");
        }
        choiDAL             = new clsCauHoi_DAL();
        choiDTO             = new clsCauHoi_DTO();
        cmn                 = new clsCommon();
        gvCauHoi.DataSource = loadDataToUI();
        gvCauHoi.DataBind();
    }
 public int Delete(clsCauHoi_DTO cauhoiDTO)
 {
     try
     {
         ListDictionary _list = new ListDictionary();
         _list.Add("MaCauHoi", cauhoiDTO.MaCauHoi);
         int iReturn = obj.ExcSql("Delete_Cau_Hoi", _list, CommandType.StoredProcedure);
         return iReturn;
     }
     catch (Exception)
     {
         //return ex.Message;
         return -1111;
     }
 }
 public int Delete(clsCauHoi_DTO cauhoiDTO)
 {
     try
     {
         ListDictionary _list = new ListDictionary();
         _list.Add("MaCauHoi", cauhoiDTO.MaCauHoi);
         int iReturn = obj.ExcSql("Delete_Cau_Hoi", _list, CommandType.StoredProcedure);
         return(iReturn);
     }
     catch (Exception)
     {
         //return ex.Message;
         return(-1111);
     }
 }
    public DataTable getCauHoi(clsCauHoi_DTO cauhoiDTO)
    {
        ListDictionary _list = new ListDictionary();
        _list.Add("MaCauHoi", cauhoiDTO.MaCauHoi);
        _list.Add("NoiDung", cauhoiDTO.NoiDung);
        _list.Add("HinhAnh", cauhoiDTO.HinhAnh);
        _list.Add("MaloaiCauHoi", cauhoiDTO.MaloaiCauHoi);

        DataTable dt = new DataTable();
        try
        {
            dt = obj.GetDataTable("Select_Cau_Hoi", CommandType.StoredProcedure);
        }
        catch
        {
            dt = null;
        }
        return dt;
    }
    public int InsertUpdate(clsCauHoi_DTO cauhoiDTO)
    {
        try
        {
            ListDictionary _list = new ListDictionary();

            _list.Add("old_id", cauhoiDTO.OldID);
            _list.Add("MaCauHoi", cauhoiDTO.MaCauHoi);
            _list.Add("NoiDung", cauhoiDTO.NoiDung);
            _list.Add("HinhAnh", cauhoiDTO.HinhAnh);
            _list.Add("MaloaiCauHoi", cauhoiDTO.MaloaiCauHoi);

            int iReturn = obj.ExcSql("Insert_Update_Cau_Hoi", _list, CommandType.StoredProcedure);
            return iReturn;
        }
        catch (Exception)
        {
            //return ex.Message;
            return -1111; // Đặt số này làm ngoại lệ ko lường trước được. ở StoredProcedure không được return có số này tránh trường hợp trùng
        }
    }
    public int InsertUpdate(clsCauHoi_DTO cauhoiDTO)
    {
        try
        {
            ListDictionary _list = new ListDictionary();

            _list.Add("old_id", cauhoiDTO.OldID);
            _list.Add("MaCauHoi", cauhoiDTO.MaCauHoi);
            _list.Add("NoiDung", cauhoiDTO.NoiDung);
            _list.Add("HinhAnh", cauhoiDTO.HinhAnh);
            _list.Add("MaloaiCauHoi", cauhoiDTO.MaloaiCauHoi);

            int iReturn = obj.ExcSql("Insert_Update_Cau_Hoi", _list, CommandType.StoredProcedure);
            return(iReturn);
        }
        catch (Exception)
        {
            //return ex.Message;
            return(-1111); // Đặt số này làm ngoại lệ ko lường trước được. ở StoredProcedure không được return có số này tránh trường hợp trùng
        }
    }
    public DataTable getCauHoi(clsCauHoi_DTO cauhoiDTO)
    {
        ListDictionary _list = new ListDictionary();

        _list.Add("MaCauHoi", cauhoiDTO.MaCauHoi);
        _list.Add("NoiDung", cauhoiDTO.NoiDung);
        _list.Add("HinhAnh", cauhoiDTO.HinhAnh);
        _list.Add("MaloaiCauHoi", cauhoiDTO.MaloaiCauHoi);

        DataTable dt = new DataTable();

        try
        {
            dt = obj.GetDataTable("Select_Cau_Hoi", CommandType.StoredProcedure);
        }
        catch
        {
            dt = null;
        }
        return(dt);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Convert.ToString(Session["TenDangNhap"]) == "")
        {
            Response.Redirect("~/dangnhap.aspx");
        }
        lchoiDAL = new clsLoaiCauHoi_DAL();
        lchoiDTO = new clsLoaiCauHoi_DTO();

        choiDAL = new clsCauHoi_DAL();
        choiDTO = new clsCauHoi_DTO();

        clchonDAL = new clsCauLuaChon_DAL();
        clchonDTO = new clsCauLuaChon_DTO();


        choi_clchonDAL = new clsCauHoi_CauLuaChon_DAL();
        choi_clchonDTO = new clsCauHoi_CauLuaChon_DTO();

        ctchoiDAL = new clsChiTietCauHoi_DAL();
        cmn       = new clsCommon();
        loadMasterData();
    }
    protected void btnLuu_Click(object sender, EventArgs e)
    {
        choiDTO = new clsCauHoi_DTO();
        clchonDTO = new clsCauLuaChon_DTO();
        choi_clchonDTO = new clsCauHoi_CauLuaChon_DTO();

        choiDTO.NoiDung = txtNoiDung.Text.ToString();
        choiDTO.HinhAnh = uplFile.FileName.ToString();
        choiDTO.MaloaiCauHoi = cboLoaiCauHoi.SelectedIndex.ToString();

        int iReturn = choiDAL.InsertUpdate(choiDTO);
        if (iReturn > 0)
        {
            uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            txtNoiDung.Focus();
        }

        clchonDTO.NoiDungCLC = txtCauLuaChon.Text.ToString();
        int iReturn1 = clchonDAL.InsertUpdate(clchonDTO);
        if (iReturn1 > 0)
        {
            // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            // txtNoiDung.Focus();
        }
        clchonDTO.NoiDungCLC = txtCauLuaChon1.Text.ToString();
        int iReturn2 = clchonDAL.InsertUpdate(clchonDTO);
        if (iReturn2 > 0)
        {
            // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            // txtNoiDung.Focus();
        }
        clchonDTO.NoiDungCLC = txtCauLuaChon2.Text.ToString();
        int iReturn3 = clchonDAL.InsertUpdate(clchonDTO);
        if (iReturn3 > 0)
        {
            // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            // txtNoiDung.Focus();
        }
        clchonDTO.NoiDungCLC = txtCauLuaChon3.Text.ToString();

        int iReturn4 = clchonDAL.InsertUpdate(clchonDTO);
        if (iReturn4 > 0)
        {
           // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
           // txtNoiDung.Focus();
        }

        choi_clchonDTO.MaCauHoi = iReturn.ToString();
        choi_clchonDTO.MaCauLuaChon = iReturn1.ToString();
        choi_clchonDTO.DapAn = rbtDapAn.Checked.ToString();

         int iReturn5 = choi_clchonDAL.InsertUpdate(choi_clchonDTO);
         if (iReturn5 >= 0)
         {
             // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
             Response.Write("Lưu dữ liệu thành công");
         }
         else
         {
             Response.Write("lưu dữ liệu thất bại");
             // txtNoiDung.Focus();
         }

        choi_clchonDTO.MaCauHoi = iReturn.ToString();
        choi_clchonDTO.MaCauLuaChon = iReturn2.ToString();
        choi_clchonDTO.DapAn = rbtDapAn1.Checked.ToString();

        int iReturn6 = choi_clchonDAL.InsertUpdate(choi_clchonDTO);
        if (iReturn6 >= 0)
        {
            // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            // txtNoiDung.Focus();
        }

        choi_clchonDTO.MaCauHoi = iReturn.ToString();
        choi_clchonDTO.MaCauLuaChon = iReturn3.ToString();
        choi_clchonDTO.DapAn = rbtDapAn2.Checked.ToString();

        int iReturn7 = choi_clchonDAL.InsertUpdate(choi_clchonDTO);
        if (iReturn7 >= 0)
        {
            // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            // txtNoiDung.Focus();
        }

        choi_clchonDTO.MaCauHoi = iReturn.ToString();
        choi_clchonDTO.MaCauLuaChon = iReturn4.ToString();
        choi_clchonDTO.DapAn = rbtDapAn3.Checked.ToString();

        int iReturn8 = choi_clchonDAL.InsertUpdate(choi_clchonDTO);
        if (iReturn8 >= 0)
        {
            // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            // txtNoiDung.Focus();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Convert.ToString(Session["TenDangNhap"]) == "")
            Response.Redirect("~/dangnhap.aspx");
        lchoiDAL = new clsLoaiCauHoi_DAL();
        lchoiDTO = new clsLoaiCauHoi_DTO();

        choiDAL = new clsCauHoi_DAL();
        choiDTO = new clsCauHoi_DTO();

        clchonDAL = new clsCauLuaChon_DAL();
        clchonDTO = new clsCauLuaChon_DTO();

        choi_clchonDAL = new clsCauHoi_CauLuaChon_DAL();
        choi_clchonDTO = new clsCauHoi_CauLuaChon_DTO();

        ctchoiDAL = new clsChiTietCauHoi_DAL();
        cmn = new clsCommon();
        loadMasterData();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Convert.ToString(Session["TenDangNhap"]) == "")
            Response.Redirect("~/dangnhap.aspx");
        choilbangDAL = new clsCauHoi_LoaiBang_DAL();
        choilbangDTO = new clsCauHoi_LoaiBang_DTO();

        lbangDAL = new clsLoaiBanglai_DAL();
        lbangDTO = new clsLoaiBanglai_DTO();

        choiDAL = new clsCauHoi_DAL();
        choiDTO = new clsCauHoi_DTO();

        cmn = new clsCommon();
        if (!IsPostBack || !IsCallback)
        {

        }
        if (!Page.IsPostBack)
        {

        }
        loadMasterData();

        if (cboLoaiBang.Value != null)
        {
            gvCauHoiLoaiBang.DataSource = loadDataToUI();
            gvCauHoiLoaiBang.DataBind();
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Convert.ToString(Session["TenDangNhap"]) == "")
         Response.Redirect("~/dangnhap.aspx");
     choiDAL = new clsCauHoi_DAL();
     choiDTO = new clsCauHoi_DTO();
     cmn = new clsCommon();
     gvCauHoi.DataSource = loadDataToUI();
     gvCauHoi.DataBind();
 }
    protected void btnLuu_Click(object sender, EventArgs e)
    {
        choiDTO        = new clsCauHoi_DTO();
        clchonDTO      = new clsCauLuaChon_DTO();
        choi_clchonDTO = new clsCauHoi_CauLuaChon_DTO();

        choiDTO.NoiDung      = txtNoiDung.Text.ToString();
        choiDTO.HinhAnh      = uplFile.FileName.ToString();
        choiDTO.MaloaiCauHoi = cboLoaiCauHoi.SelectedIndex.ToString();

        int iReturn = choiDAL.InsertUpdate(choiDTO);

        if (iReturn > 0)
        {
            uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            txtNoiDung.Focus();
        }

        clchonDTO.NoiDungCLC = txtCauLuaChon.Text.ToString();
        int iReturn1 = clchonDAL.InsertUpdate(clchonDTO);

        if (iReturn1 > 0)
        {
            // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            // txtNoiDung.Focus();
        }
        clchonDTO.NoiDungCLC = txtCauLuaChon1.Text.ToString();
        int iReturn2 = clchonDAL.InsertUpdate(clchonDTO);

        if (iReturn2 > 0)
        {
            // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            // txtNoiDung.Focus();
        }
        clchonDTO.NoiDungCLC = txtCauLuaChon2.Text.ToString();
        int iReturn3 = clchonDAL.InsertUpdate(clchonDTO);

        if (iReturn3 > 0)
        {
            // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            // txtNoiDung.Focus();
        }
        clchonDTO.NoiDungCLC = txtCauLuaChon3.Text.ToString();

        int iReturn4 = clchonDAL.InsertUpdate(clchonDTO);

        if (iReturn4 > 0)
        {
            // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            // txtNoiDung.Focus();
        }

        choi_clchonDTO.MaCauHoi     = iReturn.ToString();
        choi_clchonDTO.MaCauLuaChon = iReturn1.ToString();
        choi_clchonDTO.DapAn        = rbtDapAn.Checked.ToString();

        int iReturn5 = choi_clchonDAL.InsertUpdate(choi_clchonDTO);

        if (iReturn5 >= 0)
        {
            // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            // txtNoiDung.Focus();
        }

        choi_clchonDTO.MaCauHoi     = iReturn.ToString();
        choi_clchonDTO.MaCauLuaChon = iReturn2.ToString();
        choi_clchonDTO.DapAn        = rbtDapAn1.Checked.ToString();

        int iReturn6 = choi_clchonDAL.InsertUpdate(choi_clchonDTO);

        if (iReturn6 >= 0)
        {
            // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            // txtNoiDung.Focus();
        }

        choi_clchonDTO.MaCauHoi     = iReturn.ToString();
        choi_clchonDTO.MaCauLuaChon = iReturn3.ToString();
        choi_clchonDTO.DapAn        = rbtDapAn2.Checked.ToString();

        int iReturn7 = choi_clchonDAL.InsertUpdate(choi_clchonDTO);

        if (iReturn7 >= 0)
        {
            // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            // txtNoiDung.Focus();
        }

        choi_clchonDTO.MaCauHoi     = iReturn.ToString();
        choi_clchonDTO.MaCauLuaChon = iReturn4.ToString();
        choi_clchonDTO.DapAn        = rbtDapAn3.Checked.ToString();

        int iReturn8 = choi_clchonDAL.InsertUpdate(choi_clchonDTO);

        if (iReturn8 >= 0)
        {
            // uplFile.SaveAs(Server.MapPath(@"~\hinh\") + uplFile.FileName);
            Response.Write("Lưu dữ liệu thành công");
        }
        else
        {
            Response.Write("lưu dữ liệu thất bại");
            // txtNoiDung.Focus();
        }
    }