老师好
通过修改下面的代码后能得到用颜色标出的结果。
Select Case e.DataCol.Name
Case "客户id","客户","摘要","付款金额"
Dim drs As List(of DataRow)
Dim Filter As String
Filter = "[_Identify] >= " & e.DataRow("_Identify") & " And [客户id] = '" & e.DataRow("客户id") & "' and [客户] = '" & e.DataRow("客户") & "' and [摘要] = '" & e.DataRow("摘要") & "'"
drs = e.DataTable.Select(Filter)
For i As Integer = 0 To drs.Count - 1
Dim dr = drs(i)
If i = drs.Count - 1 Then
Filter = "[_Identify] <= " & dr("_Identify") & " And [客户id] = '" & dr("客户id") & "' and [客户] = '" & e.DataRow("客户") & "' and [摘要] = '" & e.DataRow("摘要") & "'"
Dim Val1 As Double = e.DataTable.Compute("Sum(付款金额)",Filter)
dr("累计付款") = Val1
Else
dr("累计付款") = Nothing
End If
Next
If e.DataCol.Name = "客户id" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
Filter = "[_Identify] > " & e.DataRow("_Identify") & " And [客户id] = '" & e.OldValue & "' and [客户] = '" & e.DataRow("客户") & "' and [摘要] = '" & e.DataRow("摘要") & "'"
drs = e.DataTable.Select(Filter)
For i As Integer = 0 To drs.Count - 1
Dim dr = drs(i)
If i = drs.Count - 1 Then
Filter = "[_Identify] <= " & dr("_Identify") & " And [客户id] = '" & dr("客户id") & "' and [客户] = '" & e.DataRow("客户") & "' and [摘要] = '" & e.DataRow("摘要") & "'"
Dim Val1 As Double = e.DataTable.Compute("Sum(付款金额)",Filter)
dr("累计付款") = Val1
Else
dr("累计付款") = Nothing
End If
Next
End If
If e.DataCol.Name = "客户" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
Filter = "[_Identify] > " & e.DataRow("_Identify") & " And [客户] = '" & e.OldValue & "' and [客户id] = '" & e.DataRow("客户id") & "' and [摘要] = '" & e.DataRow("摘要") & "'"
drs = e.DataTable.Select(Filter)
For i As Integer = 0 To drs.Count - 1
Dim dr = drs(i)
If i = drs.Count - 1 Then
Filter = "[_Identify] <= " & dr("_Identify") & " And [客户] = '" & e.OldValue & "' and [客户id] = '" & e.DataRow("客户id") & "' and [摘要] = '" & e.DataRow("摘要") & "'"
Dim Val1 As Double = e.DataTable.Compute("Sum(付款金额)",Filter)
End If
If e.DataCol.Name = "摘要" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
Filter = "[_Identify] > " & e.DataRow("_Identify") & " And [摘要] = '" & e.OldValue & "' and [客户] = '" & e.DataRow("客户") & "' and [摘要] = '" & e.DataRow("摘要") & "'"
End If
Next
End If
End Select
If e.DataCol.Name = "客户" Then
Dim Val1 As Double = e. DataTable.Compute("Sum(付款金额)","[客户] = '" & e.OldValue & "' and 摘要 ='押金'")
Dim Val2 As Double = e. DataTable.Compute("Sum(付款金额)","[客户] = '" & e.OldValue & "' and 摘要 ='押金退还'")
' dr("押金") = Val1 - Val2
End If