Пример #1
0
 public JsonResult InsertCutiMassal(string[] CutiId, DateTime txtTglMulai, DateTime txtTglSelesai, string txtAlasan)
 {
     try
     {
         foreach (string id in CutiId)
         {
             personal_information pInfo = sopace.personal_information.Where(e => e.NIP == id).FirstOrDefault();
             const string         chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
             Random random = new Random();
             string unique = new string(Enumerable.Repeat(chars, 4).Select(s => s[random.Next(s.Length)]).ToArray());
             cuti   ct     = new cuti();
             ct.id_cuti          = "Cuti-" + DateTime.Now.Year + "-" + unique;
             ct.NIP              = id;
             ct.no_tlp           = pInfo.no_hp;
             ct.tgl_mulai_cuti   = txtTglMulai;
             ct.tgl_selesai_cuti = txtTglSelesai;
             ct.alasan_cuti      = txtAlasan;
             ct.alamat           = pInfo.alamat_identitas;
             sopace.cutis.Add(ct);
             sopace.SaveChanges();
         }
         return(Json("Input Success"));
     }
     catch (Exception e) {
         return(Json("Input Filed, please check your data input"));
     }
 }
Пример #2
0
        public ActionResult Details(int id = 0)
        {
            cuti cute = new cuti();

            if (id != 0)
            {
                cute = db.cutis.Find(id);
            }
            return(View(cute));
        }
Пример #3
0
        public JsonResult AddCuti(string txtNIP, string txtNoTlp, DateTime txtTglMulai, DateTime txtTglSelesai, string txtAlamat, string txtAlasan)
        {
            const string chars  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            Random       random = new Random();
            string       unique = new string(Enumerable.Repeat(chars, 4).Select(s => s[random.Next(s.Length)]).ToArray());
            cuti         ct     = new cuti();

            ct.id_cuti          = "Cuti-" + DateTime.Now.Year + "-" + unique;
            ct.NIP              = txtNIP;
            ct.no_tlp           = txtNoTlp;
            ct.tgl_mulai_cuti   = txtTglMulai;
            ct.tgl_selesai_cuti = txtTglSelesai;
            ct.alamat           = txtAlamat;
            ct.alasan_cuti      = txtAlasan;
            sopace.cutis.Add(ct);
            sopace.SaveChanges();
            return(Json("Insert Cuti Success"));
        }
Пример #4
0
 public ActionResult NewCuti(cuti cute)
 {
     try
     {
         var cutitit = db.cutis.Where(u => u.nik == cute.nik && ((u.durasi_awal >= cute.durasi_awal && u.durasi_awal <= cute.durasi_akhir) || (u.durasi_akhir <= cute.durasi_akhir && u.durasi_akhir >= cute.durasi_awal))).FirstOrDefault();
         if (cutitit != null)
         {
             return(Json(new { success = false, message = "Cuti sudah ada di hari yang sama!" }, JsonRequestBehavior.AllowGet));
         }
         cute.tanggal = DateTime.Today;
         cute.oleh    = Session["nama"].ToString();
         db.cutis.Add(cute);
         cuti_user cutis     = db.cuti_user.Find(cute.nik);
         int       totalhari = Convert.ToInt32((cute.durasi_akhir - cute.durasi_awal).TotalDays);
         totalhari += 1;
         if (totalhari <= 0)
         {
             return(Json(new { success = false, message = "Periksa kembali tanggal yang diinput!" }, JsonRequestBehavior.AllowGet));
         }
         if (cutis.sisa_cuti >= totalhari)
         {
             cutis.sisa_cuti -= totalhari;
         }
         else
         {
             cutis.jatah_cuti = (cutis.jatah_cuti + cutis.sisa_cuti) - totalhari;
             cutis.sisa_cuti  = 0;
         }
         db.Entry(cutis).State = EntityState.Modified;
         db.SaveChanges();
         return(Json(new { success = true, html = Global.RenderRazorViewToString(this, "RiwayatCuti", GetRiwayatCuti()), message = "Input Cuti Sukses!" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }