以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]锁定列问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=180852) |
-- 作者:18107532666 -- 发布时间:2022/10/18 10:48:00 -- [求助]锁定列问题 以下为不同用户控制锁定列的代码,我以前的软件都好用,最近几天编的软件不起作用了,只是现在其中用了一个折叠表。但是不是折叠表的窗口表也不起用 \'因为要进入窗口状态显示,所以软件打开时所有表都要隐藏不可见和不可编辑 For Each t1 As Table In Tables \'把表名称循环出来为t t1.Visible = False
\'所有表隐藏 For Each c1 As Col
In t1.Cols \'循环出所有列为c c1.Visible =
False \'所有列不可见 c1.AllowEdit =
False \'所有列不可编辑 Next Next Forms("登录窗口").Show() \'开始打开登录窗口 Dim roles() As String = _userGroup.Split(",") \'定义roles()为数组
为用登录用户组,号分割 For Each role As String In roles \'定义role为roles() 用户组中字符串 Dim drs1 As
List(Of DataRow) = DataTables("权限").Select("可见 = \'" &
role & "\' or 可见 like \'" & role & ",*\' or 可见 like
\'*," & role & ",*\' Or 可见 like \'*," & role &
"\'") \'drs为行的集合 权限表中可见符合条件的用户组名 For Each dr1 As
DataRow In drs1 \'在符合条件用户组中循环 If
dr1.Isnull("表名") AndAlso dr1.Isnull("列名") Then \'如果登录用户组当前行的表名为空和列名同时为空则 For Each
t1 As Table In Tables \'\'把空表名称循环出来为t
t1.Visible = True \'所有表显示 Next Else If
dr1.isnull("列名") Then \'如果列名为空则
Tables(dr1("表名")).Visible = True \'表显示 For Each c1 As
Col In Tables(dr1("表名")).Cols \'循环出所有空列为c c1.Visible
= True \'所有列可见 Next Else
Tables(dr1("表名")).Visible = True \'相当于列名不为空时显示表名 For Each c1 As Col In Tables(dr1("表名")).Cols
\'循环出所有表名列为c If dr1("列名") = c1.name OrElse dr1("列名") Like c1.name & ",*" OrElse dr1("列名") Like "*," & c1.name &
",*" OrElse dr1("列名")
Like "*," & c1.name Then c1.Visible = True End If Next End If Next drs1 =
DataTables("权限").Select("可编辑 = \'" & role & "\'
or 可编辑 like \'" & role & ",*\' or 可编辑 like \'*," & role
& ",*\' Or 可编辑 like \'*," & role & "\'")\'包含登陆名的行表成集合 For Each dr1 As
DataRow In drs\'有登陆名的行循环 If
dr1.Isnull("表名") AndAlso dr1.Isnull("列名") Then\'如果表名与列名为空 For Each
t1 As Table In Tables\'t在所有表中循环
t1.Visible = True\'t表可见
t1.AllowEdit = True\'t表可编辑 Next Else If
dr1.isnull("列名") Then\'如果列名为空
Tables(dr1("表名")).Visible = True\'表名可见 For Each c1 As
Col In Tables(dr1("表名")).Cols \'t在所有表中的列循环 c1.Visible
= True\'列可见
c1.AllowEdit = True\'列可编辑 Next Else
Tables(dr1("表名")).Visible = True For Each c1 As Col In Tables(dr1("表名")).Cols If dr1("列名") = c1.name OrElse dr1("列名") Like c.name & ",*" OrElse
dr("列名") Like
"*," & c.name & ",*" OrElse dr("列名") Like "*," & c.name Then c1.Visible = True c1.AllowEdit = True End If Next End If Next TableCaptionVisible = False \'隐藏表标题 Forms("导航测一").Open() Forms("主窗口").Open() MainTable = Tables("首页") |
-- 作者:有点蓝 -- 发布时间:2022/10/18 10:57:00 -- 窗口表肯定不起作用的,因为窗口还没有打开。窗口表要另外处理,到窗口AfterLoad事件写代码控制窗口表的权限 |