1、项目属性的AfterOpenProject事件代码添加这一段:
For Each t As Table In Tables
t.Visible = False
t.AllowEdit = False
For Each c As Col In t.Cols
c.Visible = False
c.AllowEdit = False
Next
Next
'上面的代码用于打开系统后立即隐藏和禁止所有表、列
2、自定义函数"授权"代码:
For Each t As Table In Tables
t.Visible = False
t.AllowEdit = False
For Each c As Col In t.Cols
c.Visible = False
c.AllowEdit = False
Next
Next
'之所以加上前面这一段,才能实现打开系统后切换用户;
’下面是我根据系统自带的可视化授权扩展改编的授权表结构后的授权代码
Dim dr As DataRow = DataTables("用户管理").find("sys_部门设置 = '" & Vars("当前用户") & "'")
If dr IsNot Nothing
If dr("管理权限") = "超级管理员"
For Each t As Table In Tables
If left(t.name,4) <> "sys_"
t.Visible = True
t.AllowEdit = True
For Each c As Col In t.Cols
If left(c.name,4) <> "sys_"
c.Visible = True
c.AllowEdit = True
End If
Next
End If
Next
Return Nothing
End If
For Each dr In DataTables("sys_授权").Select("sys_部门设置 = '" & Vars("当前用户") & "' and 授权类别 = '表授权'","_SortKey")
If dr IsNot Nothing
If dr.IsNull("表名称") = False
Tables(dr("表名称")).Visible = True
Tables(dr("表名称")).AllowEdit = True
Dim Values() As String
If dr.IsNull("列名称") = False
Values = dr("列名称").split(",")
For Index As Integer = 0 To Values.Length - 1
Tables(dr("表名称")).cols(Values(Index)).Visible = dr("可视")
Tables(dr("表名称")).cols(Values(Index)).AllowEdit = dr("编辑")
Next
End If
End If
End If
Next
Else
MessageBox.show("对不起,系统没有对您授权,请联系系统管理员对您进行授权!")
End If
3、登录系统按钮的代码检测密码成功,所执行的代码的最后一行加上调用函数"表授权"的代码:
Functions.Execute("表授权")
注:授权表表结构改成了如下形式(您现在可以看到,我的授权表的第二、三行,程军仅可以对人事管理中的人员基本信息进行查看,仅对“工资等级”可以编辑,而这两行均包含了“工资等级”):
此主题相关图片如下:未命名.jpg

至于您的问题,根据上述思路摸索,实在再解决不了,我只有在看到您的示例文件后才可以判定和解决。