谢谢您的指点,一个是我的费用类的日期确实有问题,二来原来的代码也不是尽人意,今天参考 了内部通讯的时间段统计方法,重做了,能实现了,
再次谢谢大师无私指点!
把代码也贴出来,与小白一起学习。
Dim qs As Date = e.Form.Controls("DateTimePicker1").Value
Dim js As Date = e.Form.Controls("DateTimePicker2").Value
If qs = Nothing Or js = Nothing Then
MessageBox.Show("请输入需要查询的时间段!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
Return
End If
For Each r As Row In Tables("余额")
If r("分公司") IsNot Nothing Then
r("回款_其它老") = DataTables("回款明细").Compute("sum(回款金额)","分公司 = '" & r("分公司") & "' and 收款方式 <> '承兑' and [日期] >= #" & qs & "# And [日期] <= #" & js & "# And 年份 <> 2013 ")
r("回款_其它新") = DataTables("回款明细").Compute("sum(回款金额)","分公司 = '" & r("分公司") & "' and 收款方式 <> '承兑' and[日期] >= #" & qs & "# And [日期] <= #" & js & "# And 年份 = 2013 ")
r("回款_承兑老") = DataTables("回款明细").Compute("sum(回款金额)","分公司 = '" & r("分公司") & "' and 收款方式 = '承兑' and[日期] >= #" & qs & "# And [日期] <= #" & js & "# And 年份 <> 2013 ")
r("回款_承兑新") = DataTables("回款明细").Compute("sum(回款金额)","分公司 = '" & r("分公司") & "' and 收款方式 = '承兑' and[日期] >= #" & qs & "# And [日期] <= #" & js & "# And 年份 = 2013 ")
r("费用_经理往来") = DataTables("费用").Compute("sum(支出金额)","分公司='" & r("分公司") & "' and [日期] >= #" & qs & "# And [日期] <= #" & js & "# And 费用类型 = '经理往来'")
r("费用_劳务费用") = DataTables("费用").Compute("sum(支出金额)","分公司='" & r("分公司") & "' and[日期] >= #" & qs & "# And [日期] <= #" & js & "# And 费用类型 = '劳务费用'")
r("费用_内部往来") = DataTables("费用").Compute("sum(支出金额)","分公司='" & r("分公司") & "' and [日期] >= #" & qs & "# And [日期] <= #" & js & "# And 费用类型 = '内部往来'")
r("费用_累计已付款") = r("费用_经理往来") + r("费用_劳务费用") + r("费用_内部往来")
r("剩余可支配金额") = r("回款_可支配总额") - r("费用_累计已付款")
'r("备注") = Nothing
Else
r("回款_其它老") = Nothing
r("回款_其它新") = Nothing
r("回款_承兑老") = Nothing
r("回款_承兑新") = Nothing
r("费用_经理往来") = Nothing
r("费用_劳务费用") = Nothing
r("费用_内部往来") = Nothing
r("费用_累计已付款") = Nothing
r("剩余可支配金额") = Nothing
r("备注") = Nothing
End If
Next