// GET: PersonnelDataSheet/Edit/5 public ActionResult Edit(int?id) { CountryDD(); BloodTypeDD(); CitizenshipDD(); CivilStatusDD(); GenderDD(); PrefixDD(); ReligionDD(); SuffixDD(); SupervisorsDD(); DepartmentDD(); DepartmentUnitDD(); AppointmentStatusDD(); PositionDD(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmpMasterProfile empMasterProfile = db.EmpMasterProfiles.Find(id); if (empMasterProfile == null) { return(HttpNotFound()); } return(View("Create", empMasterProfile)); }
public ActionResult DeleteConfirmed(int id) { EmpMasterProfile empMasterProfile = db.EmpMasterProfiles.Find(id); db.EmpMasterProfiles.Remove(empMasterProfile); db.SaveChanges(); return(RedirectToAction("Create")); }
// GET: PersonnelDataSheet/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmpMasterProfile empMasterProfile = db.EmpMasterProfiles.Find(id); if (empMasterProfile == null) { return(HttpNotFound()); } return(View(empMasterProfile)); }
public ActionResult Edit([Bind(Include = "empid,empNo,namePrefixTitleID,LastName,MiddleName,FirstName,nameSuffixTitleID,GenderID,ReligionID,street,BarangayID,MunicipalityID,ProvinceID,CountryID,zipCode,residentialPhoneNo,street2,BarangayID2,MunicipalityID2,ProvinceID2,CountryID2,zipCode2,residentialPhoneNo2,birthDate,birthPlace,CivilStatusID,CitizenshipID,Height,Weight,BloodTypeID,GSIS,HDMF,PhilHealth,SSS,TIN,LandLineNo,CellphoneNo,EmailAddress,YearsInService,MonthsInService,IsSupervisor,FirstApprover,SecondApprover,IsSeparated,DeptID,DepartmentUnitID,AppointmentStatusID,PositionID,DateHired,DateResigned,CurrentSalary,DisplayPicturePath,RegionID,RegionID2")] EmpMasterProfile empMasterProfile, HttpPostedFileBase File) { if (ModelState.IsValid) { if (File != null) { if (File.ContentLength > 0) { if ((Path.GetExtension(File.FileName).ToLower() == ".jpg") || (Path.GetExtension(File.FileName).ToLower() == ".jpeg") || (Path.GetExtension(File.FileName).ToLower() == ".png") || (Path.GetExtension(File.FileName).ToLower() == ".gif")) { WebImage img = new WebImage(File.InputStream); if ((img.Width > 180) || (img.Height > 190)) { img.Resize(190, 180); string extension = Path.GetExtension(File.FileName); string filename = empMasterProfile.FirstName + empMasterProfile.MiddleName + empMasterProfile.LastName + DateTime.Now.ToString("MMddyy") + extension; empMasterProfile.DisplayPicturePath = "~/Content/EmployeeProfileImages/" + filename; img.Save(empMasterProfile.DisplayPicturePath); filename = Path.Combine(Server.MapPath("~/Content/EmployeeProfileImages/"), filename); } else { string extension = Path.GetExtension(File.FileName); string filename = empMasterProfile.FirstName + empMasterProfile.MiddleName + empMasterProfile.LastName + DateTime.Now.ToString("MMddyy") + extension; empMasterProfile.DisplayPicturePath = "~/Content/EmployeeProfileImages/" + filename; filename = Path.Combine(Server.MapPath("~/Content/EmployeeProfileImages/"), filename); File.SaveAs(filename); } } } } db.Entry(empMasterProfile).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Create")); } return(View(empMasterProfile)); }
public ActionResult Create([Bind(Include = "empid,empNo,namePrefixTitleID,LastName,MiddleName,FirstName,nameSuffixTitleID,GenderID,ReligionID,street,BarangayID,MunicipalityID,ProvinceID,CountryID,zipCode,residentialPhoneNo,street2,BarangayID2,MunicipalityID2,ProvinceID2,CountryID2,zipCode2,residentialPhoneNo2,birthDate,birthPlace,CivilStatusID,CitizenshipID,Height,Weight,BloodTypeID,GSIS,HDMF,PhilHealth,SSS,TIN,LandLineNo,CellphoneNo,EmailAddress,YearsInService,MonthsInService,IsSupervisor,FirstApprover,SecondApprover,IsSeparated,DeptID,DepartmentUnitID,AppointmentStatusID,PositionID,DateHired,DateResigned,CurrentSalary,DisplayPicturePath,RegionID,RegionID2")] EmpMasterProfile empMasterProfile, HttpPostedFileBase File, string Create, string Edit, string empid) { CountryDD(); BloodTypeDD(); CitizenshipDD(); CivilStatusDD(); GenderDD(); PrefixDD(); ReligionDD(); SuffixDD(); SupervisorsDD(); DepartmentDD(); DepartmentUnitDD(); AppointmentStatusDD(); PositionDD(); var EmployeeName = empMasterProfile.FirstName + " " + empMasterProfile.MiddleName + " " + empMasterProfile.LastName; var EmployeeNameChecker = db.EmpMasterProfiles.FirstOrDefault(id => id.empid == empMasterProfile.empid); var EmpNameChecker = db.EmpMasterProfiles.Any(name => name.FirstName + " " + name.MiddleName + " " + name.LastName == EmployeeName); //var FullNameCheck = EmployeeNameChecker.FirstName + " " + EmployeeNameChecker.MiddleName + " " + EmployeeNameChecker.LastName; if (ModelState.IsValid) { if (File != null) { if ((File.ContentLength > 0 && empMasterProfile.DisplayPicturePath != null) || (File.ContentLength > 0 && empMasterProfile.DisplayPicturePath == null)) { if ((Path.GetExtension(File.FileName).ToLower() == ".jpg") || (Path.GetExtension(File.FileName).ToLower() == ".jpeg") || (Path.GetExtension(File.FileName).ToLower() == ".png") || (Path.GetExtension(File.FileName).ToLower() == ".gif")) { WebImage img = new WebImage(File.InputStream); if ((img.Width > 180) || (img.Height > 190)) { img.Resize(190, 180); string extension = Path.GetExtension(File.FileName); string filename = empMasterProfile.FirstName + empMasterProfile.MiddleName + empMasterProfile.LastName + DateTime.Now.ToString("MMddyy") + extension; empMasterProfile.DisplayPicturePath = "~/Content/EmployeeProfileImages/" + filename; img.Save(empMasterProfile.DisplayPicturePath); filename = Path.Combine(Server.MapPath("~/Content/EmployeeProfileImages/"), filename); } else { string extension = Path.GetExtension(File.FileName); string filename = empMasterProfile.FirstName + empMasterProfile.MiddleName + empMasterProfile.LastName + DateTime.Now.ToString("MMddyy") + extension; empMasterProfile.DisplayPicturePath = "~/Content/EmployeeProfileImages/" + filename; filename = Path.Combine(Server.MapPath("~/Content/EmployeeProfileImages/"), filename); File.SaveAs(filename); } } } } else if (File == null && empMasterProfile.DisplayPicturePath == null) { empMasterProfile.DisplayPicturePath = null; } if (Create != null) { if (EmpNameChecker == false) { db.EmpMasterProfiles.Add(empMasterProfile); db.SaveChanges(); return(RedirectToAction("Create")); } else { ModelState.AddModelError(string.Empty, "Employee " + EmployeeName + " has a saved data already! Please click update if you're trying to update a data."); return(View(empMasterProfile)); } } else if (Edit != null) { db.Set <EmpMasterProfile>().AddOrUpdate(empMasterProfile); db.SaveChanges(); return(RedirectToAction("Create")); } } return(View(empMasterProfile)); }