/// <summary> /// 以鍵項查詢 /// </summary> /// <param name="codeType"></param> /// <param name="code"></param> /// <returns></returns> public SYS_CODE qryByKey(string codeType, string code) { dbTreasuryEntities context = new dbTreasuryEntities(); SYS_CODE sysCode = new SYS_CODE(); sysCode = context.SYS_CODE.Where(x => x.CODE_TYPE == codeType && x.CODE == code) .OrderBy(x => x.ISORTBY).FirstOrDefault(); return(sysCode); }
/// <summary> /// 開啟角色修改明細畫面 /// </summary> /// <param name="aplyNo"></param> /// <returns></returns> public ActionResult detailRole(string aplyNo, string roleId) { try { string execAction = ""; AuthApprDao AuthApprDao = new AuthApprDao(); AUTH_APPR authAppr = new AUTH_APPR(); if (!"".Equals(StringUtil.toString(aplyNo))) { authAppr = AuthApprDao.qryByKey(aplyNo); ViewBag.bView = "N"; } else { authAppr = AuthApprDao.qryByFreeRole(roleId); if (authAppr != null) { aplyNo = StringUtil.toString(authAppr.APLY_NO); } ViewBag.bView = "Y"; } AuthReviewRoleModel roleData = new AuthReviewRoleModel(); roleData.aplyNo = aplyNo; roleData.createUid = authAppr.CREATE_UID; OaEmpDao oaEmpDao = new OaEmpDao(); using (DB_INTRAEntities dbIntra = new DB_INTRAEntities()) { try { roleData.createUid = roleData.createUid == null ? "" : StringUtil.toString(oaEmpDao.qryByUsrId(roleData.createUid, dbIntra).EMP_NAME); } catch (Exception e) { } } roleData.createDt = authAppr.CREATE_DT.ToString(); roleData.roleName = ""; roleData.isDisabled = ""; roleData.memo = ""; roleData.roleNameB = ""; roleData.isDisabledB = ""; roleData.memoB = ""; CodeRoleHisDao CodeRoleHisDao = new CodeRoleHisDao(); CODE_ROLE_HIS codeRoleHis = CodeRoleHisDao.qryByAplyNo(aplyNo); if (codeRoleHis != null) { execAction = StringUtil.toString(codeRoleHis.EXEC_ACTION); } if ("".Equals(execAction)) { CodeRoleDao CodeRoleDao = new CodeRoleDao(); CODE_ROLE codeRole = new CODE_ROLE(); codeRole = CodeRoleDao.qryRoleByKey(authAppr.APPR_MAPPING_KEY); roleData.roleId = StringUtil.toString(codeRole.ROLE_ID); roleData.roleAuthType = StringUtil.toString(codeRole.ROLE_AUTH_TYPE); roleData.roleNameB = StringUtil.toString(codeRole.ROLE_NAME); roleData.isDisabledB = StringUtil.toString(codeRole.IS_DISABLED); roleData.memoB = StringUtil.toString(codeRole.MEMO); } else { roleData.roleId = StringUtil.toString(codeRoleHis.ROLE_ID); roleData.roleAuthType = StringUtil.toString(codeRoleHis.ROLE_AUTH_TYPE); if ("A".Equals(execAction)) { roleData.roleName = StringUtil.toString(codeRoleHis.ROLE_NAME); roleData.isDisabled = StringUtil.toString(codeRoleHis.IS_DISABLED); roleData.memo = StringUtil.toString(codeRoleHis.MEMO); } else { roleData.roleName = StringUtil.toString(codeRoleHis.ROLE_NAME); roleData.isDisabled = StringUtil.toString(codeRoleHis.IS_DISABLED); roleData.memo = StringUtil.toString(codeRoleHis.MEMO); roleData.roleNameB = StringUtil.toString(codeRoleHis.ROLE_NAME_B); roleData.isDisabledB = StringUtil.toString(codeRoleHis.IS_DISABLED_B); roleData.memoB = StringUtil.toString(codeRoleHis.MEMO_B); } } SysCodeDao sysCodeDao = new SysCodeDao(); SYS_CODE sysCode = new SYS_CODE(); sysCode = sysCodeDao.qryByKey("ROLE_AUTH_TYPE", StringUtil.toString(roleData.roleAuthType)); if (sysCode != null) { roleData.roleAuthTypeDesc = StringUtil.toString(sysCode.CODE_VALUE); } sysCode = sysCodeDao.qryByKey("IS_DISABLED", StringUtil.toString(roleData.isDisabledB)); if (sysCode != null) { roleData.isDisabledB = StringUtil.toString(sysCode.CODE_VALUE); } sysCode = sysCodeDao.qryByKey("IS_DISABLED", StringUtil.toString(roleData.isDisabled)); if (sysCode != null) { roleData.isDisabled = StringUtil.toString(sysCode.CODE_VALUE); } ViewBag.bHaveData = "Y"; ViewBag.aplyNo = aplyNo; return(View(roleData)); } catch (Exception e) { ViewBag.bHaveData = "N"; return(View()); } }