public static void UpdateSinhVien(string Mssv, SinhVien_DTO sv) { using (QuanLiSinhVienEntities db = new QuanLiSinhVienEntities()) { DeleteSinhVien(Mssv); InsertSinhVien(sv); } }
public static void InsertSinhVien(SinhVien_DTO sv) { using (QuanLiSinhVienEntities db = new QuanLiSinhVienEntities()) { db.SinhViens.Add(ReturnSV(sv)); db.SaveChanges(); } }
public static void DeleteSinhVien(string Mssv) { using (QuanLiSinhVienEntities db = new QuanLiSinhVienEntities()) { var sv = db.SinhViens.FirstOrDefault(x => x.mssv == Mssv); if (sv != null) { db.SinhViens.Remove(sv); db.SaveChanges(); } } }
public static List <SinhVien_DTO> LoadSinhVien() { using (QuanLiSinhVienEntities db = new QuanLiSinhVienEntities()) { var sv = db.SinhViens.ToList(); List <SinhVien_DTO> svDTO = new List <SinhVien_DTO>(); foreach (SinhVien s in sv) { svDTO.Add(ReturnSV_DTO(s)); } return(svDTO); } }