不会改写这段代码,而且是在订单主表.订单明细表中检查。
Select Case e.DataCol.name
Case "型号"
If e.NewValue > "" AndAlso e.DataRow.IsNull("规格") = False
Dim dr As DataRow = e.DataRow
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 "规格"
If e.NewValue > "" AndAlso e.DataRow.IsNull("型号") = False
Dim dr As DataRow = e.DataRow
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