Foxtable(狐表)用户栏目专家坐堂 → [求助]锁定列问题


  共有4935人关注过本帖树形打印复制链接

主题:[求助]锁定列问题

帅哥哟,离线,有人找我吗?
18107532666
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:117 积分:1066 威望:0 精华:0 注册:2019/12/27 20:56:00
[求助]锁定列问题  发帖心情 Post By: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("首页")

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106603 积分:542186 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/10/18 10:57:00 [只看该作者]

窗口表肯定不起作用的,因为窗口还没有打开。窗口表要另外处理,到窗口AfterLoad事件写代码控制窗口表的权限

 回到顶部