public int LoadBaiViet()
        {
            List<BAIVIET_getall_newResult> lt = new List<BAIVIET_getall_newResult>();
            BUSBaiViet BUSBaiViet = new BUSBaiViet();
            lt = BUSBaiViet.SelectBAIVIETsAll_new();

            LOAIBAIVIET ltLoaiBaiViet = new LOAIBAIVIET();
            BUSLoaiBaiViet BUSLoaiBaiViet = new BUSLoaiBaiViet();
            if (lt.Count > 0)
            {
                lt.Sort(SortByDate);
                this.GridViewBaiViet.DataSource = lt;
                GridViewBaiViet.DataBind();
                PanelDanhSach.Visible = true;
                PanelMessage.Visible = false;

                //                 for (int i = 0; i < lt.Count; i++)
                //                 {
                //                     GridViewBaiViet.Rows[i].Cells[4].Text = BUSLoaiBaiViet.TimKiem((int)lt[i].MaLoaiBaiViet).TenLoaiBaiViet;
                //                 }
                return lt.Count;
            }
            else
            {
                PanelDanhSach.Visible = false;
                PanelMessage.Visible = true;
                return 0;
            }
        }
        //Load
        public int LoadLoaiBaiViet()
        {
            List<LOAIBAIVIET_getall_chitietResult> lt = new List<LOAIBAIVIET_getall_chitietResult>();

            BUSLoaiBaiViet BUSLoaiBaiViet = new BUSLoaiBaiViet();

            lt = BUSLoaiBaiViet.SelectLOAIBAIVIETsAll_chitiet();
            if (lt.Count > 0)
            {
                this.GridViewLoaiBaiViet.DataSource = lt;
                GridViewLoaiBaiViet.DataBind();
                PanelDanhSach.Visible = true;
                PanelMessage.Visible = false;
                return lt.Count;
            }
            else
            {
                PanelDanhSach.Visible = false;
                PanelMessage.Visible = true;
                return 0;
            }
        }
        public string strMenuChuyenMuc()
        {
            string lblMenu = "";
            lblMenu += "<li>";
            lblMenu += "<a class='parent' href='#'><span>Chuyên Mục</span></a>";
            BUSChuyenMuc ChuyenMucBUS = new BUSChuyenMuc();
            List<CHUYENMUC> DSChuyenMuc = ChuyenMucBUS.SelectCHUYENMUCsAll_exception();
            BUSLoaiBaiViet LoaiBaiVietBUS = new BUSLoaiBaiViet();

            int i, j;
            lblMenu += "<div><ul>";
            for (i = 1; i < DSChuyenMuc.Count(); i++)
            {
                //MenuItem mnItem = new MenuItem(DSChuyenMuc[i].TenChuyenMuc, "", "");

                lblMenu += "<li><a href='ChuyenMuc.aspx?id="+ DSChuyenMuc[i].MaChuyenMuc.ToString()+"'><span>"+DSChuyenMuc[i].TenChuyenMuc+"</span></a>";
                List<LOAIBAIVIET> DSLoaiBaiViet = LoaiBaiVietBUS.TimKiemLoaiBaiVietTheoChuyenMuc(DSChuyenMuc[i].MaChuyenMuc);
                if (DSLoaiBaiViet.Count() != 0)
                {
                    lblMenu += "<div><ul>";

                    for (j = 0; j < DSLoaiBaiViet.Count(); j++)
                    {
                        lblMenu += "<li><a href='LoaiBaiViet.aspx?id=" + DSLoaiBaiViet[j].MaLoaiBaiViet.ToString()+ "'><span>" + DSLoaiBaiViet[j].TenLoaiBaiViet + "</span></a></li>";
                       // MenuItem mn = new MenuItem(DSLoaiBaiViet[j].TenLoaiBaiViet, "", "", "~/LoaiBaiViet.aspx?id=" + DSLoaiBaiViet[j].MaLoaiBaiViet);
                        // mnChuyenMuc.ChildItems[i + 3].ChildItems.Add(mn);
                       // mnItem.ChildItems.Add(mn);
                    }
                    lblMenu += "</ul></div>";
                }
               // mnChuyenMuc.ChildItems.Add(mnItem);

            }
            lblMenu += "</ul></div>";
            lblMenu += "</li>";
            return lblMenu;
        }
        public string strMenuHoTroSinhVien()
        {
            BUSLoaiBaiViet LoaiBaiVietBUS = new BUSLoaiBaiViet();
            BUSChuyenMuc ChuyenMucBUS = new BUSChuyenMuc();
            List<CHUYENMUC> DSChuyenMuc = ChuyenMucBUS.SelectCHUYENMUCsAll();
            string strMenu = "";
            strMenu += "<li>";
            strMenu += "<a class='parent' href='ChuyenMuc.aspx?id=1'><span>Hỗ Trợ Sinh Viên</span></a>";

            int j;
               // MenuItem mnHoTroSinhVien = new MenuItem("Hỗ Trợ Sinh Viên", "", "", "~/default.aspx");
            List<LOAIBAIVIET> DSLoaiBaiVietHoTroSV = LoaiBaiVietBUS.TimKiemLoaiBaiVietTheoChuyenMuc(DSChuyenMuc[0].MaChuyenMuc);
            if (DSLoaiBaiVietHoTroSV.Count() != 0)
            {
                strMenu += "<div><ul>";
                for (j = 0; j < DSLoaiBaiVietHoTroSV.Count(); j++)
                {
                    //MenuItem mn = new MenuItem(DSLoaiBaiVietHoTroSV[j].TenLoaiBaiViet, "", "", "~/LoaiBaiViet.aspx?id=" + DSLoaiBaiVietHoTroSV[j].MaLoaiBaiViet);
                    //mnHoTroSinhVien.ChildItems.Add(mn);
                    strMenu += "<li><a href='LoaiBaiViet.aspx?id="+DSLoaiBaiVietHoTroSV[j].MaLoaiBaiViet.ToString()+"'><span>"+DSLoaiBaiVietHoTroSV[j].TenLoaiBaiViet+"</span></a></li>";
                }
                strMenu += "</ul></div>";
            }

            strMenu += "</li>";
            return strMenu;
        }
        public string strMenuHoatDong()
        {
            string strMenu = "";
            strMenu += "<li>";
            strMenu += "<a class='parent' href='ChuyenMuc.aspx?id=8'><span>Thông tin Hoạt Động</span></a>";
            BUSLoaiBaiViet LoaiBaiVietBUS = new BUSLoaiBaiViet();

            int i;
            strMenu += "<div><ul>";
            List<LOAIBAIVIET> DSLoaiBaiViet = LoaiBaiVietBUS.TimKiemLoaiBaiVietTheoChuyenMuc(8);
                  for (i = 0; i < DSLoaiBaiViet.Count(); i++)
                    {
                        strMenu += "<li><a href='LoaiBaiViet.aspx?id=" + DSLoaiBaiViet[i].MaLoaiBaiViet.ToString() + "'><span>" + DSLoaiBaiViet[i].TenLoaiBaiViet + "</span></a></li>";
                        // MenuItem mn = new MenuItem(DSLoaiBaiViet[j].TenLoaiBaiViet, "", "", "~/LoaiBaiViet.aspx?id=" + DSLoaiBaiViet[j].MaLoaiBaiViet);
                        // mnChuyenMuc.ChildItems[i + 3].ChildItems.Add(mn);
                        // mnItemChildItems.Add(mn);
                    }

            strMenu += "</ul></div>";
            strMenu += "</li>";
            return strMenu;
        }
 protected void load_ddlLBV(int machuyenmuc)
 {
     ddlLoaiBaiViet.Items.Clear();
     // load ddlLoaiBaiViet
     BUSLoaiBaiViet BUSLoaiBaiViet = new BUSLoaiBaiViet();
     List<LOAIBAIVIET> lstLBV = BUSLoaiBaiViet.TimKiemLoaiBaiVietTheoChuyenMuc(machuyenmuc);
     for (int i = 0; i < lstLBV.Count; i++)
     {
         ListItem li = new ListItem(lstLBV[i].TenLoaiBaiViet.ToString(), lstLBV[i].MaLoaiBaiViet.ToString());
         this.ddlLoaiBaiViet.Items.Add(li);
     }
 }
        protected void XoaBai(int maloai)
        {
            try
            {

                //xac nhan truoc khi xoa
                BUSBaiViet busBaiViet = new BUSBaiViet();
                List<BAIVIET> lstBaiViet = busBaiViet.TimKiemTheoLoaiBaiViet(maloai);
                if (lstBaiViet != null)
                {
                    foreach (BAIVIET bv in lstBaiViet)
                    {
                        BUSTapTinBaiViet busTapTin = new BUSTapTinBaiViet();
                        List<TAPTINBAIVIET> lstTapTin = busTapTin.TimKiemMaBaiViet(bv.MaBaiViet);
                        if (lstTapTin != null)
                        {
                            foreach (TAPTINBAIVIET taptin in lstTapTin)
                            {
                                busTapTin.Xoa(taptin.MaTapTin);
                            }
                        }

                        busBaiViet.Xoa(bv.MaBaiViet);
                    }
                }

                    BUSLoaiBaiViet bus = new BUSLoaiBaiViet();
                    if (bus.Xoa(maloai) == 0)
                    {
                        //Thong bao

                        Response.Redirect("LoaiBaiViet.aspx");
                    }

            }

            catch
            {
            }
        }