我需要在每个窗口中都添加下面这段代码来设定窗口权限,能不能做成内部函数统一调用,需要怎么做
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