定义全局变量:
Public _UserName As String
Public _UserGroup As String
做好自定义登录界面后,想根据用户名设置权限代码如下:
教程上是表名和列名“不可编辑”我修改为“可编辑”不知道是否正确。
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 = dr("可编辑")
Else
Tables(dr("表名")).Cols(dr("列名")).Visible = Not dr("不可见")
Tables(dr("表名")).Cols(dr("列名")).AllowEdit = dr("可编辑")
End If
Next
End If
通过外部数据表做的授权表。但是设置授权后,发现并没有执行授权。请帮忙分析下问题。