我在 BeforeClose 事件中编写如下代码:
Dim shmcbx As WinForm.TextBox=e.Form.controls("shanghumingchengText")
Dim str As String =shmcbx.text
Dim t As Table = Tables("商户资料表")
Dim idx As Integer=t.findrow("商户名称= '" & str & "' and _Identify <> " & t.current("_Identify"))
Dim mqrq As Date = Date.Today
Dim zcrq As WinForm.DateTimePicker = e.Form.Controls("zhuceriqiDateTimePicker")
Dim zhxgrq As WinForm.DateTimePicker = e.Form.Controls("zuihougenggairiqiDateTimePicker")
If zcrq.Value<>Nothing Then
If zcrq.Value>mqrq Then
MessageBox.Show("所输入的注册日期有误,该日期不能大于当期日期,保存数据失败!", "提示")
Tables("商户资料表").Current.Reject
Return
End If
End If
If zhxgrq.Value<>Nothing Then
If zhxgrq.Value>mqrq Then
MessageBox.Show("所输入的最后修改日期有误,该日期不能大于当期日期,保存数据失败!", "提示")
Tables("商户资料表").Current.Reject
Return
End If
End If
If zhxgrq.Value<>Nothing Then
If zcrq.Value>zhxgrq.Value Then
MessageBox.Show("所输入的最后修改日期有误,该日期不能小于注册日期,保存数据失败!,请核实.", "提示")
Tables("商户资料表").Current.Reject
Return
End If
End If
If shmcbx.text= Nothing Then
MessageBox.Show("商户名称不能为空,保存数据失败!", "提示")
Tables("商户资料表").Current.Reject
Return
ElseIf zcrq.Value= Nothing Then
MessageBox.Show("注册日期不能为空,保存数据失败!", "提示")
Tables("商户资料表").Current.Reject
Return
ElseIf idx >=0 Then
MessageBox.Show("商户名称已存在,保存数据失败!", "提示")
Tables("商户资料表").Current.Reject
Else
Tables("商户资料表").Save
Dim rc As C1FlexGrid.CellRange = t.grid.Selection
Dim cellrect As System.Drawing.Rectangle = t.grid.RectangleToScreen(t.grid.GetCellRect(rc.r1,rc.c1))
SetCursorPos(cellrect.x, cellrect.y)
End If
xgjinzhihangjianyidong=True
jinzhihangjianyidong=True
在运行时,如果数据库中无数据会出如下错误,,该怎么处理呢?
此主题相关图片如下:1515773282(1).png
此主题相关图片如下:1515773330(1).png