以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  有个分组统计,代码如下 ,单价不要合计数, 怎么写代码?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=91911)

--  作者:jswjyjf
--  发布时间:2016/10/21 16:23:00
--  有个分组统计,代码如下 ,单价不要合计数, 怎么写代码?
有个分组统计,代码如下 ,单价不要合计数, 怎么写代码?
Dim filter1 As String
filter1="客户名称= \'" & e.Form.Controls("ComboBox1").value & "\'" & " And 加工日期 >= #" & e.Form.Controls("startdate").value & "# " & " And 加工日期 <= #" & e.Form.Controls("enddate").value & "# "
Dim g As New sqlgroupTableBuilder("统计表1", "加工单")
g.C
\'
g.Groups.AddDef("加工日期", DateGroupEnum.Day, "日")
g.Groups.AddDef("款型及款号")
g.Totals.AddDef("重量")
g.Totals.AddDef("件数")
g.Totals.AddDef("单价")
g.Totals.AddDef("金额")
g.VerticalTotal = True
g.VerticalTotal = True
g.SubTotal = True
g.filter=filter1
g.Build()
g.SubTotal = True
g.filter=filter1
g.Build()

--  作者:有点蓝
--  发布时间:2016/10/21 16:49:00
--  
生成登记表后再另外汇总

Dim b As New SQLGroupTableBuilder("统计表1","订单")
b.Groups.AddDef("日期", DateGroupEnum.Year, "年")
b.Groups.AddDef("产品") \'根据产品分组
b.Totals.AddDef("数量") \'对数量进行统计
b.Totals.AddDef("单价")
\'b.SubTotal = True
b.Build \'生成统计表
MainTable = Tables("统计表1") \'打开生成的统计表
Tables("统计表1").SubtotalGroups.Clear() \'清除原有的分组
Dim g As New Subtotalgroup \'定义一个新的分组
g.Aggregate = AggregateEnum.Sum \'统计类型为求和
g.GroupOn = "年" \'分组列为客户列
g.TotalOn = "数量" \'对数量和金额进行统计
g.Caption = "{0} 小计" \'设置标题
Tables("统计表1").SubtotalGroups.Add(g)
Tables("统计表1") .Subtotal() \'生成汇总模式


--  作者:jswjyjf
--  发布时间:2016/10/21 20:21:00
--  
小计保存 明细行不要 代码怎么写
--  作者:有点蓝
--  发布时间:2016/10/22 9:03:00
--  
直接对日期和要合计的列进行分组统计即可
--  作者:jswjyjf
--  发布时间:2016/10/25 20:30:00
--  
我设计了一个窗口
重新进行汇总,但是窗口中的表生成不了汇总
代码如下
Dim filter1 As String
filter1="客户名称= \'" & e.Form.Controls("ComboBox1").value & "\'" & " And 加工日期 >= #" & e.Form.Controls("startdate").value & "# " & " And 加工日期 <= #" & e.Form.Controls("enddate").value & "# "
Dim g As New sqlgroupTableBuilder("统计表1", "加工单")
g.C
g.Groups.AddDef("加工日期", "月份")
g.Groups.AddDef("款型及款号")
g.Totals.AddDef("件重")
g.Totals.AddDef("件数")
g.Totals.AddDef("单价")
g.Totals.AddDef("金额")
g.VerticalTotal = True
g.SubTotal = True
g.filter=filter1
g.Build()
\'\'重新生成汇总
Dim t As Table = Tables("统计表1")
Dim g1 As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
t.SpillNode = True
g1 = New Subtotalgroup
g1.Aggregate = AggregateEnum.Sum
g1.GroupOn = "月份"
g1.TotalOn = "件数,金额"
g1.Caption = "{0}月 小计"
g1.DateGroup = DateGroupEnum.Month
t.SubtotalGroups.Add(g1)
g1 = New Subtotalgroup
g1.Aggregate = AggregateEnum.Sum
g1.GroupOn = "*"
g1.TotalOn = "件数,金额"
g1.Caption = "总计"
t.SubtotalGroups.Add(g1)
t.Subtotal()\'\'
Tables(e.form.Name & "_Table1").DataSource =DataTables("统计表1")
Tables(e.form.Name & "_Table1").SetColVisibleWidth("月份|60|款型及款号|280|件重|100|件数|100|单价|100|金额|100")
Tables(e.form.Name & "_Table1").DataTable.DataCols("金额").SetFormat("0.00")
Tables(e.form.Name & "_Table1").Cols("月份").TextAlign = TextAlignEnum.Center



不知道错在哪里 ?

--  作者:有点蓝
--  发布时间:2016/10/25 20:34:00
--  
Dim filter1 As String
filter1="客户名称= \'" & e.Form.Controls("ComboBox1").value & "\'" & " And 加工日期 >= #" & e.Form.Controls("startdate").value & "# " & " And 加工日期 <= #" & e.Form.Controls("enddate").value & "# "
Dim t As Table = Tables(e.form.Name & "_Table1")
Dim g As New sqlgroupTableBuilder("统计表1", "加工单")
g.C
g.Groups.AddDef("加工日期", "月份")
g.Groups.AddDef("款型及款号")
g.Totals.AddDef("件重")
g.Totals.AddDef("件数")
g.Totals.AddDef("单价")
g.Totals.AddDef("金额")
g.VerticalTotal = True
g.SubTotal = True
g.filter=filter1
\'\'重新生成汇总
t.DataSource  = g.BuildDataSource
Dim g1 As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
t.SpillNode = True
g1 = New Subtotalgroup
g1.Aggregate = AggregateEnum.Sum
g1.GroupOn = "月份"
g1.TotalOn = "件数,金额"
g1.Caption = "{0}月 小计"
g1.DateGroup = DateGroupEnum.Month
t.SubtotalGroups.Add(g1)
g1 = New Subtotalgroup
g1.Aggregate = AggregateEnum.Sum
g1.GroupOn = "*"
g1.TotalOn = "件数,金额"
g1.Caption = "总计"
t.SubtotalGroups.Add(g1)
t.Subtotal()\'\'
t.SetColVisibleWidth("月份|60|款型及款号|280|件重|100|件数|100|单价|100|金额|100")
t.DataTable.DataCols("金额").SetFormat("0.00")
t.Cols("月份").TextAlign = TextAlignEnum.Center