统计表的DataColChanged事件代码:
If e.DataCol.Name = "产品" orelse e.DataCol.Name = "型号" Then
e.DataRow("数量") = DataTables("订单").Compute("Sum(数量)","[产品] = '" & e.DataRow("产品") & "' and 型号='" & e.DataRow("型号") & "'")
End If
订单表的DataColChanged事件代码:
If e.DataCol.Name = "数量" Then
Dim pr As DataRow
pr = DataTables("统计").Find("产品 = '" & e.DataRow("产品") & "' and 型号='" & e.DataRow("型号") & "'")
If pr IsNot Nothing Then
pr("数量")= pr("数量") + e.NewValue - e.OldValue
End If
End If