/// <summary> /// 根据用户UnitId判断是否为本单位用户或管理员 /// </summary> /// <returns></returns> public static bool IsThisUnitLeaderOrManage(string userId) { bool result = false; if (userId == Const.sysglyId || userId == Const.hfnbdId || userId == Const.sedinId) { result = true; } else { bool isRoleType = false; bool isThisUnit = false; var user = BLL.UserService.GetUserByUserId(userId); if (user != null && user.IsOffice == true) { var role = BLL.RoleService.GetRoleByRoleId(user.RoleId); if (role != null && (role.RoleType == "3" || role.RoleType == "2")) ////是管理、领导角色 { isRoleType = true; } var unit = UnitService.GetUnitByUnitId(user.UnitId); if (unit != null) { if (unit.IsThisUnit == true) { isThisUnit = true; } else { isThisUnit = false; } } } if (isRoleType && isThisUnit) { result = true; } } return(result); }
/// <summary> /// 根据用户UnitId判断是否为本单位用户或管理员 /// </summary> /// <returns></returns> public static bool IsMainUnitOrAdmin(string userId) { bool result = false; if (userId == Const.sysglyId || userId == Const.hfnbdId || userId == Const.sedinId) { result = true; } else { var user = UserService.GetUserByUserId(userId); if (user != null) { Model.Base_Unit unit = UnitService.GetUnitByUnitId(user.UnitId); if (unit != null && unit.IsThisUnit == true) { result = true; } } } return(result); }
/// <summary> /// 根据菜单id、项目id返回编码 (用于页面新增显示) /// </summary> /// <param name="menuId"></param> /// <param name="projectId"></param> /// <returns></returns> public static string ReturnCodeByMenuIdProjectId(string menuId, string projectId, string unitId) { string code = string.Empty; string ruleCodes = string.Empty; int digit = 4; string symbol = "-"; ///间隔符 var codeRecords = (from x in Funs.DB.Sys_CodeRecords where x.MenuId == menuId && x.ProjectId == projectId orderby x.CompileDate descending select x).FirstOrDefault(); if (codeRecords != null && !string.IsNullOrEmpty(codeRecords.RuleCodes)) { ruleCodes = codeRecords.RuleCodes; if (codeRecords.Digit.HasValue) { digit = codeRecords.Digit.Value; } } else { ////项目 string ruleCode = string.Empty; var project = ProjectService.GetProjectByProjectId(projectId); if (project != null) { string projectCode = project.ProjectCode; ///项目编号 ////编码规则表 var sysCodeTemplateRule = ProjectData_CodeTemplateRuleService.GetProjectData_CodeTemplateRuleByMenuIdProjectId(menuId, project.ProjectId); if (sysCodeTemplateRule != null) { symbol = sysCodeTemplateRule.Symbol; if (sysCodeTemplateRule.Digit.HasValue) { digit = sysCodeTemplateRule.Digit.Value; } if (sysCodeTemplateRule.IsProjectCode == true) { ruleCode = projectCode + symbol; } if (!string.IsNullOrEmpty(sysCodeTemplateRule.Prefix)) { ruleCode += sysCodeTemplateRule.Prefix + symbol; } if (sysCodeTemplateRule.IsUnitCode == true) { var unit = UnitService.GetUnitByUnitId(unitId); if (unit != null) { ruleCode += unit.UnitCode + symbol; } } ruleCodes = ruleCode; } } else { var codeTempRule = Funs.DB.Sys_CodeTemplateRule.FirstOrDefault(x => x.MenuId == menuId); if (codeTempRule != null && !string.IsNullOrEmpty(codeTempRule.Prefix)) { if (!string.IsNullOrEmpty(codeTempRule.Symbol)) { symbol = codeTempRule.Symbol; } ruleCodes = codeTempRule.Prefix + symbol; if (codeTempRule.Digit.HasValue) { digit = codeTempRule.Digit.Value; } } } } ////获取编码记录表最大排列序号 int maxNewSortIndex = 0; var maxSortIndex = Funs.DB.Sys_CodeRecords.Where(x => (x.ProjectId == projectId || projectId == null) && x.MenuId == menuId).Select(x => x.SortIndex).Max(); if (maxSortIndex.HasValue) { maxNewSortIndex = maxSortIndex.Value; } maxNewSortIndex = maxNewSortIndex + 1; code = (maxNewSortIndex.ToString().PadLeft(digit, '0')); ///字符自动补零 if (!string.IsNullOrEmpty(ruleCodes)) { code = ruleCodes + code; } return(code); }
/// <summary> /// 保存专项检查明细项 /// </summary> /// <param name="newDetail"></param> public static void SaveCheckSpecialDetail(Model.CheckSpecialDetailItem newDetail) { if (!string.IsNullOrEmpty(newDetail.CheckSpecialId)) { Model.Check_CheckSpecialDetail newCheckSpecialDetail = new Model.Check_CheckSpecialDetail { CheckSpecialId = newDetail.CheckSpecialId, CheckItem = newDetail.CheckItemSetId, CheckItemType = newDetail.CheckItemSetName, Unqualified = newDetail.Unqualified, UnitId = newDetail.UnitId, HandleStep = newDetail.HandleStep, CompleteStatus = newDetail.CompleteStatus, RectifyNoticeId = newDetail.RectifyNoticeId, LimitedDate = Funs.GetNewDateTime(newDetail.LimitedDate), CompletedDate = Funs.GetNewDateTime(newDetail.CompletedDate), Suggestions = newDetail.Suggestions, WorkArea = newDetail.WorkArea, CheckArea = newDetail.WorkAreaId, CheckContent = newDetail.CheckContent, }; var getUnit = UnitService.GetUnitByUnitId(newDetail.UnitId); if (getUnit != null) { newCheckSpecialDetail.UnitId = newDetail.UnitId; } var updateDetail = Funs.DB.Check_CheckSpecialDetail.FirstOrDefault(x => x.CheckSpecialDetailId == newDetail.CheckSpecialDetailId); if (updateDetail == null) { newCheckSpecialDetail.CheckSpecialDetailId = SQLHelper.GetNewID(); Funs.DB.Check_CheckSpecialDetail.InsertOnSubmit(newCheckSpecialDetail); Funs.DB.SubmitChanges(); } else { newCheckSpecialDetail.CheckSpecialDetailId = updateDetail.CheckSpecialDetailId; updateDetail.CheckItem = newCheckSpecialDetail.CheckItem; updateDetail.CheckItemType = newCheckSpecialDetail.CheckItemType; updateDetail.Unqualified = newCheckSpecialDetail.Unqualified; updateDetail.UnitId = newCheckSpecialDetail.UnitId; updateDetail.HandleStep = newCheckSpecialDetail.HandleStep; updateDetail.CompleteStatus = newCheckSpecialDetail.CompleteStatus; updateDetail.RectifyNoticeId = newCheckSpecialDetail.RectifyNoticeId; updateDetail.LimitedDate = newCheckSpecialDetail.LimitedDate; updateDetail.CompletedDate = newCheckSpecialDetail.CompletedDate; updateDetail.Suggestions = newCheckSpecialDetail.Suggestions; updateDetail.WorkArea = newCheckSpecialDetail.WorkArea; updateDetail.CheckContent = newCheckSpecialDetail.CheckContent; Funs.DB.SubmitChanges(); } ////保存附件 if (!string.IsNullOrEmpty(newDetail.AttachUrl1)) { UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(newDetail.AttachUrl1, 10, null), newDetail.AttachUrl1, Const.ProjectCheckSpecialMenuId, newCheckSpecialDetail.CheckSpecialDetailId); } else { CommonService.DeleteAttachFileById(Const.ProjectCheckSpecialMenuId, newCheckSpecialDetail.CheckSpecialDetailId); } } }