public ActionResult Edit(int?Id) { var province = locationRepository.GetProvinceList(); var StaffSocialInsurance = StaffSocialInsuranceRepository.GetvwStaffSocialInsuranceById(Id.Value); if (StaffSocialInsurance != null && StaffSocialInsurance.IsDeleted != true) { var model = new StaffSocialInsuranceViewModel(); AutoMapper.Mapper.Map(StaffSocialInsurance, model); var ProvinceSociety = province.FirstOrDefault(x => x.Name.Contains(StaffSocialInsurance.SocietyIssue == null ? "" : StaffSocialInsurance.SocietyIssue)); var ProvinceMedical = province.FirstOrDefault(x => x.Name.Contains(StaffSocialInsurance.MedicalIssue == null ? "" : StaffSocialInsurance.MedicalIssue)); model.ProvinceSociety = Convert.ToInt32(ProvinceSociety == null ? "0" : ProvinceSociety.Id); model.ProvinceMedical = Convert.ToInt32(ProvinceMedical == null ? "0" : ProvinceMedical.Id); if (model.CreatedUserId != Helpers.Common.CurrentUser.Id && Helpers.Common.CurrentUser.UserTypeId != 1) { TempData["FailedMessage"] = "NotOwner"; return(RedirectToAction("Index")); } if (string.IsNullOrEmpty(model.SocietyDefaultValue)) { model.SocietyDefaultValue = "0"; } if (string.IsNullOrEmpty(model.MedicalDefaultValue)) { model.MedicalDefaultValue = "0"; } return(View(model)); } if (Request.UrlReferrer != null) { return(Redirect(Request.UrlReferrer.AbsoluteUri)); } return(RedirectToAction("Index")); }
public ActionResult Detail(int?Id) { var StaffSocialInsurance = StaffSocialInsuranceRepository.GetAllViewStaffSocialInsuranceById(Id.Value); if (StaffSocialInsurance != null && StaffSocialInsurance.IsDeleted != true) { var path = Helpers.Common.GetSetting("Staff"); var filepath = System.Web.HttpContext.Current.Server.MapPath("~" + Helpers.Common.GetSetting("Staff")); var model = new StaffSocialInsuranceViewModel(); AutoMapper.Mapper.Map(StaffSocialInsurance, model); ////Staffs //var student = StaffsRepository.GetvwStaffsById(StaffSocialInsurance.StaffId.Value); //var staff = new StaffsViewModel(); //AutoMapper.Mapper.Map(student, model); if (model.CreatedUserId != Helpers.Common.CurrentUser.Id && Helpers.Common.CurrentUser.UserTypeId != 1) { TempData["FailedMessage"] = "NotOwner"; return(RedirectToAction("Index")); } //lấy hình if (!string.IsNullOrEmpty(model.ProfileImage)) { model.ProfileImagePath = path + model.ProfileImage; if (!System.IO.File.Exists(filepath + model.ProfileImage)) { model.ProfileImagePath = "/assets/img/no-avatar.png"; } else { model.ProfileImagePath = path + model.ProfileImage; } } else if (string.IsNullOrEmpty(model.ProfileImage)) //Đã có hình { model.ProfileImagePath = "/assets/img/no-avatar.png"; } return(View(model)); } if (Request.UrlReferrer != null) { return(Redirect(Request.UrlReferrer.AbsoluteUri)); } return(RedirectToAction("Index")); }
public ActionResult Edit(StaffSocialInsuranceViewModel model) { if (ModelState.IsValid) { if (Request["Submit"] == "Save") { var province = locationRepository.GetProvinceList(); var StaffSocialInsurance = StaffSocialInsuranceRepository.GetStaffSocialInsuranceById(model.Id); StaffSocialInsurance.ModifiedUserId = WebSecurity.CurrentUserId; StaffSocialInsurance.ModifiedDate = DateTime.Now; StaffSocialInsurance.MedicalCode = model.MedicalCode; StaffSocialInsurance.MedicalDefaultValue = Decimal.Parse(model.MedicalDefaultValue.Replace(",", "."), new CultureInfo("en-GB")); StaffSocialInsurance.MedicalStartDate = model.MedicalStartDate; StaffSocialInsurance.MedicalEndDate = model.MedicalEndDate; StaffSocialInsurance.MedicalIssue = model.ProvinceMedical != null?province.SingleOrDefault(n => n.Id == model.ProvinceMedical.Value.ToString()).Name : ""; StaffSocialInsurance.SocietyCode = model.SocietyCode; StaffSocialInsurance.SocietyDefaultValue = Decimal.Parse(model.SocietyDefaultValue.Replace(",", "."), new CultureInfo("en-GB")); StaffSocialInsurance.SocietyIssue = model.ProvinceSociety != null?province.SingleOrDefault(n => n.Id == model.ProvinceSociety.Value.ToString()).Name : ""; StaffSocialInsurance.SocietyStartDate = model.SocietyStartDate; StaffSocialInsurance.SocietyEndDate = model.SocietyEndDate; StaffSocialInsurance.StaffId = model.StaffId; StaffSocialInsurance.Note = model.Note; //Thông tin lương StaffSocialInsurance.TienLuong = string.IsNullOrEmpty(model.TienLuong) ? 0 : Decimal.Parse(model.TienLuong.Replace(",", "."), new CultureInfo("en-GB")); StaffSocialInsurance.PC_CV = string.IsNullOrEmpty(model.PC_CV) ? 0 : Decimal.Parse(model.PC_CV.Replace(",", "."), new CultureInfo("en-GB")); StaffSocialInsurance.PC_TNN = string.IsNullOrEmpty(model.PC_TNN) ? 0 : Decimal.Parse(model.PC_TNN.Replace(",", "."), new CultureInfo("en-GB")); StaffSocialInsurance.PC_TNVK = string.IsNullOrEmpty(model.PC_TNVK) ? 0 : Decimal.Parse(model.PC_TNVK.Replace(",", "."), new CultureInfo("en-GB")); StaffSocialInsurance.PC_Khac = string.IsNullOrEmpty(model.PC_Khac) ? 0 : Decimal.Parse(model.PC_Khac.Replace(",", "."), new CultureInfo("en-GB")); StaffSocialInsuranceRepository.UpdateStaffSocialInsurance(StaffSocialInsurance); TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess; return(RedirectToAction("Index")); } return(View(model)); } return(View(model)); //if (Request.UrlReferrer != null) // return Redirect(Request.UrlReferrer.AbsoluteUri); //return RedirectToAction("Index"); }
public ViewResult Create() { var model = new StaffSocialInsuranceViewModel(); model.MedicalDefaultValue = "1.5"; model.MedicalCode = "000"; model.SocietyDefaultValue = "8"; model.SocietyCode = "000"; model.TienLuong = "0"; model.PC_CV = "0"; model.PC_TNN = "0"; model.PC_TNVK = "0"; model.PC_Khac = "0"; return(View(model)); }
public ActionResult Create(StaffSocialInsuranceViewModel model) { bool checkcode_medical = StaffSocialInsuranceRepository.GetAllStaffSocialInsurance().Any(n => !string.IsNullOrEmpty(n.MedicalCode) && n.MedicalCode.Equals(model.MedicalCode.Trim())); bool checkcode_social = StaffSocialInsuranceRepository.GetAllStaffSocialInsurance().Any(n => !string.IsNullOrEmpty(n.SocietyCode) && n.SocietyCode.Equals(model.SocietyCode.Trim())); string fail = ""; if (checkcode_medical) { fail = "Mã bảo hiểm y tế đã được cấp"; } if (checkcode_social) { if (!string.IsNullOrEmpty(fail)) { fail = fail + " và Mã bảo hiểm xã hội đã được cấp"; } else { fail = "Mã bảo hiểm xã hội đã được cấp"; } } if (!string.IsNullOrEmpty(fail)) { ViewBag.FailedMessage = fail; return(View(model)); } if (ModelState.IsValid) { var province = locationRepository.GetProvinceList(); var StaffSocialInsurance = new StaffSocialInsurance(); StaffSocialInsurance.IsDeleted = false; StaffSocialInsurance.CreatedUserId = WebSecurity.CurrentUserId; StaffSocialInsurance.ModifiedUserId = WebSecurity.CurrentUserId; StaffSocialInsurance.AssignedUserId = WebSecurity.CurrentUserId; StaffSocialInsurance.CreatedDate = DateTime.Now; StaffSocialInsurance.ModifiedDate = DateTime.Now; if (!string.IsNullOrEmpty(model.MedicalCode)) { StaffSocialInsurance.MedicalCode = model.MedicalCode.Trim(); StaffSocialInsurance.MedicalDefaultValue = Decimal.Parse(model.MedicalDefaultValue.Replace(",", "."), new CultureInfo("en-GB")); StaffSocialInsurance.MedicalStartDate = model.MedicalStartDate; StaffSocialInsurance.MedicalEndDate = model.MedicalEndDate; StaffSocialInsurance.MedicalIssue = model.ProvinceMedical != null?province.SingleOrDefault(n => n.Id == model.ProvinceMedical.Value.ToString()).Name : ""; } else { StaffSocialInsurance.MedicalDefaultValue = 0; } if (!string.IsNullOrEmpty(model.SocietyCode)) { StaffSocialInsurance.SocietyCode = model.SocietyCode.Trim(); StaffSocialInsurance.SocietyDefaultValue = Decimal.Parse(model.SocietyDefaultValue.Replace(",", "."), new CultureInfo("en-GB")); StaffSocialInsurance.SocietyIssue = model.ProvinceSociety != null?province.SingleOrDefault(n => n.Id == model.ProvinceSociety.Value.ToString()).Name : ""; StaffSocialInsurance.SocietyStartDate = model.SocietyStartDate; StaffSocialInsurance.SocietyEndDate = model.SocietyEndDate; } else { StaffSocialInsurance.MedicalDefaultValue = 0; } //Thông tin lương StaffSocialInsurance.TienLuong = string.IsNullOrEmpty(model.TienLuong) ? 0 : Decimal.Parse(model.TienLuong.Replace(",", "."), new CultureInfo("en-GB")); StaffSocialInsurance.PC_CV = string.IsNullOrEmpty(model.PC_CV) ? 0 : Decimal.Parse(model.PC_CV.Replace(",", "."), new CultureInfo("en-GB")); StaffSocialInsurance.PC_TNN = string.IsNullOrEmpty(model.PC_TNN) ? 0 : Decimal.Parse(model.PC_TNN.Replace(",", "."), new CultureInfo("en-GB")); StaffSocialInsurance.PC_TNVK = string.IsNullOrEmpty(model.PC_TNVK) ? 0 : Decimal.Parse(model.PC_TNVK.Replace(",", "."), new CultureInfo("en-GB")); StaffSocialInsurance.PC_Khac = string.IsNullOrEmpty(model.PC_Khac) ? 0 : Decimal.Parse(model.PC_Khac.Replace(",", "."), new CultureInfo("en-GB")); StaffSocialInsurance.StaffId = model.StaffId; StaffSocialInsurance.Note = model.Note; StaffSocialInsurance.Status = StatusSocialInsurance.DangHoatDong.GetName(); StaffSocialInsuranceRepository.InsertStaffSocialInsurance(StaffSocialInsurance); TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess; return(RedirectToAction("Index")); } return(View(model)); }