public ActionResult Create(ThiSinh collection) { try { // TODO: Add insert logic here if (ModelState.IsValid) { byte[] imageData = null; HttpPostedFileBase poImgFile = Request.Files["fileim"]; if (poImgFile != null && poImgFile.ContentLength > 0) { using (var binary = new BinaryReader(poImgFile.InputStream)) { imageData = binary.ReadBytes(poImgFile.ContentLength); } } collection.Image = imageData; var ts = new ThiSinhData(); int id = ts.Insert(collection); if (id > 0) { return(RedirectToAction("Index", "ThiSinh")); } else { ModelState.AddModelError("", "Thêm thất bại"); } } return(View(collection)); } catch { return(View()); } }
public ActionResult Delete(int id, ThiSinh collection) { try { // TODO: Add delete logic here if (ModelState.IsValid) { var ts = new ThiSinhData(); var res = ts.Delete(id); if (res) { return(RedirectToAction("Index", "ThiSinh")); } else { ModelState.AddModelError("", "Xóa thất bại"); } } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Register(ThiSinh entity) { if (ModelState.IsValid) { var dao = new ThiSinhData(); var user = new ThiSinh(); user.GioiTinh = entity.GioiTinh; user.NgaySinh = entity.NgaySinh; user.DiaChi = entity.DiaChi; user.Image = entity.Image; user.Password = entity.Password; tn.SaveChanges(); if (dao.Insert(user) > 0) { ViewBag.Success = "Đăng ký thành công!"; entity = new ThiSinh(); } else { ModelState.AddModelError("", "Đăng ký không thành công!"); } } return(RedirectToAction("Index", "Login")); }
public ActionResult MaSinhVien() { ThiSinhData dt = new ThiSinhData(); var model = dt.ListThiSinh(); return(View(model)); }
// GET: Admin/ThiSinh public ActionResult Index() { ThiSinhData ts = new ThiSinhData(); var model = ts.ListThiSinh(); return(View(model)); }
// GET: Contest/Profile/Details/5 public ActionResult Details(int id) { ThiSinhData dt = new ThiSinhData(); var tan = dt.ListThiSinhID(id); ViewBag.ListKQ = tn.KetQuas.Where(x => x.MaThiSinh == id).ToList(); return(View(tan)); }
// GET: Admin/ThiSinh public ActionResult Index(string searchString, int page = 1, int pageSize = 3) { ThiSinhData ts = new ThiSinhData(); ViewBag.searchString = searchString; var model = ts.ListThiSinh(searchString, page, pageSize); return(View(model)); }
public ActionResult Edit(int id, ThiSinh collection) { try { // TODO: Add update logic here if (ModelState.IsValid) { byte[] imageData = null; HttpPostedFileBase poImgFile = Request.Files["fileim"]; if (poImgFile != null && poImgFile.ContentLength > 0) { using (var binary = new BinaryReader(poImgFile.InputStream)) { imageData = binary.ReadBytes(poImgFile.ContentLength); } collection.Image = imageData; var ts = new ThiSinhData(); var res = ts.Update(collection); if (res) { //return RedirectToAction("Details", "Profile"); return(RedirectToAction("Details", "Profile", new { area = "Contest", id = id })); } else { ModelState.AddModelError("", "Sửa thất bại"); } } else { byte[] tana = tn.ThiSinhs.Where(x => x.MaThiSinh == id).Select(u => u.Image).SingleOrDefault(); collection.Image = tana; var ts = new ThiSinhData(); var res = ts.Update(collection); if (res) { return(RedirectToAction("Details", "Profile", new { area = "Contest", id = id })); } else { ModelState.AddModelError("", "Sửa thất bại"); } } } //return RedirectToAction("Index"); return(RedirectToAction("Details", "Profile", new { area = "Contest", id = id })); } catch { return(View()); } }