Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
在管理项目中添加可视化授权出错,代码和截图如下,请各位老师帮助看看,谢谢!!
'可视化授权
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
代码是添加到自定义用户登录窗口的"确定"按钮中。
谢谢狐爸老师,前段代码如下,上面的代码就贴在后面,按确定就出错,请狐爸老师帮助看看,谢谢!!
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
下载信息 [文件大小: 下载次数: ] | |
![]() |
For Each dr As DataRow In DataTables("授权表").Select("分组名 = '" & _UserGroup & "'" )
改为:
For Each dr In DataTables("授权表").Select("分组名 = '" & _UserGroup & "'" )
理由参考:
http://www.foxtable.net/help/topics/1518.htm
在管理项目中添加可视化授权出错,代码和截图如下,请各位老师帮助看看,谢谢!!
'可视化授权
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
代码是添加到自定义用户登录窗口的"确定"按钮中。
你也是老革命了,这个错误很好解决嘛。
按照狐爸老师的方案,并把变量名改了重新定义,还是出错!代码和截图如下:
'可视化授权
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