Tables("授权表").Visible = True
Dim flag As Boolean = (User.Type <> UserTypeEnum.User)
For Each t As Table In Tables '显示所有表和列
t.Visible = flag
t.AllowEdit = flag
For Each c As Col In t.Cols
c.Visible = flag
c.AllowEdit = flag
Next
Next
If flag = False Then
DataTables("授权表").LoadFilter= "用户名 = '" & user.name & "'"
Else
DataTables("授权表").LoadFilter= ""
End If
DataTables("授权表").Load()
For Each dr As DataRow In DataTables("授权表").Select("用户名 = '" & User.Name & "'", "列名")
If Tables.Contains(dr("表名")) Then
Dim t As Table = Tables(dr("表名"))
If dr.IsNull("列名") Then
t.Visible = dr("可见")
t.AllowEdit = dr("可编辑")
If dr("可见") Then
For Each c As Col In t.Cols
c.Visible = True
c.AllowEdit = True
Next
End If
Else
If t.Cols.Contains(dr("列名")) Then
t.Cols(dr("列名")).Visible = dr("可见")
t.Cols(dr("列名")).AllowEdit = dr("可编辑")
End If
If dr("可见") OrElse dr("可编辑") Then
t.Visible = True
End If
End If
End If
Next