第一篇:VB0062汽车驾驶学员管理系统A2
摘 要
本系统的题目是“部队汽车驾驶学员管理系统”,主要实现学员管理的自动化与信息管理自动化、训练数据的统计,打印等功能。本系统是典型的信息管理系统(MIS),其开发主要包括前端应用程序的开发和后台数据库的建立和维护两个方面。对于前端应用程序要求具有功能完备,方便使用等特点,对于后者要求建立起数据一致性和完整性强、数据安全性好的库。采用的编程工具是VB6.0,后台数据库为Access2000。
本系统采用了软件工程的设计步骤,包括需求分析、数据库的设计、总体结构设计和详细设计,并在安装和调试的基础上进行了软件测试。测试结果表明,本系统基本实现了预定功能,即实现了部队汽车驾驶员管理的自动化。
关键词:信息管理系统 部队汽车驾驶员管理 Visual Basic 6.0 Access2000
目录
目录.......................................................................0
一、绪论..................................................错误!未定义书签。
(一)、开发背景.......................................错误!未定义书签。
(二)、系统功能简介...................................错误!未定义书签。
二、系统分析..............................................错误!未定义书签。
(一)、系统可行性分析.................................错误!未定义书签。
(二)、需求分析.......................................错误!未定义书签。
(三)、系统功能分析...................................错误!未定义书签。
三、数据库设计............................................错误!未定义书签。
(一)、数据库需求分析.................................错误!未定义书签。
(二)、数据库概念结构设计.............................错误!未定义书签。
(三)、数据库逻辑结构设计.............................错误!未定义书签。
(四)、数据库的实施和维护.............................错误!未定义书签。
四、功能模块设计..........................................错误!未定义书签。
(一)、系统总设计.....................................错误!未定义书签。
(二)、子功能模块设计.................................错误!未定义书签。
五、程序实现..............................................错误!未定义书签。
(一)、系统程序设计...................................错误!未定义书签。
六、系统测试..............................................错误!未定义书签。
七、结论..................................................错误!未定义书签。
八、参考文献..............................................错误!未定义书签。
图5.2 主程序界面
图5.3 设定机构编制窗口(FrmSDJGBZ)
图5.4学兵基本信息建档窗口(Frmda)
Powered by 计算机毕业论文网http://www.xiexiebang.com 提供 如果需要详细内容请与QQ:4991024联系
第二篇:VB图书管理系统
图书管理系统的设计与实现
目录
一、序言······················································································································4
二、需求分析说明书 ····································································································4 2.1系统介绍..................................................................................................................................................4 2.2系统面向的用户群体..............................................................................................................................4 2.3系统的功能性需求..................................................................................................................................4 2.4系统的非功能性需求..............................................................................................................................5 2.4.1用户界面需求...................................................................................................................................5 2.4.2软硬件环境需求...............................................................................................................................5 2.4.3软件质量需求...................................................................................................................................5
三、可行性分析报告 ····································································································5 3.1技术可行性..............................................................................................................................................5 3.2人员可能性..............................................................................................................................................5 3.3时间、设备可能性..................................................................................................................................5 3.4系统工作量..............................................................................................................................................5 3.5代码工作量..............................................................................................................................................5 3.6文档要求..................................................................................................................................................5
四、开发环境与项目规划 ·····························································································5 4.1开发环境..................................................................................................................................................5 4.2项目规划与管理......................................................................................................................................5 4.2.1开发人员安排...................................................................................................................................5 4.2.2开发进度安排...................................................................................................................................6
五、软件界面设计标准与规范 ······················································································6 5.1编写目的..................................................................................................................................................6 5.2界面设计思想..........................................................................................................................................6 5.3界面设计原则..........................................................................................................................................6 5.4界面设计样式..........................................................................................................................................6 5.5常见提示信息样式..................................................................................................................................6 5.6常见错误信息样式..................................................................................................................................7 5.7其他界面约定..........................................................................................................................................7
六、软件编码设计标准与规范 ······················································································7 6.1对象命名约定..........................................................................................................................................7 6.2常量和变量命名约定..............................................................................................................................8 6.3结构化编码约定......................................................................................................................................8 6.4数据源的约定..........................................................................................................................................9 6.5数据库访问约定......................................................................................................................................9 6.6其他约定..................................................................................................................................................9
七、数据库分析与设计·································································································10 7.1数据库环境说明.......................................................................................................................................10 7.2数据库命名标准与规范...........................................................................................................................10 7.3数据库逻辑设计.......................................................................................................................................10 7.4数据库物理设计.......................................................................................................................................10 7.4.1表、视图汇总...................................................................................................................................10 7.4.2各表、视图设计详解.......................................................................................................................11
八、软件体系结构设计说明书 ······················································································15 8.1系统概述..................................................................................................................................................15 8.2设计约束..................................................................................................................................................15 8.3设计策略..................................................................................................................................................15 8.4系统概要设计说明书..............................................................................................................................16 8.4.1图例说明...........................................................................................................................................16 8.4.2系统总体结构图...............................................................................................................................16 8.5系统详细设计说明书..............................................................................................................................17 8.5.1系统模块汇总...................................................................................................................................17 8.5.2系统核心模块详解...........................................................................................................................18 8.5.3系统模块详解...................................................................................................................................28
九、用户界面设计报告·································································································42 9.1界面设计规范..........................................................................................................................................42 9.2系统窗体汇总..........................................................................................................................................42 9.3主界面设计..............................................................................................................................................43 9.4子界面设计..............................................................................................................................................43 9.5界面资源设计..........................................................................................................................................44
十、软件测试分析报告·································································································44 10.1测试范围与主要内容............................................................................................................................44 10.2测试方法................................................................................................................................................44 10.3测试报告................................................................................................................................................44 10.4改进建议与措施....................................................................................................................................45
十一、软件使用说明书·································································································45 11.1软件概述.................................................................................................................................................45 11.2使用说明.................................................................................................................................................45 11.2.1系统登陆..........................................................................................................................................45 11.2.2系统退出..........................................................................................................................................46 11.2.3图书类别管理..................................................................................................................................46 11.2.4图书信息管理..................................................................................................................................48 11.2.5查询图书信息..................................................................................................................................48 11.2.6读者类别管理..................................................................................................................................49 11.2.7读者信息管理..................................................................................................................................49 11.2.8查询读者信息..................................................................................................................................50 11.2.9借书管理..........................................................................................................................................50 11.2.10还书管理........................................................................................................................................50 参考资料······················································································································51
一、序言
图书管理系统的设计与推出是多方面原因促成的,比如学校的图书管理,日常管理工作 1 都是人工操作,历史数据很难保存和利用。而其他的小型图书馆大多如此。针对这种状况,我计划开发一个面向小型图书馆的图书管理系统,实现对人员、物流的全面管理,以帮助这些图书馆早日实现书店管理信息化。
为了系统的顺利开发和维护,特编制如下技术文档:
想要全部 请加QQ:76536415 专业设计 毕业论文
第三篇:vb图书管理系统源代码
Borbook:
Public sqltxt As String Public rno As String
'保存读者借书证号 Public bno As String
'保存读者图书编号 Public xm As String
'保存读者姓名 Public dw As String
'保存读者单位 Public rs As ADODB.Recordset
Private Sub Comm1_Click()
rno = Trim(Text1(0).Text)
If rno = “" Then
MsgBox ”借书证号不能为空,请输入“, vbOKOnly, ”信息提示“
Comm2.Enabled = False
Else
sqltxt = ”select * from reader where 借书证号='“ + rno + ”'“
Set rs = exesql(sqltxt)
If rs.RecordCount = 0 Then
MsgBox ”该读者未登记,不能借书“, vbOKOnly, ”信息提示“
Comm2.Enabled = False
Else
Text2(0).Text = rs.Fields(”姓名“)
Text2(1).Text = str(rs.Fields(”借书总数“))
Text2(2).Text = str(rs.Fields(”借书总数“)rs.Fields(”已借书数“))
End If
End If
End If End Sub
Private Sub retCom_Click()
Unload Me End Sub
Private Sub Form_Load()
Comm2.Enabled = False End Sub
Edbook:
Private Sub DataGrid1_Click()
End Sub
Private Sub Form_Load()
'说明:为什么使用recs,而不直接使用adodc1.recordset.recordcount?在调用edbook1窗体添加一个记录(确定)后,再
'返回到本表单,若不在Form_Activate()事件过程中调用adodc1.refresh进行刷新,adodc1.recordset.recordcount值
'仍未增1,这样调用encomm过程时出错;若在Form_Activate()事件过程中调用adodc1.refresh进行刷新,'adodc1.recordset.recordcount值增1了,调用encomm过程时也正确,但返回本窗体时,当前行总是第一行,显然也不行,'因为用户在添加或修改后希望在datagrid1中显示当前操作的那条记录.recs = Adodc1.Recordset.RecordCount End Sub
Private Sub Form_Activate()
DataGrid1.SetFocus
Call encomm End Sub
Private Sub Comm1_Click()
flag = 1
edbook1.Show vbModal End Sub
Private Sub Comm2_Click()
flag = 2
edbook1.Show vbModal End Sub
Private Sub Comm3_Click()
If MsgBox(”真的要删除[“ + Trim(Adodc1.Recordset.Fields(”书名“))+ ”]吗?“, vbYesNo, ”信息提示“)= vbYes Then
Adodc1.Recordset.Delete
recs = recs1
Call encomm
End If End Sub
Private Sub Comm4_Click()
Unload Me End Sub
Private Sub encomm()
If recs = 0 Then
Comm2.Enabled = False
Comm3.Enabled = False
Else
Comm2.Enabled = True
Comm3.Enabled = True
End If End Sub
Edlev1:
Dim cond As String
Private Sub Form_Load()
If flag = 2 Then
Text1(0).Text = edlev.Adodc1.Recordset.Fields(”级别“)
Text1(1).Text = edlev.Adodc1.Recordset.Fields(”过期罚款“)
Text1(2).Text = edlev.Adodc1.Recordset.Fields(”借书总数“)
Text1(3).Text = edlev.Adodc1.Recordset.Fields(”借书天数“)
End If End Sub
Private Sub Comm1_Click()
If Trim(Text1(0).Text)= ”“ Or Trim(Text1(1).Text)= ”“ Or Trim(Text1(2).Text)= ”“ Or _
Trim(Text1(3).Text)= ”“ Then
MsgBox ”数据项不全,请重新设置“, vbOKOnly, ”信息提示“
Text1(0).SetFocus
Exit Sub
End If
If flag = 1 Then '添加操作
If edlev.Adodc1.Recordset.RecordCount > 0 Then '原记录个数大于0
cond = ”级别='“ + Trim(Text1(0).Text)+ ”'“
edlev.Adodc1.Recordset.MoveFirst
'每次从头开始查找
edlev.Adodc1.Recordset.Find(cond)
If Not edlev.Adodc1.Recordset.EOF()Then
MsgBox ”存在完全相同的记录“, vbOKOnly, ”信息提示“
Text1(0).SetFocus
Exit Sub
End If
End If
edlev.Adodc1.Recordset.AddNew
edlev.Adodc1.Recordset.Fields(”级别“)= Trim(Text1(0).Text)
edlev.Adodc1.Recordset.Fields(”过期罚款“)= Val(Trim(Text1(1).Text))
edlev.Adodc1.Recordset.Fields(”借书总数“)= Val(Trim(Text1(2).Text))
edlev.Adodc1.Recordset.Fields(”借书天数“)= Val(Trim(Text1(3).Text))
edlev.Adodc1.Recordset.Update
recs = recs + 1
Else
'修改操作
n = edlev.Adodc1.Recordset.AbsolutePosition
cond = ”级别='“ + Trim(Text1(0).Text)+ ”'“
edlev.Adodc1.Recordset.MoveFirst '每次从头开始查找
edlev.Adodc1.Recordset.Find(cond)
If Not edlev.Adodc1.Recordset.EOF()And edlev.Adodc1.Recordset.AbsolutePosition <> n Then
MsgBox ”存在完全相同的记录“, vbOKOnly, ”信息提示“
edlev.Adodc1.Recordset.MoveFirst
'这两个语句恢复原记录位置
edlev.Adodc1.Recordset.Move(n1)
edlev.Adodc1.Recordset.Fields(”级别“)= Trim(Text1(0).Text)
edlev.Adodc1.Recordset.Fields(”过期罚款“)= Val(Trim(Text1(1).Text))
edlev.Adodc1.Recordset.Fields(”借书总数“)= Val(Trim(Text1(2).Text))
edlev.Adodc1.Recordset.Fields(”借书天数“)= Val(Trim(Text1(3).Text))
edlev.Adodc1.Recordset.Update
End If
Unload Me End Sub
Private Sub Comm2_Click()
Unload Me End Sub
Edreader:
Private Sub DataGrid1_Click()
End Sub
Private Sub Form_Load()
recs = Adodc1.Recordset.RecordCount End Sub
Private Sub Form_Activate()
DataGrid1.SetFocus
Call encomm End Sub
Private Sub Comm1_Click()
flag = 1
edreader1.Show vbModal End Sub
Private Sub Comm2_Click()
flag = 2
edreader1.Show vbModal End Sub
Private Sub Comm3_Click()
If MsgBox(”真的要删除[“ + Trim(Adodc1.Recordset.Fields(”姓名“))+ ”]吗?“, vbYesNo, ”信息提示“)= vbYes Then
Adodc1.Recordset.Delete
recs = recs1
Call encomm
End If End Sub Private Sub Comm4_Click()
Adodc1.Recordset.UpdateBatch
Adodc1.Recordset.Close
Unload Me End Sub Private Sub encomm()
If recs = 0 Then
Comm2.Enabled = False
Comm3.Enabled = False
Else
Comm2.Enabled = True
Comm3.Enabled = True
End If End Sub
Edrec1:
Dim cond As String
Private Sub Form_Load()
Label1.Caption = cap
If flag = 1 Then
Text1.Text = ”“
Else
Text1.Text = edrec.Adodc1.Recordset.Fields(”fn“)
End If End Sub
Private Sub Comm1_Click()
If Trim(Text1.Text)= ”“ Then
MsgBox ”数据项不能为空,请重新设置“, vbOKOnly, ”信息提示“
Text1.SetFocus
Exit Sub
End If
If flag = 1 Then '添加操作
If edrec.Adodc1.Recordset.RecordCount > 0 Then '原记录个数大于0
cond = ”fn='“ + Trim(Text1.Text)+ ”'“
edrec.Adodc1.Recordset.MoveFirst
'每次从头开始查找
edrec.Adodc1.Recordset.Find(cond)
If Not edrec.Adodc1.Recordset.EOF()Then
MsgBox ”存在完全相同的记录“, vbOKOnly, ”信息提示“
Text1.SetFocus
Exit Sub
End If
End If
edrec.Adodc1.Recordset.AddNew
edrec.Adodc1.Recordset.Fields(”fn“)= Trim(Text1.Text)
edrec.Adodc1.Recordset.Update
recs = recs + 1
Else
'修改操作
n = edrec.Adodc1.Recordset.AbsolutePosition
cond = ”fn='“ + Trim(Text1.Text)+ ”'“
edrec.Adodc1.Recordset.MoveFirst '每次从头开始查找
edrec.Adodc1.Recordset.Find(cond)
If Not edrec.Adodc1.Recordset.EOF()And edrec.Adodc1.Recordset.AbsolutePosition <> n Then
MsgBox ”存在完全相同的记录“, vbOKOnly, ”信息提示“
edrec.Adodc1.Recordset.MoveFirst
'这两个语句恢复原记录位置
edrec.Adodc1.Recordset.Move(n1)
edrec.Adodc1.Recordset.Fields(”fn“)= Trim(Text1.Text)
edrec.Adodc1.Recordset.Update
End If
Unload Me End Sub
Private Sub Comm2_Click()
Unload Me End Sub
Menu:
Private Sub MDIForm_Load()
If Not userlevel = ”系统管理员“ Then
menu21.Enabled = False
menu31.Enabled = False
menu41.Enabled = False
menu42.Enabled = False
End If End Sub
Private Sub menu11_Click()
borbook.Show vbModal End Sub
Private Sub menu12_Click()
retbook.Show vbModal End Sub
Private Sub menu13_Click()
End End Sub
Private Sub menu21_Click()
edbook.Show vbModal End Sub
Private Sub menu22_Click()
qubook.Show vbModal End Sub
Private Sub menu31_Click()
edreader.Show vbModal End Sub
Private Sub menu32_Click()
qureader.Show vbModal End Sub
Private Sub menu41_Click()
setuser.Show vbModal End Sub
Private Sub menu42_Click()
If MsgBox(”本功能要清除系统中所有数据,真的初始化吗?“, vbYesNo, ”确认初始化操作“)
= vbYes Then
Call deldata(”book“)Call deldata(”reader“)Call deldata(”borrow“)Call deldata(”rlevel“)
Call deldata(”depart“)
Call deldata(”press“)
Call deldata(”oper“)
MsgBox ”系统初始化完毕,下次只能以1234/1234(用户名/口令)进入本系统“, vbOKOnly, ”信息提示“
End If End Sub
Pass:
Public n As Integer
Private Sub Command1_Click()
Dim mrc As ADODB.Recordset
txtsql = ”select * from oper where 用户名='“ & _
Trim$(Text1(0).Text)& ”'“ & ” And 口令 = '“ & Trim$(Text1(1).Text)+ ”'“
Set mrc = exesql(txtsql)
If mrc.RecordCount = 0 Then '未找到用户记录
n = n + 1
If n < 3 Then
MsgBox ”没有这个用户,继续登录“, vbOKOnly + vbExclamation, ”信息提示“
Text1(0).Text = ”“
Text1(1).Text = ”“
Text1(0).SetFocus
Else
MsgBox ”已登录失败三次,退出系统“, vbOKOnly + vbExclamation, ”信息提示“
mrc.Close
Unload Me
End If
Else
'找到合法用户记录
userlevel = Trim(mrc.Fields(”级别“))
mrc.Close
Unload Me
menu.Show '调用menu窗体
End If End Sub
Private Sub Command2_Click()
Unload Me End Sub
Private Sub Form_Load()
n = 0
'n保存登录的次数 End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
Call endata(KeyAscii)End Sub
Qubook:
Private Sub Comm1_Click()
Dim sqltxt As String
If Adodc1.Recordset.Fields(”借否“)= ”借“ Then
no = Trim(Adodc1.Recordset.Fields(”图书编号“))
sqltxt = ”select * from borrow where 图书编号='“ + no + ”'“
Set rs = exesql(sqltxt)
If rs.RecordCount = 0 Then
MsgBox ”该图书没有借书记录“, vbOKOnly, ”信息提示“
Else
MsgBox ”图书编号:“ + no + Chr(10)+ Chr(13)+ _
”书
名:“ + Trim(rs.Fields(”书名“))+ Chr(10)+ Chr(13)+ _
”借 书 人:“ + Trim(rs.Fields(”姓名“))+ Chr(10)+ Chr(13)+ _
”单
位:“ + Trim(rs.Fields(”单位“))+ Chr(10)+ Chr(13)+ _
”借书日期:“ + Format(rs.Fields(”借书日期“), ”yyyy.mm.dd“), vbOKOnly, ”查找结果“
End If
rs.Close
Else
MsgBox ”该书没有外借,不能显示借书人“, vbOKOnly, ”信息提示“
End If End Sub
Private Sub Comm2_Click()
Unload Me End Sub
Private Sub Form_Activate()
Adodc1.Refresh
DataGrid1.Refresh
DataGrid1.SetFocus
Call encomm End Sub
Private Sub selcmd1_Click()'设置条件确定
Dim str As String
str = ”“
'条件表达式
If Trim(Text1(0).Text)<> ”“ Then
If str = ”“ Then
str = ”图书编号='“ + Trim(Text1(0).Text)+ ”'“
Else
str = str + ” and 图书编号='“ + Trim(Text1(0).Text)+ ”'“
End If
End If
If Trim(Text1(1).Text)<> ”“ Then
If str = ”“ Then
str = ”书名='“ + Trim(Text1(1).Text)+ ”'“
Else
str = str + ” and 书名='“ + Trim(Text1(1).Text)+ ”'“
End If
End If
If Trim(Text1(2).Text)<> ”“ Then
If str = ”“ Then
str = ”作者='“ + Trim(Text1(2).Text)+ ”'“
Else
str = str + ” and 作者='“ + Trim(Text1(2).Text)+ ”'“
End If
End If
If Trim(Text1(3).Text)<> ”“ Then
If str = ”“ Then
str = ”出版社='“ + Trim(Text1(3).Text)+ ”'“
Else
str = str + ” and 出版社='“ + Trim(Text1(3).Text)+ ”'“
End If
End If
If Trim(Text1(4).Text)<> ”“ Then
If str = ”“ Then
str = ”借否='“ + Trim(Text1(4).Text)+ ”'“
Else
str = str + ” and 借否='“ + Trim(Text1(4).Text)+ ”'“
End If
End If
If Trim(Text1(5).Text)<> ”“ Then
If str = ”“ Then
str = ”定价=“ + Trim(Text1(5).Text)
Else
str = str + ” and 定价=“ + Trim(Text1(5).Text)
End If
End If
If str <> ”“ Then
Adodc1.RecordSource = ”select * from book where “ + str
Adodc1.Refresh
Else
Adodc1.RecordSource = ”select * from book“
Adodc1.Refresh
End If
If Adodc1.Recordset.RecordCount = 0 Then
MsgBox ”没有任何满足条件的记录“, vbOKOnly, ”信息提示“
End If
Call encomm End Sub
Private Sub selcmd2_Click()'设置条件重置
Text1(0).Text = ”“
Text1(1).Text = ”“
Text1(2).Text = ”“
Text1(3).Text = ”“
Text1(4).Text = ”“
Text1(5).Text = ”“ End Sub
Private Sub encomm()'自定义子过程:判断Adodc1中是否存在记录
If Adodc1.Recordset.RecordCount = 0 Then
Comm1.Enabled = False
Else
Comm1.Enabled = True
End If End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
Call endata(KeyAscii)End Sub
Qureader:
Private Sub Comm1_Click()
Dim strn As String
Dim sqltxt As String
no = Trim(Adodc1.Recordset.Fields(”借书证号“))
sqltxt = ”select * from borrow where 借书证号='“ + no + ”'“
Set rs = exesql(sqltxt)
If rs.RecordCount = 0 Then
MsgBox ”该读者没有借任何图书“, vbOKOnly, ”信息提示“
Else
rs.MoveFirst
strn = ”书
名(借书日期)“ + Chr(10)+ Chr(13)
Do While Not rs.EOF()
strn = strn & Trim(rs.Fields(”书名“))& ”(“ & Format(rs.Fields(”借书日期“), ”yyyy.mm.dd“)& ”)“ + Chr(10)+ Chr(13)
rs.MoveNext
Loop
MsgBox strn, vbOKOnly, ”列所借图书清单“
rs.Close
End If End Sub
Private Sub Comm2_Click()
Unload Me End Sub
Private Sub Form_Activate()
Adodc1.Refresh
DataGrid1.Refresh
DataGrid1.SetFocus
Call encomm End Sub
Private Sub selcmd1_Click()'设置条件确定
Dim str As String
str = ”“
'条件表达式
If Trim(Text1(0).Text)<> ”“ Then
If str = ”“ Then
str = ”借书证号='“ + Trim(Text1(0).Text)+ ”'“
Else
str = str + ” and 借书证号='“ + Trim(Text1(0).Text)+ ”'“
End If
End If
If Trim(Text1(1).Text)<> ”“ Then
If str = ”“ Then
str = ”姓名='“ + Trim(Text1(1).Text)+ ”'“
Else
str = str + ” and 姓名='“ + Trim(Text1(1).Text)+ ”'“
End If
End If
If Trim(Text1(2).Text)<> ”“ Then
If str = ”“ Then
str = ”单位='“ + Trim(Text1(2).Text)+ ”'“
Else
str = str + ” and 单位='“ + Trim(Text1(2).Text)+ ”'“
End If
End If
If Trim(Text1(3).Text)<> ”“ Then
If str = ”“ Then
str = ”级别='“ + Trim(Text1(3).Text)+ ”'“
Else
str = str + ” and 级别='“ + Trim(Text1(3).Text)+ ”'“
End If
End If
If Trim(Text1(4).Text)<> ”“ Then
If str = ”“ Then
str = ”性别='“ + Trim(Text1(4).Text)+ ”'“
Else
str = str + ” and 性别='“ + Trim(Text1(4).Text)+ ”'“
End If
End If
If str <> ”“ Then
Adodc1.RecordSource = ”select * from reader where “ + str
Adodc1.Refresh
Else
Adodc1.RecordSource = ”select * from reader“
Adodc1.Refresh
End If
If Adodc1.Recordset.RecordCount = 0 Then
MsgBox ”没有任何满足条件的记录“, vbOKOnly, ”信息提示“
End If
Call encomm End Sub
Private Sub selcmd2_Click()'设置条件重置
Text1(0).Text = ”“
Text1(1).Text = ”“
Text1(2).Text = ”“
Text1(3).Text = ”“
Text1(4).Text = ”“ End Sub
Private Sub encomm()'自定义子过程:判断Adodc1中是否存在记录
If Adodc1.Recordset.RecordCount = 0 Then
Comm1.Enabled = False
Else
Comm1.Enabled = True
End If End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
Call endata(KeyAscii)End Sub
Retbook:
Public rno As String Public bno As String
Private Sub Comm1_Click()
bno = Trim(Text1.Text)
If bno <> ”“ Then
Dim sqltxt As String
sqltxt = ”select * from borrow where 图书编号='“ + bno + ”'“
Set brs = exesql(sqltxt)
If brs.RecordCount = 0 Then
MsgBox ”该书不是从本图书馆所借的,不能归还!“, vbOKOnly, ”信息提示“
Else
If Trim(brs.Fields(”借书证号“))<> rno Then
If rno <> ”“ Then
'另一读者还书,自动列出上一个还书人的罚款单
dstr = ”罚款单“ + Chr(10)+ Chr(13)
dstr = dstr & ”姓名:“ & Trim(Text2(1).Text)+ ”(“ + rno + ”)罚款总额:“ & str(Text2(4).Text)& ”元“
MsgBox dstr, vbOKOnly, ”列罚款单“
End If
rno = Trim(brs.Fields(”借书证号“))
sqltxt = ”select * from book where 图书编号='“ + bno + ”'“ '处理图书记录
Set bs = exesql(sqltxt)
bs.Fields(”借否“)= ”否“
bs.Update
sqltxt = ”select * from reader where 借书证号='“ + rno + ”'“ '处理读者记录
Set rs = exesql(sqltxt)
rs.Fields(”已借书数“)= rs.Fields(”已借书数“)rs.Fields(”已借书数“)
If(Datebrs.Fields(”借书日期“)1
rs.Update
If(Datebrs.Fields(”借书日期“)1
Call encomm
End If End Sub
Private Sub Comm4_Click()
Unload Me End Sub
Private Sub encomm()
If recs = 0 Then
Comm2.Enabled = False
Comm3.Enabled = False
Else
Comm2.Enabled = True
Comm3.Enabled = True
End If End Sub
Setuser1:
Dim cond As String
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys ”{TAB}“
End If End Sub
Private Sub Form_Load()
If flag = 2 Then
Text1(0).Text = setuser.Adodc1.Recordset.Fields(”用户名“)
Text1(1).Text = setuser.Adodc1.Recordset.Fields(”口令“)
Combo1.Text = setuser.Adodc1.Recordset.Fields(”级别“)
End If End Sub
Private Sub Comm1_Click()
If Trim(Text1(0).Text)= ”“ Or Trim(Text1(1).Text)= ”“ Or Trim(Combo1.Text)= ”“ Then
MsgBox ”数据项不全,请重新设置“, vbOKOnly, ”信息提示“
Text1(0).SetFocus
Exit Sub
End If
If flag = 1 Then '添加操作
If setuser.Adodc1.Recordset.RecordCount > 0 Then '原记录个数大于0
cond = ”级别='“ + Trim(Text1(0).Text)+ ”'“
setuser.Adodc1.Recordset.MoveFirst
'每次从头开始查找
setuser.Adodc1.Recordset.Find(cond)
If Not setuser.Adodc1.Recordset.EOF()Then
MsgBox ”存在完全相同的记录“, vbOKOnly, ”信息提示“
Text1(0).SetFocus
Exit Sub
End If
End If
setuser.Adodc1.Recordset.AddNew
setuser.Adodc1.Recordset.Fields(”用户名“)= Trim(Text1(0).Text)
setuser.Adodc1.Recordset.Fields(”口令“)= Val(Trim(Text1(1).Text))
setuser.Adodc1.Recordset.Fields(”级别“)= Trim(Combo1.Text)
setuser.Adodc1.Recordset.Update
recs = recs + 1
Else
'修改操作
n = setuser.Adodc1.Recordset.AbsolutePosition
cond = ”级别='“ + Trim(Text1(0).Text)+ ”'“
setuser.Adodc1.Recordset.MoveFirst '每次从头开始查找
setuser.Adodc1.Recordset.Find(cond)
If Not setuser.Adodc1.Recordset.EOF()And setuser.Adodc1.Recordset.AbsolutePosition <> n Then
MsgBox ”存在完全相同的记录“, vbOKOnly, ”信息提示“
setuser.Adodc1.Recordset.MoveFirst
'这两个语句恢复原记录位置
setuser.Adodc1.Recordset.Move(n1)
setuser.Adodc1.Recordset.Fields(”用户名“)= Trim(Text1(0).Text)
setuser.Adodc1.Recordset.Fields(”口令“)= Val(Trim(Text1(1).Text))
setuser.Adodc1.Recordset.Fields(”级别“)= Trim(Combo1.Text)
setuser.Adodc1.Recordset.Update
End If
Unload Me End Sub
Private Sub Comm2_Click()
Unload Me End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
Call endata(KeyAscii)End Sub
模块:
Public userlevel As String '保存用户级别
Public flag As Integer
'用作记录操作标记
Public tna As String
'保存表名:用于调用edrec1窗体 Public cap As String
'保存标题名:用于调用edrec1窗体 Public recs As Integer
'保存记录集中记录个数
Sub main()
pass.Show vbModal End Sub
Public Function exesql(ByVal sql As String)As ADODB.Recordset
sql = Trim$(sql)
Set conn = New ADODB.Connection
Set rst = New ADODB.Recordset
conn.ConnectionString = ”DSN=Library;UID=sa;PWD=;“
conn.Open
Set rst.ActiveConnection = conn
rst.LockType = adLockOptimistic
rst.CursorType = adOpenKeyset
rst.Open sql
Set exesql = rst
Set rst = Nothing
Set conn = Nothing End Function
Public Sub deldata(ByVal tn As String)删除指定表中所有记录,对于oper表添加一个系统用户
Dim sql As String
sql = ”delete “ & Trim$(tn)
Set conn = New ADODB.Connection
conn.ConnectionString = ”DSN=Library;UID=sa;PWD=;“
conn.Open
conn.Execute sql
If Trim(tn)= ”oper“ Then
sql = ”insert oper values('1234','1234','系统管理员')“
conn.Execute sql
End If
conn.Close End Sub Public Sub endata(Keyasc As Integer)
If Keyasc = 13 Then
SendKeys ”{TAB}" '将回车键转换成Tab键
End If End Sub
第四篇:VB学生管理系统主要代码
主要代码如下:
Dim cn As New ADODB.Connection Dim rst0 As New ADODB.Recordset Dim rst1 As New ADODB.Recordset Dim rst2 As New ADODB.Recordset Dim rst3 As New ADODB.Recordset
Private Sub Cmd0add_Click()rst0.AddNew Cmd0add.Enabled = False Cmd0save.Enabled = True Cmd0del.Enabled = False Cmd0Exit.Enabled = True End Sub
Private Sub Cmd0del_Click()Cmd0add.Enabled = True Cmd0save.Enabled = True Cmd0del.Enabled = False Cmd0Exit.Enabled = True x = MsgBox(“确定要删除吗”, vbYesNoCancel + vbQuestion, “确认”)If x = vbYes Then rst0.Delete End Sub
Private Sub Cmd0Exit_Click()cn.close Unload Me End Sub
Private Sub Cmd0save_Click()Cmd0add.Enabled = True Cmd0save.Enabled = False Cmd0del.Enabled = True Cmd0Exit.Enabled = True rst0.Update rst0.Sort = “应聘人编号” End Sub
Private Sub Cmd1Exit_Click()cn.close Unload Me End Sub Private Sub Cmd1Import_Click()rst0.MoveFirst For i = 1 To rst0.RecordCount
rst1.AddNew
rst1.Fields(“应聘人编号”)= rst0.Fields(“应聘人编号”)
rst0.MoveNext
rst1.MoveNext Next i '
Cmd1Import.Enabled = False
' Cmd1OK.Enabled = True
' Cmd1Exit.Enabled = True
End Sub
Private Sub Cmd1OK_Click()rst1.Fields(“综合评分”)=(Val(rst1.Fields(“计算机能力”))+ rst1.Fields(“业务能力”))* 0.5 If rst1.Fields(“综合评分”)>= 6 Then
rst1.Fields(“初选状态”)= “通过”
Else
rst1.Fields(“初选状态”)= “未通过”
End If
rst1.Update
rst1.Sort = “应聘人编号” End Sub
Private Sub Cmd2Exit_Click()cn.close Unload Me End Sub
Private Sub Cmd2Import_Click()rst1.close rst1.open “select * from 初选表 where 初选状态='通过'”, cn rst1.MoveFirst For i = 1 To rst1.RecordCount
rst2.AddNew
rst2.Fields(“应聘人编号”)= rst1.Fields(“应聘人编号”)
rst2.Fields(“初选评分”)= rst1.Fields(“综合评分”)
rst1.MoveNext Next i rst2.Update Cmd2Import.Enabled = False End Sub
Private Sub Cmd2OK_Click()rst2.Fields(“综合评分”)=(rst2.Fields(“初选评分”)+ rst2.Fields(“外表形象”)+ rst2.Fields(“领悟反应能力”))/ 3 If rst2.Fields(“综合评分”)>= 6 Then
rst2.Fields(“录用情况”)= “通过” Else
rst2.Fields(“录用情况”)= “未通过” End If rst2.Update rst2.Sort = “应聘人编号” rst2.MoveLast End Sub
Private Sub Cmd3Exit_Click()cn.close Unload Me End Sub
Private Sub Cmd3Import_Click()rst2.close rst2.open “selsct * from 面试表 where 录用情况= '通过'” rst2.MoveFirst For i = 1 To rst2.RecordCount
rst3.AddNew
rst3.Fields(“应聘人编号”)= rst2.Fields(“应聘人编号”)
rst3.Fields(“面试分”)= rst2.Fields(“综合评分”)
rst3.Fields(“开始录用时间”)= Date
rst2.MoveNext Next i Cmd3Import.Enabled = False End Sub
Private Sub Cmd3OK_Click()rst3.Fields(“综合考核分”)=(rst3.Fields(“面试分”)+ rst3.Fields(“笔试分”))/ 2 If rst3.Fields(“综合考核分”)>= 6 Then
rst3.Fields(“是否录用”)= “是”
Else
rst3.Fields(“是否录用”)= “否”
End If
rst3.Update
rst3.Sort = “应聘人编号”
rst3.MoveLast End Sub
Private Sub cxtg_Click()frmDataEnv.Show 1 End Sub
Private Sub DataGrid1_Click()
End Sub
Private Sub Form_Load()cn.ConnectionString = “DSN=xsgl;name=sa;pass=sa” cn.open cn.CursorLocation = adUseClient rst0.LockType = adLockPessimistic rst1.LockType = adLockPessimistic rst2.LockType = adLockPessimistic rst3.LockType = adLockPessimistic
rst0.open “select * from 登记表”, cn Set DataGrid1.DataSource = rst0
rst1.open “select * from 初选表”, cn Set DataGrid2.DataSource = rst1 If rst1.RecordCount <> 0 Then Cmd1Import.Enabled = False End If
rst2.open “select * from 面试表”, cn Set DataGrid3.DataSource = rst2 If rst2.RecordCount <> 0 Then Cmd2Import.Enabled = False End If
rst3.open “select * from 录用表”, cn Set DataGrid4.DataSource = rst3 If rst3.RecordCount <> 0 Then Cmd3Import.Enabled = False End If End Sub 学生基本信息浏览窗口
图5.6学生基本信息浏览
主要代码如下:
string sql = string.Format(“select P_id from Tb_popedom order by P_id desc”);
if(GetConn.conn.State == ConnectionState.Closed)
{
GetConn.conn.Open();
}
SqlCommand c = new SqlCommand(sql, GetConn.conn);
SqlDataReader reader = c.ExecuteReader();
if(reader.Read())
{
string id = reader[“P_id”].ToString();
txt_id.Text =(int.Parse(id.Substring(1,(id.Length-1)))+ 1)+ “";
}
reader.Close();
GetConn.conn.Close();
////加载一级菜单
sql = ”select * from Tb_function where F_level='1'“;
if(GetConn.conn.State == ConnectionState.Closed)
{
GetConn.conn.Open();
}
sda = new SqlDataAdapter(sql, GetConn.conn);
sda.Fill(ds, ”fun");
……
}
第五篇:VB用户登录管理系统
软件开发环境与工具
实验报告
实验二
实验题目:用户登录及管理系统 实验地点:软件实验室一 指导老师:王琦 实验类型:设计型
系 班:计算机科学与技术系1103班 姓 名:秦芳芳(2011100316)
2013年11月22日
一.实验项目名称:用户登录及管理系统 二.实验目的和任务:
1、掌握系统登录界面设计基本流程
2、了解用户管理所要实现的基本功能
3、要求利用三层架构思想机ado.Net相关技术实现程序
三.实验内容及要求:
1、能够进行登录验证
2、能够实现对用户的基本管理,管理员能够进行查询添加修改删除
3、利用ado.net数据库连接访问数据库,提高安全性
四.实验步骤:
1、class1.vb的代码:
Imports System.Data.SqlClient Public Class Class1
Dim strconn As String = Me.getstrconn()Public Function yanzheng(ByVal str1 As String)As Integer
Dim conn As New SqlConnection conn.ConnectionString = strconn conn.Open()Dim cmd As New SqlCommand
cmd.CommandText = “select * from student where sname ='” & str1 & “'” cmd.Connection = conn 'cmd.CommandType = CommandType.Text
Dim dr As SqlDataReader dr = cmd.ExecuteReader If dr.Read Then dr.Close()conn.Close()Return 1 Else
dr.Close()conn.Close()Return 0 End If
End Function
Public Function pwdyanzheng(ByVal str As String)As SqlDataReader
Dim conn As New SqlConnection conn.ConnectionString = strconn conn.Open()
Dim cmd As New SqlCommand
cmd.CommandText = “select * from student where sname = '” & str & “'” cmd.Connection = conn Dim dr As SqlDataReader = cmd.ExecuteReader Return dr End Function
Public Function getstrconn()As String
Dim str As String str = “server=” & System.Configuration.ConfigurationManager.AppSettings(“server”)& “;” str &= “uid=” & System.Configuration.ConfigurationManager.AppSettings(“uid”)& “;” str &= “pwd=” & System.Configuration.ConfigurationManager.AppSettings(“pwd”)& “;” str &= “database=” & System.Configuration.ConfigurationManager.AppSettings(“database”)Return str End Function
Public Function getalldata()As DataSet
Dim conn As New SqlConnection conn.ConnectionString = strconn conn.Open()Dim da As New SqlDataAdapter(“select * from student”, conn)Dim ds As New DataSet da.Fill(ds, “student”)conn.Close()Return ds End Function
Public Function insdata(ByVal str1 As String, ByVal str2 As String)As String
Dim conn As New SqlConnection conn.ConnectionString = strconn Dim cmd As New SqlCommand cmd.Connection = conn cmd.CommandText = “insert into student(sname,sno)values('” & str1 & “','” & str2 & “')”
Try
conn.Open()cmd.ExecuteNonQuery()Return “1”
Catch ex As Exception
Return “-1” & ex.Message End Try
conn.Close()
End Function
Public Function upd(ByVal str1 As String, ByVal str2 As String)As String
Dim conn As New SqlConnection conn.ConnectionString = strconn Dim cmd As New SqlCommand cmd.Connection = conn cmd.CommandText = “update student set sno ='” & str2 & “'where sname ='” & str1 & “'”
Try
conn.Open()cmd.ExecuteNonQuery()Return “1”
Catch ex As Exception
Return “-1” & ex.Message End Try
conn.Close()End Function
Public Function deldata(ByVal str As String)As String
Dim conn As New SqlConnection conn.ConnectionString = strconn Dim cmd As New SqlCommand cmd.Connection = conn cmd.CommandText = “delete from student where sname ='” & str & “'”
Try
conn.Open()cmd.ExecuteNonQuery()Return “1”
Catch ex As Exception
Return “-1” & ex.Message End Try
conn.Close()End Function
Public Function search(ByVal str1 As String)As String
Dim conn As New SqlConnection conn.ConnectionString = strconn Dim cmd As New SqlCommand cmd.Connection = conn cmd.CommandText = “select * from student”
Try
conn.Open()cmd.ExecuteNonQuery()Return “1”
Catch ex As Exception
Return “-1” & ex.Message End Try
conn.Close()End Function
End Class
2、进入界面功能的代码:
Imports System.Data.SqlClient Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click Dim o As New Class
1Dim f As Integer
f = o.yanzheng(Me.TextBox1.Text)If f = 0 Then
MsgBox(“不存在该用户,请重新输入!”)Me.TextBox1.Text = “"
Me.TextBox1.Focus()Else
If f = 1 Then
Dim dr As SqlDataReader
dr = o.pwdyanzheng(Me.TextBox1.Text)dr.Read()If RTrim(dr!sno)<> Me.TextBox2.Text Then MsgBox(”密码错误,请重新输入!“)Me.TextBox2.Text = ”“
Me.TextBox2.Focus()Else
Dim strpwd As String
strpwd = Me.TextBox2.Text strpwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strpwd, ”md5“)Dim frm As New Form2
frm.loginname = Me.TextBox1.Text frm.logintime = TimeOfDay frm.Show()Me.Hide()End If
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click MyBase.Dispose()
End Sub End Class
3、用户管理和浏览信息界面的代码: Public Class Form2
Public loginname As String
Public logintime As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click Me.Hide()Form3.Show()End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click Me.Hide()Form4.Show()End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles MyBase.Load Me.loginstatusname.Text = ”用户名:“ & loginname Me.loginstatustime.Text = ”登录时间:“ & logintime End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Timer1.Tick Me.ToolStripStatusLabel1.Text = Now End Sub End Class
4、增,删,改,查功能页面的代码: Public Class Form3
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button3.Click Me.Hide()del.Show()End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click Me.Hide()ins.Show()End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click Me.Hide()upda.Show()End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)Handles Button4.Click Me.Close()search.Show()End Sub End Class
5、显示信息界面的代码: Public Class Form4
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click Me.Close()Form2.Show()End Sub
Private Sub Form4_Load(ByVal sender As Object, ByVal e As System.EventArgs)Handles Me.Load Dim o As New Class
1Dim ds As New DataSet ds = o.getalldata()Me.DataGridView1.Refresh()Me.DataGridView1.DataSource = ds.Tables(”student“)End Sub End Class
6、插入信息界面的代码: Public Class ins
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click Dim o As New Class1
o.insdata(Me.TextBox1.Text, Me.TextBox2.Text)Me.Close()Form2.Show()End Sub End Class
7、查询信息界面的代码: Public Class search
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)Handles Button1.Click Dim o As New Class
1Dim ds As New DataSet
o.search(Me.TextBox1.Text)ds = o.getalldata()Me.DataGridView1.Refresh()Me.DataGridView1.DataSource = ds.Tables(”student")End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)Handles Button2.Click
Me.Close()Form2.Show()End Sub
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)Handles DataGridView1.CellClick Me.TextBox1.Text = DataGridView1.CurrentRow.Cells.Item(0).Value.ToString Me.TextBox2.Text = DataGridView1.CurrentRow.Cells.Item(1).Value.ToString Me.TextBox3.Text = DataGridView1.CurrentRow.Cells.Item(2).Value.ToString Me.TextBox4.Text = DataGridView1.CurrentRow.Cells.Item(3).Value.ToString Me.TextBox5.Text = DataGridView1.CurrentRow.Cells.Item(4).Value.ToString End Sub End Class
8、修改信息界面的代码: Public Class upda
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click Dim o As New Class1
o.upd(Me.TextBox1.Text, Me.TextBox2.Text)Me.Close()Form2.Show()End Sub End Class
9、删除信息界面的代码: Public Class del
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)Handles Button1.Click Dim o As New Class1
'o.deldata(Me.TextBox1.Text)o.deldata(Me.TextBox1.Text)Me.Close()Form2.Show()End Sub
End Class
五、运行结果及截图:
(1)建立数据库
(2)运行截图
六、实验总结:
通过本次实验,我大致掌握了一个登录系统界面设计的基本流程,同时了解了用户管理所要实现的基本功能,而且能够利用三层架构思想机ado.Net相关技术实现程序,能够进行登录验证,实现了对用户的基本管理,在系统中实现了增删查改的功能,利用ado.net数据库连接访问数据库,提高了安全性,为以后的学习打下了很好的基础。