public void LoadCM()
        {
            string where = " Ma_Chuyenmuc_Cha = 0 AND HienThi_BDT = 1 and HienThi_BDT = 1 ";
            if (!String.IsNullOrEmpty(this.txtSearch_name.Text.Trim()))
            {
                where += " AND Ten_ChuyenMuc like N'%" + UltilFunc.SqlFormatText(this.txtSearch_name.Text.Trim()) + "%'";
            }
            if (ddlLang.SelectedIndex > 0)
            {
                where += " AND Ma_AnPham =" + UltilFunc.SqlFormatText(ddlLang.SelectedValue);
            }

            //where += " Order by T_ChuyenMuc.ThuTuHienThi ASC";
            ChuyenmucDAL _cateDAL = new ChuyenmucDAL();
            DataSet      _ds;

            _ds = _cateDAL.BindGridT_Cagegorys(0, 5000, where);
            int       TotalRecords = Convert.ToInt32(_ds.Tables[1].Rows[0].ItemArray[0].ToString());
            int       TotalRecord  = Convert.ToInt32(_ds.Tables[0].Rows.Count);
            DataTable _dv          = _cateDAL.BindGridCategory(_ds.Tables[0]);

            _ds.Clear();
            dgCategorysCopy.DataSource = _dv;
            dgCategorysCopy.DataBind();
        }
        public void Danhsach_ChuyenMuc()
        {
            string where = " Ma_Chuyenmuc_Cha=0";
            if (cbo_Anpham.SelectedIndex > 0)
            {
                where += " and Ma_AnPham=" + cbo_Anpham.SelectedValue.ToString();
            }
            if (!String.IsNullOrEmpty(this.txtSearch_ChuyenMuc.Text.Trim()))
            {
                where += " and " + string.Format(" Ten_ChuyenMuc like N'%{0}%'", UltilFunc.SqlFormatText(this.txtSearch_ChuyenMuc.Text.Trim()))
                         + " or Ma_ChuyenMuc in( select Ma_Chuyenmuc_Cha from T_ChuyenMuc where Ma_ChuyenMuc in (select Ma_ChuyenMuc from T_ChuyenMuc where " + string.Format(" Ten_ChuyenMuc like N'%{0}%'", UltilFunc.SqlFormatText(this.txtSearch_ChuyenMuc.Text.Trim())) + "))";
            }
            if (chk_Hoatdong.Checked)
            {
                where += " and Hoatdong=1";
            }
            if (!chk_Hoatdong.Checked)
            {
                where += " and Hoatdong=0";
            }
            if (CheckBoxBaoDT.Checked)
            {
                where += " and HienThi_BDT=1";
            }
            if (CheckBoxBaoIn.Checked)
            {
                where += " and HienThi_BaoIn=1";
            }

            pages.PageSize = Global.MembersPerPage;
            ChuyenmucDAL _chuyenmucDAL = new ChuyenmucDAL();
            DataSet      _ds;

            if (Session["where_chuyenmuc"] != null)
            {
                _ds = _chuyenmucDAL.BindGridT_Cagegorys(pages.PageIndex, pages.PageSize, Session["where_chuyenmuc"].ToString());
            }
            else
            {
                _ds = _chuyenmucDAL.BindGridT_Cagegorys(pages.PageIndex, pages.PageSize, where);
            }
            int TotalRecords = Convert.ToInt32(_ds.Tables[1].Rows[0].ItemArray[0].ToString());
            int TotalRecord  = Convert.ToInt32(_ds.Tables[0].Rows.Count);

            if (TotalRecord == 0)
            {
                if (Session["where_chuyenmuc"] != null)
                {
                    _ds = _chuyenmucDAL.BindGridT_Cagegorys(pages.PageIndex - 1, pages.PageSize, Session["where_chuyenmuc"].ToString());
                }
                else
                {
                    _ds = _chuyenmucDAL.BindGridT_Cagegorys(pages.PageIndex - 1, pages.PageSize, where);
                }
            }
            DataTable dt = _chuyenmucDAL.BindGridCategory(_ds.Tables[0]);

            grdListCate.DataSource = dt;
            grdListCate.DataBind();
            _ds.Clear();
            pages.TotalRecords     = curentPages.TotalRecords = TotalRecords;
            curentPages.TotalPages = pages.CalculateTotalPages();
            curentPages.PageIndex  = pages.PageIndex;
            Session["PageIndex"]   = pages.PageIndex;
        }