'检测数据是否完整
If Text1(0).Text = "" Then
MsgBox "住户编号不可为空!", vbOKOnly + vbInformation, "注意"
Text1(0).SetFocus
Exit Sub
ElseIf Text1(1).Text = "" Then
MsgBox "物业地址不可为空!", vbOKOnly + vbInformation, "注意"
Text1(1).SetFocus
Exit Sub
ElseIf Text1(3).Text = "" Or IsNumeric(Text1(3).Text) = False Then
MsgBox "建筑面积应为数字!", vbOKOnly + vbInformation, "注意"
Text1(3).SetFocus
Exit Sub
ElseIf Text1(4).Text = "" Or IsNumeric(Text1(4).Text) = False Then
MsgBox "使用面积应为数字!", vbOKOnly + vbInformation, "注意"
Text1(4).SetFocus
Exit Sub
ElseIf Text1(5).Text = "" Then
MsgBox "业主姓名不可为空!", vbOKOnly + vbInformation, "注意"
Text1(5).SetFocus
Exit Sub
ElseIf IsDate(Text1(13).Text) = False Then
MsgBox "入住日期书写不对,应为2009-1-1这样的格式!", vbOKOnly + vbInformation, "注意"
Text1(13).SetFocus
Exit Sub
ElseIf Not Text1(14).Text = "" And IsDate(Text1(14).Text) = False Then
MsgBox "迁出时间应为空或2009-1-1这样的格式!", vbOKOnly + vbInformation, "注意"
Text1(14).SetFocus
Exit Sub
End If
'添加数据后保存
If add = 1 Then
'检测住户编号这个主键是否已经在表中存在
Dim rs_check As New ADODB.Recordset
Dim sqlCheck As String
sqlCheck = "select * from Client where 住户编号= '" & (Text1(0).Text) & "'"
rs_check.Open sqlCheck, conn, adOpenStatic, adLockOptimistic
If Not rs_check.EOF And Not rs_check.BOF Then
MsgBox "该住户编号已经存在,请重填一个!", vbOKOnly + vbInformation, "注意"
rs_check.Close
Text1(0).SetFocus
Text1(0).Text = ""
Exit Sub
End If
rs_check.Close
'主键不重复,可以加入表中
rs_client.AddNew
For i = 0 To 14
rs_client.Fields(i) = Text1(i).Text
Next i
rs_client.Fields(15) = Combo1.Text
rs_client.Update
'添加保存之后,显示总信息条数需要加1
Text2.Text = Val(Text2.Text) - 1
'修改数据后的保存
Else
rs_client.Update
End If
MsgBox "保存数据成功!", vbOKOnly + vbInformation, "祝贺"
'保存后需要设置其他按钮可用,以及各个text框不可写
cmdAdd.Enabled = True
cmdEdit.Enabled = True
cmdDel.Enabled = True
cmdSave.Enabled = False
cmdCancel.Enabled = False
cmdFirst.Enabled = True
cmdPrev.Enabled = True
cmdNext.Enabled = True
cmdLast.Enabled = True
cmdQuery.Enabled = True
For i = 0 To 14
Text1(i).Enabled = False
Next i
Combo1.Enabled = False
End Sub
4.3.3物业管理模块设计
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] 下一页