Example #1
0
 private void DeleteTKB(int maLop, string namHoc)
 {
     using (var db = new TKBEntities())
     {
         ThoiKhoaBieu tkb = db.ThoiKhoaBieux.FirstOrDefault(p => p.Lop.MaLop == maLop && (p.NamHoc == namHoc || (namHoc == null && p.NamHoc.Equals(null))));
         if (tkb != null)
         {
             List<ChiTietTKB> chiTiets = db.ChiTietTKBs.Where(p => p.ThoiKhoaBieu.MaTKB == tkb.MaTKB).ToList();
             if (chiTiets != null)
             {
                 foreach (var ct in chiTiets)
                 {
                     db.DeleteObject(ct);
                 }
                 db.SaveChanges();
             }
             db.DeleteObject(tkb);
             db.SaveChanges();
         }
     }
 }
Example #2
0
 public bool XoaPhong(int maPhong)
 {
     try
     {
         using (var db = new TKBEntities())
         {
             Phong gv = db.Phongs.First(l => l.MaPhong == maPhong);
             db.DeleteObject(gv);
             db.SaveChanges();
             return true;
         }
     }
     catch
     {
         return false;
     }
 }
Example #3
0
 public bool XoaGiaoVien(int maGiaoVien)
 {
     try
     {
         using (var db = new TKBEntities())
         {
             GiaoVien gv = db.GiaoViens.First(l => l.MaGiaoVien == maGiaoVien);
             db.DeleteObject(gv);
             db.SaveChanges();
             return true;
         }
     }
     catch
     {
         return false;
     }
 }
Example #4
0
 public bool XoaLop(int maLop)
 {
     try
     {
         using (var db = new TKBEntities())
         {
             Lop lop = db.Lops.First(l => l.MaLop == maLop);
             db.DeleteObject(lop);
             db.SaveChanges();
             return true;
         }
     }
     catch
     {
         return false;
     }
 }
Example #5
0
        public bool DeleteChiTietTKB(int maChiTiet)
        {
            try
            {
                using (var db = new TKBEntities())
                {
                    ChiTietTKB chiTiet = db.ChiTietTKBs.FirstOrDefault(p => p.MaChiTietTKB == maChiTiet);
                    if (chiTiet != null)
                    {
                        db.DeleteObject(chiTiet);
                        db.SaveChanges();
                    }

                    return true;
                }
            }
            catch (Exception ex)
            {
                return false;
            }
        }