狐表中的自带高效流水账项目中表有:产品,出库,入库,库存列,通过代码可以求得相同产品的库存数量。
请问:
若是在上表修改为:产品,工序名称,生产数量,累计完成等列
现在需要求得相同产品中的相同工序的生产数量的累计完成数量
求问代码如何修改
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("产品") & "'", "[_SortKey] Desc")
If dr Is Nothing Then
mr("累计完成") = mr("生产数量")
dr = mr
End If
drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [产品] = '" & dr("产品") & "'", "[_SortKey]")
For i As Integer = 1 To drs.Count - 1
drs(i)("累计完成") = drs(i-1)("累计完成") + 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 & "'", "[_SortKey] Desc")
If dr Is Nothing Then
dr = e.DataTable.Find("[产品] = '" & e.OldValue & "'", "[_SortKey]")
If dr IsNot Nothing Then
dr("累计完成") = dr("生产数量")
End If
End If
If dr IsNot Nothing Then
drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [产品] = '" & dr("产品") & "'", "[_SortKey]")
For i As Integer = 1 To drs.Count - 1
drs(i)("累计完成") = drs(i-1)("累计完成") + drs(i)("生产数量") Next
End If
End If
End Select
Dim Key As Decimal
Dim Index As Integer
Dim Filter As String
Dim r As Row
Index = Math.Min(e.OldIndex, e.NewIndex)
Key = e.Table.Rows(Index)("_SortKey")
r = e.Table.Rows(e.NewIndex)
Filter = "[_SortKey] >= " & Key & " And [产品] = '" & r("产品") & "'"
e.Table.DataTable.DataCols("生产数量").RaiseDataColChanged(Filter)
谢谢了