《毕业设计源代码.doc》由会员分享,可在线阅读,更多相关《毕业设计源代码.doc(33页珍藏版)》请在三一办公上搜索。
1、毕业设计源代码学生姓名: 班级学号: 指导教师: 职 称: 所在系(教研室): 其中登录按钮的源码如下:Private Sub cmdLogin_Click() 首先检查用户是否输入了用户名和密码 If txtUser.Text = Then MsgBox 请输入用户名!, vbOKOnly + vbInformation, 注意 txtUser.SetFocus Exit Sub ElseIf txtPwd.Text = Then MsgBox 请输入密码!, vbOKOnly + vbInformation, 注意 txtPwd.SetFocus Exit Sub End If Dim s
2、qluser As String 构造查询该用户名和密码的sql语句 sqluser = select * from UserTable where Username = & txtUser.Text _ & and Password = & txtPwd.Text & rs_user.CursorLocation = adUseClient 打开数据游标 rs_user.Open sqluser, conn, adOpenKeyset, adLockPessimistic If rs_user.EOF = True Then MsgBox 用户名或密码不正确!, vbOKOnly + vbI
3、nformation, 注意 rs_user.Close 清空txtUser和txtPwd文本框 txtUser.Text = txtPwd.Text = Exit Sub Else 还需使其他菜单可用 MDIfrmMain.mnAddUser.Enabled = True MDIfrmMain.mnBasicData.Enabled = True MDIfrmMain.mnWuYe.Enabled = True MDIfrmMain.mnDataTg.Enabled = True 提示用户登录成功并关闭游标和登录窗口 MsgBox 登录成功!, vbOKOnly + vbInformatio
4、n, 注意 rs_user.Close Unload Me End If End Sub并添加相关代码.其中重点分析按钮源码如下:。添加按钮的代码:Private Sub cmdAdd_Click() 设置除保存和取消按钮外的其他按钮不可用 cmdAdd.Enabled = False cmdEdit.Enabled = False cmdDel.Enabled = False cmdSave.Enabled = True cmdCancel.Enabled = True cmdFirst.Enabled = False cmdPrev.Enabled = False cmdNext.Enab
5、led = False cmdLast.Enabled = False cmdQuery.Enabled = False 需要清空所有text框,并且设置它们可写 For i = 0 To 14 Text1(i).Text = Text1(i).Enabled = True Next i Combo1.Enabled = True add变量用于保存时判断是从添加还是修改后保存 add = 1 Text1(0).SetFocus Text1(13).Text = DateEnd Sub修改按钮的源码:Private Sub cmdEdit_Click() 设置除保存和取消按钮外的其他按钮不可用
6、 cmdAdd.Enabled = False cmdEdit.Enabled = False cmdDel.Enabled = False cmdSave.Enabled = True cmdCancel.Enabled = True cmdFirst.Enabled = False cmdPrev.Enabled = False cmdNext.Enabled = False cmdLast.Enabled = False cmdQuery.Enabled = False 需要设置除主键之外的text框可写 For i = 1 To 14 Text1(i).Enabled = True N
7、ext i Combo1.Enabled = True add = 0End Sub删除按钮的源码如下:Private Sub cmdDel_Click() 当单击删除记录时,需要弹出一个提示框,警告用户 Dim answer As String answer = MsgBox(确定要删除吗?, vbYesNo, ) 确实删除 If answer = vbYes Then rs_client.Delete 删除当前记录 rs_client.Update 更新删除 MsgBox 成功删除!, vbOKOnly + vbExclamation, Else Exit Sub End If 删除之后,
8、显示总信息条数需要减 1 Text2.Text = Val(Text2.Text) - 1 删除当前记录后,需要显示下一条记录,如果删除的是最后一条记录,则显示上一条记录 先移动rs_client记录到后一条 rs_client.MoveNext If rs_client.EOF Then rs_client.MovePrevious 如果没有到记录首则显示改记录 If Not rs_client.BOF Then For i = 0 To 14 Text1(i).Text = rs_client.Fields(i) Next i If rs_client.Fields(15) = 男 The
9、n Combo1.ListIndex = 0 Else Combo1.ListIndex = 1 End If 如果到记录首,则表格已经为空,置所有text框显示为空 ElseIf rs_client.BOF Then For i = 0 To 14 Text1(i).Text = Next i End If 如果删除的不是首尾记录,则显示当前记录即可 Else For i = 0 To 14 Text1(i).Text = rs_client.Fields(i) Next i If rs_client.Fields(15) = 男 Then Combo1.ListIndex = 0 Else
10、 Combo1.ListIndex = 1 End If End If End Sub保存按钮的源码如下:Private Sub cmdSave_Click() 检测数据是否完整 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 Tex
11、t1(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
12、 业主姓名不可为空!, vbOKOnly + vbInformation, 注意 Text1(5).SetFocus Exit Sub ElseIf IsDate(Text1(13).Text) = False Then MsgBox 入住日期书写不对,应为2000-1-1这样的格式!, vbOKOnly + vbInformation, 注意 Text1(13).SetFocus Exit Sub ElseIf Not Text1(14).Text = And IsDate(Text1(14).Text) = False Then MsgBox 迁出时间应为空或2000-1-1这样的格式!,
13、 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
14、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_
15、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 cmdFirs
16、t.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 = FalseEnd Sub其中添加,修改,删除按包的源码设计同上,重点分析保存按钮的源码如下:Private Sub cmdSave_Click() 检测数据是否完整 If Text1(0).Text = Then MsgBox 设备编号不可为空!,
17、vbOKOnly + vbInformation, 注意 Text1(0).SetFocus Exit Sub ElseIf Text1(1).Text = Then MsgBox 设备名称不可为空!, vbOKOnly + vbInformation, 注意 Text1(1).SetFocus Exit Sub ElseIf IsDate(Text1(5).Text) = False Then MsgBox 购买日期书写不对,应为2000-1-1这样的格式!, vbOKOnly + vbInformation, 注意 Text1(5).SetFocus Exit Sub End If 添加数
18、据后保存 If add = 1 Then 检测房间编号这个主键是否已经在表中存在 Dim rs_check As New ADODB.Recordset Dim sqlCheck As String sqlCheck = select * from Equipment where 设备编号= & (Text1(0).Text) & rs_check.Open sqlCheck, conn, adOpenStatic, adLockOptimistic If Not rs_check.EOF And Not rs_check.BOF Then MsgBox 该设备编号已经存在,请重填一个!, v
19、bOKOnly + vbInformation, 注意 rs_check.Close Text1(0).SetFocus Text1(0).Text = Exit Sub End If rs_check.Close 主键不重复,可以加入表中 rs_equip.AddNew For i = 0 To 6 rs_equip.Fields(i) = Text1(i).Text Next i rs_equip.Update 添加之后显示总共条数信息加 1 Text2.Text = Val(Text2.Text) + 1 修改数据后的保存 Else rs_equip.Update End If MsgB
20、ox 保存数据成功!, 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 = Tru
21、e For i = 0 To 6 Text1(i).Enabled = False Next i End Sub(该模块其它几个窗体的设计跟此窗体的设计雷同)其中排序按钮的源码如下:Private Sub cmdOrder_Click() Dim sql As String If rs_order.State = adStateOpen Then rs_order.Close End If sql = select * from Equipment order by & Combo1.Text rs_order.CursorLocation = adUseClient rs_order.Ope
22、n sql, conn, adOpenStatic, adLockOptimistic 设置DataGrid1的数据源 Set DataGrid1.DataSource = rs_order DataGrid1.Refresh 使用分组统计,并显示在DataGrid2中 首先需要设置DataGrid2可见 DataGrid2.Visible = True 设置网格不可写 DataGrid2.AllowAddNew = False DataGrid2.AllowDelete = False DataGrid2.AllowUpdate = False Dim sql2 As String 下面的s
23、ql语句已用户选择的combo1.text分组、排序,并且统计同一个combo1.text的数量 sql2 = select & Combo1.Text & , count( & Combo1.Text & _ ) as 数量统计 from Equipment group by & Combo1.Text & order by & Combo1.Text If rs_tg.State = adStateOpen Then rs_tg.Close End If rs_tg.CursorLocation = adUseClient rs_tg.Open sql2, conn, adOpenStat
24、ic, adLockOptimistic 设置DataGrid2的数据源 Set DataGrid2.DataSource = rs_tg DataGrid2.Refresh End SubRootMost Recent Package=标准安装软件包 1Package|标准安装软件包 1|RootSubWizProgID=PDWizard.SetupPkgSubWizBuildFolder=f:小区物业管理Package|标准安装软件包 1|Configure DAO ISAMsApplicable=NoPackage|标准安装软件包 1|Configure DAO ODBCJetWorks
25、pace=ODBCDirect=Package|标准安装软件包 1|Files FoundXiaoQuGuanli.mdb=F:源代码XiaoQuGuanli.mdbPackage|标准安装软件包 1|Files ReleasedPackage|标准安装软件包 1|Missing Dependency InformationD:Program FilesCommon FilesSystemadomsado25.tlb=D:WINNTsystem32msstdfmt.dll=C:Program FilesCommon FilesSystemadomsado25.tlb=Package|标准安装软
26、件包 1|Out-of-Date Dependency InformationD:WINNTsystem32mscomctl.ocx=D:WINNTsystem32msdatgrd.ocx=D:WINNTsystem32tabctl32.ocx=C:WINDOWSsystem32MSCOMCTL.OCX=C:WINDOWSsystem32MSSTDFMT.DLL=Package|标准安装软件包 1|Files Addedxiaoquguanli.mdb=Package|标准安装软件包 1|Files Removedd:program filescommon filessystemadomsad
27、o25.tlb=Package|标准安装软件包 1|Files In ProjectF:源代码小区物业管理系统.exe=YesC:WINDOWSsystem32msvbvm60.dll=YesC:WINDOWSsystem32oleaut32.dll=YesC:WINDOWSsystem32olepro32.dll=YesC:WINDOWSsystem32asycfilt.dll=YesC:WINDOWSsystem32stdole2.tlb=YesD:VB98WizardsPDWizardRedistCOMCAT.DLL=YesC:WINDOWSsystem32VB6CHS.DLL=YesC
28、:Program FilesCommon FilesSystemadomsado25.tlb=YesC:WINDOWSsystem32MSADODC.OCX=YesC:WINDOWSsystem32MSSTDFMT.DLL=YesC:WINDOWSsystem32STDFTCHS.DLL=YesC:WINDOWSsystem32ADODCCHS.DLL=YesC:WINDOWSsystem32TABCTL32.OCX=YesC:WINDOWSsystem32TABCTCHS.DLL=YesC:WINDOWSsystem32MSDATGRD.OCX=YesC:WINDOWSsystem32DAT
29、GDCHS.DLL=YesC:WINDOWSsystem32MSCOMCTL.OCX=YesC:WINDOWSsystem32MSCMCCHS.DLL=YesD:VB98WizardsPDWizardSETUP.EXE=YesD:VB98WizardsPDWizardSETUP1.EXE=YesC:WINDOWSsystem32VB6STKIT.DLL=YesD:VB98WizardsPDWizardST6UNST.EXE=YesF:源代码XiaoQuGuanli.mdb=YesPackage|标准安装软件包 1|Configure Registry FilesApplicable=NoPac
30、kage|标准安装软件包 1|Configure Remote ServersApplicable=NoPackage|标准安装软件包 1|Install LocationsH:未完成VB房产建筑第4章 小区物业管理系统源代码小区物业管理系统.exe=$(AppPath)D:WINNTsystem32MSVBVM60.DLL=$(WinSysPathSysFile)D:WINNTsystem32oleaut32.dll=$(WinSysPathSysFile)D:WINNTsystem32olepro32.dll=$(WinSysPathSysFile)D:WINNTsystem32asycf
31、ilt.dll=$(WinSysPathSysFile)D:WINNTsystem32stdole2.tlb=$(WinSysPathSysFile)E:Program FilesMicrosoft Visual StudioVB98WizardsPDWizardRedistCOMCAT.DLL=$(WinSysPathSysFile)D:WINNTsystem32vb6chs.dll=$(WinSysPath)D:Program FilesCommon FilesSystemadomsado25.tlb=$(WinSysPath)D:WINNTsystem32MSADODC.OCX=$(Wi
32、nSysPath)D:WINNTsystem32msstdfmt.dll=$(WinSysPath)D:WINNTsystem32ADODCCHS.DLL=$(WinSysPath)D:WINNTsystem32tabctl32.ocx=$(WinSysPath)D:WINNTsystem32tabctchs.dll=$(WinSysPath)D:WINNTsystem32msdatgrd.ocx=$(WinSysPath)D:WINNTsystem32datgdchs.dll=$(WinSysPath)D:WINNTsystem32mscomctl.ocx=$(WinSysPath)D:WI
33、NNTsystem32mscmcchs.dll=$(WinSysPath)E:Program FilesMicrosoft Visual StudioVB98WizardsPDWizardSETUP.EXE=$(AppPath)E:Program FilesMicrosoft Visual StudioVB98WizardsPDWizardSETUP1.EXE=$(WinPath)D:WINNTsystem32VB6STKIT.DLL=$(WinSysPathSysFile)E:Program FilesMicrosoft Visual StudioVB98WizardsPDWizardST6
34、UNST.EXE=$(WinPath)H:已经完成测试程序VB房产建筑第4章 小区物业管理系统源代码小区物业管理系统.exe=$(AppPath)H:已经完成测试程序VB房产建筑第4章 小区物业管理系统源代码XiaoQuGuanli.mdb=$(AppPath)F:源代码小区物业管理系统.exe=$(AppPath)C:WINDOWSsystem32msvbvm60.dll=$(WinSysPathSysFile)C:WINDOWSsystem32oleaut32.dll=$(WinSysPathSysFile)C:WINDOWSsystem32olepro32.dll=$(WinSysPat
35、hSysFile)C:WINDOWSsystem32asycfilt.dll=$(WinSysPathSysFile)C:WINDOWSsystem32stdole2.tlb=$(WinSysPathSysFile)D:VB98WizardsPDWizardRedistCOMCAT.DLL=$(WinSysPathSysFile)C:WINDOWSsystem32VB6CHS.DLL=$(WinSysPath)C:Program FilesCommon FilesSystemadomsado25.tlb=$(WinSysPath)C:WINDOWSsystem32MSADODC.OCX=$(W
36、inSysPath)C:WINDOWSsystem32MSSTDFMT.DLL=$(WinSysPath)C:WINDOWSsystem32STDFTCHS.DLL=$(WinSysPath)C:WINDOWSsystem32ADODCCHS.DLL=$(WinSysPath)C:WINDOWSsystem32TABCTL32.OCX=$(WinSysPath)C:WINDOWSsystem32TABCTCHS.DLL=$(WinSysPath)C:WINDOWSsystem32MSDATGRD.OCX=$(WinSysPath)C:WINDOWSsystem32DATGDCHS.DLL=$(
37、WinSysPath)C:WINDOWSsystem32MSCOMCTL.OCX=$(WinSysPath)C:WINDOWSsystem32MSCMCCHS.DLL=$(WinSysPath)D:VB98WizardsPDWizardSETUP.EXE=$(AppPath)D:VB98WizardsPDWizardSETUP1.EXE=$(WinPath)C:WINDOWSsystem32VB6STKIT.DLL=$(WinSysPathSysFile)D:VB98WizardsPDWizardST6UNST.EXE=$(WinPath)F:源代码XiaoQuGuanli.mdb=$(App
38、Path)Package|标准安装软件包 1|Configure Shared FilesApplicable=YesH:未完成VB房产建筑第4章 小区物业管理系统源代码小区物业管理系统.exe=NoH:已经完成测试程序VB房产建筑第4章 小区物业管理系统源代码小区物业管理系统.exe=NoH:已经完成测试程序VB房产建筑第4章 小区物业管理系统源代码XiaoQuGuanli.mdb=NoF:源代码小区物业管理系统.exe=NoF:源代码XiaoQuGuanli.mdb=NoPackage|标准安装软件包 1|DistributionType=singleSize=Title=小区物业管理系统
39、Package|标准安装软件包 1|IconGroupsGroup0=小区物业管理系统PrivateGroup0=TrueParent0=$(Programs)Package|标准安装软件包 1|小区物业管理系统Icon1=小区物业管理系统.exeTitle1=小区物业管理系统StartIn1=$(AppPath)Key1=Icon1Package|标准安装软件包 1|PackagePackageFolder=f:小区物业管理ProjectFolder=F:源代码ServerSideCab=File1=f:小区物业管理setup.exeFile2=f:小区物业管理Setup.LstFile3=
40、f:小区物业管理小区物业管理系统.CABHandler1=PDWizard.FolderDplySubWizHandler2=PDWizard.WebPostDplySubWizfrmLogin = 139, 41, 664, 481, C, 85, 210, 458, 506, CMDIfrmMain = 45, 97, 636, 533, C, 34, 24, 561, 487, CfrmAddUser = 18, 11, 635, 626, C, 104, 133, 545, 527, CfrmChPwd = 10, 72, 705, 610, C, 101, 43, 517, 390, CModule1 = 126, 73, 651, 513, CfrmClient = 20, 106, 739, 683, C, -6, 81, 739, 669, CfrmQueryClient = 16, 16, 715, 540, C, 48, 67, 691, 502, CfrmTableClient = -1, 108, 737, 639, C, 13, 137, 7