Dim d As Date = e.Form.Controls("DateTimePicker1").value
Dim y As Integer = d.Year
Dim m As Integer = d.Month
Dim dt1 As New Date(y, m, 1) '按月统计
Dim q As Integer = math.Ceiling(d.month / 3)
Dim dt2 As New Date(y, 3 * (q - 1) + 1, 1) '获取该季度的第一天
Dim dt3 As New Date(y, 3 * q, Date.DaysInMonth(2011,3 * q)) '获取该季度的最后一天
Dim filter As String = ""
DataTables("汇总").StopRedraw
DataTables("汇总").DataRows.Clear
For Each xh As String In DataTables("库存流水帐").GetValues("型号", "型号 is not null")
Dim ndr As DataRow = DataTables("汇总").AddNew
ndr("型号") = xh
filter = "型号 = '" & xh & "' and 时间 >= #" & dt1 & "# and 时间 < #" & dt1.AddMonths(1) & "#"
ndr("入库统计_本月累计入库") = DataTables("库存流水帐").Compute("sum(入库数量)", filter)
ndr("出库统计_本月累计出库") = DataTables("库存流水帐").Compute("sum(出库数量)", filter)
filter = "型号 = '" & xh & "' and 时间 >= #" & dt2 & "# and 时间 < #" & dt3.AddDays(1) & "#"
ndr("入库统计_本季累计入库") = DataTables("库存流水帐").Compute("sum(出库数量)", filter)
Next
DataTables("汇总").ResumeRedraw