public ActionResult Create(ViolatorKTV violatorKTV) { if (ModelState.IsValid) { var dao = new ViolatorKTVDao(); //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]; violatorKTV.CreatedBy = session.UserName; violatorKTV.CreatedDate = DateTime.Now; long id = dao.Insert(violatorKTV); if (id > 0) { SetAlert("Thêm chấm công nhân viên thành công", "success"); return(RedirectToAction("Index", "ViolatorKTV")); } else { ModelState.AddModelError("", "Thêm chấm nhân viên công không thành công"); } } SetViewBag(); SetAlert("Error", "error"); return(RedirectToAction("Index", "ViolatorKTV")); }
public long Update(ViolatorKTV entity, string username) { var violatorKTV = db.ViolatorKTVs.Find(entity.ID); violatorKTV.Employee_ID = entity.Employee_ID; violatorKTV.Tour = entity.Tour; violatorKTV.Fruit = entity.Fruit; violatorKTV.Description = entity.Description; //Ngày chỉnh sửa = Now violatorKTV.ModifiedBy = username; violatorKTV.ModifiedDate = DateTime.Now; db.SaveChanges(); return(entity.ID); }
public long Insert(ViolatorKTV entity) { int a = 0; string[] arrEmpId = string.Join(",", entity.SelectedIDArray).Replace(" ", "").Split(','); for (int i = 0; i < arrEmpId.Length; i++) { entity.Employee_ID = Int32.Parse(arrEmpId[i]); entity.TimeOut = entity.TimeIn.AddHours(12); db.ViolatorKTVs.Add(entity); db.SaveChanges(); a = 1; } return(a); }
public ActionResult Edit(ViolatorKTV violatorKTV) { if (ModelState.IsValid) { var dao = new ViolatorKTVDao(); var session = (UserLogin)Session[CommonConstants.USER_SESSION]; long id = dao.Update(violatorKTV, session.UserName); if (id > 0) { SetAlert("Sửa thông tin nhân viên thành công", "success"); return(RedirectToAction("Index", "ViolatorKTV")); } else { SetAlert("Tài khoản hoặc mã nhân viên đã tồn tại!", "error"); return(RedirectToAction("Index", "ViolatorKTV")); } } SetViewBag(); SetAlert("Sửa thông tin nhân viên thất bại", "error"); return(RedirectToAction("Index", "ViolatorKTV")); }