逻辑思维的错误,老是想在同订单号范围判断品名和型号规格
Select Case e.DataCol.name
Case "订单号"
If e.DataCol.Name= "订单号" Then
Dim dr As DataRow = e.DataTable.Find("订单号='" & e.NewValue & "' and 品名='" & e.DataRow("品名") & "' and 型号规格='" & e.DataRow("型号规格") & "'")
If dr IsNot Nothing Then
MessageBox.Show("已经存在相同型号和规格的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
End If
End If
Case "品名"
If e.DataCol.Name= "品名" Then
Dim dr As DataRow = e.DataTable.Find("品名='" & e.NewValue & "' and 订单号='" & e.DataRow("订单号") & "' and 型号规格='" & e.DataRow("型号规格") & "'")
If dr IsNot Nothing Then
MessageBox.Show("已经存在相同型号和规格的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
End If
End If
Case "型号规格"
If e.DataCol.Name= "型号规格" Then
Dim dr As DataRow = e.DataTable.Find("型号规格='" & e.NewValue & "' and 订单号='" & e.DataRow("订单号") & "' and 品名='" & e.DataRow("品名") & "'")
If dr IsNot Nothing Then
MessageBox.Show("已经存在相同型号和规格的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
End If
End If
End Select