表事件代码如下,表中操作正常,但为何在窗口(表类型为:Normal)中不能实现(重复值判断)?求老师指点!谢谢!
If e.DataCol.Name = "箱号" Then
If e.NewValue Is Nothing Then
MessageBox.Show("转运箱码不允许为空!")
e.Cancel = True
End If
End If
Select Case e.DataCol.name
Case "箱号"
Dim dr As DataRow = e.DataRow
If dr.IsNull("箱号") = False Then
If e.DataTable.SqlCompute("Count([_Identify])", "箱号 = '" & dr("箱号") & "' ") > 1 Then
MessageBox.Show("此箱码已经存在,请勿重复接收!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
e.DataRow(e.DataCol.Name) = e.OldValue '取消输入
Else
e.DataRow("接收人姓名") = _UserName
e.DataRow("接收实验室") = _UserDept
e.DataRow("接收时间") = Date.Now()
DataTables("jsb").Save()
Tables("jsb").AddNew()
End If
End If
End Select
Select Case e.DataCol.name
Case "接收时间", "接收人姓名", "接收实验室"
Dim drs As List(Of DataRow)
drs = DataTables("A20220712").SqlSelect("箱号 = '" & e.DataRow("箱号") & "'")
For Each dr As DataRow In drs
dr(e.DataCol.Name) = e.DataRow(e.DataCol.Name)
Next
DataTables("A20220712").SQLUpdate(drs)
End Select