以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]做成内部函数  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=146235)

--  作者:紫色幽魂
--  发布时间:2020/2/19 17:11:00
--  [求助]做成内部函数
我需要在每个窗口中都添加下面这段代码来设定窗口权限,能不能做成内部函数统一调用,需要怎么做

For Each c As Winform.Control In e.Form.Controls
    If c.Name.Contains("QX_")
        c.Enabled = False
        Dim dr As DataRow = DataTables("用户权限_窗口权限").Find("窗口名 = \'"& e.Form.Name &"\' and 控件名 = \'"& c.Name &"\'")
        If dr Is Nothing
            Dim zdr As DataRow = DataTables("用户权限_窗口权限").AddNew
            zdr("窗口名") = e.Form.Name
            zdr("控件名") = c.Name
        Else
            \'角色集合
            Dim js As String = _UserGroup
            Dim jh1 As new List(of String)
            jh1.AddRange(js.Split("|"))
            If jh1.Contains("管理员")
                Return
            End If
            \'权限中的角色集合
            Dim js2 As String = dr("角色")
            Dim jh2 As new List(of String)
            jh2.AddRange(js2.Split(","))
            For Each j1 As String In jh1
                For Each j2 As String In jh2
                    If j1 = j2
                        c.Enabled = True
                    End If
                Next
            Next
        End If
    End If
Next

--  作者:有点蓝
--  发布时间:2020/2/19 17:18:00
--  
函数abc

dim e  = args(0)
For Each c As Winform.Control In e.Form.Controls
    If c.Name.Contains("QX_")
……上面的其它代码

窗口里调用
Functions.Execute("函数abc",e)