// GET: NAMHOCs/Create public ActionResult Create() { NAMHOC obj = new NAMHOC(); obj.NH_MA = CreateID.CreateID_ByteText(); return(View(obj)); }
public ActionResult Xoanamhoc(int id) { NAMHOC namhoc = db.NAMHOCs.Find(id); if (namhoc != null) { List <KIHOC> listKiHoc = db.KIHOCs.Where(n => n.id_NAMHOC == namhoc.id).ToList(); foreach (var item in listKiHoc) { db.KIHOCs.Remove(item); } db.NAMHOCs.Remove(namhoc); db.SaveChanges(); } Session["chuyenTab"] = 5; if (Session["id_hsDetail"] != null) { int id_hs = (int)Session["id_HS"]; return(RedirectToAction("DetailChung/" + id_hs, "HocSinh")); } if (Session["id_HS"] != null) { int id_hs = (int)Session["id_HS"]; return(RedirectToAction("DetailChung/" + id_hs, "HocSinh")); } return(View()); }
public ActionResult DeleteConfirmed(string id) { NAMHOC nAMHOC = db.NAMHOCs.Find(id); db.NAMHOCs.Remove(nAMHOC); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "NH_MA,NH_NAMHOC")] NAMHOC nAMHOC) { if (ModelState.IsValid) { db.Entry(nAMHOC).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nAMHOC)); }
public JsonResult ThemNamhoc(NAMHOC namhoc) { if (ModelState.IsValid) { db.NAMHOCs.Add(namhoc); db.SaveChanges(); return(Json(namhoc, JsonRequestBehavior.AllowGet)); } return(Json(namhoc, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveNamhoc(NAMHOC namhoc) { if (ModelState.IsValid) { namhoc.id_HB = (int)Session["id_hocba"]; db.NAMHOCs.Add(namhoc); db.SaveChanges(); return(Json(namhoc, JsonRequestBehavior.AllowGet)); } return(Json("NO", JsonRequestBehavior.AllowGet)); }
public ActionResult Create([Bind(Include = "NH_MA,NH_NAMHOC")] NAMHOC nAMHOC) { if (ModelState.IsValid) { db.NAMHOCs.Add(nAMHOC); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nAMHOC)); }
// Lấy năm học tiếp theo public static List <NAMHOC> LayNamHocTiepTheo(string maNamHocCu) { List <NAMHOC> namHoc = new List <NAMHOC>(); using (SQL_QLHSDataContext db = new SQL_QLHSDataContext()) { NAMHOC namHocCu = db.NAMHOCs.Where(a => a.MANAMHOC == maNamHocCu).FirstOrDefault(); int nam = namHocCu.NAM1.Value; namHoc = db.NAMHOCs.Where(a => a.NAM1 == nam + 1).ToList(); } return(namHoc); }
// GET: NAMHOCs/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NAMHOC nAMHOC = db.NAMHOCs.Find(id); if (nAMHOC == null) { return(HttpNotFound()); } return(View(nAMHOC)); }
// Lấy năm học hiện tại public static NAMHOC LayNamHocHienTai() { NAMHOC namHoc = new NAMHOC(); using (SQL_QLHSDataContext db = new SQL_QLHSDataContext()) { var ds = db.sp_LayNamHocHienTai(); foreach (var x in ds) { namHoc.MANAMHOC = x.MANAMHOC; namHoc.TENNAMHOC = x.TENNAMHOC; } } return(namHoc); }
private void btnSave_Click(object sender, EventArgs e) { if (!btnNew.Enabled) { NAMHOC _newTerm = new NAMHOC(); _newTerm.manh = txtID.Text; _newTerm.tennh = txtNameTerm.Text; try { frmLogin._database.NAMHOCs.InsertOnSubmit(_newTerm); frmLogin._database.SubmitChanges(); } catch (Exception Ex) { MessageBox.Show(Ex.Message); } finally { dGVTermLoadData(); ChangeSttControl(false); MessageBox.Show("New Term Create Successfull"); } } else { if (txtID.Text != "") { NAMHOC _editTerm = frmLogin._database.NAMHOCs.Single(p => p.manh == txtID.Text); _editTerm.tennh = txtNameTerm.Text; DialogResult _dialogResult = MessageBox.Show("Do you want to edit term ?", "Confirm", MessageBoxButtons.YesNo); if (_dialogResult == DialogResult.Yes) { try { frmLogin._database.SubmitChanges(); } catch (Exception Ex) { MessageBox.Show(Ex.Message); } finally { dGVTermLoadData(); } } } } }
// Lấy năm học theo Mã HS public static List <NAMHOC> LayNamHocTheoMaHS(string maHS) { List <NAMHOC> lst = new List <NAMHOC>(); using (SQL_QLHSDataContext db = new SQL_QLHSDataContext()) { var ds = db.sp_LayNamHocTheoMaHS(maHS); foreach (var x in ds) { NAMHOC namHoc = new NAMHOC(); { namHoc.MANAMHOC = x.MANAMHOC; namHoc.TENNAMHOC = x.TENNAMHOC; lst.Add(namHoc); } } } return(lst); }
// Lấy tất cả các năm học public static List <NAMHOC> LayTatCaNamHoc() { List <NAMHOC> lst = new List <NAMHOC>(); using (SQL_QLHSDataContext db = new SQL_QLHSDataContext()) { var ds = db.NAMHOCs.ToList(); foreach (var x in ds) { NAMHOC namHoc = new NAMHOC(); { namHoc.MANAMHOC = x.MANAMHOC; namHoc.TENNAMHOC = x.TENNAMHOC; lst.Add(namHoc); } } } return(lst); }
public JsonResult NhapDiem(KIHOC kihoc) { if (ModelState.IsValid) { kihoc.id_NAMHOC = (int)Session["id_namhoc"]; db.KIHOCs.Add(kihoc); db.SaveChanges(); //để cập nhật lại năm học đã nhập đủ điểm 3 kì List <KIHOC> diemnamhoc = db.KIHOCs.Where(n => n.id_NAMHOC == kihoc.id_NAMHOC).ToList(); if (diemnamhoc.Count > 0 && diemnamhoc.Count == 3) { NAMHOC namhoc = db.NAMHOCs.Find(kihoc.id_NAMHOC); namhoc.Status = true; db.Entry(namhoc).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(Json(kihoc, JsonRequestBehavior.AllowGet)); } return(Json(kihoc, JsonRequestBehavior.AllowGet)); }
private void btnDelete_Click(object sender, EventArgs e) { NAMHOC _deleteTerm = frmLogin._database.NAMHOCs.Single(p => p.manh == txtID.Text); DialogResult _dialogResult = MessageBox.Show("Do you want to delete term " + txtID.Text + "?", "Confirm", MessageBoxButtons.YesNo); if (_dialogResult == DialogResult.Yes) { try { frmLogin._database.NAMHOCs.DeleteOnSubmit(_deleteTerm); frmLogin._database.SubmitChanges(); } catch (Exception Ex) { MessageBox.Show(Ex.Message); } finally { dGVTermLoadData(); } } }
public JsonResult SaveDiem3Ky(KIHOC diemKyI, KIHOC diemKyII, KIHOC diemKyCN) { if (ModelState.IsValid) { diemKyI.id_NAMHOC = (int)Session["id_namhoc"]; db.KIHOCs.Add(diemKyI); diemKyII.id_NAMHOC = (int)Session["id_namhoc"]; db.KIHOCs.Add(diemKyII); diemKyCN.id_NAMHOC = (int)Session["id_namhoc"]; db.KIHOCs.Add(diemKyCN); db.SaveChanges(); //để cập nhật lại năm học đã nhập đủ điểm 3 kì List <KIHOC> diemnamhoc = db.KIHOCs.Where(n => n.id_NAMHOC == diemKyI.id_NAMHOC).ToList(); if (diemnamhoc.Count > 0 && diemnamhoc.Count == 3) { NAMHOC namhoc = db.NAMHOCs.Find(diemKyI.id_NAMHOC); namhoc.StatusNH = true; db.Entry(namhoc).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(Json("YES", JsonRequestBehavior.AllowGet)); } return(Json("NO", JsonRequestBehavior.AllowGet)); }
public ActionResult Suanamhoc(NAMHOC namhoc) { if (ModelState.IsValid) { int id_hs = 0; if (Session["id_hsDetail"] != null) { id_hs = (int)Session["id_hsDetail"]; } else { if (Session["id_HS"] != null) { id_hs = (int)Session["id_HS"]; } } db.Entry(namhoc).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); Session["chuyenTab"] = 5; return(RedirectToAction("DetailChung/" + id_hs, "HocSinh")); } return(View(db.NAMHOCs.Find(namhoc.id))); }
/// <summary> /// xóa một năm học khỏi database /// </summary> public void XoaNamHoc(NAMHOC namhoc) { DB.usp_DeleteNamhoc(namhoc.NAMHOC1); }
/// <summary> /// insert năm học vào database /// </summary> public void ThemNamHoc(NAMHOC namhoc) { DB.usp_InsertNamhoc(namhoc.NAMHOC1); }
public DiemKyHoc(NAMHOC nh, List <KIHOC> listKH) { this.Namhoc = nh; this.Lkihoc = listKH; }