public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } visa_and_labour_card visa_and_labour_card = db.visa_and_labour_card.Find(id); if (visa_and_labour_card == null) { return(HttpNotFound()); } ViewBag.gender = new SelectList(db.Tables, "gender", "gender"); var alist = this.db.master_file.OrderBy(e => e.employee_no).ToList(); var afinallist = new List <master_file>(); foreach (var file in alist) { if (afinallist.Count == 0) { afinallist.Add(file); } if (!afinallist.Exists(x => x.employee_no == file.employee_no)) { afinallist.Add(file); } } this.ViewBag.employee_no = new SelectList(afinallist, "employee_id", "employee_no"); ViewBag.emp_no1 = new SelectList(afinallist, "employee_id", "employee_name"); return(View(visa_and_labour_card)); }
// POST: visa_and_labour_card/Deledir public ActionResult DeleteConfirmed(int id) { visa_and_labour_card visa_and_labour_card = db.visa_and_labour_card.Find(id); db.visa_and_labour_card.Remove(visa_and_labour_card); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } visa_and_labour_card visa_and_labour_card = db.visa_and_labour_card.Find(id); if (visa_and_labour_card == null) { return(HttpNotFound()); } return(View(visa_and_labour_card)); }
public ActionResult Edit([Bind(Include = "id,lc_no,uid_no,emp_no,passport_no,company_code,nationality,person_code,class_type,rv_expiry,lc_expiry,passport_expiry,proff_as_per_visa")] visa_and_labour_card visa_and_labour_card, HttpPostedFileBase fileBase) { string serverfile; if (fileBase != null) { var a = db.master_file.Find(visa_and_labour_card.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_and_labour_card/" + fileexe); serverfile = "D:/HR/img/visa_and_labour_card/" + a.employee_no;/*+ "/"+ passport.employee_no + fileexe;*/ filepath = Directory.CreateDirectory(serverfile); int i = 0; do { serverfile = "D:/HR/img/visa_and_labour_card/" + a.employee_no + "/" + a.employee_no + "_" + i + fileexe; i++; } while (System.IO.File.Exists(serverfile = "D:/HR/img/visa_and_labour_card/" + a.employee_no + "/" + a.employee_no + "_" + i + fileexe)); fileBase.SaveAs(serverfile); } else { serverfile = null; } if (ModelState.IsValid) { var img = new visa_and_labour_card(); img.lc_no = visa_and_labour_card.lc_no; img.uid_no = visa_and_labour_card.uid_no; img.emp_no = visa_and_labour_card.emp_no; img.class_type = visa_and_labour_card.class_type; img.rv_expiry = visa_and_labour_card.rv_expiry; img.lc_expiry = visa_and_labour_card.lc_expiry; img.proff_as_per_visa = visa_and_labour_card.proff_as_per_visa; img.imgpath = serverfile; img.changed_by = User.Identity.Name; img.date_changed = DateTime.Now; db.visa_and_labour_card.Add(img); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.gender = new SelectList(db.Tables, "gender", "gender"); var alist = this.db.master_file.OrderBy(e => e.employee_no).ToList(); var afinallist = new List <master_file>(); foreach (var file in alist) { if (afinallist.Count == 0) { afinallist.Add(file); } if (!afinallist.Exists(x => x.employee_no == file.employee_no)) { afinallist.Add(file); } } this.ViewBag.employee_no = new SelectList(afinallist, "employee_id", "employee_no"); ViewBag.emp_no1 = new SelectList(afinallist.OrderBy(x => x.employee_name), "employee_id", "employee_name"); return(View(visa_and_labour_card)); }