Syscmd.Project.Save()
Dim b As New SQLGroupTableBuilder("统计表1","中间计量表")
b.C
b.Groups.AddDef("项目名称") '根据产品分组
b.Groups.AddDef("施工合同段") '根据产品分组
b.Groups.AddDef("计量期次") '根据产品分组
b.Groups.AddDef("章节") '根据产品分组
b.Totals.AddExp("第100章","case when 章节 = '100' then Round(申报数量 * 单价,0) else 0 end")
b.Totals.AddExp("第200章","case when 章节 = '200' then Round(申报数量 * 单价,0) else 0 end")
b.Totals.AddExp("第300章","case when 章节 = '300' then Round(申报数量 * 单价,0) else 0 end")
b.Totals.AddExp("第400章","case when 章节 = '400' then Round(申报数量 * 单价,0) else 0 end")
b.Totals.AddExp("第500章","case when 章节 = '500' then Round(申报数量 * 单价,0) else 0 end")
b.Totals.AddExp("第600章","case when 章节 = '600' then Round(申报数量 * 单价,0) else 0 end")
b.Totals.AddExp("第700章","case when 章节 = '700' then Round(申报数量 * 单价,0) else 0 end")
b.Totals.AddExp("第800章","case when 章节 = '800' then Round(申报数量 * 单价,0) else 0 end")
b.Totals.AddExp("第900章","case when 章节 = '900' then Round(申报数量 * 单价,0) else 0 end")
b.Build '生成统计表
'MainTable = Tables("统计表1") '打开生成的统计表
DataTables("计量汇总").DataRows.Clear
Dim Cols1() As String = {"项目名称","施工合同段","计量期次","第100章","第200章","第300章","第400章","第500章","第600章","第700章","第800章","第900章"}'指定数据来源列
Dim Cols2() As String = {"项目名称","施工合同段","计量期次","第100章","第200章","第300章","第400章","第500章","第600章","第700章","第800章","第900章"}'指定数据接收表
For Each dr1 As DataRow In DataTables("统计表1").Select("[计量期次] > 0")
Dim dr2 As DataRow = DataTables("计量汇总").Find("项目名称 = '" & dr1("项目名称") & "' and 施工合同段 = '" & dr1("施工合同段") & "' and 计量期次 = '" & dr1("计量期次") & "'")
If dr2 Is Nothing Then
dr2 = DataTables("计量汇总").AddNew()
End If
For i As Integer = 0 To Cols1.Length -1
dr2(Cols2(i)) = dr1(Cols1(i))
Next
Next