以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]未将对象引用设置到对象的实例 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=170715) |
-- 作者:lgj716330 -- 发布时间:2021/8/4 17:05:00 -- [求助]未将对象引用设置到对象的实例 错误所在事件:项目,LoadUserSetting 详细错误信息: 未将对象引用设置到对象的实例。 LoadUserSetting中有以下代码,用开发者进没有错误提示,一般用户进提示上面错误,麻烦看下哪里要调整 If User.Type = UserTypeEnum.User Then For Each dr1 As DataRow In DataTables("授权表三").DataRows Dim nms() As String Dim nms1() As String If dr1.Isnull("受限角色")=False Then nms = dr1("受限角色").Split(",") End If If dr1.Isnull("非受限角色")=False Then nms1 = dr1("非受限角色").Split(",") End If If dr1("用户名列")=True Then For Each nm As String In nms For Each nm1 As String In nms1 If dr1.Isnull("非受限角色")=False And user.roles.contains(nm1) Then DataTables(dr1("表名")).LoadFilter = "" ElseIf dr1.Isnull("受限角色")=False And user.roles.contains(nm) Then DataTables(dr1("表名")).LoadFilter = "" & dr1("列名") & " In ( \'" & dr1("列内容").Value.replace(",","\',\'") & "\')" Else DataTables(dr1("表名")).LoadFilter = "" & dr1("列名") & " = \'" & User.Name & "\'" End If Next Next End If If dr1("用户名列")=False Then For Each nm As String In nms For Each nm1 As String In nms1 If dr1.Isnull("非受限角色")=False And user.roles.contains(nm1) Then DataTables(dr1("表名")).LoadFilter = "" ElseIf dr1.Isnull("受限角色")=False And user.roles.contains(nm) Then DataTables(dr1("表名")).LoadFilter = "" & dr1("列名") & " In ( \'" & dr1("列内容").Value.replace(",","\',\'") & "\')" End If Next Next End If Next End If |
-- 作者:有点蓝 -- 发布时间:2021/8/4 17:15:00 -- If dr1.Isnull("受限角色")=False Then nms = dr1("受限角色").Split(",") else continue for End If If dr1.Isnull("非受限角色")=False Then nms1 = dr1("非受限角色").Split(",") else continue for End If |
-- 作者:lgj716330 -- 发布时间:2021/8/4 18:53:00 -- If User.Type = UserTypeEnum.User Then For Each dr1 As DataRow In DataTables("授权表三").DataRows Dim nms() As String Dim nms1() As String If dr1.Isnull("受限角色")=False Then nms = dr1("受限角色").Split(",") Else Continue For End If If dr1.Isnull("非受限角色")=False Then nms1 = dr1("非受限角色").Split(",") Else Continue For End If For Each nm As String In nms For Each nm1 As String In nms1 If dr1("用户名列")=True Then If dr1.Isnull("非受限角色")=False And User.IsRole(nm1) Then DataTables(dr1("表名")).LoadFilter = "" ElseIf dr1.Isnull("受限角色")=False And dr1.Isnull("列内容")=False And User.IsRole(nm) Then DataTables(dr1("表名")).LoadFilter = "" & dr1("列名") & " In ( \'" & dr1("列内容").replace(",","\',\'") & "\')" Else DataTables(dr1("表名")).LoadFilter = "" & dr1("列名") & " = \'" & User.Name & "\'" End If End If If dr1("用户名列")=False Then If dr1.Isnull("非受限角色")=False And User.IsRole(nm1) Then DataTables(dr1("表名")).LoadFilter = "" ElseIf dr1.Isnull("受限角色")=False And dr1.Isnull("列内容")=False And User.IsRole(nm) Then DataTables(dr1("表名")).LoadFilter = "" & dr1("列名") & " In ( \'" & dr1("列内容").replace(",","\',\'") & "\')" End If End If Next Next Next End If 当符合标颜色的条件时,还是会加载全部的数据,条件没起作用
|
-- 作者:有点蓝 -- 发布时间:2021/8/5 8:48:00 -- msgbox(user.Roles) \'登录用户角色看看 |
-- 作者:lgj716330 -- 发布时间:2021/8/5 11:24:00 -- msgbox(user.Roles)显示是直营财务,没问题 |
-- 作者:有点蓝 -- 发布时间:2021/8/5 12:06:00 -- If User.Type = UserTypeEnum.User Then For Each dr1 As DataRow In DataTables("授权表三").DataRows If dr1.Isnull("受限角色") OrElse dr1.Isnull("非受限角色") Then Continue For Dim r1,r2 As Boolean For Each nm As String In dr1("受限角色").Split(",") If User.IsRole(nm) Then r1=True Exit For End If Next For Each nm1 As String In dr1("非受限角色").Split(",") If User.IsRole(nm1) Then r2=True Exit For End If Next If r2 Then DataTables(dr1("表名")).LoadFilter = "" ElseIf dr1.Isnull("列内容")=False And r1 Then DataTables(dr1("表名")).LoadFilter = dr1("列名") & " In ( \'" & dr1("列内容").replace(",","\',\'") & "\')" ElseIf dr1("用户名列")=True DataTables(dr1("表名")).LoadFilter = dr1("列名") & " = \'" & User.Name & "\'" Else DataTables(dr1("表名")).LoadFilter = "1=2" End If Next End If
|