代码如下
If e.DataRow.Isnull("产品编号") = False AndAlso e.DataRow.Isnull("产品名称") = False Then
Dim filter As String = "产品编号 = '" & e.DataRow("产品编号") & "' and 产品名称 = '" & e.DataRow("产品名称") & "'"
Dim fdr As DataRow = DataTables("库存表").Find(filter)
If fdr Is Nothing Then
fdr = DataTables("库存表").AddNew()
End If
fdr("产品编号") = e.DataRow("产品编号")
fdr("产品名称") = e.DataRow("产品名称")
fdr("数量") = e.DataTable.Compute("sum(数量)", filter)
End If