修改代码
Select Case e.DataCol.name
Case "类型"
If e.DataRow.IsNull("类型") = False AndAlso e.DataRow.IsNull("描述") = False Then
Dim dr As DataRow
If e.OldValue = Nothing Then
dr = DataTables("库存").Find("类型 = '" & e.NewValue & "' and 描述 = '" & e.DataRow("描述") & "'")
Else
dr = DataTables("库存").Find("类型 = '" & e.oldvalue & "' and 描述 = '" & e.DataRow("描述") & "'")
End If
If dr Is Nothing Then
dr = DataTables("库存").AddNew()
dr("类型") = e.DataRow("类型")
dr("描述") = e.DataRow("描述")
dr("数量") = e.DataRow("数量")
dr("单价") = e.DataRow("单价")
Else
dr("类型") = e.DataRow("类型")
End If
End If
Case "描述"
Case "类型"
If e.DataRow.IsNull("类型") = False AndAlso e.DataRow.IsNull("描述") = False Then
Dim dr As DataRow
If e.OldValue = Nothing Then
dr = DataTables("库存").Find("类型 = '" & e.DataRow("类型") & "' and 描述 = '" & e.NewValue & "'")
Else
dr = DataTables("库存").Find("类型 = '" & e.DataRow("类型") & "' and 描述 = '" & e.oldvalue & "'")
End If
If dr Is Nothing Then
dr = DataTables("库存").AddNew()
dr("类型") = e.DataRow("类型")
dr("描述") = e.DataRow("描述")
dr("数量") = e.DataRow("数量")
dr("单价") = e.DataRow("单价")
Else
dr("类型") = e.DataRow("类型")
End If
End If
Case "描述","数量","单价"
Dim dr As DataRow = DataTables("库存").Find("类型 = '" & e.DataRow("类型") & "' and 描述 = '" & e.DataRow("描述") & "'")
If dr Is Nothing Then
dr = DataTables("库存").AddNew()
dr("类型") = e.DataRow("类型")
dr("描述") = e.DataRow("描述")
End If
dr("单价") = e.DataRow("单价")
dr("数量") = e.DataTable.Compute("sum(数量)","类型 = '" & e.DataRow("类型") & "' and 描述 = '" & e.DataRow("描述") & "'")
End Select