老师,我看视频教程,不分表也可以实现控件、表列权限,是用内表,我用内表试也可以,但外部数据源是实现控件权限,表列不行,分表也不行问题一:按你实例入库明细是在正表实现,副表偶尔是实现,我再做一个出库明细就不行,
问题二:我把控件、表列分表,控件是可以实现,表列是不实现,不知为什么?
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("用户名 = '" & _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
End If
'表权限授权
Tables("授权表").Visible = (User.Type <> UserTypeEnum.User)
If User.Type = UserTypeEnum.User Then
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
End If
'窗口按键权限--可视化授权-AfterLoad(打开窗口后的事件)--对窗口上-按键进行授权:
For Each dr3 As DataRow In DataTables("授权表").Select("用户名 = '" & _UserName & "' And 窗口按键名称= '" & e.Form.Name & "'")
e.Form.Controls(dr3("事件权限")).Visible = Not dr3("不可见")
e.Form.Controls(dr3("事件权限")).Enabled = Not dr3("不可编辑")
Next
'表列权限--可视化授权-AfterLoad(打开窗口后的事件)--对窗口上-按键进行授权:
'For Each dr1 As DataRow In DataTables("表权限授权").Select("用户名 = '" & _UserName & "' And 表名= '" & e.Form.Name & "'")
' e.Form.Controls(dr1("列名")).Visible = Not dr1("不可见")
' e.Form.Controls(dr1("列名")).Enabled = Not dr1("不可编辑")
'Next
Dim t As Table = Tables("入库查询_入库明细")
For Each dr1 As DataRow In DataTables("表权限授权").Select("用户名 = '" & _UserName & "' And 表名= '" & e.Form.Name & "'")
t.Cols(dr1("列名")).Visible = Not dr1("不可见")
t.Cols(dr1("列名")).AllowEdit = Not dr1("不可编辑")
Next