Dim ny As WinForm.ComboBox = e.Form.Controls("ComboBox10")
Dim g1 As New GroupTableBuilder("统计表1", DataTables("明细根表"))
Dim dt1 As fxDataSource
g1.Groups.AddDef("运输审核_结算月", "结算月")
g1.Groups.AddDef("销售审核_销档", "销档")
g1.Groups.AddDef("销售名称", "客户名称")
g1.Groups.AddDef("销售审核_吉", "吉")
g1.Groups.AddDef("销售审核_吉", "吉辅")
g1.Groups.AddDef("销售审核_开piao", "piao")
g1.Totals.AddDef("销", AggregateEnum.Count,"销")
g1.Totals.AddDef("生产信息_类型", AggregateEnum.Count, "砼车数")
g1.Totals.AddDef("销量", "当月_总方量")
g1.Totals.AddDef("销售_砼销额", "砼金额")
g1.Totals.AddDef("GDBFJE", "运输补助")
g1.Totals.AddDef("GDBCJE", "超时补助")
g1.Totals.AddDef("工地补助_工补其", "其他费用")
g1.Totals.AddDef("月调整_方量")
g1.Totals.AddDef("月调整_金额")
g1.VerticalTotal = True
g1.Filter = "[运输审核_结算月] = '" & ny.text & "' and [销] = 'X' and [生产信息_类型] = '砼'"
dt1 = g1.BuildDataSource()
Dim g2 As New GroupTableBuilder("统计表1", DataTables("明细根表"))
Dim dt2 As fxDataSource
g2.Groups.AddDef("运输审核_结算月", "结算月")
g2.Groups.AddDef("销售名称", "客户名称")
g2.Totals.AddDef("销量", "水")
g2.Totals.AddDef("销售_水销额", "水金额")
g2.VerticalTotal = True
g2.Filter = "[运输审核_结算月] = '" & ny.text & "' and [生产信息_类型] = '水'"
dt2 = g2.BuildDataSource()
Dim g3 As New GroupTableBuilder("统计表2", DataTables("泵送明细"))
Dim dt3 As fxDataSource
g3.Groups.AddDef("财务结算年月")
g3.Groups.AddDef("销售工地名称")
g3.Totals.AddDef("结算_销售","泵送费用")
g3.VerticalTotal = True
g3.Filter = "[财务结算年月] = '" & ny.text & "'"
dt3 = g3.BuildDataSource()
Dim ar1() As String = {"结算月","客户名称"}
Dim ar2() As String = {"结算月","客户名称"}
Dim ar3() As String = {"财务结算年月","销售工地名称"}
dt1.Combine(ar1,dt2,ar2)
dt1.Combine(ar1,dt3,ar3)
Tables("明细根表_Table10").DataSource = dt1
Dim g4 As New GroupTableBuilder("统计表2", DataTables("明细根表"))
Dim dt4 As fxDataSource
g4.Groups.AddDef("运输审核_结算月", "结算月")
g4.Groups.AddDef("销售名称", "客户名称")
g4.Groups.AddDef("销售标号")
g4.Totals.AddDef("销售_砼销价", AggregateEnum.Average, "单价")
g4.Totals.AddDef("销量")
g4.VerticalTotal = True
g4.Filter = "[运输审核_结算月] = '" & ny.text & "' and [销] = 'X' and [销售标号] is not Null"
dt4 = g4.BuildDataSource()
Tables("明细根表_Table11").DataSource = dt4
Dim t1 As Table = Tables("明细根表_Table10")
Dim t2 As Table = Tables("明细根表_Table11")
t1.StopRedraw
For i As Integer = 2 To t2.Cols.count-1
t1.DataTable.DataCols.Add(t2.Cols(i).name, Gettype(String), 32, "", t2.Cols(i).caption)
Next
For i As Integer = 0 To t1.Rows.count-2
Dim r1 As Row = t1.Rows(i)
Dim nr1 As Row = Nothing
For Each dr2 As DataRow In t2.DataTable.Select("结算月='" & r1("结算月") & "' and 客户名称='" & r1("客户名称") & "'")
If nr1 Is Nothing Then
nr1 = r1
Else
nr1 = t1.addnew
End If
For Each c As Col In t1.Cols
nr1(c.name) = r1(c.name)
Next
For c As Integer = 2 To t2.Cols.count-1
nr1(t2.cols(c).name) = dr2(t2.cols(c).name)
Next
Next
Next
t1.ResumeRedraw
t1.sort = "结算月,客户名称"
MainTable = t1
Tables("明细根表_Table10").sort = "销档"
DataTables("明细根表_Table10").DataCols.Add("当月_水", Gettype(Double), "iif([水] = 0,null,[水])" )
DataTables("明细根表_Table10").DataCols.Add("当月_砼水金额", Gettype(Double), "iif([吉辅] = '√',null,isnull([砼金额],0) + isnull([水金额],0))" )
DataTables("明细根表_Table10").DataCols.Add("当月_泵送金额", Gettype(Double), "iif([吉辅] = '√',null,iif([泵送费用] = 0,null,[泵送费用]))" )
DataTables("明细根表_Table10").DataCols.Add("当月_运补", Gettype(Double), "iif([吉辅] = '√',null,iif([运输补助] = 0,null,[运输补助]))" )
DataTables("明细根表_Table10").DataCols.Add("当月_超补", Gettype(Double), "iif([吉辅] = '√',null,iif([超时补助] = 0,null,[超时补助]))" )
DataTables("明细根表_Table10").DataCols.Add("当月_他费", Gettype(Double), "iif([吉辅] = '√',null,iif([其他费用] = 0,null,[其他费用]))" )
DataTables("明细根表_Table10").DataCols.Add("调整_方量", Gettype(Double), "iif([吉辅] = '√',null,iif([月调整_方量] = 0,null,[月调整_方量]))" )
DataTables("明细根表_Table10").DataCols.Add("调整_金额", Gettype(Double), "iif([吉辅] = '√',null,iif([月调整_金额] = 0,null,[月调整_金额]))" )
DataTables("明细根表_Table10").DataCols.Add("砼/水明细_浇筑标号", Gettype(String), "[销售标号]" )
DataTables("明细根表_Table10").DataCols.Add("砼/水明细_单价", Gettype(Double), "iif([吉辅] = '√',0,[单价])" )
DataTables("明细根表_Table10").DataCols.Add("砼/水明细_方/车", Gettype(Double), "销量" )
DataTables("明细根表_Table10").DataCols.Add("砼/水明细_金额", Gettype(Double), "[砼/水明细_单价] * [砼/水明细_方/车]" )
DataTables("明细根表_Table10").DataCols.Add("当月_总金额", Gettype(Double), "iif([吉辅] = '√',null,isnull([当月_砼水金额],0) + isnull([当月_泵送金额],0) + isnull([当月_运补],0) + isnull([当月_超补],0) + isnull([当月_他费],0)) " )
DataTables("明细根表_Table10").DataCols.Add("总方量", Gettype(Double), "isnull([当月_总方量],0) + isnull([调整_方量],0) " )
DataTables("明细根表_Table10").DataCols.Add("总金额", Gettype(Double), "iif([吉辅] = '√',0,isnull([当月_总金额],0) + isnull([调整_金额],0)) " )
Tables("明细根表_Table10").Cols("销").Visible = False
Tables("明细根表_Table10").Cols("吉辅").Visible = False
Tables("明细根表_Table10").Cols("砼车数").Visible = False
Tables("明细根表_Table10").Cols("砼金额").Visible = False
Tables("明细根表_Table10").Cols("运输补助").Visible = False
Tables("明细根表_Table10").Cols("超时补助").Visible = False
Tables("明细根表_Table10").Cols("其他费用").Visible = False
Tables("明细根表_Table10").Cols("月调整_方量").Visible = False
Tables("明细根表_Table10").Cols("月调整_金额").Visible = False
Tables("明细根表_Table10").Cols("水").Visible = False
Tables("明细根表_Table10").Cols("水金额").Visible = False
Tables("明细根表_Table10").Cols("泵送费用").Visible = False
Tables("明细根表_Table10").Cols("销售标号").Visible = False
Tables("明细根表_Table10").Cols("单价").Visible = False
Tables("明细根表_Table10").Cols("销量").Visible = False
Tables("明细根表_Table10").Cols("总方量").Move(7)
Tables("明细根表_Table10").Cols("总金额").Move(8)
Tables("明细根表_Table10").Cols("当月_水").Move(12)
Tables("明细根表_Table10").Cols("当月_总金额").Move(13)
Dim t As Table = Tables("明细根表_Table10")
Dim pr As Row = Nothing
For Each r As Row In t.Rows
If pr IsNot Nothing AndAlso r("客户名称") = pr("客户名称") AndAlso r("吉") = pr("吉") AndAlso r("piao") = pr("piao") AndAlso r("总方量") = pr("总方量") AndAlso r("总金额") = pr("总金额") AndAlso r("当月_总方量") = pr("当月_总方量") AndAlso r("当月_水") = pr("当月_水") AndAlso r("当月_总金额") = pr("当月_总金额") AndAlso r("当月_砼水金额") = pr("当月_砼水金额") AndAlso r("当月_泵送金额") = pr("当月_泵送金额") AndAlso r("当月_运补") = pr("当月_运补") AndAlso r("当月_超补") = pr("当月_超补") AndAlso r("当月_他费") = pr("当月_他费") AndAlso r("调整_方量") = pr("调整_方量") AndAlso r("调整_金额") = pr("调整_金额") Then
r("客户名称") = Nothing
r("吉") = Nothing
r("piao") = Nothing
r("总方量") = Nothing
r("总金额") = Nothing
r("当月_总方量") = Nothing
r("当月_水") = Nothing
r("当月_总金额") = Nothing
r("当月_砼水金额") = Nothing
r("当月_泵送金额") = Nothing
r("当月_运补") = Nothing
r("当月_超补") = Nothing
r("当月_他费") = Nothing
r("调整_方量") = Nothing
r("调整_金额") = Nothing
Else
pr = r
End If
Next
Tables("明细根表_Table10").AutoSizeCols()
Tables("明细根表_Table11").AutoSizeCols()