进货、销售、退货数量及库存数据计算可以这样:
For Each dr As DataRow In DataTables("库存清单").DataRows
Dim sum1,sum2,sum3 As Integer
Dim dr1 As DataRow = DataTables("进货单").Find("型号 = '" & dr("型号") & "'")
If dr1 IsNot Nothing Then
sum1 = DataTables("进货单").Compute("Sum(数量)","型号 = '" & dr("型号") & "'")
dr("进货_数量") = sum1
End If
Dim dr2 As DataRow = DataTables("销售单").Find("型号 = '" & dr("型号") & "'")
If dr2 IsNot Nothing Then
sum2 = DataTables("销售单").Compute("Sum(数量)","型号 = '" & dr("型号") & "'")
dr("销售_数量") = sum2
End If
Dim dr3 As DataRow = DataTables("退货单").Find("型号 = '" & dr("型号") & "'")
If dr3 IsNot Nothing Then
sum3 = DataTables("退货单").Compute("Sum(数量)","型号 = '" & dr("型号") & "'")
dr("退货_数量") = sum3
End If
dr("库存_数量") = sum1-sum2-sum3
Next
单价不知道怎么弄
假如某个物品销售不止一次,且销售价格不一,此时的销售价格怎么算?是按平均算还是……?