/// <summary> /// Xoa khoa theo ma khoa /// </summary> /// <param name="maKhoa"></param> /// <returns></returns> public bool Delete(string maKhoa) { if (string.IsNullOrEmpty(maKhoa)) { return(false); } KhoaDAO context = new KhoaDAO(); Khoa kh = new Khoa(); try { kh = context.GetById(maKhoa); if (kh != null) { LopBLL lopContext = new LopBLL(); List <Lop> lstLop = lopContext.GetByMaKhoa(maKhoa); if (lstLop.Count == 0) { context.Delete(maKhoa); return(true); } } return(false); } catch (Exception ex) { Console.WriteLine(ex); return(false); } }
/// <summary> /// Lay 1 record dua vao ma khoa /// </summary> /// <param name="maKhoa"></param> /// <returns>Khoa</returns> public Khoa GetById(string maKhoa) { if (maKhoa == "" || maKhoa == null) { return(null); } KhoaDAO context = new KhoaDAO(); try { Khoa khoa = context.GetById(maKhoa); return(khoa); } catch (Exception ex) { Console.WriteLine(ex); return(null); } }