Dim c1 As String = e.Form.Controls("ComboBox1").Text
Dim c2 As String = e.Form.Controls("ComboBox2").Text
Dim c3 As String = e.Form.Controls("ComboBox3").Text
Dim d As Date = new Date(Date.Today.Year, 1, 1)
Dim filter As String = "项目名称 is not null"
Dim dt1 As DataTable = DataTables("付款表")
Dim dt2 As DataTable = DataTables("资金来源表")
Dim f_fk1 As String = "付款日期 < #" & d & "#"
Dim f_fk2 As String = "付款日期 >= #" & d & "# And 付款日期 < #" & d.AddYears(1) & "#"
Dim f_ly1 As String = "日期 < #" & d &"#"
Dim f_ly2 As String = "日期 >= #" & d & "# And 日期 < #" & d.AddYears(1) & "#"
If c1 > "" Then
filter &= " and 项目名称 = '" & c1 & "'"
End If
If c2 > "" Then
f_fk1 &= " and 付款日期 >= #" & c2 & "#"
f_fk2 &= " And 付款日期 >= #" & c2 & "#"
f_ly1 &= " and 日期 >= #" & c2 & "#"
f_ly2 &= " And 日期 >= #" & c2 & "#"
End If
If c3 > "" Then
f_fk1 &= " and 付款日期 <= #" & c3 & "#"
f_fk2 &= " And 付款日期 <= #" & c3 & "#"
f_ly1 &= " and 日期 <= #" & c3 & "#"
f_ly2 &= " And 日期 <= #" & c3 & "#"
End If
Dim dt3 As DataTable = DataTables("投资统计表")
dt3.DataRows.Clear
For Each xm As String In dt2.GetValues("项目名称", filter)
Dim ndr As DataRow = dt3.AddNew
ndr("项目名称") = xm
ndr("第三列") = dt2.Compute("sum(收款金额)", f_ly2 & " and 项目名称 = '" & xm & "'")
ndr("第四列") = dt2.Compute("sum(收款金额)", f_ly1 & " and 项目名称 = '" & xm & "'")
ndr("第六列") = dt1.Compute("sum(付款金额)", f_fk2 & " and 项目名称 = '" & xm & "'")
ndr("第七列") = dt1.Compute("sum(付款金额)", f_fk1 & " and 项目名称 = '" & xm & "'")
Next