'出库量大于库存量禁止出库,不能小于零
'-------------------------------------------------------------------------------------------
If e.DataCol.Name = "物料代码" Then '如果内容发生变动的是物料代码列
If e.NewValue Is Nothing Then '如果新值是空白,也就是物料代码列的内容为空
e.DataRow("出库数量") = Nothing '那么清空此行出库数量列的内容
End If
End If
Dim dg As DataRow = DataTables("库存材料表").Find("[物料代码] = '" & e.DataRow("物料代码") & "'","_Identify Desc")'获得最后一行
If dg IsNot Nothing Then '如果找到了同名的物料代码行,也就是dr不是Nothing
If e.DataRow("出库数量") > dg("库存数量") Then
MessageBox.Show("出库量不能大于库存量!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.DataRow("出库数量") = dg("库存数量")
End If
If e.DataRow("出库数量") < 0 Then
e.DataRow("出库数量") = Nothing
End If
End If
这段代码错误码,写在DataColChanging事件中对不对