protected void Page_Load(object sender, EventArgs e)
    {
        if (Convert.ToString(Session["TenDangNhap"]) == "")
        {
            Response.Redirect("~/dangnhap.aspx");
        }
        ctdthiDAL = new clsCauTrucDeThi_DAL();
        ctdthiDTO = new clsCauTrucDeThi_DTO();

        loaichoiDAL = new clsLoaiCauHoi_DAL();
        loaichoiDTO = new clsLoaiCauHoi_DTO();


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


        cmn = new clsCommon();
        if (!IsPostBack || !IsCallback)
        {
        }
        if (!Page.IsPostBack)
        {
        }
        loadMasterData();
        if (cboLoaiBang.Value != null)
        {
            gvCauTrucDeThi.DataSource = loadDataToUI();
            gvCauTrucDeThi.DataBind();
        }
    }
    public int Delete(clsCauTrucDeThi_DTO ctdtDTO)
    {
        try
        {
            ListDictionary _list = new ListDictionary();
            _list.Add("STT", ctdtDTO.STT);

            int iReturn = obj.ExcSql("Delete_Cau_Truc_De_Thi", _list, CommandType.StoredProcedure);
            return(iReturn);
        }
        catch (Exception)
        {
            //return ex.Message;
            return(-1111);
        }
    }
 protected void gvCauTrucDeThi_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
 {
     if (e.Parameters == "Update")
     {
         gvCauTrucDeThi.DataSource = loadDataToUI();
         gvCauTrucDeThi.Selection.UnselectAll();
     }
     else
     {
         ctdthiDTO            = new clsCauTrucDeThi_DTO();
         ctdthiDTO.MaLoaiBang = e.Parameters;
         DataTable dt = ctdthiDAL.getCauTrucDeThi(ctdthiDTO);
         gvCauTrucDeThi.DataSource = dt;
         gvCauTrucDeThi.DataBind();
     }
 }
 protected void gvCauTrucDeThi_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
 {
     if (e.Parameters == "Update")
     {
         gvCauTrucDeThi.DataSource = loadDataToUI();
         gvCauTrucDeThi.Selection.UnselectAll();
     }
     else
     {
         ctdthiDTO = new clsCauTrucDeThi_DTO();
         ctdthiDTO.MaLoaiBang = e.Parameters;
         DataTable dt = ctdthiDAL.getCauTrucDeThi(ctdthiDTO);
         gvCauTrucDeThi.DataSource = dt;
         gvCauTrucDeThi.DataBind();
     }
 }
    public int Delete(clsCauTrucDeThi_DTO ctdtDTO)
    {
        try
        {
            ListDictionary _list = new ListDictionary();
            _list.Add("STT", ctdtDTO.STT);

            int iReturn = obj.ExcSql("Delete_Cau_Truc_De_Thi", _list, CommandType.StoredProcedure);
            return iReturn;
        }
        catch (Exception)
        {
            //return ex.Message;
            return -1111;
        }
    }
 public DataTable getCauTrucDeThi(clsCauTrucDeThi_DTO ctdtDTO)
 {
     ListDictionary _list = new ListDictionary();
     _list.Add("STT", ctdtDTO.STT);
     _list.Add("MaLoaiBang", ctdtDTO.MaLoaiBang);
     _list.Add("MaloaiCauHoi", ctdtDTO.MaloaiCauHoi);
     _list.Add("SoCau", ctdtDTO.SoCau);
     DataTable dt = new DataTable();
     try
     {
         dt = obj.GetDataTable("Select_Cau_Truc_De_Thi", CommandType.StoredProcedure);
     }
     catch
     {
         dt = null;
     }
     return dt;
 }
    public int InsertUpdate(clsCauTrucDeThi_DTO ctdtDTO)
    {
        try
        {
            ListDictionary _list = new ListDictionary();
            _list.Add("old_id", ctdtDTO.OldID);
            _list.Add("STT", ctdtDTO.STT);
            _list.Add("MaLoaiBang", ctdtDTO.MaLoaiBang);
            _list.Add("MaloaiCauHoi", ctdtDTO.MaloaiCauHoi);
            _list.Add("SoCau", ctdtDTO.SoCau);

            int iReturn = obj.ExcSql("Insert_Update_Cau_Truc_De_Thi", _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 getCauTrucDeThi(clsCauTrucDeThi_DTO ctdtDTO)
    {
        ListDictionary _list = new ListDictionary();

        _list.Add("STT", ctdtDTO.STT);
        _list.Add("MaLoaiBang", ctdtDTO.MaLoaiBang);
        _list.Add("MaloaiCauHoi", ctdtDTO.MaloaiCauHoi);
        _list.Add("SoCau", ctdtDTO.SoCau);
        DataTable dt = new DataTable();

        try
        {
            dt = obj.GetDataTable("Select_Cau_Truc_De_Thi", CommandType.StoredProcedure);
        }
        catch
        {
            dt = null;
        }
        return(dt);
    }
    public int InsertUpdate(clsCauTrucDeThi_DTO ctdtDTO)
    {
        try
        {
            ListDictionary _list = new ListDictionary();
            _list.Add("old_id", ctdtDTO.OldID);
            _list.Add("STT", ctdtDTO.STT);
            _list.Add("MaLoaiBang", ctdtDTO.MaLoaiBang);
            _list.Add("MaloaiCauHoi", ctdtDTO.MaloaiCauHoi);
            _list.Add("SoCau", ctdtDTO.SoCau);

            int iReturn = obj.ExcSql("Insert_Update_Cau_Truc_De_Thi", _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
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Convert.ToString(Session["TenDangNhap"]) == "")
            Response.Redirect("~/dangnhap.aspx");
        ctdthiDAL = new clsCauTrucDeThi_DAL();
        ctdthiDTO = new clsCauTrucDeThi_DTO();

        loaichoiDAL = new clsLoaiCauHoi_DAL();
        loaichoiDTO = new clsLoaiCauHoi_DTO();

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

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

        }
        if (!Page.IsPostBack)
        {

        }
        loadMasterData();
        if (cboLoaiBang.Value != null)
        {
            gvCauTrucDeThi.DataSource = loadDataToUI();
            gvCauTrucDeThi.DataBind();
        }
    }