/// <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); } }
public string CreateMaSV(string maLop) { SinhVienBLL contextSV = new SinhVienBLL(); LopBLL contextL = new LopBLL(); HeDaoTaoBLL contextHDT = new HeDaoTaoBLL(); try { Lop Lop = contextL.GetById(maLop); if (Lop != null) { string stt = ""; int dem = contextSV.GetByMaLop(maLop).Count; if (dem >= 100) { stt = dem.ToString().Trim(); } else if (dem < 100 && dem >= 10) { stt = "0" + dem.ToString().Trim(); } else { stt = "00" + dem.ToString().Trim(); } string ma = "N" + Lop.NienKhoa.Substring(2, 2) + Lop.MaHDT.Substring(0, 1) + Lop.MaHDT.Substring(2, 1) + Lop.MaKhoa.Substring(0, 2) + stt; return(ma); } return(null); } catch (Exception ex) { Console.WriteLine(ex); return(null); } }