应该不是这个代码的原因,可能又触发了其它事件,或者有多处表达式列计算受数量、单价、金额的影响。
金额的计算要放到统计前
If e.DataCol.Name = "数量" Or e.DataCol.Name = "单价" Then
If e.DataRow.IsNull("数量") OrElse e.DataRow.IsNull("单价") Then
e.DataRow("金额")=Nothing
Else
e.DataRow("金额")=e.DataRow("数量")*e.DataRow("单价")
End If
Dim dr As DataRow
dr= DataTables("订单").Find("订单编号='" & e.DataRow("订单编号") & "'")
If dr IsNot Nothing Then
dr("金额")= DataTables("订单明细").Compute("Sum(金额)","订单编号 ='" & e.DataRow("订单编号") & "'")
dr("数量")= DataTables("订单明细").Compute("Sum(数量)","订单编号 ='" & e.DataRow("订单编号") & "'")
End If
End If