private ApplicationActionResult GetData() { _employeeID = GetIdFromUrl(); CheckPermissions(); _employeeDto = PageMethodsHelper.InvokeWebAPI <EmployeeDto>(WebAPIVariables.employee, "?id=" + _employeeID).FirstOrDefault(); _employeeMembershipDto = PageMethodsHelper.InvokeWebAPI <EmployeeMembershipDto>(WebAPIVariables.employeeMembership, "?id=" + _employeeID).FirstOrDefault(); _employeeSalaryDto = PageMethodsHelper.InvokeWebAPI <EmployeeSalaryDto>(WebAPIVariables.employeeSalary, "?id=" + _employeeID).FirstOrDefault(); _employeeContractDto = PageMethodsHelper.InvokeWebAPI <EmployeeContractDto>(WebAPIVariables.employeeContract, "?id=" + _employeeID).FirstOrDefault(); if (_employeeDto == null || _employeeMembershipDto == null || _employeeSalaryDto == null || _employeeContractDto == null) { throw new ApplicationLayerException("NoData", ErrorNumbers.MyPortalFinancesGetData, SessionUser.Id); } var cph = (ContentPlaceHolder)Master.Master.FindControl("MainContent"); ((Image)cph.FindControl("btn_Image")).ImageUrl = @"~\Content\ThumbnailEmployee\" + _employeeID + ".png"; return(new ApplicationActionResult() { Success = true }); }
/// <summary> /// 人事填报工资条-获取人员列表 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <EmployeeSalaryDto> GetAllEmployee(EmployeeSearchInput input) { var model = new EmployeeSalaryDto(); if (input.Year.HasValue == false) { input.Year = DateTime.Now.Year; } if (input.Month.HasValue == false) { input.Month = DateTime.Now.Month - 1; var set = _setting.FirstOrDefault(ite => ite.Name == "HR.Salary.Setting"); if (set == null) { throw new UserFriendlyException((int)ErrorCode.CodeValErr, "请先设置工资发放日期。"); } var setting = Newtonsoft.Json.JsonConvert.DeserializeObject <SalarySettingInput>(set.Value); var date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, setting.Day); if (DateTime.Now.Day <= date.Day) { input.Month = input.Month - 2; } } var query = _employeeRepository.GetAll(); if (string.IsNullOrWhiteSpace(input.SearchKey) == false) { query = query.Where(ite => ite.Name.Contains(input.SearchKey) || ite.Phone.Contains(input.SearchKey) || ite.Code.Contains(input.SearchKey)); } if (input.OrgId.HasValue) { var orgu = _userOrganizationUnitRepository.GetAll().Where(ite => ite.OrganizationUnitId == input.OrgId.Value).Select(ite => ite.UserId).ToList(); query = query.Where(ite => orgu.Contains(ite.UserId.Value)); } if (input.IsTemp.HasValue && input.IsTemp.Value) { query = query.Where(ite => ite.IsTemp == true); } var totalCount = query.Count(); var ret = query.OrderByDescending(r => r.LastModificationTime).PageBy(input).Select(ite => new EmployeeSalaryBillDto() { Name = ite.Name, EmployeeId = ite.Id, Month = input.Month.Value, Year = input.Year.Value, UserId = ite.UserId }).ToList(); foreach (var r in ret) { var s = _employeeSalaryBillRepository.FirstOrDefault(ite => ite.Year == DateTime.Now.Year && ite.Month == input.Month.Value && ite.EmployeeId == r.EmployeeId); if (s != null) { r.AccumulationFund = s.AccumulationFund; r.BaseSalary = s.BaseSalary; r.Deduction = s.Deduction; r.DeductionReason = s.DeductionReason; r.Id = s.Id; r.EndowmentInsurance = s.EndowmentInsurance; r.InjuryInsurance = s.InjuryInsurance; r.MaternityInsurance = s.MaternityInsurance; r.MedicalInsurance = s.MedicalInsurance; r.Month = s.Month; r.MonthBonus = s.MonthBonus; r.PreSalary = s.PreSalary; r.QuarterBonus = s.QuarterBonus; r.Salary = s.Salary; r.Tax = s.Tax; r.UnworkInsurance = s.UnworkInsurance; r.WorkBonus = s.WorkBonus; r.WorkSalary = s.WorkSalary; r.Year = s.Year; r.YearBonus = s.YearBonus; } if (r.UserId.HasValue) { var org = await(from a in _userOrganizationUnitRepository.GetAll() join b in _organizationUnitRepository.GetAll() on a.OrganizationUnitId equals b.Id where a.UserId == r.UserId.Value select new SimpleOrganizationDto() { Code = b.Code, Id = a.OrganizationUnitId, IsMain = a.IsMain, Title = b.DisplayName }).ToListAsync(); var post = from a in _postsRepository.GetAll() join b in _userPostsRepository.GetAll() on a.Id equals b.PostId join c in _organizationUnitPostsRepository.GetAll() on b.OrgPostId equals c.Id join d in _organizationUnitRepository.GetAll() on c.OrganizationUnitId equals d.Id where b.UserId == r.UserId.Value select new UserPostDto { Id = b.Id, OrgPostId = c.Id, PostId = a.Id, PostName = a.Name, OrgName = d.DisplayName }; r.Organization = org.ToList(); r.Posts = post.ToList(); } } model.Items = new PagedResultDto <EmployeeSalaryBillDto>(totalCount, ret); model.Year = input.Year.Value; model.Month = input.Month.Value; return(model); }
private ApplicationActionResult GetData() { _employeeID = GetIdFromUrl(); if (_employeeID == 0) { _employeeID = SessionUser.Id; lbl_EndDateContractLabel.Visible = false; lbl_EndDateContract.Visible = false; lbl_DateDismissalLabel.Visible = false; lbl_DateDismissal.Visible = false; } CheckPermissions(); _employeeDto = PageMethodsHelper.InvokeWebAPI <EmployeeDto>(WebAPIVariables.employee, "?id=" + _employeeID).FirstOrDefault(); _employeeMembershipDto = PageMethodsHelper.InvokeWebAPI <EmployeeMembershipDto>(WebAPIVariables.employeeMembership, "?id=" + _employeeID).FirstOrDefault(); _employeeSalaryDto = PageMethodsHelper.InvokeWebAPI <EmployeeSalaryDto>(WebAPIVariables.employeeSalary, "?id=" + _employeeID).FirstOrDefault(); _employeeContractDto = PageMethodsHelper.InvokeWebAPI <EmployeeContractDto>(WebAPIVariables.employeeContract, "?id=" + _employeeID).FirstOrDefault(); if (_employeeDto == null || _employeeMembershipDto == null || _employeeSalaryDto == null || _employeeContractDto == null) { throw new ApplicationLayerException("NoData", ErrorNumbers.MyPortalFinancesGetData, SessionUser.Id); } var cph = (ContentPlaceHolder)Master.Master.FindControl("MainContent"); var basic = @"~\Content\ThumbnailEmployee\"; var employeeImage = SessionUser.Id + ".png"; var emptyImage = "empty.png"; var dataFile = Server.MapPath(basic) + employeeImage; if (File.Exists(dataFile)) { ((Image)cph.FindControl("btn_Image")).ImageUrl = basic + employeeImage; } else { ((Image)cph.FindControl("btn_Image")).ImageUrl = basic + emptyImage; } ((Panel)cph.FindControl("pnl_Employee")).Visible = false; if (GetIdFromUrl() != 0) { employeeImage = _employeeID + ".png"; dataFile = Server.MapPath(basic) + employeeImage; if (File.Exists(dataFile)) { ((Image)cph.FindControl("btn_ImageEmployee")).ImageUrl = basic + employeeImage; } else { ((Image)cph.FindControl("btn_ImageEmployee")).ImageUrl = basic + emptyImage; } ((Panel)cph.FindControl("pnl_Employee")).Visible = true; ((Panel)cph.FindControl("pnl_MainEmployee")).Visible = false; } else { ((Panel)cph.FindControl("pnl_MainEmployee")).Visible = true; } return(new ApplicationActionResult() { Success = true }); }