Select Case e.DataCol.name
Case "商品编号","初始数据"
e.DataRow("库存_仓库") = e.DataRow("库存_仓库")
e.DataRow("库存_店铺") = e.DataRow("库存_店铺")
e.DataRow("库存_缓冲") = e.DataRow("库存_缓冲")
If e.DataRow.IsNull("商品编号") = False Then
Dim sum7 As Double = DataTables("库存调拨").Compute("sum(调拨数量)", "调入仓库 = '仓库' and 商品编号 = '" & e.DataRow("商品编号") & "'")
Dim sum8 As Double = DataTables("库存调拨").Compute("sum(调拨数量)", "调出仓库 = '仓库' and 商品编号 = '" & e.DataRow("商品编号") & "'")
e.DataRow("库存_仓库") = 0 + DataTables("入库表").Compute("sum(入库数量)", "商品编号 = '" & e.DataRow("商品编号") & "'and 仓库='仓库'") - DataTables("销售表").Compute("sum(销售数量)", "商品编号 = '" &e.DataRow("商品编号") & "'and 仓库='仓库'") + DataTables("退货信息").Compute("sum(退货数量)", "商品编号 = '" &e.DataRow("商品编号") & "'and 仓库='仓库'") + sum7 - sum8
Dim sum10 As Double = DataTables("库存调拨").Compute("sum(调拨数量)", "调入仓库 = '店铺' and 商品编号 = '" & e.DataRow("商品编号") & "'")
Dim sum11 As Double = DataTables("库存调拨").Compute("sum(调拨数量)", "调出仓库 = '店铺' and 商品编号 = '" & e.DataRow("商品编号") & "'")
e.DataRow("库存_店铺") = 0 + DataTables("入库表").Compute("sum(入库数量)", "商品编号 = '" & e.DataRow("商品编号") & "'and 仓库='店铺'") - DataTables("销售表").Compute("sum(销售数量)", "商品编号 = '" &e.DataRow("商品编号") & "'and 仓库='店铺'") + DataTables("退货信息").Compute("sum(退货数量)", "商品编号 = '" &e.DataRow("商品编号") & "'and 仓库='店铺'") + sum10 - sum11
Dim sum15 As Double = DataTables("库存调拨").Compute("sum(调拨数量)", "调入仓库 = '缓冲' and 商品编号 = '" & e.DataRow("商品编号") & "'")
Dim sum16 As Double = DataTables("库存调拨").Compute("sum(调拨数量)", "调出仓库 = '缓冲' and 商品编号 = '" & e.DataRow("商品编号") & "'")
e.DataRow("库存_缓冲") = 0 + DataTables("入库表").Compute("sum(入库数量)", "商品编号 = '" & e.DataRow("商品编号") & "'and 仓库='缓冲'") - DataTables("销售表").Compute("sum(销售数量)", "商品编号 = '" &e.DataRow("商品编号") & "'and 仓库='缓冲'") + DataTables("退货信息").Compute("sum(退货数量)", "商品编号 = '" &e.DataRow("商品编号") & "'and 仓库='缓冲'") + sum15 - sum16
e.DataRow("累计_总出库") = DataTables("销售表").Compute("sum(销售数量)", "商品编号 = '" &e.DataRow("商品编号") & "'")
e.DataRow("累计_总入库") = DataTables("入库表").Compute("sum(入库数量)", "商品编号 = '" &e.DataRow("商品编号") & "'")
e.DataRow("库存数量") = e.DataRow("初始数据") + e.DataRow("库存_仓库") + e.DataRow("库存_店铺") + e.DataRow("库存_缓冲")
End If
End Select