// GET: HOCKies/Create public ActionResult Create() { HOCKY obj = new HOCKY(); obj.HK_MA = CreateID.CreateID_ByteText(); return(View(obj)); }
// Lấy hệ số public static int layHeSo(string maHK) { using (SQL_QLHSDataContext db = new SQL_QLHSDataContext()) { HOCKY hk = db.HOCKies.Where(a => a.MAHK == maHK).FirstOrDefault(); return(hk.HESO.Value); } }
public ActionResult DeleteConfirmed(string id) { HOCKY hOCKY = db.HOCKies.Find(id); db.HOCKies.Remove(hOCKY); db.SaveChanges(); return(RedirectToAction("Index")); }
// Sửa hệ số học kỳ public static void Update(string maHK, int heSo) { using (SQL_QLHSDataContext db = new SQL_QLHSDataContext()) { HOCKY hk = db.HOCKies.Where(a => a.MAHK == maHK).FirstOrDefault(); hk.HESO = heSo; db.SubmitChanges(); } }
public ActionResult Edit([Bind(Include = "HK_MA,HK_TEN")] HOCKY hOCKY) { if (ModelState.IsValid) { db.Entry(hOCKY).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hOCKY)); }
public ActionResult Create([Bind(Include = "HK_MA,HK_TEN")] HOCKY hOCKY) { if (ModelState.IsValid) { db.HOCKies.Add(hOCKY); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hOCKY)); }
// GET: HOCKies/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HOCKY hOCKY = db.HOCKies.Find(id); if (hOCKY == null) { return(HttpNotFound()); } return(View(hOCKY)); }
public List <HOCKY> GetAll() { List <HOCKY> hockys = new List <HOCKY>(); string query = "SELECT * FROM HOCKY"; DataTable data = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow item in data.Rows) { int HocKy = (int)item["HocKy"]; string NienKhoa = item["NienHoc"].ToString(); DateTime?NgayBatDau = item["NgayBatDau"].ToString() == string.Empty ? null : (DateTime?)item["NgayBatDau"]; DateTime?NgayKatThuc = item["NgayKetThuc"].ToString() == string.Empty ? null : (DateTime?)item["NgayKetThuc"]; HOCKY HK = new HOCKY(HocKy, NienKhoa, NgayBatDau, NgayKatThuc); hockys.Add(HK); } return(hockys); }
// Lấy tất cả các học kỳ public static List <HOCKY> LayTatCaHocKy() { List <HOCKY> lst = new List <HOCKY>(); using (SQL_QLHSDataContext db = new SQL_QLHSDataContext()) { var ds = db.HOCKies.ToList(); foreach (var x in ds) { HOCKY hocKy = new HOCKY(); { hocKy.MAHK = x.MAHK; hocKy.TENHOCKY = x.TENHOCKY; hocKy.HESO = x.HESO; lst.Add(hocKy); } } } return(lst); }