public ActionResult EditTechnicalTitle(string id) { IOccupationBLL bLL = new OccupationBLL(); TechnicalTitle technicalTitle = bLL.GetTechnicalTitleById(Convert.ToInt32(id)); Models.TechnicalTitle technicalTitleView = new Models.TechnicalTitle { Id = technicalTitle.Id, Name = technicalTitle.Name }; ViewData["technicalTitleView"] = technicalTitleView; return(View()); }
/// <summary> /// 控制器内部方法 /// </summary> /// <param name="id">通过id装载视图模型Staff</param> private void GetStaffById(string id) { IStaffBLL staffBLL = new StaffBLL(); IOrgBLL orgBLL = new OrgBLL(); IOccupationBLL occupationBLL = new OccupationBLL(); ISalaryBLL salaryBLL = new SalaryBLL(); Staff staff = staffBLL.GetStaffById(Convert.ToInt32(id)); Models.Staff staffView = new Models.Staff(); Type type = typeof(Models.Staff); Type modelType = typeof(Staff); var props = type.GetProperties(); foreach (var p in props) { if (modelType.GetProperty(p.Name) != null) { p.SetValue(staffView, modelType.GetProperty(p.Name).GetValue(staff)); } } ThirdOrg thirdOrg = orgBLL.GetThirdOrgById(staff.ThirdOrgId); SecondOrg secondOrg = orgBLL.GetSecondOrgById(thirdOrg.ParentOrgId); FirstOrg firstOrg = orgBLL.GetFirstOrgById(secondOrg.ParentOrgId); OccupationName occupationName = occupationBLL.GetOccupationNameById(staff.OccId); OccupationClass occupationClass = occupationBLL.GetOccupationClassById(occupationName.ClassId); SalaryStandard salaryStandard = salaryBLL.GetSalaryStandardById(staff.StandardId); TechnicalTitle technicalTitle = occupationBLL.GetTechnicalTitleById(staff.TechnicalTitleId); staffView.FirstOrg = new Models.FirstOrg { Id = firstOrg.Id, OrgLevel = firstOrg.OrgLevel, OrgName = firstOrg.OrgName }; staffView.SecondeOrg = new Models.SecondeOrg { Id = secondOrg.Id, OrgName = secondOrg.OrgName, OrgLevel = secondOrg.OrgLevel, ParentOrg = staffView.FirstOrg }; staffView.ThirdOrg = new Models.ThirdOrg { Id = thirdOrg.Id, ParentOrg = staffView.SecondeOrg, OrgLevel = thirdOrg.OrgLevel, OrgName = thirdOrg.OrgName }; staffView.OccupationClass = new Models.OccupationClass { Id = occupationClass.Id, Name = occupationClass.Name }; staffView.OccupationName = new Models.OccupationName { Id = occupationName.Id, Name = occupationName.Name, OccupationClass = staffView.OccupationClass }; staffView.SalaryStandard = new Models.SalaryStandard { Id = salaryStandard.Id, StandardName = salaryStandard.StandardName, Total = salaryStandard.Total }; staffView.TechnicalTitle = new Models.TechnicalTitle { Id = technicalTitle.Id, Name = technicalTitle.Name }; ViewData["staffView"] = staffView; //装载所有职称 List <Models.TechnicalTitle> list = new List <Models.TechnicalTitle>(); List <TechnicalTitle> tempList = occupationBLL.GetAllTechnicalTitle(); foreach (var tt in tempList) { Models.TechnicalTitle tempTechnicalTitle = new Models.TechnicalTitle { Id = tt.Id, Name = tt.Name }; list.Add(tempTechnicalTitle); } ViewData["tTitleList"] = list; //装载该职位的所有薪酬标准 List <SalaryStandard> standardList = salaryBLL.GetAllStandardByOccId(staff.OccId); List <Models.SalaryStandard> standardListView = new List <Models.SalaryStandard>(); foreach (var s in standardList) { Models.SalaryStandard tempStandard = new Models.SalaryStandard { Id = s.Id, StandardName = s.StandardName, Total = s.Total }; standardListView.Add(tempStandard); } ViewData["standardListView"] = standardListView; }