public bool CapNhatGiaoVien(GiaoVien GiaoVienClient) { try { using (var db = new TKBEntities()) { GiaoVien gv = db.GiaoViens.First(l => l.MaGiaoVien == GiaoVienClient.MaGiaoVien); gv.TenGiaoVien = GiaoVienClient.TenGiaoVien; gv.GioiTinh = GiaoVienClient.GioiTinh; gv.DiaChi = GiaoVienClient.DiaChi; gv.DienThoai = GiaoVienClient.DienThoai; gv.Email = GiaoVienClient.Email; db.SaveChanges(); return true; } } catch { return false; } }
private bool KiemTraGiaoVien(List<ThoiKhoaBieu> lstTKB, List<List<ChiTietTKB>> arrTKB, GiaoVien giaoVien, int maMonHoc, int thu, int tiet) { if (tiet < 2 || (tiet >= 2 && (arrTKB[thu][tiet - 2].MonHoc == null || (arrTKB[thu][tiet - 2].MonHoc != null && arrTKB[thu][tiet - 2].MonHoc.MaMonHoc != maMonHoc)))) { return KiemTraTKBLopKhac(lstTKB, giaoVien, thu, tiet, maMonHoc); } return false; }
private bool GetGiaoVien(List<ThoiKhoaBieu> lstTKB, List<List<ChiTietTKB>> arrTKB, List<GiaoVien> dsGiaoVien, int maMonHoc, int thu, int tiet, out GiaoVien giaoVien) { giaoVien = null; for (int i = 0; i < dsGiaoVien.Count; i++) if (dsGiaoVien[i].MonHoc != null && dsGiaoVien[i].MonHoc.MaMonHoc == maMonHoc) { if (tiet < 2 || (tiet >= 2 && (arrTKB[thu][tiet - 2].MonHoc == null || (arrTKB[thu][tiet - 2].MonHoc != null && arrTKB[thu][tiet - 2].MonHoc.MaMonHoc != maMonHoc)))) { if (tiet >= 9 || (tiet < 9 && (arrTKB[thu][tiet + 2].MonHoc == null || (arrTKB[thu][tiet + 2].MonHoc != null && arrTKB[thu][tiet + 2].MonHoc.MaMonHoc != maMonHoc)))) { if (KiemTraTKBLopKhac(lstTKB, dsGiaoVien[i], thu, tiet, maMonHoc)) { giaoVien = dsGiaoVien[i]; return true; } } } } return false; }
public bool ThemGiaoVien(GiaoVien gv) { try { using (var db = new TKBEntities()) { db.AddToGiaoViens(gv); db.SaveChanges(); } return true; } catch { return false; } }
private bool KiemTraTKBLopKhac(List<ThoiKhoaBieu> lstTKB, GiaoVien giaoVien, int thu, int tiet, int maMonHoc) { for (int j = 0; j < lstTKB.Count; j++) { int newThu = thu; int newTiet = tiet; List<ChiTietTKB> chiTiets = lstTKB[j].MaTKB == 0 ? lstTKB[j].ChiTietTKBs.ToList() : GetDanhSachChiTietTKB(lstTKB[j].MaTKB); if (lstTKB[j].MaTKB != 0) { newThu = thu + 2; newTiet = tiet + 1; } for (int k = 0; k < chiTiets.Count; k++) { ChiTietTKB ct = chiTiets[k]; if (ct.Thu == newThu && ct.TietBatDau == newTiet && (int)ct.MonHocReference.EntityKey.EntityKeyValues[0].Value == maMonHoc && (int)ct.GiaoVienReference.EntityKey.EntityKeyValues[0].Value == giaoVien.MaGiaoVien) return false; } } return true; }