-- 作者:zcw2764
-- 发布时间:2012/10/15 16:28:00
-- [求助]自定义函数故障求解
自定义功能权限函数,代码如下,用Functions.execute("功能权限","人力资源","职工信息","","") 调用时显示超出数组界限,不知原因何在,求高手指点 "
Dim str0 As String = args(0) Dim str1 As String = args(1) Dim str2 As String = args(2) Dim str3 As String = args(3) Dim str4 As String Dim strs As New List(of String) Dim dt As DataTable Dim dr As DataRow Dim cmd As new sqlcommand cmd.ConnectionName = _DBSource1 If _UserID = "000" Then Return True Exit Function End If cmd.CommandText = "SELECT * From {系统_功能权限} where 功能权限分组 = \'管理员\'" dt = cmd.ExecuteReader() If dt.DataRows.count <> 0 Then For Each dr In dt.DataRows If dr.IsNull("功能权限用户") = False Then strs.AddRange(dr("功能权限用户").Split(",")) If Strs.Contains(_UserID) = True Then Return True Exit Function End If End If Next Else messagebox.show("未找到 [管理员] 功能权限分组或权限,请检查","提示") Return False Exit Function End If If str1 Is Nothing Then str4 = "功能权限分组 = \'" & str0 & "\' And 功能权限子组 is null And 功能权限名称 is null And 功能权限细分 is null" ElseIf str2 Is Nothing Then str4 = "功能权限分组 = \'" & str0 & "\' And 功能权限子组 = \'" & str1 & "\' And 功能权限名称 is null And 功能权限细分 is null" ElseIf str3 Is Nothing Then str4 = "功能权限分组 = \'" & str0 & "\' And 功能权限子组 = \'" & str1 & "\' And 功能权限名称 = \'" & str2 & "\' And 功能权限细分 Is null" Else str4 = "功能权限分组 = \'" & str0 & "\' And 功能权限子组 = \'" & str1 & "\' And 功能权限名称 = \'" & str2 & "\' And 功能权限细分 = \'" & str3 & "\'" End If cmd.CommandText = "SELECT * From {系统_功能权限} where " & str4 & " " dt = cmd.ExecuteReader() If dt.DataRows.count = 1 Then dr = dt.DataRows(0) If dr.IsNull("功能权限用户") = False Then strs.AddRange(dr("功能权限用户").Split(",")) If Strs.Contains(_UserID) = True Then Return True Else Return False End If Else Return False End If Else messagebox.show("未找到[" & str0 & "] - [" & str1 & "] - [" & str2 & "] - [" & str3 & "] 功能权限设置,请检查","提示") Return False End If
|