生产计划表,DataColChanging事件
Select Case e.DataCol.name
Case "订单号"
Dim dr As DataRow = e.DataRow
If e.NewValue > "" AndAlso dr.IsNull("型号") = False Then
If e.DataTable.Find("订单号 = '" & e.NewValue & "' And 型号 = '" & dr("型号") & "'") IsNot Nothing Then
MessageBox.Show("已经存在相同产品名称和订单号的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
End If
End If
Case "型号"
Dim dr As DataRow = e.DataRow
If dr.IsNull("订单号") = False AndAlso e.NewValue > "" Then
If e.DataTable.Find("订单号 = '" & dr("订单号") & "' And 型号 = '" & e.NewValue & "'") IsNot Nothing Then
MessageBox.Show("已经存在相同产品名称和订单号的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
End If
End If
End Select