哪位老师帮我看看代码,为什么就不计算或计不正确呢。。。。。
Dim y As Integer = Date.Today.Year
Dim w As Integer = Date.Today.DayOfWeek '算出今天是星期几
Dim m As Integer = Date.Today.Month
Dim dt1 As Date = Date.Today '获取今天的日期
Dim dt5 As Date = Date.Today.AddDays(-w) '获取本周的第一天
Dim dt6 As Date = Date.Today.AddDays(6 - w) '获取本周的最后一天
Dim dt7 As New Date(y, m, 1)
Dim dt8 As New Date(y, m, Date.DaysInMonth(y, m)) '获取本月的最后一天
Dim q As Integer = (Date.Today.Month - 1) \ 3 + 1 '计算现在是第几个季度
Dim dt11 As New Date(y, 3 * (q - 1) + 1, 1) '获取本季度的第一天
Dim dt12 As New Date(y, 3 * q, Date.DaysInMonth(y,3 * q)) '获取本季度的最后一天
Dim dt13 As New Date(y, 1, 1)
Dim dt14 As New Date(y, 12, 31)
If e.DataCol.Name = "单位简称" Then
Dim filter1 As String = "单位简称 = '" & e.DataRow("单位简称") & "'"
e.DataRow("本周本金1") = DataTables("hbfxjhb").Compute("Count(_Identify)" ,filter1 & "And [rq] >= '" & dt5 & "'And [rq] <= '" & dt6 & "'And [hbje] > 0 ")
e.DataRow("本周本金2") = DataTables("hbfxjhb").Compute("sum(hbje)" ,filter1 & "And [rq] >= '" & dt5 & "'And [rq] <= '" & dt6 & "'")
e.DataRow("本周本金3") = DataTables("hbmxb").Compute("Count(_Identify)",filter1 & "And [rq] >= '" & dt5 & "'And [rq] <= '" & dt6 & "'")
e.DataRow("本周本金4") = DataTables("hbmxb").Compute("sum(hkje)",filter1 & "And [rq] >= '" & dt5 & "'And [rq] <= '" & dt6 & "'")/10000
e.DataRow("本周本金6") = DataTables("xzfkmxb").Compute("Count(_Identify)",filter1 & "And [rq] >= '" & dt5 & "'And [rq] <= '" & dt6 & "'")
e.DataRow("本周本金5") = DataTables("xzfkmxb").Compute("sum(byfk)",filter1 & "And [rq] >= '" & dt5 & "'And [rq] <= '" & dt6 & "'")/10000
e.DataRow("本周利息1") = DataTables("hbfxjhb").Compute("Count(_Identify)",filter1 & "And [rq] >= '" & dt5 & "'And [rq] <= '" & dt6 & "'And [fxje] > 0 ")
e.DataRow("本周利息2") = DataTables("hbfxjhb").Compute("sum(fxje)",filter1 & "And [rq] >= '" & dt5 & "'And [rq] <= '" & dt6 & "'")
e.DataRow("本周利息3") = DataTables("lxmxb").Compute("Count(_Identify)",filter1 & "And [rq] >= '" & dt5 & "'And [rq] <= '" & dt6 & "'")
e.DataRow("本周利息4") = DataTables("lxmxb").Compute("sum(zfje)",filter1 & "And [rq] >= '" & dt5 & "'And [rq] <= '" & dt6 & "'")/10000
e.DataRow("本周piao据2") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [到期日期] >= '" & dt5 & "'And [到期日期] <= '" & dt6 & "'")/10000
e.DataRow("本周piao据4") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [到期日期] >= '" & dt5 & "'And [到期日期] <= '" & dt6 & "'and [兑付] = 'True' ")/10000
e.DataRow("本周piao据5") = DataTables("pjmxb").Compute("Count(_Identify)",filter1 & "And [出piao日期] >= '" & dt5 & "'And [出piao日期] <= '" & dt6 & "'")
e.DataRow("本周piao据6") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [出piao日期] >= '" & dt5 & "'And [出piao日期] <= '" & dt6 & "'")/10000
e.DataRow("本月本金1") = DataTables("hbfxjhb").sqlCompute("Count(_Identify)",filter1 & "And [rq] >= '" & dt7 & "'And [rq] <= '" & dt8 & "'And [hbje] > 0 ")
e.DataRow("本月本金2") = DataTables("hbfxjhb").sqlCompute("sum(hbje)",filter1 & "And [rq] >= '" & dt7 & "'And [rq] <= '" & dt8 & "'")
e.DataRow("本月本金3") = DataTables("hbmxb").sqlCompute("Count(_Identify)",filter1 & "And [rq] >= '" & dt7 & "'And [rq] <= '" & dt8 & "'")
e.DataRow("本月本金4") = DataTables("hbmxb").sqlCompute("sum(hkje)",filter1 & "And [rq] >= '" & dt7 & "'And [rq] <= '" & dt8 & "'")/10000
e.DataRow("本月本金6") = DataTables("xzfkmxb").sqlCompute("Count(_Identify)",filter1 & "And [rq] >= '" & dt7 & "'And [rq] <= '" & dt8 & "'")
e.DataRow("本月本金5") = DataTables("xzfkmxb").sqlCompute("sum(byfk)",filter1 & "And [rq] >= '" & dt7 & "'And [rq] <= '" & dt8 & "'")/10000
e.DataRow("本月利息1") = DataTables("hbfxjhb").sqlCompute("Count(_Identify)",filter1 & "And [rq] >= '" & dt7 & "'And [rq] <= '" & dt8 & "'And [fxje] > 0 ")
e.DataRow("本月利息2") = DataTables("hbfxjhb").sqlCompute("sum(fxje)",filter1 & "And [rq] >= '" & dt7 & "'And [rq] <= '" & dt8 & "'")
e.DataRow("本月利息3") = DataTables("lxmxb").sqlCompute("Count(_Identify)",filter1 & "And [rq] >= '" & dt7 & "'And [rq] <= '" & dt8 & "'")
e.DataRow("本月利息4") = DataTables("lxmxb").sqlCompute("sum(zfje)",filter1 & "And [rq] >= '" & dt7 & "'And [rq] <= '" & dt8 & "'")/10000
e.DataRow("本月piao据2") = DataTables("pjmxb").sqlCompute("sum(开piao金额)",filter1 & "And [到期日期] >= '" & dt7 & "'And [到期日期] <= '" & dt8 & "'")/10000
e.DataRow("本月piao据4") = DataTables("pjmxb").sqlCompute("sum(开piao金额)",filter1 & "And [到期日期] >= '" & dt7 & "'And [到期日期] <= '" & dt8 & "'and [兑付] = 'True' ")/10000
e.DataRow("本月piao据5") = DataTables("pjmxb").sqlCompute("Count(_Identify)",filter1 & "And [出piao日期] >= '" & dt7 & "'And [出piao日期] <= '" & dt8 & "'")
e.DataRow("本月piao据6") = DataTables("pjmxb").sqlCompute("sum(开piao金额)",filter1 & "And [出piao日期] >= '" & dt7 & "'And [出piao日期] <= '" & dt8 & "'")/10000
e.DataRow("本季本金2") = DataTables("hbfxjhb").sqlCompute("sum(hbje)",filter1 & "And [rq] > '" & dt11 & "'And [rq] <= '" & dt12 & "'")
e.DataRow("本季本金4") = DataTables("hbmxb").sqlCompute("sum(hkje)",filter1 & "And [rq] > '" & dt11 & "'And [rq] <= '" & dt12 & "'")/10000
e.DataRow("本季利息2") = DataTables("hbfxjhb").sqlCompute("sum(hbje)",filter1 & "And [rq] > '" & dt11 & "'And [rq] <= '" & dt12 & "'")
e.DataRow("本季利息4") = DataTables("lxmxb").sqlCompute("sum(zfje)",filter1 & "And [rq] > '" & dt11 & "'And [rq] <= '" & dt12 & "'")/10000
e.DataRow("本季piao据2") = DataTables("pjmxb").sqlCompute("sum(开piao金额)",filter1 & "And [到期日期] > '" & dt11 & "'And [到期日期] <= '" & dt12 & "'")/10000
e.DataRow("本季piao据2") = DataTables("pjmxb").sqlCompute("sum(开piao金额)",filter1 & "And [到期日期] > '" & dt11 & "'And [到期日期] <= '" & dt12 & "'and [兑付] = 'True' ")/10000
e.DataRow("本年本金2") = DataTables("hbfxjhb").sqlCompute("sum(hbje)",filter1 & "And [rq] > '" & dt13 & "'And [rq] <= '" & dt14 & "'")
e.DataRow("本年本金4") = DataTables("hbmxb").sqlCompute("sum(hkje)",filter1 & "And [rq] > '" & dt13 & "'And [rq] <= '" & dt14 & "'")/10000
e.DataRow("本年利息2") = DataTables("hbfxjhb").sqlCompute("sum(hbje)",filter1 & "And [rq] > '" & dt13 & "'And [rq] <= '" & dt14 & "'")
e.DataRow("本年利息4") = DataTables("lxmxb").sqlCompute("sum(zfje)",filter1 & "And [rq] > '" & dt13 & "'And [rq] <= '" & dt14 & "'")/10000
e.DataRow("本年piao据2") = DataTables("pjmxb").sqlCompute("sum(开piao金额)",filter1 & "And [到期日期] > '" & dt13 & "'And [到期日期] <= '" & dt14 & "'")/10000
e.DataRow("本年piao据4") = DataTables("pjmxb").sqlCompute("sum(开piao金额)",filter1 & "And [到期日期] > '" & dt13 & "'And [到期日期] <= '" & dt14 & "'and [兑付] = 'True' ")/10000
End If