public ActionResult PopUpSaldo(int id = 1) { saldo_awal saldo = new saldo_awal(); saldo = db.saldo_awal.Where(x => x.id_saldo == id).FirstOrDefault(); return(View(saldo)); }
public ActionResult PopUpSaldo(saldo_awal saldo) { try { saldo_awal saldoupdate = db.saldo_awal.Find(1); saldoupdate.default_inap = saldo.default_inap; saldoupdate.default_jalan = saldo.default_jalan; saldoupdate.default_kacamata = saldo.default_kacamata; db.Entry(saldoupdate).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, html = Global.RenderRazorViewToString(this, "ListRequestClaim", GetRequestClaim()), message = "Saldo Awal berhasil diubah" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Validate(user user, string returnUrl) { using (dbOpsModel db = new dbOpsModel()) { string email = Convert.ToString(user.email).ToUpper().Trim(); string pass = md5.encryption(user.password); //string pass = user.password; var userDetails = db.users.Where(x => x.email.ToUpper() == email && x.password == pass).FirstOrDefault(); if (userDetails == null) { ViewBag.msg = "<script>Swal.fire({ type: 'error', title: 'Login Gagal!', text: 'E-Mail atau Password salah'});</script>"; return(View("Index")); } else if (userDetails.status_kerja == "Tidak Aktif") { ViewBag.msg = "<script>Swal.fire({ type: 'error', title: 'Login Gagal!', text: 'Akun anda sudah dinon-aktifkan!'});</script>"; return(View("Index")); } else { FormsAuthentication.SetAuthCookie(user.email, false); Session["nik"] = userDetails.nik; Session["nama"] = userDetails.nama; Session["jabatan"] = userDetails.jabatan; if (userDetails.jabatan == "a" || userDetails.jabatan == "s") { return(RedirectToAction("Admin", "Login")); } else if (userDetails.jabatan == "k") { //renewal cuti cuti_user cek = db.cuti_user.Find(userDetails.nik); if (cek.valid_jatah <= DateTime.Today) { while (cek.valid_jatah <= DateTime.Today) { DateTime validdate2 = cek.valid_jatah; cek.valid_jatah = validdate2.AddYears(1); } DateTime validdate = cek.valid_jatah; if (cek.jatah_cuti > 0) { cek.sisa_cuti = cek.jatah_cuti; cek.jatah_cuti += 12; cek.jatah_cuti -= cek.sisa_cuti; cek.valid_sisa = validdate.AddMonths(6); } else { cek.jatah_cuti += 12; cek.valid_sisa = validdate.AddMonths(6); } } if (cek.valid_sisa <= DateTime.Today) { cek.sisa_cuti = 0; } db.Entry(cek).State = EntityState.Modified; db.SaveChanges(); //akhir renewal cuti //renewal saldo medical saldo_medical valid = db.saldo_medical.Find(userDetails.nik); saldo_awal saldoawal = db.saldo_awal.Find(1); if (valid.valid_rawat <= DateTime.Today) { valid.saldo_rawatinap = saldoawal.default_inap; valid.saldo_rawatjalan = saldoawal.default_jalan; if (valid.valid_rawat == userDetails.join_date.AddMonths(3)) { DateTime validdate = userDetails.join_date; valid.valid_rawat = validdate.AddYears(1); while (valid.valid_rawat <= DateTime.Today) { DateTime validdate2 = valid.valid_rawat; valid.valid_rawat = validdate2.AddYears(1); } } else { DateTime validdate = valid.valid_rawat; valid.valid_rawat = validdate.AddYears(1); } } if (valid.valid_kacamata <= DateTime.Today) { valid.saldo_kacamata = saldoawal.default_kacamata; if (valid.valid_kacamata == userDetails.join_date.AddMonths(3)) { DateTime validkacamata = userDetails.join_date; valid.valid_kacamata = validkacamata.AddYears(2); while (valid.valid_kacamata <= DateTime.Today) { DateTime validdate2 = valid.valid_kacamata; valid.valid_kacamata = validdate2.AddYears(2); } int tai = Convert.ToInt32(userDetails.join_date.Year); if (tai % 2 == 0) { DateTime validdate2 = valid.valid_kacamata; valid.valid_kacamata = validdate2.AddYears(1); } } else { DateTime validkacamata = valid.valid_kacamata; valid.valid_kacamata = validkacamata.AddYears(2); } } db.Entry(valid).State = EntityState.Modified; //end renewalmedical db.SaveChanges(); return(RedirectToAction("Karyawan", "Login")); } else { return(View("../Home/Index")); } } } }
public ActionResult RequestClaimK(claim_medical claim) { int id = Convert.ToInt32(Session["nik"]); saldo_medical ceksaldo = db.saldo_medical.Find(id); saldo_awal saldoawal = db.saldo_awal.Find(1); if (claim.total_tagihan < 0) { return(Json(new { success = false, message = "Total tagihan tidak boleh minus!" }, JsonRequestBehavior.AllowGet)); } if (claim.tanggal_perawatan > DateTime.Today) { return(Json(new { success = false, message = "Input tanggal tidak valid!" }, JsonRequestBehavior.AllowGet)); } if (claim.tipe_perawatan == "Rawat Inap") { var cekinap = db.claim_medical.Where(x => x.nik == id && x.status == "Request" && x.tipe_perawatan == "Rawat Inap").FirstOrDefault(); if (cekinap == null) { if (ceksaldo.saldo_rawatinap != 0) { claim.nik = Convert.ToInt32(Session["nik"]); claim.tanggal = DateTime.Today; claim.status = "Request"; claim.total_claim = 0; string fileName = Path.GetFileNameWithoutExtension(claim.filekwintasi.FileName); string extension = Path.GetExtension(claim.filekwintasi.FileName); fileName = fileName + claim.nik + DateTime.Now.ToString("yymmssffff") + extension; claim.file_kwintasi = "~/AppFiles/FileUser/" + fileName; claim.filekwintasi.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/FileUser/"), fileName)); db.claim_medical.Add(claim); db.SaveChanges(); return(Json(new { success = true, html = Global.RenderRazorViewToString(this, "ListRequestClaimK", GetRequestClaimK()), message = "Request claim medical rawat inap berhasil diajukan!" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Saldo claim rawat inap anda sudah habis " }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, message = "Harap tunggu, Request claim inap anda sebelumnya masih diproses" }, JsonRequestBehavior.AllowGet)); } } else if (claim.tipe_perawatan == "Rawat Jalan") { var cekjalan = db.claim_medical.Where(x => x.nik == id && x.status == "Request" && x.tipe_perawatan == "Rawat Jalan").FirstOrDefault(); if (cekjalan == null) { if (ceksaldo.saldo_rawatjalan != 0) { claim.nik = Convert.ToInt32(Session["nik"]); claim.tanggal = DateTime.Today; claim.status = "Request"; claim.total_claim = 0; string fileName = Path.GetFileNameWithoutExtension(claim.filekwintasi.FileName); string extension = Path.GetExtension(claim.filekwintasi.FileName); fileName = fileName + claim.nik + DateTime.Now.ToString("yymmssffff") + extension; claim.file_kwintasi = "~/AppFiles/FileUser/" + fileName; claim.filekwintasi.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/FileUser/"), fileName)); db.claim_medical.Add(claim); db.SaveChanges(); return(Json(new { success = true, html = Global.RenderRazorViewToString(this, "ListRequestClaimK", GetRequestClaimK()), message = "Request claim medical rawat jalan berhasil diajukan!" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Saldo claim rawat jalan anda sudah habis " }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, message = "Harap tunggu, Request claim jalan anda sebelumnya masih diproses" }, JsonRequestBehavior.AllowGet)); } } else { var cekkacamata = db.claim_medical.Where(x => x.nik == id && x.status == "Request" && x.tipe_perawatan == "Kacamata").FirstOrDefault(); if (cekkacamata == null) { saldo_medical cek = db.saldo_medical.Find(id); if (cek.saldo_kacamata == saldoawal.default_kacamata) { claim.nik = Convert.ToInt32(Session["nik"]); claim.tanggal = DateTime.Today; claim.status = "Request"; claim.total_claim = 0; string fileName = Path.GetFileNameWithoutExtension(claim.filekwintasi.FileName); string extension = Path.GetExtension(claim.filekwintasi.FileName); fileName = fileName + claim.nik + DateTime.Now.ToString("yymmssffff") + extension; claim.file_kwintasi = "~/AppFiles/FileUser/" + fileName; claim.filekwintasi.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/FileUser/"), fileName)); db.claim_medical.Add(claim); db.SaveChanges(); return(Json(new { success = true, html = Global.RenderRazorViewToString(this, "ListRequestClaimK", GetRequestClaimK()), message = "Request Claim Medical Berhasil Diajukan!" }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false, message = "Claim kacamata hanya bisa sekali dalam 2 tahun!" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Harap tunggu, Request claim kacamata anda sedang diproses" }, JsonRequestBehavior.AllowGet)); } } }