Select Case e.DataCol.name
Case "编号", "数量", "日期"
Dim dr As DataRow = e.DataRow
If dr.IsNull("编号") = False AndAlso dr.IsNull("数量") = False AndAlso dr.IsNull("日期") = False Then
If e.DataTable.Compute("Count([_Identify])", "编号 = '" & dr("编号") & "' And 数量 = '" & dr("数量") & "'And 日期 = '" & dr("日期") & "'") > 1 Then
MessageBox.Show("已经存在相同型号和规格的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
e.DataRow(e.DataCol.Name) = e.OldValue
End If
End If
End Select
Dim nma() As String = {"编号", "型号", "规格"} '
Dim nmb() As String = {"编号", "型号", "规格"} '
For Each r As Row In Tables("导入窗口_产品表").GetCheckedRows '
If DataTables("表C").Find("编号 = '" & r("编号") & "' And 型号 = '" & r("型号") & "'And 规格 = '" & r("规格") & "'") Is Nothing Then '
Dim dr As Row = Tables("表C").AddNew '
For i As Integer = 0 To nma.Length - 1
dr(nmb(i)) = r(nma(i))
Next
Else
MessageBox.Show("已经存在相同型号和规格的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Next
执行
执行上面的代码,是正表禁止重复,无法禁止副表复复,这样造成系统不能正常使用,