Dim Filter As String = "1=1"
Dim Filter1 As String = "1=1"
With e.Form.Controls("SYB")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "事业部 In ( '" & .Value.replace(",","','") & "')"
End If
End With
With e.Form.Controls("RQ1")
If .Value IsNot Nothing Then
If Filter1 > "" Then
Filter1 = Filter1 & " And "
End If
Filter1 = Filter1 & "日期 >= '" & .value & "'"
End If
End With
With e.Form.Controls("RQ2")
If .Value IsNot Nothing Then
If Filter1 > "" Then
Filter1 = Filter1 & " And "
End If
Filter1 = Filter1 & "日期 <= '" & .value & "'"
End If
End With
Dim dtb As New DataTableBuilder("表B")
dtb.AddDef("日期", Gettype(Date), 4)
dtb.AddDef("费用类型", Gettype(String), 10)
dtb.AddDef("费用性质", Gettype(String), 10)
dtb.AddDef("费用科目", Gettype(String), 10)
dtb.AddDef("生产部门", Gettype(String), 10)
dtb.AddDef("固定费用", Gettype(Double))
dtb.Build()
Dim kms() As String = {"A1","A2","A3","A4","A5"}
For Each dr1 As DataRow In DataTables("固定费用分配表").DataRows
For Each km As String In kms
Dim dr2 As DataRow = DataTables("表B").AddNew()
dr2("日期") = dr1("日期")
dr2("费用类型") = dr1("费用类型")
dr2("费用性质") = dr1("费用性质")
dr2("费用科目") = dr1("费用科目")
dr2("生产部门") = km
dr2("固定费用") = dr1(km)
Next
Next
Dim b As New SQLCrossTableBuilder("统计表1","表B")
Dim dt1 As fxDataSource
b.AddTable("表B","生产部门","生产部门档案","部门名称")
b.HGroups.AddDef("日期",DateGroupEnum.none)
b.HGroups.AddDef("生产部门")
b.VGroups.AddDef("费用性质")
b.VGroups.AddDef("费用类型")
b.Totals.AddDef("固定费用")
b.Filter = Filter1
dt1 = b.BuildDataSource()
dt1.Show("统计表1")
临时表可以用SQLCrossTableBuilder吗,上述代码显示错误,“多余的)在查询表达式‘[日期])‘中