建议你写到DataColChanged事件吧。
如果写到ing事件,要这样改的
Select Case e.DataCol.Name
Case "销售数量_片数","销售数量_破损片"
Dim dr As DataRow = e.DataRow
Dim kcdr As DataRow = DataTables("商品信息表").Find("产品ID = '" & e.DataRow("产品ID") & "'")
Dim xssl As Double
If e.DataCol.name = "销售数量_片数" Then
xssl = e.newvalue + dr("销售数量_破损片")
ElseIf e.DataCol.name = "销售数量_破损片" then
xssl = dr("销售数量_片数") + e.newvalue
End If
If kcdr IsNot Nothing Then
msgbox("xssl =" & xssl & ",库存_片数量=" & kcdr("库存_片数量")) '弹出看看是不是条件不符合
If xssl > kcdr("库存_片数量") Then
e.Cancel = True
MessageBox.show("销售数量超过库存数量!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
End If
End If
End Select