For Each dr As DataRow In drs
Filter = "[_Identify] <= " & dr("_Identify") & " And [配件信息_配件编码] = '" & dr("配件信息_配件编码") & "'"
Dim Val1 As Double = e.DataTable.Compute("Sum(出入库信息_入库数量)",Filter)
Dim Val2 As Double = e.DataTable.Compute("Sum(出入库信息_出库数量)",Filter)
Dim Val3 As Double = e.DataTable.Compute("Sum(库存结余)",Filter & " And 出入库信息_入库数量 Is null And 出入库信息_出库数量 Is null")
dr("库存结余") = Val1 - Val2 + val3
Next
改成
For Each dr As DataRow In drs
Filter = "[_Identify] <= " & dr("_Identify") & " And [配件信息_配件编码] = '" & dr("配件信息_配件编码") & "'"
Dim Val1 As Double = e.DataTable.Compute("Sum(出入库信息_入库数量)",Filter)
Dim Val2 As Double = e.DataTable.Compute("Sum(出入库信息_出库数量)",Filter)
dr("库存结余") = Val1 - Val2
Next