dataColChanged事件
If e.DataCol.Name = "品名" Then
If e.NewValue Is Nothing Then
e.DataRow("单价") = Nothing
Else
Dim dr As DataRow
dr = DataTables("价格表").Find("品名 = '" & e.DataRow("品名") & "'")
If dr IsNot Nothing Then
e.DataRow("单价") = dr("价格")
End If
End If
End If
Select Case e.DataCol.Name
Case "数量"
If e.DataRow("数量") = 12 Then
e.DataRow("总价") = e.DataRow("单价") * e.DataRow("数量") - e.DataRow("单价")
Else
e.DataRow("总价") = e.DataRow("单价") * e.DataRow("数量")
End If
Dim db As DataRow = DataTables("价格表").Find("品名 = '" & e.DataRow("品名") & "'")
If db IsNot Nothing Then
db("库存") = db("库存") - e.DataRow("数量")
End If
End Select