以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  插入汇总行  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=39437)

--  作者:yuyijun2
--  发布时间:2013/8/24 11:29:00
--  插入汇总行


Dim bd1 As New GroupTableBuilder("统计表1",DataTables("行政案件"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("办案部门") \'根据办案部门分组
dt1 = bd1.BuildDataSource()
Tables("统计_Table1").DataSource = dt1 \'将统计结果绑定到Table
With DataTables("统计_Table1").DataCols  \'用表达式列计算库存数据
  .Add("金额(元)_行政罚款",Gettype(Decimal))
  .Add("金额(元)_款1",Gettype(Decimal))
  .Add("金额(元)_合计",Gettype(Decimal)) 
  .Add("查办案件(宗)_投诉",Gettype(Integer))
End With
For Each dr As Row In Tables("统计_Table1").Rows
    dr("罚款金额(元)_行政罚款") = DataTables("行政案件").Compute("Sum(行政罚款)", "[办案部门] = \'" & dr("办案部门") & "\' And [结案日期]>=#" & e.form.controls("DateTimePicker1").Value & "# and [结案日期]<=#" & e.form.controls("DateTimePicker2").Value & "# ")
   dr("罚款金额(元)_折1") = DataTables("行政案件").Compute("Count(款1)", "[办案部门] = \'" & dr("办案部门") & "\' And [结案日期]>=#" & e.form.controls("DateTimePicker1").Value & "# and [结案日期]<=#" & e.form.controls("DateTimePicker2").Value & "# ")
   dr("罚款金额(元)_合计") = dr("罚款金额(元)_木材折款")+dr("罚款金额(元)_行政罚款") 
   dr("查办案件(宗)_投诉") = DataTables("行政案件").Compute("Count(办案部门)", "[办案部门] = \'" & dr("办案部门") & "\' And [来源]=\'投诉\'And [结案日期]>=#" & e.form.controls("DateTimePicker1").Value & "# and [结案日期]<=#" & e.form.controls("DateTimePicker2").Value & "# ") 

 Next

 

在上面的代码中如何在"统计_Table1"表插入汇总行让"金额(元)_行政罚款"等全部列的垂直和,代码怎么写?

 


--  作者:狐狸爸爸
--  发布时间:2013/8/24 11:45:00
--  

答案在这里:

http://www.foxtable.com/help/topics/2669.htm

 


--  作者:yuyijun2
--  发布时间:2013/8/24 12:04:00
--  

帮我写一下吧图片点击可在新窗口打开查看


--  作者:狐狸爸爸
--  发布时间:2013/8/24 14:06:00
--  

你这是后面添加的计算,不能用哪个方法,你直接针对统计表设置汇总模式即可:

http://www.foxtable.com/help/topics/1372.htm

 

Dim bd1 As New GroupTableBuilder("统计表1",DataTables("行政案件"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("办案部门") \'根据办案部门分组
dt1 = bd1.BuildDataSource()
Tables("统计_Table1").DataSource = dt1 \'将统计结果绑定到Table
With DataTables("统计_Table1").DataCols \'用表达式列计算库存数据
    .Add("金额(元)_行政罚款",Gettype(Decimal))
    .Add("金额(元)_款1",Gettype(Decimal))
    .Add("金额(元)_合计",Gettype(Decimal))
    .Add("查办案件(宗)_投诉",Gettype(Integer))
End With
For Each dr As Row In Tables("统计_Table1").Rows
    dr("罚款金额(元)_行政罚款") = DataTables("行政案件").Compute("Sum(行政罚款)", "[办案部门] = \'" & dr("办案部门") & "\' And [结案日期]>=#" & e.form.controls("DateTimePicker1").Value & "# and [结案日期]<=#" & e.form.controls("DateTimePicker2").Value & "# ")
    dr("罚款金额(元)_折1") = DataTables("行政案件").Compute("Count(款1)", "[办案部门] = \'" & dr("办案部门") & "\' And [结案日期]>=#" & e.form.controls("DateTimePicker1").Value & "# and [结案日期]<=#" & e.form.controls("DateTimePicker2").Value & "# ")
    dr("罚款金额(元)_合计") = dr("罚款金额(元)_木材折款")+dr("罚款金额(元)_行政罚款")
    dr("查办案件(宗)_投诉") = DataTables("行政案件").Compute("Count(办案部门)", "[办案部门] = \'" & dr("办案部门") & "\' And [来源]=\'投诉\'And [结案日期]>=#" & e.form.controls("DateTimePicker1").Value & "# and [结案日期]<=#" & e.form.controls("DateTimePicker2").Value & "# ")
Next
Dim g As New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "*"

g.TotalOn = "罚款金额(元)_行政罚款,罚款金额(元)_折1,罚款金额(元)_合计,查办案件(宗)_投诉"
g.Caption = "总计"
Tables("统计_Table1").SubtotalGroups.Add(g)
Tables("统计_Table1").Subtotal