コード例 #1
0
        public JsonResult AddReqKKRJ(string txtjabatan, string txtAlamat)
        {
            cekSession();
            const string chars  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            Random       random = new Random();
            string       unique = new string(Enumerable.Repeat(chars, 4).Select(s => s[random.Next(s.Length)]).ToArray());
            string       nama   = sopace.personal_information.Where(e => e.NIP == nip).Select(e => e.nama_pegawai).FirstOrDefault();

            if (nama != null)
            {
                request req = new request();
                req.id_req          = "KKRJ-" + DateTime.Now.ToString("yyyy").ToString() + "-" + unique;
                req.NIP             = nip;
                req.nama_pegawai    = nama;
                req.tanggal_request = DateTime.Now;
                req.status          = "requested";
                sopace.requests.Add(req);
                sopace.SaveChanges();

                keterangan_kerja kk = new keterangan_kerja();
                kk.id_req  = req.id_req;
                kk.jabatan = txtjabatan;
                kk.alamat  = txtAlamat;
                sopace.keterangan_kerja.Add(kk);
                sopace.SaveChanges();
                return(Json("Insert Request Success", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("Insert Request Failed", JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public JsonResult EditKKRJ(string txtIDReq, string txtjabatan, string txtAlamat)
        {
            keterangan_kerja kk = sopace.keterangan_kerja.Where(e => e.id_req == txtIDReq).First();

            kk.jabatan             = txtjabatan;
            kk.alamat              = txtAlamat;
            sopace.Entry(kk).State = EntityState.Modified;
            sopace.SaveChanges();
            return(Json("Update Data Request Success", JsonRequestBehavior.AllowGet));
        }