请教一下老师们,下面的代码需要25秒才能执行完,有没有快一点的方法?
Dim g1 As New SQLGroupTableBuilder("统计表1", "母猪基本信息")
g1.C
Dim d1 As fxDataSource
g1.Groups.AddDef("购买_日期", DateGroupEnum.Year, "日期_年")
g1.Groups.AddDef("购买_日期", "日期_月")
g1.Totals.AddDef("购买_金额", "购买_母猪")
g1.Filter = "[sys_user]='" & user.Name & "'"
d1 = g1.BuildDataSource()
Dim g2 As New SQLGroupTableBuilder("统计表2", "公猪信息")
g2.C
Dim d2 As fxDataSource
g2.Groups.AddDef("购买_日期", DateGroupEnum.Year, "日期_年")
g2.Groups.AddDef("购买_日期", "日期_月")
g2.Totals.AddDef("购买_金额", "购买_公猪")
g2.Filter = "[sys_user]='" & user.Name & "'"
d2 = g2.BuildDataSource()
Dim g3 As New SQLGroupTableBuilder("统计表3", "肉猪信息")
g3.C
Dim d3 As fxDataSource
g3.Groups.AddDef("购买_日期", DateGroupEnum.Year, "日期_年")
g3.Groups.AddDef("购买_日期", "日期_月")
g3.Totals.AddDef("购买_金额", "购买_肉猪")
g3.Filter = "[sys_user]='" & user.Name & "'"
d3 = g3.BuildDataSource()
Dim g4 As New SQLGroupTableBuilder("统计表4", "饲料采购")
g4.C
Dim d4 As fxDataSource
g4.Groups.AddDef("日期", DateGroupEnum.Year, "日期_年")
g4.Groups.AddDef("日期", "日期_月")
g4.Totals.AddDef("饲料量_总金额", "饲料")
g4.Filter = "[sys_user]='" & user.Name & "'"
d4 = g4.BuildDataSource()
Dim g5 As New SQLGroupTableBuilder("统计表5", "疫苗采购")
g5.C
Dim d5 As fxDataSource
g5.Groups.AddDef("日期", DateGroupEnum.Year, "日期_年")
g5.Groups.AddDef("日期", "日期_月")
g5.Totals.AddDef("总金额", "疫苗")
g5.Filter = "[sys_user]='" & user.Name & "'"
d5 = g5.BuildDataSource()
Dim g6 As New SQLGroupTableBuilder("统计表6", "药品采购")
g6.C
Dim d6 As fxDataSource
g6.Groups.AddDef("日期", DateGroupEnum.Year, "日期_年")
g6.Groups.AddDef("日期", "日期_月")
g6.Totals.AddDef("总金额", "药品")
g6.Filter = "[sys_user]='" & user.Name & "'"
d6 = g6.BuildDataSource()
Dim g7 As New SQLGroupTableBuilder("统计表7", "易耗品采购")
g7.C
Dim d7 As fxDataSource
g7.Groups.AddDef("日期", DateGroupEnum.Year, "日期_年")
g7.Groups.AddDef("日期", "日期_月")
g7.Totals.AddDef("总金额", "易耗品")
g7.Filter = "[sys_user]='" & user.Name & "'"
d7 = g7.BuildDataSource()
Dim g8 As New SQLGroupTableBuilder("统计表8", "保险费")
g8.C
Dim d8 As fxDataSource
g8.Groups.AddDef("日期", DateGroupEnum.Year, "日期_年")
g8.Groups.AddDef("日期", "日期_月")
g8.Totals.AddDef("投保金额", "保险费")
g8.Filter = "[sys_user]='" & user.Name & "'"
d8 = g8.BuildDataSource()
Dim g9 As New SQLGroupTableBuilder("统计表9", "水电费")
g9.C
Dim d9 As fxDataSource
g9.Groups.AddDef("日期", DateGroupEnum.Year, "日期_年")
g9.Groups.AddDef("日期", "日期_月")
g9.Totals.AddDef("金额", "水电费")
g9.Filter = "[sys_user]='" & user.Name & "'"
d9 = g9.BuildDataSource()
Dim g10 As New SQLGroupTableBuilder("统计表10", "工资费用")
g10.C
Dim d10 As fxDataSource
g10.Groups.AddDef("日期", DateGroupEnum.Year, "日期_年")
g10.Groups.AddDef("日期", "日期_月")
g10.Totals.AddDef("金额", "工资费用")
g10.Filter = "[sys_user]='" & user.Name & "'"
d10 = g10.BuildDataSource()
Dim g11 As New SQLGroupTableBuilder("统计表11", "工程折旧费用")
g11.C
Dim d11 As fxDataSource
g11.Groups.AddDef("日期", DateGroupEnum.Year, "日期_年")
g11.Groups.AddDef("日期", "日期_月")
g11.Totals.AddDef("支出金额", "工程折旧费")
g11.Filter = "[sys_user]='" & user.Name & "'"
d11 = g11.BuildDataSource()
Dim g12 As New SQLGroupTableBuilder("统计表12", "其他支出")
g12.C
Dim d12 As fxDataSource
g12.Groups.AddDef("日期", DateGroupEnum.Year, "日期_年")
g12.Groups.AddDef("日期", "日期_月")
g12.Totals.AddDef("金额", "其他支出")
g12.Filter = "[sys_user]='" & user.Name & "'"
d12 = g12.BuildDataSource()
Dim nms As String() = {"日期_年","日期_月"}
d1.Combine(nms,d2,nms)
d1.Combine(nms,d3,nms)
d1.Combine(nms,d4,nms)
d1.Combine(nms,d5,nms)
d1.Combine(nms,d6,nms)
d1.Combine(nms,d7,nms)
d1.Combine(nms,d8,nms)
d1.Combine(nms,d9,nms)
d1.Combine(nms,d10,nms)
d1.Combine(nms,d11,nms)
d1.Combine(nms,d12,nms)
Tables("支出统计_Table1").DataSource = d1
With DataTables("支出统计_Table1").DataCols
.Add("合计",Gettype(Integer), "IsNull([购买_母猪],0) + ISNULL([购买_公猪],0) + ISNULL([购买_肉猪],0) + ISNULL([饲料],0) + ISNULL([疫苗],0) + ISNULL([药品],0) + ISNULL([易耗品],0) + ISNULL([保险费],0) + ISNULL([水电费],0) + ISNULL([工资费用],0) + ISNULL([工程折旧费],0) + ISNULL([其他支出],0) ")
.Add("比例_母猪",Gettype(Double),"IIF(IsNull([购买_母猪],0) = 0, null, IsNull([购买_母猪],0) / IsNull([合计],0))")
.Add("比例_公猪",Gettype(Double),"IIF(IsNull([购买_公猪],0) = 0, null, IsNull([购买_公猪],0) / IsNull([合计],0))")
.Add("比例_肉猪",Gettype(Double),"IIF(IsNull([购买_肉猪],0) = 0, null, IsNull([购买_肉猪],0) / IsNull([合计],0))")
.Add("比例_饲料",Gettype(Double),"IIF(IsNull([饲料],0) = 0, null, IsNull([饲料],0) / IsNull([合计],0))")
.Add("比例_疫苗",Gettype(Double),"IIF(IsNull([疫苗],0) = 0, null, IsNull([疫苗],0) / IsNull([合计],0))")
.Add("比例_药品",Gettype(Double),"IIF(IsNull([药品],0) = 0, null, IsNull([药品],0) / IsNull([合计],0))")
.Add("比例_易耗品",Gettype(Double),"IIF(IsNull([易耗品],0) = 0, null, IsNull([易耗品],0) / IsNull([合计],0))")
.Add("比例_保险费",Gettype(Double),"IIF(IsNull([保险费],0) = 0, null, IsNull([保险费],0) / IsNull([合计],0))")
.Add("比例_水电费",Gettype(Double),"IIF(IsNull([水电费],0) = 0, null, IsNull([水电费],0) / IsNull([合计],0))")
.Add("比例_工资费用",Gettype(Double),"IIF(IsNull([工资费用],0) = 0, null, IsNull([工资费用],0) / IsNull([合计],0))")
.Add("比例_工程折旧费",Gettype(Double),"IIF(IsNull([工程折旧费],0) = 0, null, IsNull([工程折旧费],0) / IsNull([合计],0))")
.Add("比例_其他支出",Gettype(Double),"IIF(IsNull([其他支出],0) = 0, null, IsNull([其他支出],0) / IsNull([合计],0))")
End With
Dim s As String() = {"比例_母猪","比例_公猪","比例_肉猪","比例_饲料","比例_疫苗","比例_药品","比例_易耗品","比例_保险费","比例_水电费","比例_工资费用","比例_工程折旧费","比例_其他支出"}
For i As Integer = 0 To s.Length - 1
DataTables("支出统计_Table1").DataCols(s(i)).SetFormat("0.0%")
Next
Tables("支出统计_Table1").DefaultColWidth = 70