public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MonHoc monHoc = contextMH.GetById(id); if (monHoc == null) { return(HttpNotFound()); } return(View(monHoc)); }
public ActionResult DangKyMonHoc() { string maSV = Session["MaSV"].ToString().Trim(); KhoaBLL contextK = new KhoaBLL(); LopTinChiBLL contextLTC = new LopTinChiBLL(); List <LopTinChi> lstLTC = contextLTC.GetAll(); MonHocBLL contextMH = new MonHocBLL(); GiangVienBLL contextGV = new GiangVienBLL(); // chỉ cho sinh viên đăng ký lớp đang mở List <LopTinChiModel> listLTCModel = new List <LopTinChiModel>(); foreach (LopTinChi ltc in lstLTC) { var query = ltc.SinhViens.Where(x => x.MaSV == maSV).FirstOrDefault(); if (query == null) { if (ltc.TrangThai == true && ltc.SinhViens.Count < 50) { GiangVien giangVien = contextGV.GetById(ltc.MaGV); MonHoc monHoc = contextMH.GetById(ltc.MaMonHoc); LopTinChiModel ltcModel = new LopTinChiModel() { MaLopTC = ltc.MaLopTC, TrangThai = ltc.TrangThai, MaGV = ltc.MaGV, MaMonHoc = ltc.MaMonHoc, Nhom = ltc.Nhom, NienKhoa = ltc.NienKhoa, GiangVienModel = new GiangVienModel() { MaGV = giangVien.MaGV, Email = giangVien.Email, GioiTinh = giangVien.GioiTinh, HoVaTenLot = giangVien.HoVaTenLot, MaKhoa = giangVien.MaKhoa, MatKhau = giangVien.MatKhau, NgaySinh = giangVien.NgaySinh, SDT = giangVien.SDT, TenGV = giangVien.TenGV, TrinhDo = giangVien.TrinhDo }, MonHoc = new MonHocModel { MaMH = monHoc.MaMH, SoTinChiLyThuyet = monHoc.SoTinChiLyThuyet, SoTinChiThucHanh = monHoc.SoTinChiThucHanh, TenMH = monHoc.TenMH } }; listLTCModel.Add(ltcModel); } } } ViewBag.Khoa = new SelectList(contextK.GetAll(), "MaKhoa", "TenKhoa"); return(View(listLTCModel)); }
public ActionResult Details(int id) { LopTinChi lopTinChi = contextLopTC.GetById(id); if (lopTinChi == null) { return(HttpNotFound()); } GiangVienBLL ctGV = new GiangVienBLL(); MonHocBLL ctMH = new MonHocBLL(); lopTinChi.GiangVien = ctGV.GetById(lopTinChi.MaGV); lopTinChi.MonHoc = ctMH.GetById(lopTinChi.MaMonHoc); lopTinChi.NienKhoaHocKy = contextNKHK.GetById(lopTinChi.NienKhoa); return(View(lopTinChi)); }
public JsonResult GetLopTC(int maLopTC) { LopTinChiModel ltcModel; LopTinChiBLL contextLTC = new LopTinChiBLL(); LopTinChi ltc = contextLTC.GetById(maLopTC); GiangVienBLL contextGV = new GiangVienBLL(); MonHocBLL contextMH = new MonHocBLL(); if (ltc != null) { ltcModel = new LopTinChiModel { MaGV = ltc.MaGV, MaLopTC = ltc.MaLopTC, MaMonHoc = ltc.MaMonHoc, Nhom = ltc.Nhom, NienKhoa = ltc.NienKhoa, TrangThai = ltc.TrangThai }; GiangVien gv = contextGV.GetById(ltc.MaGV); MonHoc mh = contextMH.GetById(ltc.MaMonHoc); ltcModel.MonHoc = new MonHocModel { MaMH = mh.MaMH, SoTinChiThucHanh = mh.SoTinChiThucHanh, SoTinChiLyThuyet = mh.SoTinChiLyThuyet, TenMH = mh.TenMH }; ltcModel.GiangVien = new GiangVienModel { MaGV = gv.MaGV, Email = gv.Email, GioiTinh = gv.GioiTinh, HoVaTenLot = gv.HoVaTenLot, MaKhoa = gv.MaKhoa, MatKhau = gv.MatKhau, NgaySinh = gv.NgaySinh, SDT = gv.SDT, TenGV = gv.TenGV, TrinhDo = gv.TrinhDo }; return(Json(new { LTC = ltcModel })); } return(Json(new { LTC = "NULL" })); }
public List <SupportThoiKhoaBieu> GetListSPTKB(string tuan, ICollection <LopTinChi> lopTCs) { List <SupportThoiKhoaBieu> lstSPTKB = new List <SupportThoiKhoaBieu>(); ThoiKhoaBieuBLL contextTKB = new ThoiKhoaBieuBLL(); DateTime dtStart = DateTime.Parse(tuan.Split('-')[1].ToString().Trim(), new CultureInfo("en-US")); DateTime dtEnd = DateTime.Parse(tuan.Split('-')[3].ToString().Trim(), new CultureInfo("en-US")); MonHocBLL contextMH = new MonHocBLL(); foreach (var item in lopTCs) { if (item.TrangThai == true) { SupportThoiKhoaBieu spTKB = new SupportThoiKhoaBieu(); spTKB.listTKB = contextTKB.GetByMaLopTC(item.MaLopTC).Select(s => new ThoiKhoaBieuModel { Ngay = s.Ngay, Buoi = s.Buoi, MaLopTC = s.MaLopTC, TietBD = s.TietBD }).ToList(); //duyệt danh sách thời khóa biểu của lớp tín chỉ đăng ký xem đã hoàn thành chưa foreach (var tkb in spTKB.listTKB) { if (lstSPTKB.Count > 0) { int count = lstSPTKB.Count; for (int i = 0; i < count; i++) { var itemSPTKB = lstSPTKB[i]; if (itemSPTKB.MonHoc.MaMH == item.MaMonHoc) { if (tkb.Ngay.DayOfYear >= dtStart.DayOfYear && tkb.Ngay.DayOfYear <= dtEnd.DayOfYear) { ThoiKhoaBieuModel tkbModel = new ThoiKhoaBieuModel { Buoi = tkb.Buoi, MaLopTC = tkb.MaLopTC, Ngay = tkb.Ngay, TietBD = tkb.TietBD }; itemSPTKB.listTKB.Add(tkbModel); } } else { SupportThoiKhoaBieu sptkb = new SupportThoiKhoaBieu(); sptkb.listTKB = new List <ThoiKhoaBieuModel>(); MonHoc mh = contextMH.GetById(item.MaMonHoc); sptkb.MonHoc = new MonHocModel { MaMH = mh.MaMH, SoTinChiLyThuyet = mh.SoTinChiLyThuyet, SoTinChiThucHanh = mh.SoTinChiThucHanh, TenMH = mh.TenMH }; ThoiKhoaBieuModel tkbModel = new ThoiKhoaBieuModel { Buoi = tkb.Buoi, MaLopTC = tkb.MaLopTC, Ngay = tkb.Ngay, TietBD = tkb.TietBD }; sptkb.listTKB.Add(tkbModel); lstSPTKB.Add(sptkb); } } } else { if (tkb.Ngay.DayOfYear >= dtStart.DayOfYear && tkb.Ngay.DayOfYear <= dtEnd.DayOfYear) { SupportThoiKhoaBieu sptkb = new SupportThoiKhoaBieu(); sptkb.listTKB = new List <ThoiKhoaBieuModel>(); MonHoc mh = contextMH.GetById(item.MaMonHoc); sptkb.MonHoc = new MonHocModel { MaMH = mh.MaMH, SoTinChiLyThuyet = mh.SoTinChiLyThuyet, SoTinChiThucHanh = mh.SoTinChiThucHanh, TenMH = mh.TenMH }; ThoiKhoaBieuModel tkbModel = new ThoiKhoaBieuModel { Buoi = tkb.Buoi, MaLopTC = tkb.MaLopTC, Ngay = tkb.Ngay, TietBD = tkb.TietBD }; sptkb.listTKB.Add(tkbModel); lstSPTKB.Add(sptkb); } } } } } return(lstSPTKB); }
public JsonResult LocTheoNieKhoaHocKy(string nienKhoa, int hocky) { string maSV = Session["MaSV"].ToString().Trim(); if (string.IsNullOrEmpty(nienKhoa) || hocky < 0 || hocky > 3) { return(Json(new { msg = "FALSE" })); } KhoaBLL contextK = new KhoaBLL(); LopTinChiBLL contextLTC = new LopTinChiBLL(); List <LopTinChi> lstLTC = contextLTC.GetAll(); NienKhoaHocKyBLL contextNKHK = new NienKhoaHocKyBLL(); MonHocBLL contextMH = new MonHocBLL(); GiangVienBLL contextGV = new GiangVienBLL(); List <LopTinChiModel> listLTCModel = new List <LopTinChiModel>(); foreach (LopTinChi ltc in lstLTC) { NienKhoaHocKy nkhk = contextNKHK.GetById(ltc.NienKhoa); var query = ltc.SinhViens.Where(x => x.MaSV == maSV).FirstOrDefault(); if (query == null) { if (ltc.TrangThai == true && ltc.NienKhoa == nienKhoa && nkhk.HocKy == hocky && ltc.SinhViens.Count < 50) { GiangVien giangVien = contextGV.GetById(ltc.MaGV); MonHoc monHoc = contextMH.GetById(ltc.MaMonHoc); LopTinChiModel ltcModel = new LopTinChiModel() { MaLopTC = ltc.MaLopTC, TrangThai = ltc.TrangThai, MaGV = ltc.MaGV, MaMonHoc = ltc.MaMonHoc, Nhom = ltc.Nhom, NienKhoa = ltc.NienKhoa, GiangVienModel = new GiangVienModel() { MaGV = giangVien.MaGV, Email = giangVien.Email, GioiTinh = giangVien.GioiTinh, HoVaTenLot = giangVien.HoVaTenLot, MaKhoa = giangVien.MaKhoa, MatKhau = giangVien.MatKhau, NgaySinh = giangVien.NgaySinh, SDT = giangVien.SDT, TenGV = giangVien.TenGV, TrinhDo = giangVien.TrinhDo }, MonHoc = new MonHocModel { MaMH = monHoc.MaMH, SoTinChiLyThuyet = monHoc.SoTinChiLyThuyet, SoTinChiThucHanh = monHoc.SoTinChiThucHanh, TenMH = monHoc.TenMH } }; listLTCModel.Add(ltcModel); } } } ViewBag.Khoa = new SelectList(contextK.GetAll(), "MaKhoa", "TenKhoa"); if (listLTCModel.Count > 0) { return(Json(new { msg = listLTCModel })); } return(Json(new { msg = "FALSE" })); }
public JsonResult LuuDangKy() { string maSV = Session["MaSV"].ToString().Trim(); LopTinChiBLL contextLTC = new LopTinChiBLL(); List <LopTinChi> lstLTC = contextLTC.GetAll(); MonHocBLL contextMH = new MonHocBLL(); GiangVienBLL contextGV = new GiangVienBLL(); List <LopTinChiModel> listLTCModel = new List <LopTinChiModel>(); foreach (LopTinChi ltc in lstLTC) { var query = ltc.SinhViens.Where(x => x.MaSV == maSV).FirstOrDefault(); if (query == null) { if (ltc.TrangThai == true && ltc.SinhViens.Count < 50) { GiangVien giangVien = contextGV.GetById(ltc.MaGV); MonHoc monHoc = contextMH.GetById(ltc.MaMonHoc); LopTinChiModel ltcModel = new LopTinChiModel() { MaLopTC = ltc.MaLopTC, TrangThai = ltc.TrangThai, MaGV = ltc.MaMonHoc, MaMonHoc = ltc.MaMonHoc, Nhom = ltc.Nhom, NienKhoa = ltc.NienKhoa, GiangVienModel = new GiangVienModel() { MaGV = giangVien.MaGV, Email = giangVien.Email, GioiTinh = giangVien.GioiTinh, HoVaTenLot = giangVien.HoVaTenLot, MaKhoa = giangVien.MaKhoa, MatKhau = giangVien.MatKhau, NgaySinh = giangVien.NgaySinh, SDT = giangVien.SDT, TenGV = giangVien.TenGV, TrinhDo = giangVien.TrinhDo }, MonHoc = new MonHocModel { MaMH = monHoc.MaMH, SoTinChiLyThuyet = monHoc.SoTinChiLyThuyet, SoTinChiThucHanh = monHoc.SoTinChiThucHanh, TenMH = monHoc.TenMH } }; listLTCModel.Add(ltcModel); } } } DangKyModel dk = new DangKyModel(); List <int> listMaLopDK = (List <int>)TempData["ListLopTCDK"]; if (listMaLopDK.Count > 0) { foreach (int a in listMaLopDK) { LopTinChiModel ltcModel = listLTCModel.Where(x => x.MaLopTC == a).FirstOrDefault(); if (ltcModel != null) { if (Session["MaSV"] != null) { contextLTC.DangKy(ltcModel.MaLopTC, maSV); } } } TempData.Clear(); return(Json(new { msg = "Lưu đăng ký thành công!" })); } return(Json(new { msg = "Lỗi!" })); }
public JsonResult DeleteSelectMonHoc(int maLopTC) { string maSV = Session["MaSV"].ToString().Trim(); LopTinChiBLL contextLTC = new LopTinChiBLL(); List <LopTinChi> lstLTC = contextLTC.GetAll(); MonHocBLL contextMH = new MonHocBLL(); GiangVienBLL contextGV = new GiangVienBLL(); List <LopTinChiModel> listLTCModel = new List <LopTinChiModel>(); foreach (LopTinChi ltc in lstLTC) { var query = ltc.SinhViens.Where(x => x.MaSV == maSV).FirstOrDefault(); if (query == null) { if (ltc.TrangThai == true && ltc.SinhViens.Count < 50) { GiangVien giangVien = contextGV.GetById(ltc.MaGV); MonHoc monHoc = contextMH.GetById(ltc.MaMonHoc); LopTinChiModel ltcModel = new LopTinChiModel() { MaLopTC = ltc.MaLopTC, TrangThai = ltc.TrangThai, MaGV = ltc.MaMonHoc, MaMonHoc = ltc.MaMonHoc, Nhom = ltc.Nhom, NienKhoa = ltc.NienKhoa, GiangVienModel = new GiangVienModel() { MaGV = giangVien.MaGV, Email = giangVien.Email, GioiTinh = giangVien.GioiTinh, HoVaTenLot = giangVien.HoVaTenLot, MaKhoa = giangVien.MaKhoa, MatKhau = giangVien.MatKhau, NgaySinh = giangVien.NgaySinh, SDT = giangVien.SDT, TenGV = giangVien.TenGV, TrinhDo = giangVien.TrinhDo }, MonHoc = new MonHocModel { MaMH = monHoc.MaMH, SoTinChiLyThuyet = monHoc.SoTinChiLyThuyet, SoTinChiThucHanh = monHoc.SoTinChiThucHanh, TenMH = monHoc.TenMH } }; listLTCModel.Add(ltcModel); } } } if (listLTCModel.Count > 0) { LopTinChiModel ltc = listLTCModel.Where(x => x.MaLopTC == maLopTC).FirstOrDefault(); if (ltc != null) { if (TempData["SoTinChiDK"] != null) { List <int> listMaLopDK = (List <int>)TempData["ListLopTCDK"]; var itemToRemove = listMaLopDK.Single(r => r == maLopTC); listMaLopDK.Remove(itemToRemove); TempData["ListLopTCDK"] = listMaLopDK; int tong = Int32.Parse(TempData["SoTinChiDK"].ToString()) - ltc.TongSoTinChi; TempData["SoTinChiDK"] = tong; return(Json(new { msg = "OK" })); } } } return(Json(new { msg = "FALSE" })); }