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("等级") & "'And [色号] = " & mr("色号") , "[_SortKey] Desc")
If dr Is Nothing Then
mr("库存") = mr("入库") - mr("出库")
dr = mr
End If
drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [产品编号] = '" & mr("产品编号") & "'And [等级] = '" & mr("等级") & "'And [色号] = " & mr("色号") , "[_SortKey]")
For i As Integer = 1 To drs.Count - 1
drs(i)("库存") = drs(i-1)("库存") + drs(i)("入库") - drs(i)("出库")
Next
End Select
注意色号是整数型,表达式是不能用单引号的,请参考:
http://help.foxtable.com/topics/1284.htm
[此贴子已经被作者于2011-4-21 16:59:11编辑过]