public int EditLopHocPhan(eLopHocPhan x) { try { LopHocPhan m = db.LopHocPhans.Where(t => t.ID_LopHocPhan == x.ID_LopHocPhan).FirstOrDefault(); if (m == null) { return(0); } m.ID_LopHocPhan = x.ID_LopHocPhan; m.ID_HocPhan = x.ID_HocPhan; m.ID_GiangVien = x.ID_GiangVien; m.HocKy = x.HocKy; m.ID_NhanVienPDT = x.ID_NhanVienPDT; m.ID_NienKhoa = x.ID_NienKhoa; m.TrangThai = x.TrangThai; m.NgayBatDau = x.NgayBatDau; m.NgayKetThuc = x.NgayKetThuc; m.SoTiet = x.SoTiet; m.SoLuong = new DangKyHocPhanDAL().SoLuong(x.ID_LopHocPhan); db.SaveChanges(); return(1); } catch (Exception) { return(0); } return(1); }
public bool XoaLopHocPhan(string idLHP) { try { List <Diem> lstDiem = db.Diems.Where(x => x.ID_LopHocPhan == idLHP).ToList(); List <DangKyHocPhan> lstDK = db.DangKyHocPhans.Where(x => x.ID_LopHocPhan == idLHP).ToList(); List <LichHoc_LopHocPhan> lstLichLT = db.LichHoc_LopHocPhan.Where(x => x.ID_LopHocPhan == idLHP).ToList(); List <NhomThucHanh> lstNhomTH = db.NhomThucHanhs.Where(x => x.ID_LopHocPhan == idLHP).ToList(); foreach (NhomThucHanh t in lstNhomTH) { List <LichHoc_NhomThucHanh> lstLichTH = db.LichHoc_NhomThucHanh.Where(x => x.ID_NhomThucHanh == t.ID_NhomThucHanh).ToList(); db.LichHoc_NhomThucHanh.RemoveRange(lstLichTH); } db.Diems.RemoveRange(lstDiem); db.DangKyHocPhans.RemoveRange(lstDK); db.LichHoc_LopHocPhan.RemoveRange(lstLichLT); db.NhomThucHanhs.RemoveRange(lstNhomTH); LopHocPhan s = db.LopHocPhans.Where(c => c.ID_LopHocPhan == idLHP).FirstOrDefault(); db.LopHocPhans.Remove(s); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public int AddLopHocPhan(eLopHocPhan x) { try { LopHocPhan m = new LopHocPhan(); m.ID_LopHocPhan = x.ID_LopHocPhan; m.ID_HocPhan = x.ID_HocPhan; m.ID_GiangVien = x.ID_GiangVien; m.HocKy = x.HocKy; m.ID_NhanVienPDT = x.ID_NhanVienPDT; m.TrangThai = x.TrangThai; m.NgayBatDau = x.NgayBatDau; m.NgayKetThuc = x.NgayKetThuc; m.SoLuong = db.DangKyHocPhans.Where(t => t.ID_LopHocPhan == x.ID_LopHocPhan).Count(); m.SoTiet = x.SoTiet; m.ID_NienKhoa = x.ID_NienKhoa; db.LopHocPhans.Add(m); db.SaveChanges(); return(1); } catch (Exception) { return(0); } }
public string GetTrangThai(string id) { LopHocPhan x = db.LopHocPhans.Where(s => s.ID_LopHocPhan == id).FirstOrDefault(); if (x != null) { return(x.TrangThai); } return(""); }