/// <summary> /// Xoa khoa theo ma khoa /// </summary> /// <param name="maLop"></param> /// <returns>true, false</returns> public bool Delete(string maLop) { if (string.IsNullOrEmpty(maLop)) { return(false); } LopDAO context = new LopDAO(); Lop lp = new Lop(); try { lp = context.GetById(maLop); if (lp != null) { SinhVienBLL svContext = new SinhVienBLL(); List <SinhVien> lstSV = svContext.GetByMaLop(maLop); if (lstSV.Count == 0) { context.Delete(maLop); return(true); } } return(false); } catch (Exception ex) { Console.WriteLine(ex); return(false); } }
/// <summary> /// Lay 1 record dua vao ma lop /// </summary> /// <param name="maLop"></param> /// <returns>Lop</returns> public Lop GetById(string maLop) { if (maLop == "" || maLop == null) { return(null); } LopDAO context = new LopDAO(); try { Lop lp = context.GetById(maLop); return(lp); } catch (Exception ex) { Console.WriteLine(ex); return(null); } }