Dim d As Date= Date.Today
Dim y As new timespan(90, 0, 0, 0)
Dim e As new timespan(83, 0, 0, 0)
Dim f As new timespan(60, 0, 0, 0)
Dim g As new timespan(7, 0, 0, 0)
Dim h As new timespan(30, 0, 0, 0)
Dim s As Date
s=d-y
Dim o As Date
o=d-e
Dim p As Date
P=d-f
Dim q As Date
Q=d-g
Dim r As Date
r=d-h
Dim dn As DataRow
For i As Integer=0 To DataTables("库存表20211005").datarows.count-1
dn=DataTables("库存表20211005").datarows(i)
dn("数量90天内")=DataTables("基础数据20211005").compute("sum(数量)", "[入库时间]>#" & s & "# and [物料编码]='"& dn("物料编码") &"'")
Next i
Dim dr As DataRow
Dim du As DataRow
Dim dv As DataRow
For j As Integer=0 To DataTables("库存表20211005").datarows.count-1
dr=DataTables("库存表20211005").datarows(j)
du=DataTables("库存表20210928").find("[物料编码]='"& dr("物料编码") &"'")
dv=DataTables("库存表20210907").find("[物料编码]='"& dr("物料编码") &"'")
If du Is Nothing
dr("与上周比90天内")=dr("数量90天内")
dr("本周到期转出90天内")=0
Else
dr("与上周比90天内")=dr("数量90天内")-du("数量90天内")
dr("本周到期转出90天内")=DataTables("基础数据20211005").compute("sum(数量)", "[入库时间]<#" & o & "# and [入库时间]>#" & s & "# and [物料编码]='"& dr("物料编码") &"'")
End If
If dv Is Nothing
dr("与上月比90天内")=dr("数量90天内")
dr("本月到期转出90天内")=0
Else
dr("与上月比90天内")=dr("数量90天内")-dv("数量90天内")
dr("本月到期转出90天内")=DataTables("基础数据20211005").compute("sum(数量)", "[入库时间]<#" & p & "# and [入库时间]>#" & s & "# and [物料编码]='"& dr("物料编码") &"'")
End If
dr("本周新近转入90天内")=DataTables("基础数据20211005").compute("sum(数量)", "[入库时间]>#" & q & "# and [物料编码]='"& dr("物料编码") &"'")
dr("本周库存消化库存报废退回库存90天内")=dr("与上周比90天内")+dr("本周到期转出90天内")-dr("本周新近转入90天内")
dr("本月新近转入90天内")=DataTables("基础数据20211005").compute("sum(数量)", "[入库时间]>#" & r & "# and [物料编码]='"& dr("物料编码") &"'")
dr("本月库存消化库存报废退回库存90天内")=dr("与上月比90天内")+dr("本月到期转出90天内")-dr("本月新近转入90天内")
Next j
Dim d2 As Date= Date.Today
Dim x2 As new timespan(91, 0, 0, 0)
Dim y2 As new timespan(180, 0, 0, 0)
Dim e2 As new timespan(173, 0, 0, 0)
Dim f2 As new timespan(150, 0, 0, 0)
Dim g2 As new timespan(98, 0, 0, 0)
Dim h2 As new timespan(121, 0, 0, 0)
Dim s2 As Date
S2=d2-y2
Dim t2 As Date
t2=d2-x2
Dim o2 As Date
O2=d2-e2
Dim p2 As Date
P2=d2-f2
Dim q2 As Date
Q2=d2-g2
Dim r2 As Date
R2=d2-h2
Dim dn2 as datarow
For i2 As Integer=0 To DataTables("库存表20211005").datarows.count-1
dn2=DataTables("库存表20211005").datarows(i2)
dn2(“数量91天至180天内”)=datatables(“基础数据20211005”).compute(“sum(数量)”, “[入库时间]>#" & s2 & "# and [入库时间]<=#" & t2 & "# and [物料编码]='"& dn2("物料编码") &"'")
Next i2
Dim dr2 As DataRow
Dim du2 As DataRow
Dim dv2 As DataRow
For j2 As Integer=0 To DataTables("库存表20211005").datarows.count-1
dr2=DataTables("库存表20211005").datarows(j2)
du2=DataTables("库存表20210928").find("[物料编码]='"& dr2("物料编码") &"'")
dv2=DataTables("库存表20210907").find("[物料编码]='"& dr2("物料编码") &"'")
if du2 is nothing
dr2("与上周比91天至180天内")=dr2("数量91天至180天内")
dr2("本周到期转出91天至180天内")=0
else
dr2("与上周比91天至180天内")=dr2("数量91天至180天内")-du2("数量91天至180天内")
dr2("本周到期转出91天至180天内")=datatables(“基础数据20211005”).compute(“sum(数量)”, “[入库时间]<#" & o2 & "# and [入库时间]>#" & s2 & "# and [物料编码]='"& dr2("物料编码") &"'")
End if
if dv2 is nothing
dr2("与上月比91天至180天内")=dr2("数量91天至180天内")
dr2("本月到期转出91天至180天内")=0
else
dr2("与上月比91天至180天内")=dr2("数量91天至180天内")-dv2("数量91天至180天内")
dr2("本月到期转出91天至180天内")=datatables(“基础数据20211005”).compute(“sum(数量)”, “[入库时间]<#" & p2 & "# and [入库时间]>=#" & s2 & "# and [物料编码]='"& dr2("物料编码") &"'")
End if
dr2(“本周到期转入91天至180天内”)=datatables(“基础数据20211005”).compute(“sum(数量)”, “[入库时间]>#" &q2 & "# and [入库时间]<=#" & t2 & "# and [物料编码]='"& dr2("物料编码") &"'")
dr2("本周库存消化库存报废退回库存91天至180天内")=dr2("与上周比91天至180天内")+dr2("本周到期转出91天至180天内")-dr2(“本周到期转入91天至180天内”)
dr2(“本月到期转入91天至180天内”)=datatables(“基础数据20211005”).compute(“sum(数量)”, “[入库时间]>#" & r2 & "# and [入库时间]<=#" & t2 & "# and [物料编码]='"& dr2("物料编码") &"'")
dr2("本月库存消化库存报废退回库存91天至180天内")=dr2("与上月比91天至180天内")+dr2("本月到期转出91天至180天内")-dr2(“本月到期转入91天至180天内”)
Next j2
Dim d3 As Date= Date.Today
Dim x3 As new timespan(181, 0, 0, 0)
Dim y3 As new timespan(365, 0, 0, 0)
Dim e3 As new timespan(358, 0, 0, 0)
Dim f3 As new timespan(335, 0, 0, 0)
Dim g3 As new timespan(188, 0, 0, 0)
Dim h3 As new timespan(211, 0, 0, 0)
Dim s3 As Date
S3=d3-y3
Dim t3 As Date
T3=d3-x3
Dim o3 As Date
O3=d3-e3
Dim p3 As Date
P3=d3-f3
Dim q3 As Date
Q3=d3-g3
Dim r3 As Date
R3=d3-h3
Dim dn3 as datarow
For i3 As Integer=0 To DataTables("库存表20211005").datarows.count-1
dn3=DataTables("库存表20211005").datarows(i3)
dn3(“数量181天至365天内”)=datatables(“基础数据20211005”).compute(“sum(数量)”, “[入库时间]>#" & s3 & "# and [入库时间]<=#" & t3 & "# and [物料编码]='"& dn3("物料编码") &"'")
Next i3
Dim dr3 As DataRow
Dim du3 As DataRow
Dim dv3 As DataRow
For j3 As Integer=0 To DataTables("库存表20211005").datarows.count-1
dr3=DataTables("库存表20211005").datarows(j3)
du3=DataTables("库存表20210928").find("[物料编码]='"& dr3("物料编码") &"'")
dv3=DataTables("库存表20210907").find("[物料编码]='"& dr3("物料编码") &"'")
if du3 is nothing
dr3("与上周比181天至365天内")=dr3("数量181天至365天内")
dr3("本周到期转出181天至365天内")=0
else
dr3("与上周比181天至365天内")=dr3("数量181天至365天内")-du3("数量181天至365天内")
dr3("本周到期转出181天至365天内")=datatables(“基础数据20211005”).compute(“sum(数量)”, “[入库时间]<#" & o3 & "# and [入库时间]>=#" & s3 & "# and [物料编码]='"& dr3("物料编码") &"'")
End if
if dv3 is nothing
dr3("与上月比181天至365天内")=dr3("数量181天至365天内")
dr3("本月到期转出181天至365天内")=0
else
dr3("与上月比181天至365天内")=dr3("数量181天至365天内")-dv3("数量181天至365天内")
dr3("本月到期转出181天至365天内")=datatables(“基础数据20211005”).compute(“sum(数量)”, “[入库时间]<#" & p3 & "# and [入库时间]>=#" & s3 & "# and [物料编码]='"& dr3("物料编码") &"'")
End if
dr3(“本周到期转入181天至365天内”)=datatables(“基础数据20211005”).compute(“sum(数量)”, “[入库时间]>#" & q3 & "# and [入库时间]<=#" & t3 & "# and [物料编码]='"& dr3("物料编码") &"'")
dr3("本周库存消化库存报废退回库存181天至365天内")=dr3("与上周比181天至365天内")+dr3("本周到期转出181天至365天内")-dr3(“本周到期转入181天至365天内”)
dr3(“本月到期转入181天至365天内”)=datatables(“基础数据20211005”).compute(“sum(数量)”, “[入库时间]>#" & r3 & "# and [入库时间]<=#" & t3 & "# and [物料编码]='"& dr3("物料编码") &"'")
dr3("本月库存消化库存报废退回库存181天至365天内")=dr3("与上月比181天至365天内")+dr3("本月到期转出181天至365天内")-dr3(“本月到期转入181天至365天内”)
Next j3
Dim d4 As Date= Date.Today
Dim x4 As new timespan(366, 0, 0, 0)
Dim y4 As new timespan(730, 0, 0, 0)
Dim e4 As new timespan(723, 0, 0, 0)
Dim f4 As new timespan(700, 0, 0, 0)
Dim g4 As new timespan(373, 0, 0, 0)
Dim h4 As new timespan(396, 0, 0, 0)
Dim s4 As Date
这是基础数据,共有73000多行,按照物料编码的间隔日期数量汇总,如90天第一种物料编码汇总多少
这是想要表述出来的