以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]权限代码 可否优化!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=16896)

--  作者:gaoyong30000
--  发布时间:2012/2/27 9:47:00
--  [求助]权限代码 可否优化!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

权限表如图:


此主题相关图片如下:1.jpg
按此在新窗口浏览图片

 

我现在建了3个内部函数

①shouquan

Dim dt As DataTable = DataTables("授权")
Dim dr As DataRow
dr = dt.Find("导航分组 = \'" & args(0) & "\' And 功能模块 = \'" & args(1) & "\' And 流程 = \'" & args(2) & "\'")
If dr.IsNull("用户") = False Then
    Dim nms() As String = dr("用户").Split(",")
    For Each nm As String In nms
        If nm = _UserGroup Then \'如果授权用户包括登录用户所属的分组或其用户名
            Return True \'返回True
        End If
    Next
End If
Return False

 

②shouquan导航分组

Dim dt As DataTable = DataTables("授权")
Dim drs As List(of DataRow)
drs = dt.Select("导航分组 = \'" & args(0) & "\'")
For Each mr As DataRow In drs
    If mr.IsNull("用户") = False Then
        Dim nms() As String = mr("用户").Split(",")
        For Each nm As String In nms
            If nm = _UserGroup Then \'如果授权用户包括登录用户所属的分组或其用户名
                Return True \'返回True
            End If
        Next
    End If
Next
Return False

 

 

③shouquan功能模块

Dim dt As DataTable = DataTables("授权")
Dim drs As List(of DataRow)
drs = dt.Select("功能模块 = \'" & args(0) & "\'")
For Each mr As DataRow In drs
    If mr.IsNull("用户") = False Then
        Dim nms() As String = mr("用户").Split(",")
        For Each nm As String In nms
            If nm = _UserGroup Then \'如果授权用户包括登录用户所属的分组或其用户名
                Return True \'返回True
            End If
        Next
    End If
Next
Return False

 

shouquan是为了判断 3列的权限

shouquan导航分组 是为了判断是否有【导航分组】权限 不需要再判断后面2列

shouquan功能模块 类似

 

请问这样是否合理??

 

 

 

 


--  作者:狐狸爸爸
--  发布时间:2012/2/27 10:09:00
--  
我觉得后面两个,这样才合理:
 
\'shouquan导航分组
Dim dt As DataTable = DataTables("授权")
Dim dr As DataRow
dr = dt.Find("导航分组 = \'" & args(0) & "\' And 功能模块 Is Null And 流程 Is Null")
If dr.IsNull("用户") = False Then
    Dim nms() As String = dr("用户").Split(",")
    For Each nm As String In nms
        If nm = _UserGroup Then \'如果授权用户包括登录用户所属的分组或其用户名
            Return True \'返回True
        End If
    Next
End If
Return False
 
\'shouquan功能模块
Dim dt As DataTable = DataTables("授权")
Dim dr As DataRow
dr = dt.Find("导航分组 = \'" & args(0) & "\' And 功能模块  = \'" &  args(1) & "\' And 流程 Is Null")
If dr.IsNull("用户") = False Then
    Dim nms() As String = dr("用户").Split(",")
    For Each nm As String In nms
        If nm = _UserGroup Then \'如果授权用户包括登录用户所属的分组或其用户名
            Return True \'返回True
        End If
    Next
End If
Return False

--  作者:gaoyong30000
--  发布时间:2012/2/27 11:00:00
--  

哦 这样

 

 

还是分 3个内部函数是把


--  作者:gaoyong30000
--  发布时间:2012/2/27 20:55:00
--  
明白了~~~~~~