Foxtable(狐表)用户栏目专家坐堂 → 用了可视化授权,又用了自定义用户与权限管理,可是可视化授权失效了,不知道改怎么改


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

主题:用了可视化授权,又用了自定义用户与权限管理,可是可视化授权失效了,不知道改怎么改

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


加好友 发短信
等级:一尾狐 帖子:445 积分:4777 威望:0 精华:0 注册:2010/4/11 14:09:00
用了可视化授权,又用了自定义用户与权限管理,可是可视化授权失效了,不知道改怎么改  发帖心情 Post By:2010/8/22 0:54:00 [只看该作者]

用了可视化授权的代码

 

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
Tables("授权表").Visible = (User.Type <> UserTypeEnum.User )
If User.Type = UserTypeEnum.User Then
    For Each dr As DataRow In DataTables("授权表").Select("分组名 = '" & User.Group & "'" )
        If dr.IsNull("列名") Then
            Tables(dr("表名")).Visible = Not dr("不可见")
            Tables(dr("表名")).AllowEdit = Not dr("不可编辑")
        Else
            Tables(dr("表名")).Cols(dr("列名")).Visible = Not dr("不可见")
            Tables(dr("表名")).Cols(dr("列名")).AllowEdit = Not dr("不可编辑")
        End If
    Next
End If

 

又用了帮助中的 自定义用户与权限管理

 

可是 可视化授权中的代码失效了,该怎么改啊?


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


加好友 发短信
等级:管理员 帖子:47448 积分:251054 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2010/8/23 8:28:00 [只看该作者]

帮助的自定义权限管理,定义了两个变量:

 

Public _UserName As String
Public _UserGroup As String

 

分别用于代替user.Name和user.group,至于user.Type则没有对应的变量,要么你自己自定义修改用户管理的代码,增加对应的设置和变量,要么修改一楼的代码,用_UserGroup代替User.Type.

代码是灵活的,关键要理解,才能融会贯通。


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


加好友 发短信
等级:幼狐 帖子:136 积分:1361 威望:0 精华:0 注册:2017/2/25 22:34:00
  发帖心情 Post By:2017/9/13 19:37:00 [只看该作者]

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
Tables("授权表").Visible = ( _UserGroup <> UserTypeEnum.User )
If User.Type = UserTypeEnum.User Then
    For Each dr As DataRow In DataTables("授权表").Select("分组名 = '" & User.Group & "'" )
        If dr.IsNull("列名") Then
            Tables(dr("表名")).Visible = Not dr("不可见")
            Tables(dr("表名")).AllowEdit = Not dr("不可编辑")
        Else
            Tables(dr("表名")).Cols(dr("列名")).Visible = Not dr("不可见")
            Tables(dr("表名")).Cols(dr("列名")).AllowEdit = Not dr("不可编辑") 
        End If
    Next
End If



我也遇到此问题,还没测试,不知道是不是上面改的可以?
[此贴子已经被作者于2017/9/13 19:38:16编辑过]

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


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

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
Tables("授权表").Visible = (_UserGroup <> "管理员分组")
If _UserGroup <> "管理员分组" Then
    For Each dr As DataRow In DataTables("授权表").Select("分组名 = '" & _UserGroup & "'" )
        If dr.IsNull("列名") Then
            Tables(dr("表名")).Visible = Not dr("不可见")
            Tables(dr("表名")).AllowEdit = Not dr("不可编辑")
        Else
            Tables(dr("表名")).Cols(dr("列名")).Visible = Not dr("不可见")
            Tables(dr("表名")).Cols(dr("列名")).AllowEdit = Not dr("不可编辑")
        End If
    Next
end if

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


加好友 发短信
等级:幼狐 帖子:136 积分:1361 威望:0 精华:0 注册:2017/2/25 22:34:00
  发帖心情 Post By:2017/9/14 9:38:00 [只看该作者]

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
Tables("用户授权表").Visible = (_UserGroup  <> UserTypeEnum.User )

If _UserGroup  = UserTypeEnum.User Then
    For Each dr As DataRow In DataTables("用户授权表").Select("姓名 = '" & _UserName & "'" )
MessageBox.Show("1")
        If dr.IsNull("受限列的名称") Then
            Tables(dr("受限表的名称")).Visible = Not dr("不可见")
            Tables(dr("受限表的名称")).AllowEdit = Not dr("不可编辑")
        Else
            Tables(dr("受限表的名称")).Cols(dr("受限列的名称")).Visible = Not dr("不可见")
            Tables(dr("受限表的名称")).Cols(dr("受限列的名称")).AllowEdit = Not dr("不可编辑") 
        End If
    Next
End If
判定用户名,是否这样改?代码没完全明白

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


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

直接写

 

r 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
 
    For Each dr As DataRow In DataTables("用户授权表").Select("姓名 = '" & _UserName & "'" )
MessageBox.Show("1")
        If dr.IsNull("受限列的名称") Then
            Tables(dr("受限表的名称")).Visible = Not dr("不可见")
            Tables(dr("受限表的名称")).AllowEdit = Not dr("不可编辑")
        Else
            Tables(dr("受限表的名称")).Cols(dr("受限列的名称")).Visible = Not dr("不可见")
            Tables(dr("受限表的名称")).Cols(dr("受限列的名称")).AllowEdit = Not dr("不可编辑") 
        End If
    Next
 

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


加好友 发短信
等级:幼狐 帖子:136 积分:1361 威望:0 精华:0 注册:2017/2/25 22:34:00
  发帖心情 Post By:2017/9/14 11:23:00 [只看该作者]

 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
        Tables("产品管理").Visible = True



For Each dr As DataRow In DataTables("用户授权表").Select("姓名 = '" & _UserName & "'" )
    
    If dr.IsNull("受限列的名称") Then
        Tables(dr("受限表的名称")).Visible = not dr("可见")
        Tables(dr("受限表的名称")).AllowEdit = not dr("可编辑")
    Else
        Tables(dr("受限表的名称")).Cols(dr("受限列的名称")).Visible = not dr("可见")
        Tables(dr("受限表的名称")).Cols(dr("受限列的名称")).AllowEdit =not  dr("可编辑")
    End If
Next

主要是不可见的内容太多,设置麻烦。想把设置不可见转变成可见
1、一进入就为全部不可见.根据授权表要求的可见可编辑的列,显示出来。
2、假如设置权限有不可见,不可编辑,更改为设置,只可见,只可编辑的话,如何对代码进行修改?上面这么改?

[此贴子已经被作者于2017/9/14 12:00:34编辑过]

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


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

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
For Each dr As DataRow In DataTables("用户授权表").Select("姓名 = '" & _UserName & "'" )
    If dr.IsNull("受限列的名称") Then
        Tables(dr("受限表的名称")).Visible = dr("可见")
        Tables(dr("受限表的名称")).AllowEdit = dr("可编辑")
    Else
        Tables(dr("受限表的名称")).Cols(dr("受限列的名称")).Visible = dr("可见")
        Tables(dr("受限表的名称")).Cols(dr("受限列的名称")).AllowEdit = dr("可编辑")
    End If
Next

 回到顶部