以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  可视化授权:同样代码,为何改为外部数据源就无效呢?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=33794)

--  作者:阿标
--  发布时间:2013/5/24 12:36: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

--  作者:zerov
--  发布时间:2013/5/24 13:20:00
--  
你的外部数据源用不用分组(User.Group),并且设定为全局代码没有?
--  作者:阿标
--  发布时间:2013/5/24 14:22:00
--  

我设了全局代码,我用的外部数据源是分组(User.Group)的!


--  作者:Bin
--  发布时间:2013/5/24 14:23:00
--  
一步步调试 弹出需要判断的值 看看是否正常获得.
--  作者:阿标
--  发布时间:2013/5/24 14:37:00
--  

我没有设到全局代码,只是在项目属性的项目事件LoadUserSetting中,加入如下代码:

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

我用的外部数据源是分组(User.Group)的!


--  作者:Bin
--  发布时间:2013/5/24 14:40:00
--  
一步步调试 弹出需要判断的值 看看是否正常获得.
然后分析为什么没有获得这个值.
如果代码之前是可以的,说明代码没问题.反复发代码也没用.


如果确保都能正常获得值,再来分析代码是否有问题.