示例#1
0
        public ActionResult Edit(visa visa, HttpPostedFileBase fileBase)
        {
            string serverfile;

            if (fileBase != null)
            {
                var           a        = db.master_file.Find(visa.emp_no);
                var           imgname  = System.IO.Path.GetFileName(fileBase.FileName);
                var           fileexe  = System.IO.Path.GetExtension(fileBase.FileName);
                DirectoryInfo filepath = new DirectoryInfo("D:/HR/img/visa/" + fileexe);
                serverfile = "D:/HR/img/visa/" + a.employee_no; /*+ "/"+ passport.employee_no + fileexe;*/
                filepath   = Directory.CreateDirectory(serverfile);
                int i = 0;
                do
                {
                    serverfile = "D:/HR/img/visa/" + a.employee_no + "/" + a.employee_no + "_" + i + fileexe;
                    i++;
                } while (System.IO.File.Exists(serverfile =
                                                   "D:/HR/img/visa/" + a.employee_no + "/" + a.employee_no + "_" + i + fileexe));

                fileBase.SaveAs(serverfile);
            }
            else
            {
                serverfile = null;
                var imglist = db.visas.ToList().FindAll(x => x.emp_no == visa.emp_no)
                              .OrderByDescending(x => x.date_changed).ToList();
                var imgpath1 = imglist.FindAll(c => c.imgpath != null);
                if (imgpath1.Count != 0)
                {
                    var imgpath = imglist.FindAll(c => c.imgpath != null).OrderByDescending(x => x.date_changed).First().imgpath;
                    serverfile = imgpath;
                }
            }

            if (ModelState.IsValid)
            {
                var img = new visa();
                img.file_no           = visa.file_no;
                img.place_of_issue    = visa.place_of_issue;
                img.accompanied_by    = visa.accompanied_by;
                img.rv_issue          = visa.rv_issue;
                img.sponsor           = visa.sponsor;
                img.uid_no            = visa.uid_no;
                img.emp_no            = visa.emp_no;
                img.rv_expiry         = visa.rv_expiry;
                img.proff_as_per_visa = visa.proff_as_per_visa;
                img.imgpath           = serverfile;
                img.changed_by        = User.Identity.Name;
                img.date_changed      = DateTime.Now;
                db.visas.Add(img);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.gender  = new SelectList(db.Tables, "gender", "gender");
            ViewBag.emp_no  = new SelectList(db.master_file, "employee_id", "employee_no");
            ViewBag.emp_no1 = new SelectList(db.master_file, "employee_id", "employee_name");
            return(View(visa));
        }
示例#2
0
        public JsonResult AddReqVisa(string txtnopass, string txtKeperluan)
        {
            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          = "VISA-" + 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();

                visa vs = new visa();
                vs.id_req      = req.id_req;
                vs.no_passport = txtnopass;
                vs.keperluan   = txtKeperluan;
                sopace.visas.Add(vs);
                sopace.SaveChanges();
                return(Json("Insert Request Success", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("Insert Request Failed", JsonRequestBehavior.AllowGet));
            }
        }
示例#3
0
        public ActionResult DeleteConfirmed(int id)
        {
            visa visa = db.visas.Find(id);

            db.visas.Remove(visa);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#4
0
        public JsonResult EditVisa(string txtIDReq, string txtnopass, string txtKeperluan)
        {
            visa vs = sopace.visas.Where(e => e.id_req == txtIDReq).First();

            vs.no_passport         = txtnopass;
            vs.keperluan           = txtKeperluan;
            sopace.Entry(vs).State = EntityState.Modified;
            sopace.SaveChanges();
            return(Json("Update Data Request Success", JsonRequestBehavior.AllowGet));
        }
示例#5
0
        private void addVisa_Click(object sender, EventArgs e)
        {
            visa v = new visa {
                date_of_issue = DateTime.Now, expirition_date = DateTime.Now
            };
            VisaForm visaForm = new VisaForm(v);

            visaForm.ShowDialog();
            client.visas.Add(v);
            setDGVDatasourse();
        }
示例#6
0
        private void visaDGV_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            ;
            visa     v        = visaDGV.Rows[e.RowIndex].DataBoundItem as visa;
            VisaForm visaForm = new VisaForm(v);

            visaForm.ShowDialog();
            setDGVDatasourse();
        }
示例#7
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            visa visa = db.visas.Find(id);

            if (visa == null)
            {
                return(HttpNotFound());
            }

            return(View(visa));
        }
示例#8
0
        public void TestMethod2()
        {
            //1 person, 2 wallets. wallet1= visa, disc. wallet2= mc. 100 balance each

            visa       visa1     = new visa("Visa", 100, visaRate);
            discover   discover1 = new discover("Discover", 100, discoverRate);
            mastercard mc2       = new mastercard("Mastercard", 100, mastercardRate);

            double visaInterest = visa1.simpleInterest();
            double mcInterest   = mc2.simpleInterest();
            double discInterest = discover1.simpleInterest();
            double totInterest  = visaInterest + mcInterest + discInterest;

            Assert.AreEqual(16, totInterest, DELTA);                 //total interest
            Assert.AreEqual(11, visaInterest + discInterest, DELTA); //wallet 1 interest
            Assert.AreEqual(5, mcInterest, DELTA);
        }
示例#9
0
        public void TestMethod1()
        {
            //1 person, 1 wallet. visa, mc, discover 100 balance each

            visa       visa1     = new visa("Visa", 100, visaRate);
            mastercard mc1       = new mastercard("Mastercard", 100, mastercardRate);
            discover   discover1 = new discover("Discover", 100, discoverRate);

            double visaInterest = visa1.simpleInterest();
            double mcInterest   = mc1.simpleInterest();
            double discInterest = discover1.simpleInterest();
            double totInterest  = visaInterest + mcInterest + discInterest;

            Assert.AreEqual(10, visaInterest, DELTA); //visa interest
            Assert.AreEqual(5, mcInterest, DELTA);    //mastercard interest
            Assert.AreEqual(1, discInterest, DELTA);  //discover interest
            Assert.AreEqual(16, totInterest, DELTA);  //total interest
        }
示例#10
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            visa visa = db.visas.Find(id);

            if (visa == null)
            {
                return(HttpNotFound());
            }

            ViewBag.gender  = new SelectList(db.Tables, "gender", "gender");
            ViewBag.emp_no  = new SelectList(db.master_file, "employee_id", "employee_no");
            ViewBag.emp_no1 = new SelectList(db.master_file, "employee_id", "employee_name");
            return(View(visa));
        }
示例#11
0
        public void TestMethod3()
        {
            //2 people 1 wallet each.
            //person 1 has mc and visa. person 2 has visa and mc.  100 balance all cards,

            mastercard mc1   = new mastercard("Mastercard", 100, mastercardRate);
            visa       visa1 = new visa("Visa", 100, visaRate);

            double mcInterest1   = mc1.simpleInterest();
            double visaInterest1 = visa1.simpleInterest();

            Assert.AreEqual(15, mcInterest1 + visaInterest1, DELTA);

            visa       visa2 = new visa("Visa", 100, visaRate);
            mastercard mc2   = new mastercard("Mastercard", 100, mastercardRate);

            double mcInterest2   = mc2.simpleInterest();
            double visaInterest2 = visa2.simpleInterest();

            Assert.AreEqual(15, mcInterest2 + visaInterest2, DELTA);
        }
示例#12
0
 public VisaForm(visa visa)
 {
     InitializeComponent();
     this.visa = visa;
     fillBoxes();
 }