以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 关于加载后统计问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=164302) |
-- 作者:lin98 -- 发布时间: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() |
-- 作者:有点蓝 -- 发布时间: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() |