예제 #1
0
        /**
         * 新增角色功能資料檔
         **/
        public int Insert(CODE_ROLE_FUNC roleFunc, SqlConnection conn, SqlTransaction transaction)
        {
            string     sql     = @"insert into CODE_ROLE_FUNC
        (ROLE_ID, SYS_CD, FUNC_ID, LAST_UPDATE_UID, LAST_UPDATE_DT)
        values (@ROLE_ID, @SYS_CD, @FUNC_ID, @LAST_UPDATE_UID, @LAST_UPDATE_DT)
        ";
            SqlCommand command = conn.CreateCommand();

            command.Connection  = conn;
            command.Transaction = transaction;

            try
            {
                command.CommandText = sql;
                command.Parameters.AddWithValue("@ROLE_ID", StringUtil.toString(roleFunc.ROLE_ID));
                command.Parameters.AddWithValue("@SYS_CD", StringUtil.toString(roleFunc.SYS_CD));
                command.Parameters.AddWithValue("@FUNC_ID", StringUtil.toString(roleFunc.FUNC_ID));
                command.Parameters.AddWithValue("@LAST_UPDATE_UID", StringUtil.toString(roleFunc.LAST_UPDATE_UID));
                command.Parameters.AddWithValue("@LAST_UPDATE_DT", DateTime.Now);

                int cnt = command.ExecuteNonQuery();

                return(cnt);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #2
0
        //        /// <summary>
        //        /// 以roleId為鍵項,查詢該角色擁有的功能
        //        /// </summary>
        //        /// <param name="roleId"></param>
        //        /// <returns></returns>
        //        public List<CODEROLEFUNCTION> getFuncRoleByRole(String roleId)
        //        {
        //            using (DbAccountEntities db = new DbAccountEntities())
        //            {
        //                List<CODEROLEFUNCTION> roleFunc = db.CODEROLEFUNCTION.Where(x => x.CROLEID == roleId).ToList();

        //                return roleFunc;
        //            }
        //        }


        /**
         * 刪除角色功能資料檔
         **/
        public int Delete(CODE_ROLE_FUNC roleFunc, SqlConnection conn, SqlTransaction transaction)
        {
            string     sql     = @"delete CODE_ROLE_FUNC
        where 1=1
        and ROLE_ID = @ROLE_ID and FUNC_ID = @FUNC_ID
        ";
            SqlCommand command = conn.CreateCommand();

            command.Connection  = conn;
            command.Transaction = transaction;

            try
            {
                command.CommandText = sql;
                command.Parameters.AddWithValue("@ROLE_ID", StringUtil.toString(roleFunc.ROLE_ID));
                command.Parameters.AddWithValue("@FUNC_ID", StringUtil.toString(roleFunc.FUNC_ID));

                int cnt = command.ExecuteNonQuery();

                return(cnt);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #3
0
        /// <summary>
        /// 處理角色功能異動
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="aplyNO"></param>
        /// <param name="conn"></param>
        /// <param name="transaction"></param>
        private void procRoleFuncHis(string roleId, string aplyNo, SqlConnection conn, SqlTransaction transaction)
        {
            CodeRoleFuncHisDao      codeRoleFuncHisDao = new CodeRoleFuncHisDao();
            List <RoleFuncHisModel> cRoleFuncList      = codeRoleFuncHisDao.qryByAplyNo(aplyNo);

            if (cRoleFuncList != null)
            {
                if (cRoleFuncList.Count > 0)
                {
                    CodeRoleFunctionDao roleFuncDao = new CodeRoleFunctionDao();

                    foreach (RoleFuncHisModel d in cRoleFuncList)
                    {
                        CODE_ROLE_FUNC dFunc = new CODE_ROLE_FUNC();
                        Log            log   = new Log();
                        switch (d.execAction)
                        {
                        case "A":
                            dFunc.ROLE_ID         = roleId;
                            dFunc.SYS_CD          = "TREASURY";
                            dFunc.FUNC_ID         = d.cFunctionID;
                            dFunc.LAST_UPDATE_UID = Session["UserID"].ToString();
                            dFunc.LAST_UPDATE_DT  = DateTime.Now;


                            //新增資料
                            roleFuncDao.Insert(dFunc, conn, transaction);


                            //新增LOG
                            log.CFUNCTION = "角色管理(功能授權)-新增";
                            log.CACTION   = "A";
                            log.CCONTENT  = roleFuncDao.logContent(dFunc);
                            LogDao.Insert(log, Session["UserID"].ToString());

                            break;

                        case "D":
                            dFunc = roleFuncDao.getFuncRoleByKey(roleId, d.cFunctionID);

                            //新增LOG
                            log.CFUNCTION = "角色管理(功能授權)-刪除";
                            log.CACTION   = "D";
                            log.CCONTENT  = roleFuncDao.logContent(dFunc);
                            LogDao.Insert(log, Session["UserID"].ToString());

                            //刪除資料
                            roleFuncDao.Delete(dFunc, conn, transaction);
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }
예제 #4
0
        /**
         * 將角色功能資料檔的各欄位組成一字串,for Log
         **/
        public String logContent(CODE_ROLE_FUNC roleFun)
        {
            String content = "";

            content += StringUtil.toString(roleFun.ROLE_ID) + '|';
            content += StringUtil.toString(roleFun.SYS_CD) + '|';
            content += StringUtil.toString(roleFun.FUNC_ID) + '|';
            content += StringUtil.toString(roleFun.LAST_UPDATE_UID) + '|';
            content += roleFun.LAST_UPDATE_DT;

            return(content);
        }
예제 #5
0
        public CODE_ROLE_FUNC getFuncRoleByKey(string roleId, string cFunctionID)
        {
            using (new TransactionScope(
                       TransactionScopeOption.Required,
                       new TransactionOptions
            {
                IsolationLevel = IsolationLevel.ReadUncommitted
            }))
            {
                using (dbTreasuryEntities db = new dbTreasuryEntities())
                {
                    CODE_ROLE_FUNC roleFunc = db.CODE_ROLE_FUNC.Where(x => x.ROLE_ID == roleId &&
                                                                      x.FUNC_ID == cFunctionID).FirstOrDefault();

                    return(roleFunc);
                }
            }
        }