Select Case e.DataCol.name '日期姓名防重复输入验证
Case "日期","姓名"
if e.datarow.isnull("日期") = false
Dim xh As date
Dim gg As String
If e.DataCol.Name= "日期" Then
xh = new date(e.NewValue.year,e.NewValue.month,1)
gg = e.DataRow("姓名")
Else
gg = e.NewValue
xh = new date(e.DataRow("日期").year,e.DataRow("日期").month,1)
End If
If xh > "" AndAlso gg > "" Then
Dim dr As DataRow = e.DataRow
If e.DataTable.Find("日期 >= #" & xh & "# and 日期 < #" & xh.addmonths(1) & "# And 姓名 = '" & gg & "'") IsNot Nothing Then
MessageBox.Show("该学员本月已录入完成,不能重复,只能修改!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
End If
End If
end if
End Select