老师好,我想在下面代码中再增加两个计算条件。标出的是新增条件。
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") & "'"
drs = e.DataTable.Select(Filter)
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 .........."
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 .........."
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 .........."
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 .........."
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 .........."
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 .........."
Dim Val1 As Double = e.DataTable.Compute("Sum(付款金额)",Filter)
……
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 .........."
……
End Select
老师,“
摘要”列里有两个字段一个是“
押金”另一个是“
退还押金”还有两列是“
付款金额”,“累计付款”。我想如果是押金就累加
付款金额列的数据如果是退还押金就减去付款金额列中的数据。
此主题相关图片如下:2025-01-06 10 37 50.png
老师 我想不增加列的前提下根据前面两列的条件”客户,客户ID”来计算押金和押金退还。
[此贴子已经被作者于2025/1/21 17:44:22编辑过]
老师,我前面要加两个条件即谁给的押金,退给谁的。搞不明白。
客户,客户ID