public ActionResult Create(Violator violator) { if (ModelState.IsValid) { var dao = new ViolatorDao(); //lấy id trong session đăng nhập của quản trị lưu vào phiên tạo mới user var session = (UserLogin)Session[CommonConstants.USER_SESSION]; violator.CreatedBy = session.UserName; violator.CreatedDate = DateTime.Now; long id = dao.Insert(violator); if (id > 0) { SetAlert("Thêm chấm công nhân viên thành công", "success"); return(RedirectToAction("Index", "Violator")); } else { ModelState.AddModelError("", "Thêm chấm nhân viên công không thành công"); } } SetViewBag(); SetTypeBag(); SetAlert("Error", "error"); return(RedirectToAction("Index", "Violator")); }
public ActionResult Edit(int id) { var violator = new ViolatorDao().ViewDetail(id); SetViewBag(); SetTypeBag(); return(View(violator)); }
public ActionResult Index(string searchString, int page = 1, int pageSize = 10) { var session = (UserLogin)Session[CommonConstants.USER_SESSION]; var dao = new ViolatorDao(); var model = dao.ListAllPaging(searchString, page, pageSize, session.DepartmentID); ViewBag.SearchString = searchString; return(View(model)); }
public ActionResult Edit(Violator violator) { if (ModelState.IsValid) { var dao = new ViolatorDao(); var session = (UserLogin)Session[CommonConstants.USER_SESSION]; long id = dao.Update(violator, session.UserName); if (id > 0) { SetAlert("Sửa thông tin nhân viên thành công", "success"); return(RedirectToAction("Index", "Violator")); } else { SetAlert("Tài khoản hoặc mã nhân viên đã tồn tại!", "error"); return(RedirectToAction("Index", "Violator")); } } SetTypeBag(); SetViewBag(); SetAlert("Sửa thông tin nhân viên thất bại", "error"); return(RedirectToAction("Index", "Violator")); }
public void SetTypeBag(int?selectedId = null) { var dao = new ViolatorDao(); ViewBag.Type_ID = new SelectList(dao.ListAll(), "ID", "Type", selectedId); }