Select Case e.DataCol.Name
Case "项目名称","施工合同段","支付编号","桩号","申报数量"
Dim drs As List(of DataRow)
Dim Filter As String
Filter = "[_SortKey] >= " & e.DataRow("_SortKey") & " And [项目名称] = '" & e.DataRow("项目名称") & " And [施工合同段] = '" & e.DataRow("施工合同段") & " And [支付编号] = '" & e.DataRow("支付编号") & " And [桩号] = '" & e.DataRow("桩号") & "'"
drs = e.DataTable.Select(Filter)
For Each dr As DataRow In drs
Filter = "[_SortKey] <= " & dr("_SortKey") & " And [项目名称] = '" & e.DataRow("项目名称") & " And [施工合同段] = '" & e.DataRow("施工合同段") & " And [支付编号] = '" & e.DataRow("支付编号") & " And [桩号] = '" & e.DataRow("桩号") & "'"
Dim Val1 As Double = e.DataTable.Compute("Sum(申报数量)",Filter)
dr("累计申报数量") = Val1
Next
If e.DataCol.Name = "项目名称" AndAlso e.DataCol.Name = "施工合同段" AndAlso e.DataCol.Name = "支付编号" AndAlso e.DataCol.Name = "桩号" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
Filter = "[_SortKey] > " & e.DataRow("_SortKey") & " And [项目名称] = '" & e.OldValue & "' And [施工合同段] = '" & e.OldValue & "' And [施工合同段] = '" & e.OldValue & "' And [支付编号] = '" & e.OldValue & "' And [桩号] = '" & e.OldValue & "'"
drs = e.DataTable.Select(Filter)
For Each dr As DataRow In drs
Filter = "[_SortKey] <= " & dr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "'"
Dim Val1 As Double = e.DataTable.Compute("Sum(申报数量)",Filter)
dr("累计申报数量") = Val1
Next
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("项目名称") & "' And [施工合同段] = '" & r("施工合同段") & "' And [支付编号] = '" & r("支付编号") & "' And [桩号] = '" & r("桩号") & "'"
e.Table.DataTable.DataCols("申报数量").RaiseDataColChanged(Filter)
表DataRowDeleting
e.DataRow("申报数量") = 0
表AfterLoad:
Dim drs As New List(of DataRow)
For Each nm As String In e.DataTable.GetValues("项目名称") '找出每个产品的第一行数据, 添加到集合drs中
drs.Add(e.DataTable.Find("项目名称 = '" & nm & "'", "[_SortKey]"))
Next
For Each r As DataRow In drs
e.DataTable.DataCols("申报数量").RaiseDataColChanged(r)
Next