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 (e.DataCol.Name = "科目编号" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue) OrElse ( If e.DataCol.Name = "项目编号" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue ) Then
If e.DataCol.Name = "科目编号" Then
dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [科目编号] = '" & e.OldValue & "'And 项目编号 = '" & e.DataRow("项目编号") & "'", "[_SortKey] Desc")
If dr Is Nothing Then
dr = e.DataTable.Find("[科目编号] = '" & e.OldValue & "'And 项目编号 = '" & e.DataRow("项目编号") & "'", "[_SortKey] Desc")
End If
Else
dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [项目编号] = '" & e.OldValue & "'And 科目编号 = '" & e.DataRow("科目编号") & "'", "[_SortKey] Desc")
If dr Is Nothing Then
dr = e.DataTable.Find("[项目编号] = '" & e.OldValue & "'And 科目编号 = '" & e.DataRow("科目编号") & "'", "[_SortKey] Desc")
End If
End If
If dr IsNot Nothing Then
dr("余额") = dr("借方金额") - dr("贷方金额")
drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [科目编号] = '" & dr("科目编号") & "' 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
[此贴子已经被作者于2016/3/10 21:32:39编辑过]