改为
Dim s As String = "不允许基本信息表删除已引用到比赛积分表的数据"
Select Case e.DataCol.Name
Case "棋赛名称","姓名"
e.DataRow.Save
If e.NewValue Is Nothing AndAlso e.OldValue > ""
Dim Filter As String
If e.DataCol.Name = "姓名" Then
Filter = "[棋赛名称] = '" & e.DataRow("棋赛名称") & "'And 姓名 = '" & e.OldValue & "'"
Else
Filter = "[棋赛名称] = '" & e.OldValue & "'And 姓名 = '" & e.DataRow("姓名") & "'"
End If
Dim dt As DataRow
dt = DataTables("比赛积分").SQLfind( Filter )
If dt IsNot Nothing Then
MessageBox.Show(s,"提示")
e.Cancel= True
ElseIf e.DataCol.Name ="姓名"
dt = DataTables("对阵表").SQLfind("红方_姓名 = '" & e.DataRow("姓名") & "' Or 黑方_姓名 = '" & e.DataRow("姓名") & "'")
If dt IsNot Nothing Then
MessageBox.Show(s,"提示")
e.Cancel= True
End If
End If
End If
End Select
Select Case e.DataCol.Name
Case "棋赛名称","编号"
e.DataRow.Save
If e.DataCol.Name = "棋赛名称" AndAlso e.NewValue Is Nothing AndAlso e.OldValue > "" OrElse e.DataCol.Name = "编号" AndAlso e.NewValue = Nothing AndAlso e.OldValue <> Nothing Then
Dim Filter As String
If e.DataCol.Name = "编号" Then
Filter = "[棋赛名称] = '" & e.DataRow("棋赛名称") & "'And 编号 = " & e.OldValue
Else
Filter = "[棋赛名称] = '" & e.OldValue & "'And 编号 = " & e.DataRow("编号")
End If
Dim dt As DataRow
dt = DataTables("比赛积分").SQLfind(Filter )
If dt IsNot Nothing Then
MessageBox.Show(s,"提示")
e.Cancel= True
End If
End If
End Select