public JsonResult Add(pengajuan_cuti pengajuan_Cuti) { try { pengajuan_Cuti.karyawan_id = (int)Session["emp_id"]; pengajuan_Cuti.tgl_pengajuan = DateTime.Now; pengajuan_Cuti.status_approval1 = "Pending"; if (new[] { "Izin", "Setengah Hari", "Potong Gaji" }.Contains(pengajuan_Cuti.jenis_cuti)) { pengajuan_Cuti.status_approval2 = "Approved"; pengajuan_Cuti.tgl_approval1 = DateTime.Now; } else { pengajuan_Cuti.status_approval2 = "Pending"; } pengajuan_Cuti.date_created = DateTime.Now; db.pengajuan_cuti.Add(pengajuan_Cuti); db.SaveChanges(); return(Json("0", JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json("1", JsonRequestBehavior.AllowGet)); } }
public JsonResult Edit(LeaveApprovalViewModel approvalLeave) { var approval = db.pengajuan_cuti.Find(approvalLeave.pengajuan_cuti_id); approval.status_approval1 = approvalLeave.status_approval1; approval.tgl_approval1 = approvalLeave.tgl_approval1; approval.date_modified = DateTime.Now; if (TryUpdateModel(approvalLeave)) { try { db.SaveChanges(); return(Json("0", JsonRequestBehavior.AllowGet)); } catch (DataException) { return(Json("1", JsonRequestBehavior.AllowGet)); } } else { return(Json("1", JsonRequestBehavior.AllowGet)); } }
public ActionResult Register(user_login user_Login) { try { using (var db = new HRISContext()) { var chkUser = (from s in db.user_login where s.user_id == user_Login.user_id select s).FirstOrDefault(); if (chkUser == null) { var keyNew = PasswordHashHelper.GeneratePassword(10); var pass = PasswordHashHelper.EncodePassword(user_Login.password, keyNew); user_Login.password = pass; user_Login.vcode = keyNew; db.user_login.Add(user_Login); db.SaveChanges(); ModelState.Clear(); return(RedirectToAction("LogIn", "Login")); } ViewBag.ErrorMessage = "User Already Exixts!"; return(View()); } } catch (Exception e) { ViewBag.ErrorMessage = "Some exception occured" + e; return(View()); } }
public JsonResult Add(ref_gol_jabatan ref_Gol_Jabatan) { try { var check = db.ref_gol_jabatan.SingleOrDefault(m => m.gol_jabatan_id == ref_Gol_Jabatan.gol_jabatan_id); if (check == null) { db.ref_gol_jabatan.Add(ref_Gol_Jabatan); db.SaveChanges(); return(Json("0", JsonRequestBehavior.AllowGet)); } return(Json("1", JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json("2", JsonRequestBehavior.AllowGet)); } }
public JsonResult Add(ref_cctr cctr) { try { var check = db.ref_cctr.SingleOrDefault(m => m.cctr_id == cctr.cctr_id); if (check == null) { db.ref_cctr.Add(cctr); db.SaveChanges(); return(Json("0", JsonRequestBehavior.AllowGet)); } return(Json("1", JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json("2", JsonRequestBehavior.AllowGet)); } }
public JsonResult Add(ref_divisi _Divisi) { try { var check = db.ref_divisi.SingleOrDefault(m => m.nama_divisi == _Divisi.nama_divisi); if (check == null) { db.ref_divisi.Add(_Divisi); db.SaveChanges(); return(Json("0", JsonRequestBehavior.AllowGet)); } return(Json("1", JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json("2", JsonRequestBehavior.AllowGet)); } }
public ActionResult Create(karyawan karyawan) { try { if (ModelState.IsValid) { db.karyawan.Add(karyawan); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DbEntityValidationException e) { var newException = new FormattedDbEntityValidationException(e); //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(RedirectToAction("Index")); }
public ActionResult Create(user_login user_Login) { try { var check = (from s in db.user_login where s.user_id == user_Login.user_id select s).FirstOrDefault(); if (check == null) { var keyNew = PasswordHashHelper.GeneratePassword(10); var pass = PasswordHashHelper.EncodePassword(user_Login.user_id + DateTime.Now.Year.ToString(), keyNew); user_login _Login = new user_login { user_id = user_Login.user_id, password = pass, vcode = keyNew, role = user_Login.role, status = user_Login.status, date_created = DateTime.Now }; karyawan karyawan = new karyawan { user_id = _Login.user_id }; db.user_login.Add(_Login); db.karyawan.Add(karyawan); db.SaveChanges(); ModelState.Clear(); return(Json("0", JsonRequestBehavior.AllowGet)); } return(Json("1", JsonRequestBehavior.AllowGet)); } catch (DbEntityValidationException e) { return(Json("2", JsonRequestBehavior.AllowGet)); } }
public ActionResult LogOut() { var user_id = Session["user_id"].ToString(); using (HRISContext db = new HRISContext()) { var updateUserLogin = db.user_login.SingleOrDefault(m => m.user_id == user_id); updateUserLogin.last_login = DateTime.Now; db.user_login.Attach(updateUserLogin); db.Entry(updateUserLogin).Property(x => x.last_login).IsModified = true; db.SaveChanges(); } FormsAuthentication.SignOut(); Session.Abandon(); return(RedirectToAction("Index", "Home")); }
public JsonResult Add(hist_karyawan hist_Karyawan) { try { var user_id = Session["user_id"].ToString(); hist_Karyawan.created_by = user_id; hist_Karyawan.date_created = DateTime.Now; db.hist_karyawan.Add(hist_Karyawan); db.SaveChanges(); return(Json("0", JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json("2", JsonRequestBehavior.AllowGet)); } }