原来的项目是根据用户分组进行授权,现在打算按照角色来授权,将用户组改成角色,并将扩展列类型设置为多值字段,最后对代码应该如何修改,才能达到按照角色来授权的效果,请各位老师指教,谢谢!!
'按分组的可视化授权代码
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
Dim ds As DataRow
Tables("授权表").Visible = (User.Type <> UserTypeEnum.User )
If User.Type = UserTypeEnum.User Then
For Each ds In DataTables("授权表").Select("用户组 = '" & _UserGroup & "'" )
If ds.IsNull("列名") Then
Tables(ds("表名")).Visible = Not ds("不可见")
Tables(ds("表名")).AllowEdit = Not ds("不可编辑")
Else
Tables(ds("表名")).Cols(ds("列名")).Visible = Not ds("不可见")
Tables(ds("表名")).Cols(ds("列名")).AllowEdit = Not ds("不可编辑")
End If
Next
End If