以文本方式查看主题

-  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=11233)

--  作者:yyzlxc
--  发布时间:2011/7/14 10:35:00
--  [求助]添加可视化授权出错(已解决)

在管理项目中添加可视化授权出错,代码和截图如下,请各位老师帮助看看,谢谢!!

 

\'可视化授权
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("分组名 = \'" & _UserGroup & "\'" )
        If dr.IsNull("列名") Then
            Tables(dr("表名")).Visible = Not dr("不可见")
            Tables(dr("表名")).AllowEdit = Not dr("不可编辑")
        Else
            Tables(dr("表名")).Cols(dr("列名")).Visible = Not dr("不可见")
            Tables(dr("表名")).Cols(dr("列名")).AllowEdit = Not dr("不可编辑")
        End If
    Next
End If

 


此主题相关图片如下:a.png
按此在新窗口浏览图片

 

代码是添加到自定义用户登录窗口的"确定"按钮中。

[此贴子已经被作者于2011-7-14 11:31:58编辑过]

--  作者:狐狸爸爸
--  发布时间:2011/7/14 10:41:00
--  
你没有贴出完整的代码吧?
--  作者:lihe60
--  发布时间:2011/7/14 10:45:00
--  
自己找原因吧。
--  作者:lihe60
--  发布时间:2011/7/14 10:45:00
--  
提示很清楚的。
--  作者:yyzlxc
--  发布时间:2011/7/14 10:47:00
--  

谢谢狐爸老师,前段代码如下,上面的代码就贴在后面,按确定就出错,请狐爸老师帮助看看,谢谢!!

Dim UserName As String = e.Form.Controls("UserName").Value
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim dr As DataRow
cmd.C
If UserName = ""  Then
    Messagebox.show("请选择用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
End If
cmd.CommandText = "Select * From {Users} Where [Name] = \'" & UserName & "\'"
dt = cmd.ExecuteReader
dr = dt.DataRows(0)
If e.Form.Controls("PassWord").Value = dr("Password") Then
    _UserName = UserName
    _UserGroup = dr("Group")
    e.Form.Close
Else
    Messagebox.show("密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
\'非开发隐藏表标题
If _UserGroup <> "开发" Then
    TableCaptionVisible = False
Else
    TableCaptionVisible = True
End If
\'打开表返回最末行
With Tables("日报源表")
    .Position = .Rows.Count - 1
End With

 

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目120.zip


--  作者:banemon
--  发布时间:2011/7/14 10:48:00
--  
重新定义个变量就好了.
--  作者:狐狸爸爸
--  发布时间:2011/7/14 10:51:00
--  

For Each dr As DataRow In DataTables("授权表").Select("分组名 = \'" & _UserGroup & "\'" )

 

改为:

 

For Each dr In DataTables("授权表").Select("分组名 = \'" & _UserGroup & "\'" )

 

理由参考:

 

http://www.foxtable.net/help/topics/1518.htm

 


--  作者:lihe60
--  发布时间:2011/7/14 10:52:00
--  
以下是引用yyzlxc在2011-7-14 10:35:00的发言:

在管理项目中添加可视化授权出错,代码和截图如下,请各位老师帮助看看,谢谢!!

 

\'可视化授权
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("分组名 = \'" & _UserGroup & "\'" )
        If dr.IsNull("列名") Then
            Tables(dr("表名")).Visible = Not dr("不可见")
            Tables(dr("表名")).AllowEdit = Not dr("不可编辑")
        Else
            Tables(dr("表名")).Cols(dr("列名")).Visible = Not dr("不可见")
            Tables(dr("表名")).Cols(dr("列名")).AllowEdit = Not dr("不可编辑")
        End If
    Next
End If

 


此主题相关图片如下:a.png
按此在新窗口浏览图片

 

代码是添加到自定义用户登录窗口的"确定"按钮中。

[此贴子已经被作者于2011-7-14 10:37:53编辑过]

你也是老革命了,这个错误很好解决嘛。


--  作者:lihe60
--  发布时间:2011/7/14 10:55:00
--  
Dim dr As DataRow
For Each dr As DataRow In DataTables("授权表").Select("分组名 = \'" & _UserGroup & "\'" )
重复了。

--  作者:yyzlxc
--  发布时间:2011/7/14 11:17:00
--  

按照狐爸老师的方案,并把变量名改了重新定义,还是出错!代码和截图如下:

 

\'可视化授权
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

 

 


图片点击可在新窗口打开查看此主题相关图片如下:b.png
图片点击可在新窗口打开查看