Foxtable(狐表)用户栏目专家坐堂 → 统计查询多角色授权问题


  共有213人关注过本帖树形打印复制链接

主题:统计查询多角色授权问题

帅哥哟,离线,有人找我吗?
wlj88868
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:188 积分:1333 威望:0 精华:0 注册:2016/4/27 9:39:00
统计查询多角色授权问题  发帖心情 Post By:2024/5/29 21:13:00 [只看该作者]

Dim Filter As String
Filter = "[管辖部门] in ('" & user.Roles.replace(",", "','") & "')"
Filter = "[品牌] in ('" & user.Roles.replace(",", "','") & "')"

With e.Form.Controls("combobox1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter &"品牌 like '%" & .Value & "%'"
    End If
End With
With e.Form.Controls("combobox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "销售型号 like'%" & .Value & "%'"
    End If
End With
With e.Form.Controls("combobox12")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "销售商场  like'%" & .Value & "%'"
    End If
End With
With e.Form.Controls("StartDate")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "销售日期 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("EndDate")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "销售日期 <= #" & .Value & "#"
    End If
End With
Dim bd1 As New SqlGroUPTableBuilder("查询表_table1", "销售资料")
Dim dt1 As fxDataSource
bd1.groups.AddDef("销售商场")'根据型号分组
bd1.groups.AddDef("品牌")'根据型号分组
bd1.Groups.AddDef("销售型号")'根据型号分组
bd1.Groups.AddDef("管辖部门")'根据型号分组
bd1.Groups.AddDef("销售日期", "月")
bd1.Totals.AddDef("数量")
bd1.Totals.AddDef("销售单价")
bd1.Filter = Filter
dt1 = bd1.BuildDataSource()
Tables("查询表_table1").DataSource = dt1 '将统计结果绑定到Table
With Tables("查询表_Table1")
    Dim g As SubtotalGroup '定义一个新的分组
    .SubtotalGroups.Clear() '清除原有的分组
    g = New SubtotalGroup
    g.GroupOn = "月" '分组列为客户
    g.TotalOn = "数量,销售单价" '对数量和金额进行统计
    .SubtotalGroups.Add(g) '加入刚刚定义的分组
    g = New SubtotalGroup
    g.GroupOn = "销售商场" '分组列为客户
    g.TotalOn = "数量,销售单价" '对数量和金额进行统计
    .SubtotalGroups.Add(g) '加入刚刚定义的分组
    g = New SubtotalGroup
    g.GroupOn = "*" '分组列为客户
    g.TotalOn = "数量,销售单价" '对数量和金额进行统计
    .SubtotalGroups.Add(g) '加入刚刚定义的分组
    .Subtotal() '生成汇总模式  
End With
Tables("查询表_Table1").SysStyles("Subtotal0").BackColor = Color.LightSkyBlue'小计行颜色
Tables("查询表_Table1").SysStyles("Subtotal1").BackColor = Color.Turquoise'小计2颜色
Tables("查询表_Table1").Cols("销售商场").Width = 160'列宽设置
Tables("查询表_Table1").Cols("销售型号").Width = 120'列宽设置
Tables("查询表_Table1").Cols("数量").TextAlign = TextAlignEnum.Center'数据居中
Tables("查询表_Table1").Cols("销售单价").TextAlign = TextAlignEnum.Center'数据居中
Tables("查询表_Table1").Cols("月").TextAlign = TextAlignEnum.Center'数据居中
'Tables("查询表_Table1").Filter = Filter & "[管辖部门] in ('" & user.Roles.replace(",", "','") & "')"
'Tables("查询表_Table1").Filter =  "[品牌] in ('" & user.Roles.replace(",", "','") & "')"

 

 

老师上面2句红色的就下一句起作用,,这个2个角色同时生效需要怎么设置呀


 回到顶部
帅哥哟,离线,有人找我吗?
hongsejiyi
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小狐 帖子:328 积分:5062 威望:0 精华:0 注册:2019/1/1 15:53:00
  发帖心情 Post By:2024/5/29 21:22:00 [只看该作者]

Dim Filter As String
Filter = "[管辖部门] in ('" & user.Roles.replace(",", "','") & "') and  [品牌] in ('" & user.Roles.replace(",", "','") & "')"


以上的根据角色的权限之间的关系决定是用 and 还是 or



 回到顶部
帅哥哟,离线,有人找我吗?
wlj88868
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:188 积分:1333 威望:0 精华:0 注册:2016/4/27 9:39:00
  发帖心情 Post By:2024/5/30 7:48:00 [只看该作者]

收到,谢谢,我and接了把前面的"忘记删了,怪不得不起作用,现在OK了

 回到顶部