帮助是单条件计算流水账,现在是多条件计算流水账该如何修改下列黄色代码?
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("项目编号") & "'", "[_SortKey] Desc")
If dr Is Nothing Then
mr("余额") = mr("借方金额") - mr("贷方金额")
dr = mr
End If
drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [科目编号] = '" & dr("科目编号") & "'[项目编号] = '" & mr("项目编号") & "'", "[_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