If e.DataCol.Name = "数量" Then
Dim 当前行 As DataRow = e.DataRow
If 当前行.IsNull("名称") = False Then
Dim 当前时间之前当前物品入库数 As Integer = DataTables("入库表").Compute("Sum(数量)", "名称='" & 当前行("名称") & "' and 时间<=#" & 当前行("时间") & "#")
Dim 当前时间之前当前物品出库数 As Integer = e.DataTable.Compute("Sum(数量)", "名称='" & 当前行("名称") & "' and 时间<=#" & 当前行("时间") & "#")
当前行("存量") = 当前时间之前当前物品入库数 - 当前时间之前当前物品出库数
End If
End If