Dim Filter As String
With e.Form.Controls("品牌")
If .Value IsNot Nothing Then
Filter = "品牌 = '" & .Value & "'"
End If
End With
With e.Form.Controls("门店")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "门店 = '" & .Value & "'"
End If
End With
With e.Form.Controls("年份")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "年份 = '" & .Value & "'"
End If
End With
With e.Form.Controls("季节")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "季节 = '" & .Value & "'"
End If
End With
With e.Form.Controls("开始日期")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "单据日期 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("截止日期")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "单据日期 <= #" & .Value & "#"
End If
End With
If Filter > "" Then
Tables("出入库明细").Filter = Filter
End If
Dim dt1,dt2 As DataTable
dt1=DataTables("出入库明细")
dt2=DataTables("库调明细表_主表")
Dim Arys As List(Of String())
Dim dr As DataRow
Arys = DataTables("出入库明细").GetValues("编码|名称|颜色|尺码|年份|季节|零售价|款号",Filter)
For Each Ary As String() In Arys
dr= DataTables("库存报表").addnew
dr("编码")=Ary(0)
dr("名称")=Ary(1)
dr("颜色")=Ary(2)
dr("尺码")=Ary(3)
dr("年份")=Ary(4)
dr("季节")=Ary(5)
dr("零售价")=Ary(6)
Next
dr("库房_调拨出库")=dt1.Compute("sum(数量)", Filter & " And 编码 = '"& dr("编码") &"'" And 业务单号首位 = 'D'and 收发类型= '调拨出库')
dr("店铺_调拨出库")=dt1.Compute("sum(数量)", Filter & " And 编码 = '"& dr("编码") &"'" And 业务单号首位 = 'R'and 收发类型= '调拨出库')
dr("店铺_调拨入库")=dt1.Compute("sum(数量)", Filter & " And 编码 = '"& dr("编码") &"'" And 业务单号首位 = 'R'and 收发类型= '调拨入库')
dr("库房_收货入库")=dt1.Compute("sum(数量)", Filter & " And 编码 = '"& dr("编码") &"'" And 业务单号首位 = 'F'and 收发类型= '收货入库')
dr("库房_返货出库")=dt1.Compute("sum(数量)", Filter & " And 编码 = '"& dr("编码") &"'" And 业务单号首位 = 'T'and 收发类型= '返货出库')
dr("店铺_零售出库")=dt1.Compute("sum(数量)", Filter & " And 编码 = '"& dr("编码") &"'" And 收发类型= '零售出库')
dr("店铺_零退入库")=dt1.Compute("sum(数量)", Filter & " And 编码 = '"& dr("编码") &"'" And 收发类型= '零退入库')
dr("店铺_库调")=dt2.Compute("sum(数量)", Filter & " And 编码 = '"& dr("编码") &"'" And 收发类型= '库调')
dr("店铺_退货入库")=dt2.Compute("sum(数量)", Filter & " And 编码 = '"& dr("编码") &"'" And 收发类型= '退货入库')