Dim tb As Table = Tables("公用窗体_zjjgyszqkTable")
Dim dt As DataTable = tb.DataSource
Dim g As New GroupTableBuilder("最近几个月收支情况报表", DataTables("收支交易流水"))
g.Groups.AddDef("记账日期", DateGroupEnum.Month,"月份")
g.Totals.AddDef("收入金额")
g.Totals.AddDef("支出金额")
g.Filter = "[记账日期] >= ‘" & qsrq & "’ And [记账日期] <= ’" & jsrq & "‘“
g.SubTotal = True
tb.DataSource = g.BuildDataSource
If dt.DataCols.Contains("收支差额") = False Then '用表达式列计算库存数据
dt.DataCols.Add("收支差额",Gettype(Double), "IsNull([收入金额],0) - ISNULL([支出金额],0)")
End if
tb.SetColVisibleWidth("月份|100|收入金额|120|支出金额|120|收支差额|120")
dt.DataCols("收入金额").SetFormat("0.00")
dt.DataCols("支出金额").SetFormat("0.00")
dt.DataCols("收支差额").SetFormat("0.00")
For Each c As Col In tb.Cols
c.TextAlign = TextAlignEnum.Center
Next
dt.GlobalHandler.PrepareEdit=True
t = Tables("公用窗体_zjjgyszqkTable")
t.Cols("月份").GrandTotal = True '指定要合计的列
t.Cols("收入金额").GrandTotal = True
t.Cols("支出金额").GrandTotal = True
t.Cols("收支差额").GrandTotal = True
t.Sort = "月份" '指定排序字段
t.GrandTotal = True '显示合计模式
t.Grid.Name = t.Name
AddHandler t.grid.Paint, AddressOf Grid_Paint