Foxtable(狐表)用户栏目专家坐堂 → 角色设置出错


  共有2857人关注过本帖树形打印复制链接

主题:角色设置出错

帅哥哟,离线,有人找我吗?
ss
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:94 积分:760 威望:0 精华:0 注册:2012/11/2 16:18:00
角色设置出错  发帖心情 Post By:2015/1/27 16:17:00 [只看该作者]

请教下各位大师,设计的权限出现错误,麻烦帮看下,开发密码888,其它123.

For Each t As Table In Tables

    t.Visible = False

    t.AllowEdit = False

    For Each c As Col In t.Cols

        c.Visible = False

        c.AllowEdit = False

    Next

Next

Dim roles As String = "'" & _UserGroup.Replace(",", "','") & "'"

Dim drs As List(Of DataRow) = DataTables("权限").Select("角色名 in (" & roles & ")")

For Each dr As DataRow In drs

    If dr.IsNull("列名") Then

        If Tables(dr("表名")).Visible = False Then

            Tables(dr("表名")).Visible = dr("可见")

        End If

        If Tables(dr("表名")).AllowEdit = False Then

            Tables(dr("表名")).AllowEdit = dr("可编辑")

        End If

    Else

        If Tables(dr("表名")).Cols(dr("列名")).Visible = False Then

            Tables(dr("表名")).Cols(dr("列名")).Visible = dr("可见")

        End If

        If Tables(dr("表名")).Cols(dr("列名")).AllowEdit = False Then

            Tables(dr("表名")).Cols(dr("列名")).AllowEdit  = dr("可编辑")

        End If

    End If

Next

 下载信息  [文件大小:   下载次数: ]
点击浏览该文件:管理项目11.foxdb


 回到顶部
帅哥哟,离线,有人找我吗?
Bin
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2015/1/27 16:25:00 [只看该作者]

你用的不是自定义用户管理

你为何用全局变量来判断呢

Dim roles As String = "'" & _UserGroup.Replace(",", "','") & "'"

这是不对的.

user.group才对.  而且没看懂你这个代码的意图?  你用户组是有多个的,这个方式?

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2015/1/27 16:32:00 [只看该作者]

If user.Type = UserTypeEnum.Developer = False Then
    For Each t As Table In Tables
        t.Visible = False
        t.AllowEdit = False
        For Each c As Col In t.Cols
            c.Visible = False
            c.AllowEdit = False
        Next
    Next
    If User.Roles <> Nothing Then
        Dim roles As String = "'" & User.Roles.Replace(",", "','") & "'"
        Dim drs As List(Of DataRow) = DataTables("权限").Select("角色名 in (" & roles & ")")
        For Each dr As DataRow In drs
            If dr.IsNull("列名") Then
                If Tables(dr("表名")).Visible = False Then
                    Tables(dr("表名")).Visible = dr("可见")
                End If
                If Tables(dr("表名")).AllowEdit = False Then
                    Tables(dr("表名")).AllowEdit = dr("可编辑")
                End If
            Else
                If Tables(dr("表名")).Cols(dr("列名")).Visible = False Then
                    Tables(dr("表名")).Cols(dr("列名")).Visible = dr("可见")
                End If
                If Tables(dr("表名")).Cols(dr("列名")).AllowEdit = False Then
                    Tables(dr("表名")).Cols(dr("列名")).AllowEdit  = dr("可编辑")
                End If
            End If
        Next
    End If
End If

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2015/1/27 16:34:00 [只看该作者]

If user.Type = UserTypeEnum.Developer Then
    For Each t As Table In Tables
        t.Visible = True
        t.AllowEdit = True
        For Each c As Col In t.Cols
            c.Visible = True
            c.AllowEdit = True
        Next
    Next
   
Else
    For Each t As Table In Tables
        t.Visible = False
        t.AllowEdit = False
        For Each c As Col In t.Cols
            c.Visible = False
            c.AllowEdit = False
        Next
    Next
    If User.Roles <> Nothing Then
        Dim roles As String = "'" & User.Roles.Replace(",", "','") & "'"
        Dim drs As List(Of DataRow) = DataTables("权限").Select("角色名 in (" & roles & ")")
        For Each dr As DataRow In drs
            If dr.IsNull("列名") Then
                If Tables(dr("表名")).Visible = False Then
                    Tables(dr("表名")).Visible = dr("可见")
                End If
                If Tables(dr("表名")).AllowEdit = False Then
                    Tables(dr("表名")).AllowEdit = dr("可编辑")
                End If
            Else
                If Tables(dr("表名")).Cols(dr("列名")).Visible = False Then
                    Tables(dr("表名")).Cols(dr("列名")).Visible = dr("可见")
                End If
                If Tables(dr("表名")).Cols(dr("列名")).AllowEdit = False Then
                    Tables(dr("表名")).Cols(dr("列名")).AllowEdit  = dr("可编辑")
                End If
            End If
        Next
    End If
End If

 回到顶部
帅哥哟,离线,有人找我吗?
ss
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:94 积分:760 威望:0 精华:0 注册:2012/11/2 16:18:00
  发帖心情 Post By:2015/1/27 17:01:00 [只看该作者]

甜老师输了没报错,但是看不见表是怎么一回事呢?

 回到顶部
帅哥哟,离线,有人找我吗?
Bin
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2015/1/27 17:02:00 [只看该作者]

权限问题.用开发者登录看

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2015/1/27 17:06:00 [只看该作者]

 看4楼代码。

 回到顶部
帅哥哟,离线,有人找我吗?
ss
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:94 积分:760 威望:0 精华:0 注册:2012/11/2 16:18:00
  发帖心情 Post By:2015/1/27 18:30:00 [只看该作者]

看不见列啊

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2015/1/27 19:09:00 [只看该作者]

If user.Type = UserTypeEnum.Developer Then
    For Each t As Table In Tables
        t.Visible = True
        t.AllowEdit = True
        For Each c As Col In t.Cols
            c.Visible = True
            c.AllowEdit = True
        Next
    Next
   
Else
    For Each t As Table In Tables
        t.Visible = False
        t.AllowEdit = False
        For Each c As Col In t.Cols
            c.Visible = False
            c.AllowEdit = False
        Next
    Next
    If User.Roles <> Nothing Then
        Dim roles As String = "'" & User.Roles.Replace(",", "','") & "'"
        Dim drs As List(Of DataRow) = DataTables("权限").Select("角色名 in (" & roles & ")")
        For Each dr As DataRow In drs
            If dr.IsNull("列名") Then
                If Tables(dr("表名")).Visible = False Then
                    Tables(dr("表名")).Visible = dr("可见")
                    For Each c As Col In Tables(dr("表名")).Cols
                        If c.Visible = False Then
                            c.Visible = dr("可见")
                        End If
                    Next
                End If
                If Tables(dr("表名")).AllowEdit = False Then
                    Tables(dr("表名")).AllowEdit = dr("可编辑")
                    For Each c As Col In Tables(dr("表名")).Cols
                        If c.AllowEdit = False
                            c.AllowEdit = dr("可编辑")
                        End If
                    Next
                End If
            Else
                If Tables(dr("表名")).Cols(dr("列名")).Visible = False Then
                    Tables(dr("表名")).Cols(dr("列名")).Visible = dr("可见")
                End If
                If Tables(dr("表名")).Cols(dr("列名")).AllowEdit = False Then
                    Tables(dr("表名")).Cols(dr("列名")).AllowEdit  = dr("可编辑")
                End If
            End If
        Next
    End If
End If

[此贴子已经被作者于2015-1-27 19:09:50编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
ss
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:94 积分:760 威望:0 精华:0 注册:2012/11/2 16:18:00
  发帖心情 Post By:2015/1/27 22:34:00 [只看该作者]

没注意看,随便设置权限问题,谢谢甜老师、Bin老师帅哥哟,离线,有人找我吗?

 回到顶部