'添加数据后保存 If add = 1 Then copyright paper51.com '检测住户编号这个主键是否已经在表中存在 copyright paper51.com Dim rs_check AsNew ADODB.Recordset 内容来自论文无忧网 www.paper51.com Dim sqlCheck AsString paper51.com
sqlCheck ="select * from Client where 住户编号= '" & (Text1(0).Text) &"'" paper51.com rs_check.OpensqlCheck, conn, adOpenStatic, adLockOptimistic http://www.paper51.com If Notrs_check.EOF And Not rs_check.BOF Then 内容来自论文无忧网 www.paper51.com MsgBox "该住户编号已经存在,请重填一个!", vbOKOnly + vbInformation, "注意" copyright paper51.com
rs_check.Close paper51.com Text1(0).SetFocus copyright paper51.com
Text1(0).Text = "" 内容来自论文无忧网 www.paper51.com Exit Sub paper51.com
End If 内容来自www.paper51.com rs_check.Close 内容来自论文无忧网 www.paper51.com '主键不重复,可以加入表中 http://www.paper51.com rs_client.AddNew 内容来自www.paper51.com For i = 0 To 14 内容来自www.paper51.com rs_client.Fields(i) = Text1(i).Text 内容来自www.paper51.com Next i paper51.com
rs_client.Fields(15) = Combo1.Text paper51.com
rs_client.Update 内容来自www.paper51.com '添加保存之后,显示总信息条数需要加1 http://www.paper51.com Text2.Text =Val(Text2.Text) - 1 内容来自www.paper51.com '修改数据后的保存 内容来自www.paper51.com Else 内容来自论文无忧网 www.paper51.com
rs_client.Update http://www.paper51.com End If 内容来自www.paper51.com
MsgBox "保存数据成功!",vbOKOnly + vbInformation, "祝贺" 内容来自论文无忧网 www.paper51.com '保存后需要设置其他按钮可用,以及各个text框不可写 http://www.paper51.com
cmdAdd.Enabled = True 内容来自www.paper51.com cmdEdit.Enabled = True paper51.com cmdDel.Enabled = True 内容来自论文无忧网 www.paper51.com
cmdSave.Enabled = False http://www.paper51.com cmdCancel.Enabled = False 内容来自论文无忧网 www.paper51.com cmdFirst.Enabled = True 内容来自论文无忧网 www.paper51.com cmdPrev.Enabled = True paper51.com
cmdNext.Enabled = True copyright paper51.com cmdLast.Enabled = True copyright paper51.com
cmdQuery.Enabled = True paper51.com For i = 0 To 14 内容来自论文无忧网 www.paper51.com Text1(i).Enabled= False paper51.com Next i paper51.com
Combo1.Enabled = False paper51.com End Sub paper51.com 3.4.3物业管理模块设计 内容来自www.paper51.com
内容来自论文无忧网 www.paper51.com 其中添加,修改,删除按包的源码设计同上,重点分析保存按钮的源码如下: paper51.com
Private Sub cmdSave_Click() http://www.paper51.com
'检测数据是否完整 http://www.paper51.com If Text1(0).Text= "" Then http://www.paper51.com MsgBox "设备编号不可为空!", vbOKOnly + vbInformation, "注意" http://www.paper51.com Text1(0).SetFocus copyright paper51.com Exit Sub paper51.com
ElseIfText1(1).Text = "" Then 内容来自论文无忧网 www.paper51.com MsgBox "设备名称不可为空!", vbOKOnly + vbInformation, "注意" paper51.com Text1(1).SetFocus 内容来自论文无忧网 www.paper51.com
Exit Sub paper51.com ElseIfIsDate(Text1(5).Text) = False Then copyright paper51.com MsgBox "购买日期书写不对,应为2000-1-1这样的格式!", vbOKOnly + vbInformation, "注意" paper51.com Text1(5).SetFocus http://www.paper51.com Exit Sub 内容来自www.paper51.com End If copyright paper51.com '添加数据后保存 paper51.com If add = 1 Then paper51.com '检测房间编号这个主键是否已经在表中存在 paper51.com
Dim rs_check AsNew ADODB.Recordset 内容来自www.paper51.com Dim sqlCheck AsString paper51.com sqlCheck ="select * from Equipment where 设备编号= '" & (Text1(0).Text) & "'" http://www.paper51.com rs_check.OpensqlCheck, conn, adOpenStatic, adLockOptimistic 内容来自www.paper51.com If Notrs_check.EOF And Not rs_check.BOF Then http://www.paper51.com MsgBox "该设备编号已经存在,请重填一个!", vbOKOnly + vbInformation, "注意" paper51.com rs_check.Close copyright paper51.com Text1(0).SetFocus 内容来自www.paper51.com
Text1(0).Text = "" 内容来自www.paper51.com
Exit Sub copyright paper51.com End If 内容来自论文无忧网 www.paper51.com
rs_check.Close copyright paper51.com
'主键不重复,可以加入表中 内容来自论文无忧网 www.paper51.com rs_equip.AddNew 内容来自论文无忧网 www.paper51.com For i = 0 To 6 内容来自论文无忧网 www.paper51.com
rs_equip.Fields(i) = Text1(i).Text 内容来自www.paper51.com Next i 内容来自www.paper51.com rs_equip.Update http://www.paper51.com '添加之后显示总共条数信息加 1 内容来自www.paper51.com Text2.Text =Val(Text2.Text) + 1 内容来自论文无忧网 www.paper51.com '修改数据后的保存 内容来自www.paper51.com
Else paper51.com rs_equip.Update copyright paper51.com End If 内容来自www.paper51.com
MsgBox "保存数据成功!", vbOKOnly + vbInformation, "祝贺" copyright paper51.com '保存后需要设置其他按钮可用,以及各个text框不可写 内容来自www.paper51.com cmdAdd.Enabled = True 内容来自www.paper51.com cmdEdit.Enabled = True copyright paper51.com cmdDel.Enabled = True 内容来自论文无忧网 www.paper51.com cmdSave.Enabled = False 内容来自www.paper51.com cmdCancel.Enabled = False copyright paper51.com
cmdFirst.Enabled = True 内容来自论文无忧网 www.paper51.com
cmdPrev.Enabled = True 内容来自www.paper51.com cmdNext.Enabled = True paper51.com cmdLast.Enabled = True 内容来自www.paper51.com cmdQuery.Enabled = True 内容来自www.paper51.com
For i = 0 To 6 http://www.paper51.com Text1(i).Enabled= False 内容来自www.paper51.com Next i 内容来自www.paper51.com End Sub http://www.paper51.com (该模块其它几个窗体的设计跟此窗体的设计雷同) http://www.paper51.com
|