protected void GridViewTapTin_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "XoaTapTin")
            {
                int idBV = Convert.ToInt32(e.CommandArgument);

                //List<BAIVIET> lt = new List<BAIVIET>();

                //BUSBaiViet busBaiViet = new BUSBaiViet();
                //lt = busBaiViet.SelectBAIVIETsAll();

                BUSTapTinBaiViet bus = new BUSTapTinBaiViet();
                bus.Xoa(idBV);
                List<TAPTINBAIVIET> gvTapTinDS = bus.TimKiemMaBaiViet(int.Parse(Request.QueryString["id"]));
                //     gvTapTinDS.Add(ttbvDTO);
                this.GridViewTapTin.DataSource = gvTapTinDS;
                this.GridViewTapTin.DataBind();
                FilterSTT(gvTapTinDS.Count, 0, 30);
            }
        }
        protected void XoaTapTin(int maTapTin)
        {
            try
            {

                //xac nhan truoc khi xoa

                    BUSTapTinBaiViet bus = new BUSTapTinBaiViet();
                    TAPTINBAIVIET ttbv = bus.TimKiemMaTapTin(maTapTin);
                    XoaFile(ttbv.DuongDan);
                    if (bus.Xoa(maTapTin) == 0)
                    {
                        //Thong bao

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

            }

            catch
            {
            }
        }
        protected void XoaChuyenMuc(int maChuyenMuc)
        {
            try
            {

                //xac nhan truoc khi xoa

                BUSBaiViet busBaiViet = new BUSBaiViet();
                List<BAIVIET> lstBaiViet = busBaiViet.LayDSBaiVietTheoChuyenMuc(maChuyenMuc);
                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);
                    }
                }

                    BUSChuyenMuc busChuyenMuc = new BUSChuyenMuc();
                    if (busChuyenMuc.Xoa(maChuyenMuc) == 0)
                    {
                        //Thong bao

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

            }

            catch
            {
            }
        }
 protected void XoaFile_Click(string tenTapTin)
 {
     DialogResult rs = MessageBox.Show("Bạn có chắc là muốn xoá lịch làm việc " + tenTapTin + " không?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (rs == DialogResult.Yes)
         {
             //Goi ham xoa
             BUSTapTinBaiViet busTapTinBaiViet = new BUSTapTinBaiViet();
             TAPTINBAIVIET ttbv = busTapTinBaiViet.TimKiemTenTapTin(tenTapTin);
             XoaFile(ttbv.DuongDan);
             busTapTinBaiViet.Xoa(ttbv.MaTapTin);
             Response.Redirect("LichLamViec.aspx");
         }
         else
         {
             Response.Redirect("LichLamViec.aspx");
         }
 }
        protected void btnXoa_Click(object sender, EventArgs e)
        {
            try
            {
                //lay thong tin tu textbox
                int mataptin = int.Parse(Request.QueryString["id"]);

                //xac nhan truoc khi xoa

                    BUSTapTinBaiViet BUSTapTinBaiViet = new BUSTapTinBaiViet();
                    if (BUSTapTinBaiViet.Xoa(mataptin) == 0)
                    {
                        //Thong bao
                        lbThongBao.Text = "Xóa Thành Công";
                        lbThongBao.Visible = true;
                        Response.Redirect("TapTinBaiViet.aspx");
                    }

            }

            catch
            {
                lbThongBao.Text = "Xoa Không Thành Công";
                lbThongBao.Visible = true;
            }
        }
        protected void btnXoa_Click(object sender, EventArgs e)
        {
            try
            {
                //lay thong tin tu textbox
                int machuyenmuc = int.Parse(Request.QueryString["id"]);
                BUSBaiViet busBaiViet = new BUSBaiViet();
                List<BAIVIET> lstBaiViet = busBaiViet.LayDSBaiVietTheoChuyenMuc(machuyenmuc);
                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);
                    }
                }

                //xac nhan truoc khi xoa

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

            }

            catch
            {
                lbThongBao.Text = "Xoa Không Thành Công";
                lbThongBao.Visible = true;
            }
        }
        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
            {
            }
        }