public ActionResult Create(DayOff dayOff) { if (ModelState.IsValid) { var dao = new DayOffDao(); //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]; dayOff.CreatedBy = session.UserName; dayOff.CreatedDate = DateTime.Now; long id = dao.Insert(dayOff); if (id > 0) { SetAlert("Thêm xin nghỉ thành công", "success"); return(RedirectToAction("Index", "DayOff")); } else { ModelState.AddModelError("", "Nhân viên không tồn tại"); } } SetViewBag(); SetAlert("Error", "error"); return(RedirectToAction("Index", "DayOff")); }
public ActionResult Edit(int id) { var dayOff = new DayOffDao().ViewDetail(id); SetViewBag(); return(View(dayOff)); }
public ActionResult Index(string searchString, int page = 1, int pageSize = 10) { var session = (UserLogin)Session[CommonConstants.USER_SESSION]; var dao = new DayOffDao(); var model = dao.ListAllPaging(searchString, page, pageSize, session.DepartmentID); ViewBag.SearchString = searchString; return(View(model)); }
public ActionResult Edit(DayOff dayOff) { if (ModelState.IsValid) { var dao = new DayOffDao(); var session = (UserLogin)Session[CommonConstants.USER_SESSION]; long id = dao.Update(dayOff, session.UserName); if (id > 0) { SetAlert("Sửa thông tin nhân viên thành công", "success"); return(RedirectToAction("Index", "DayOff")); } else { SetAlert("Tài khoản hoặc mã nhân viên đã tồn tại!", "error"); return(RedirectToAction("Index", "DayOff")); } } SetViewBag(); SetAlert("Sửa thông tin nhân viên thất bại", "error"); return(RedirectToAction("Index", "DayOff")); }