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
e.DataRow("品名")=Nothing
e.DataRow("单价") = Nothing
e.DataRow("计量单位") = Nothing
MessageBox.Show("2同一订单号已经存在相同型号和规格的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
Return
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
e.DataRow("品名")=Nothing
e.DataRow("单价") = Nothing
e.DataRow("计量单位") = Nothing
e.Cancel = True
MessageBox.Show("3已经存在相同型号和规格的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
End If
End Select