Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共3 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

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

1楼
wlj88868 发表于: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个角色同时生效需要怎么设置呀

2楼
hongsejiyi 发表于:2024/5/29 21:22:00

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


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


3楼
wlj88868 发表于:2024/5/30 7:48:00
收到,谢谢,我and接了把前面的"忘记删了,怪不得不起作用,现在OK了
共3 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02344 s, 2 queries.