Foxtable(狐表)用户栏目专家坐堂 → 关于加载后统计问题


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

主题:关于加载后统计问题

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


加好友 发短信
等级:六尾狐 帖子:1360 积分:9034 威望:0 精华:0 注册:2020/11/4 22:15:00
关于加载后统计问题  发帖心情 Post By:2021/5/5 14:46:00 [只看该作者]

需求是,根据当前用户(分组)加载数据进行统计。
下面代码,能根据当前用户(分组)加载数据显示,但统计都按全部统计,不能按需求,根据当前用户(分组)加载数据进行统计。

Table控件的类型根据需要设置为SQLTable:

tSelec * From {订单} Where [_Identify] Is Null


Dim y As Integer = Date.Today.Year
Dim dt1 As New Date(y, 1, 1)
Dim dt2 As New Date(y, 12, 31)
Dim Filter As String
Dim s As String = ""
Select Case User.Group
    Case "录入者","",Nothing
        s =user.name
    Case Else
        Dim dr2 As DataRow
        dr2 = DataTables("用户").Find("[分组] = '" & User.Group & "'")
        If dr2 IsNot Nothing Then
            s = dr2("下级")
        End If
End Select
Filter = "日期 >= #" & dt1 & "# And 日期 <= #" & dt2 & "# and 录入者 in ('" & s.replace(",","','") & "')"
DataTables("分组加载统计_Table1").LoadFilter = Filter
DataTables("分组加载统计_Table1").Load()


Dim Filter As String
Dim b As New GroupTableBuilder("统计表1",DataTables("订单"))
b.Groups.AddDef("产品")
b.Totals.AddDef("数量","订购数量") '添加数量列用于统计
b.Filter = Filter
Tables("分组加载统计_Table1").DataSource = b.BuildDataSource()

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


加好友 发短信
等级:超级版主 帖子:110574 积分:562760 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/5/5 14:58:00 [只看该作者]

Dim y As Integer = Date.Today.Year
Dim dt1 As New Date(y, 1, 1)
Dim dt2 As New Date(y, 12, 31)
Dim Filter As String
Dim s As String = ""
Select Case User.Group
    Case "录入者","",Nothing
        s =user.name
    Case Else
        Dim dr2 As DataRow
        dr2 = DataTables("用户").Find("[分组] = '" & User.Group & "'")
        If dr2 IsNot Nothing Then
            s = dr2("下级")
        End If
End Select
Filter = "日期 >= #" & dt1 & "# And 日期 <= #" & dt2 & "# and 录入者 in ('" & s.replace(",","','") & "')"
Dim b As New GroupTableBuilder("统计表1",DataTables("订单"))
b.Groups.AddDef("产品")
b.Totals.AddDef("数量","订购数量") '添加数量列用于统计
b.Filter = Filter
Tables("分组加载统计_Table1").DataSource = b.BuildDataSource()

 回到顶部