按照此方法 报错
~
此主题相关图片如下:搜狗截图_2011-09-01_23-09-56.png
代码:
DataColChanging
e.DataRow("入库数量") = 0
e.DataRow("出库数量") = 0
DataColChanged
Select Case e.DataCol.Name
Case "款式","型号"
e.DataRow("遍号") = e.DataRow("款式") + e.DataRow("型号")
End Select
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
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)
此主题相关图片如下:未命名.jpg
[此贴子已经被作者于2011-9-2 8:37:45编辑过]