protected void btnThem_Click(object sender, EventArgs e)
        {
            try
            {
                //lay thong tin tu textbox
                HETHONGTOCHUC lpDTO = new HETHONGTOCHUC();
                //lpDTO.MaBai = int.Parse(this.txtmahethongtochuc.Text);
                lpDTO.TieuDe = this.txttenhethongtochuc.Text;
                lpDTO.NoiDung = this.ednoidung.Content;

                //Goi ham cap nhat
                BUSHeThongToChuc BUSHeThongToChuc = new BUSHeThongToChuc();
                if (BUSHeThongToChuc.Them(lpDTO) == 1)
                {
                    //Thong bao
                    lbThongBao.Text = "Thêm Thành Công";
                    lbThongBao.Visible = true;
                    //Response.Redirect("LoaiMatHang.aspx");
                }
                else
                {
                    lbThongBao.Text = "Thêm Không Thành Công";
                    lbThongBao.Visible = true;
                }
            }

            catch
            {
                lbThongBao.Text = "Thêm Không Thành Công";
                lbThongBao.Visible = true;
            }
        }
        private void loadHETHONGTOCHUC(int maHETHONGTOCHUC)
        {
            BUSHeThongToChuc BUSHeThongToChuc = new BUSHeThongToChuc();
            int MaBaiViet = int.Parse(Request.QueryString["id"]);
            HETHONGTOCHUC HETHONGTOCHUC = BUSHeThongToChuc.TimKiem(MaBaiViet);
            this.lblNoiDungBaiViet.Text = HETHONGTOCHUC.NoiDung;

            lblTieuDe.Text = HETHONGTOCHUC.TieuDe;
            lblTieuDe.Font.Bold = true;
            lblTieuDe.Font.Size = 18;
        }
        private void loadDSHETHONGTOCHUC()
        {
            BUSHeThongToChuc HETHONGTOCHUCBus = new BUSHeThongToChuc();
            List<HETHONGTOCHUC> DSHETHONGTOCHUC = HETHONGTOCHUCBus.SelectHETHONGTOCHUCsAll();

            string noidung = "";
            lblTieuDe.Font.Bold = true;
            lblTieuDe.Font.Size = 18;
            for (int i = 0; i < DSHETHONGTOCHUC.Count(); i++)
            {
                noidung += "<a href='" + "HETHONGTOCHUC.aspx?id=" + DSHETHONGTOCHUC[i].MaBai + "'> " + DSHETHONGTOCHUC[i].TieuDe + "</a>";
                noidung += "<br />";
                noidung += DSHETHONGTOCHUC[i].NoiDung;
                noidung += "<br /><hr><br />";
            }
            ltrNoiDung.Text = noidung;
        }
        //Load
        public int LoadHeThongToChuc()
        {
            List<HETHONGTOCHUC> lt = new List<HETHONGTOCHUC>();

            BUSHeThongToChuc BUSHeThongToChuc = new BUSHeThongToChuc();

            lt = BUSHeThongToChuc.SelectHETHONGTOCHUCsAll();
            if (lt.Count > 0)
            {
                this.GridViewHeThongToChuc.DataSource = lt;
                GridViewHeThongToChuc.DataBind();
                PanelDanhSach.Visible = true;
                PanelMessage.Visible = false;
                return lt.Count;
            }
            else
            {
                PanelDanhSach.Visible = false;
                PanelMessage.Visible = true;
                return 0;
            }
        }
        protected void XoaBai(int maBai)
        {
            try
            {

                //xac nhan truoc khi xoa
                 //Goi ham xoa
                    BUSHeThongToChuc bus = new BUSHeThongToChuc();
                    if (bus.Xoa(maBai) == 0)
                    {
                        //Thong bao

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

            catch
            {
            }
        }
 public string strMenuHeThongToChuc()
 {
     string str = "";
     str += "<li>";
     str += "<a href='HeThongToChuc.aspx' class='parent'><span>Hệ Thống Tổ Chức</span></a>";
     str += "<div><ul>";
     BUSHeThongToChuc HttcBUS = new BUSHeThongToChuc();
     List<HETHONGTOCHUC> DSHttc = HttcBUS.SelectHETHONGTOCHUCsAll();
     int i;
     for (i = 0; i < DSHttc.Count(); i++)
     {
         str += "<li><a href='HeThongToChuc.aspx?id=" + DSHttc[i].MaBai.ToString() + "'><span>" + DSHttc[i].TieuDe + "</span></a>";
         //MenuItem mn = new MenuItem(DSHttc[i].TieuDe, "", "", "~/HeThongToChuc.aspx?id=" + DSHttc[i].MaBai);
         //mnHeThongToChuc.ChildItems.Add(mn);
     }
     str += "</ul></div>";
     str += "</li>";
     return str;
 }
        protected void btnXoa_Click(object sender, EventArgs e)
        {
            try
            {
                //lay thong tin tu textbox
                int mahethongtochuc = int.Parse(Request.QueryString["id"]);

                //xac nhan truoc khi xoa

                    //Goi ham xoa
                    BUSHeThongToChuc BUSHeThongToChuc = new BUSHeThongToChuc();
                    if (BUSHeThongToChuc.Xoa(mahethongtochuc) == 0)
                    {
                        //Thong bao
                        lbThongBao.Text = "Xóa Thành Công";
                        lbThongBao.Visible = true;
                        Response.Redirect("HeThongToChuc.aspx");
                    }
            }

            catch
            {
                lbThongBao.Text = "Xoa Không Thành Công";
                lbThongBao.Visible = true;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Thong tin nguoi dung

            if (!IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {
                    //lay ma
                    int mahethongtochuc = int.Parse(Request.QueryString["id"]);

                    //lay thong tin va load len cac textbox
                    BUSHeThongToChuc BUSHeThongToChuc = new BUSHeThongToChuc();
                    HETHONGTOCHUC lpDTO = BUSHeThongToChuc.TimKiem(mahethongtochuc);
                    //  this.txtmahethongtochuc.Text = Convert.ToString(lpDTO.MaBai );
                    this.txttenhethongtochuc.Text = lpDTO.TieuDe;
                    this.ednoidung.Content = lpDTO.NoiDung;
                }
            }
        }