BeforeBuild
Select Case e.Book.TempLate
Case "辅机收发存"
vars("数量") = 0
vars("除税") = 0
e.Book.Marks.Add("当月入库数量",0)
e.Book.Marks.Add("当月入库金额除税",0)
End Select
BuildDetail
Select Case e.Book.TempLate
Case "辅机收发存"
If e.DataRow IsNot Nothing AndAlso e.Region = "生产令号" Then
Dim y As Integer = Date.Today.Year
Dim m As Integer = Date.Today.Month
Dim dt1 As New Date(y, m, 1)
Dim dt2 As New Date(y, m, Date.DaysInMonth(y, m)) '获取本月的最后一天
Dim Filter As String
Filter = "入库时间 >= #" & dt1 & "# And 入库时间 <= #" & dt2 & "#"
vars("数量") += e.DataRow("已入库数量")
e.Book.Marks("当月入库数量") = vars("数量")
e.Book.Marks("当月入库金额除税") = val(DataTables("入库信息").find(Filter)("当月入库金额除税"))
e.Book.Marks("当月入库数量合计") = val(DataTables("入库信息").Compute("sum(当月入库数量)",Filter))
e.Book.Marks("当月入库金额除税合计") = val(DataTables("入库信息").Compute("sum(当月入库金额除税)",Filter))
End If
End Select