以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  自定义用户后该如何设置权限!  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=45859)

--  作者:三人行必有我师
--  发布时间:2014/2/12 14:22:00
--  自定义用户后该如何设置权限!

定义全局变量:

 

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

 

通过外部数据表做的授权表。但是设置授权后,发现并没有执行授权。请帮忙分析下问题。


--  作者:Bin
--  发布时间:2014/2/12 14:28:00
--  
你应该判断外部数据源的用户名变量,否则你要

定义全局变量:

 

Public _UserName As String
Public
 _UserGroup As String

何用?


--  作者:三人行必有我师
--  发布时间:2014/2/12 14:41:00
--  

Public _UserName As String
Public
 _UserGroup As String

是开始自定义用户时,定义的2个全局变量!

 

现在授权功能设置完后,无法使用,我该如何设置!


--  作者:Bin
--  发布时间:2014/2/12 14:51:00
--  
不可能无法使用,如果你赋值了的话.

而且,你下面的代码,并没见你有使用啊,你用的还是系统内置的用户

--  作者:三人行必有我师
--  发布时间:2014/2/12 15:28:00
--  

我在项目属性设置权限后,代码如下:

If _UserName = "张三" Then
    DataTables
("库存").AllowEdit = True
Else
    DataTables
("库存").AllowEdit = False
End
If

 

 

这样设置后,为什么用张三的用户登录系统后,也无法编辑库存的数据呢?


--  作者:Bin
--  发布时间:2014/2/12 15:30:00
--  
1.你代码放在哪里?
2.你在这段代码之前弹出一下_Username的值看看是什么.

--  作者:三人行必有我师
--  发布时间:2014/2/12 15:36:00
--  

代码放在项目事件LoadUserSetting里。。

步骤2该如何操作啊,Bin老师!