这个是狐表自带的高效流水账,我在其中加了“公司”一列,狐表自带的高效流水账是以产品的入库、出库计算库存,我想实现以公司产品的入库、出库计算出库存,就是在原来”产品“计算库存的基础上加入一个前提条件“公司”来计算库存,以实现每个公司的每种产品单独计算库存,希望能得到帮助,
以下是狐表自带的代码:该如何修改?求解........................
例子二_DataColChanged
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("入库") - 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)("入库") - 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("入库") - 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)("入库") - drs(i)("出库")
Next
End If
End If
End Select
例子二_DataRowDeleting
e.DataRow("入库") = 0
e.DataRow("出库") = 0
例子二_AfterMoveRow
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)