多值字段的话,直接用 like '* *' 就可以解决了。
你的表中,用户列是单值,帮你去掉了循环。应该可以。
If User.Type <> UserTypeEnum.User Then ' 如果是开发者或者管理员 Return True '则具备所有权限 End If Dim dt As DataTable = DataTables("授权") Dim dr As DataRow '首先判断分组的授权用户是否包括此用户或此用户所属的分组 dr = dt.Find("分组 = '" & args(0) & "' And 权限 Is Null" ) If dr Is Nothing Then MessageBox.show("不存在名为""" & args(0) & "分组!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return False End If If dr.IsNull("用户") = False Then Dim yh As String = dr("用户") If yh = User.Group OrElse yh = User.Name Then '如果授权用户包括登录用户所属的分组或其用户名 Return True '返回True End If End If '然后判断权限的授权用户是否包括此用户或此用户所属的分组 If Args(1) = "" Then Return False End If dr = dt.Find("分组 = '" & args(0) & "' And 权限 like '*" & args(1) & "*'") If dr Is Nothing Then MessageBox.show("不存在名为""" & args(1) & "权限!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return False End If If dr.IsNull("用户") = False Then Dim yh As String = dr("用户") If yh = User.Group OrElse yh = User.Name Then '如果授权用户包括登录用户所属的分组或其用户名 Return True '返回True End If End If Return False
|