Select Case e.DataCol.Name
Case "物料名称", "入库数量", "库存数量", "规格型号"
Dim dr As DataRow
Dim mr As DataRow = e.DataRow
Dim drs As List(Of DataRow)
dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [物料名称] = '" & mr("物料名称") & "' and [规格型号]='" & mr("规格型号") & "'", "[_SortKey] Desc")
If dr Is Nothing Then
mr("库存数量") = mr("入库数量") - mr("出库数量")
dr = mr
End If
drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [物料名称] = '" & dr("物料名称") & "' and [规格型号]='" & mr("规格型号") & "'", "[_SortKey]")
For i As Integer = 1 To drs.Count - 1
drs(i)("库存数量") = drs(i - 1)("库存数量") + drs(i)("入库数量") - drs(i)("出库数量")
Next
If e.DataCol.Name = "物料名称" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [物料名称] = '" & e.OldValue & "' and [规格型号]='" & e.OldValue & "'", "[_SortKey] Desc")
If dr Is Nothing Then
dr = e.DataTable.Find("[物料名称] = '" & e.OldValue & "' and [规格型号]='" & e.OldValue & "'", "[_SortKey]")
If dr IsNot Nothing Then
dr("库存数量") = dr("入库数量") - dr("出库数量")
End If
End If
If dr IsNot Nothing Then
drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [物料名称] = '" & dr("物料名称") & "' and [规格型号] ='" & mr("规格型号") & "'", "[_SortKey]")
For i As Integer = 1 To drs.Count - 1
drs(i)("物料名称") = drs(i - 1)("库存数量") + drs(i)("入库数量") - drs(i)("出库数量")
Next
End If
End If
End Select此主题相关图片如下:微信图片_20220605211113.png
我想通过物料名称 加规格型号 都相同才能计算 问一下这个该怎么改