第一篇:VB2010教材管理系统2
毕 业 论 文
教材管理系统一、课题内容
1、教材管理系统发展的背景和现况
2、教材管理系统功能模块的设计与介绍
3、教材管理系统的系统介绍和使用
二、课题任务要求
1、了解教材管理系统发展状况和前景
2、教材管理系统的功能模块的设计
3、教材管理系统的详细设计
4、教材管理系统平台的建设
目 录
第一章 引言...............................................................错误!未定义书签。
1.1 背景...........................................................................错误!未定义书签。
1.1.1教材管理系统.................错误!未定义书签。1.1.2信息管理系统.................错误!未定义书签。
1.2开发教材管理系统的目的和原则.........错误!未定义书签。1.3开发环境介绍......................................................错误!未定义书签。
毕 业 论 文
1.3.1 开发平台.....................错误!未定义书签。
1.3.2 数据库查询语言——SQL........错误!未定义书签。
1.3.3 数据库设计工具——ACCESS数据库管理系统 错误!未定义书签。
第二章 系统设计..................................................错误!未定义书签。
2.1 系统分析................................................................错误!未定义书签。2.2 系统流程和操作方式设计.........................错误!未定义书签。
第三章 系统界面设计.....................................错误!未定义书签。
3.1系统界面设计......................................................错误!未定义书签。3.2系统的界面及窗体............................................................................3
3.2.1 下面是系统的主要窗体......................3 3.2.2 界面多文档(MDI)frmDMI的设计及代码错误!未定义书签。
第四章 数据库的设计........................................错误!未定义书签。
4.1数据库设计...........................................................错误!未定义书签。
4.1.1 数据库概念和发展.........错误!未定义书签。4.1.2 数据库模型及参照完整性..错误!未定义书签。
4.1.3数据库的建立与连接............错误!未定义书签。
4.2 数据库查询设计...............................................错误!未定义书签。
4.2.1查询功能简介..................错误!未定义书签。
毕 业 论 文
4.2.2查询功能实现的相关技术........错误!未定义书签。4.2.3查询功能的具体实现............错误!未定义书签。
4.3系统测试与评价................................................错误!未定义书签。
总 结...............................................................................错误!未定义书签。致 谢..................................................................................错误!未定义书签。参考文献...........................................................................错误!未定义书签。
图3-1功能模块结构
3.2系统的界面及窗体
3.2.1 下面是系统的主要窗体
毕 业 论 文
图3-2 登录窗口
图3-3 系统界面
图3-4 4
毕 业 论 文
图3-5
3、密码更改-----通过用户对自己的密码进行修改如图3-6
图3-6
4、教材订购(图3-7)
毕 业 论 文
图3-7
5、教材入库与发放(图3-
8、图3-9)
图3-8
毕 业 论 文
图3-9
6、查询
查询是本系统的重点部分之一,系统功能的强大与否与数据库的的查询有密切的关系如图3-
10、3-11
图3-10
图3-11
这
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旅游管理系统实验报告
VB实验报告
——旅游资源管理及路线设计系统
实验报告
1.实验目的(1)学会程序的设置,掌握数据库的建立以及与程序的链接。
(2)将零散的知识系统化。
(3)进一步加深对计算机的了解。
2.实验要求
制作一个旅游资源管理及路线设计系统。主要内容包括:
①管理员管理,其中分为管理模块与查询模块。管理模块分为旅游信息管理、景点管理、导游管理。查询模块分为景点与导游管理、导游与景点查询、导游与游客查询、景点与游客管理、游客与景点管理。
②员工查询,其中分为景点与导游管理、导游与景点查询、导游与游客查询、景点与游客管理、游客与景点管理。
③游客查询,基本查询与员工查询一样。
此系统涵盖管理员与员工及游客三大系统。包含管理与查询。管理可以对导游的信息以及景点的各个信息做出及时的修改。同时也可以查询到很多方面,如导游信息、旅游线路、旅游价格、旅游景点的风景、以及最终的满意程度。
3.实验内容与步骤
(1)在界面上设置出旅游线路的整体规划。
(2)根据界面编写程序。
①编写管理员登陆界面的代码
Option Explicit
Public txtsql As String
Public username As String
Private Sub Form_Load()
txtid.Text = “"
txtpas.Text = ”“
End Sub
'启动拖放
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
moveit = True
cx = X: cy = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If moveit = True Then
'调用函数获得鼠标位置,未知信息存放在变量zb中
GetCursorPos zb
Me.Move zb.X * 1565, zb.Y * 15350
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
moveit = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unload Me
End Sub
Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'启动拖放
moveit = True
cx = X: cy = Y
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If moveit = True Then
'调用函数获得鼠标位置,未知信息存放在变量zb中
GetCursorPos zb
Me.Move zb.X * 1565, zb.Y * 15350
End If
End Sub
Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'停止拖放
moveit = False
End Sub
Private Sub Image3_Click()
txtid.Text = ”“
txtpas.Text = ”“
End Sub
Private Sub Image5_Click()
End
End Sub
Private Sub Label4_Click()
'查找数据库中是否有相同名称的用户
txtsql = ”select username from 用户权限表 where username='“ & Trim(txtid.Text)& ”'“
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = txtsql
Adodc1.Refresh
If Adodc1.Recordset.EOF = True Then'如果当前记录位置位于Recordset对象的最后一个记录之后
MsgBox ” 用户名错误!“, vbExclamation + vbOKOnly, ”警告“
txtid.Text = ”“
txtid.SetFocus
Else
'查找数据库中是否有相同密码的用户
txtsql = ”select username from 用户权限表 where password='“ & Trim(txtpas.Text)& ”'“
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = txtsql
Adodc1.Refresh
'记录是否为空
If Adodc1.Recordset.EOF = True Then'如果当前记录位置位于Recordset对象的最后一个记录之后
MsgBox ” 密码错误!“, vbExclamation + vbOKOnly, ”警告“
txtpas.Text = ”“
txtpas.SetFocus
Else
管理员总控.Show
Unload Me
End If
End If
End Sub
Private Sub Label5_Click()
txtid.Text = ”“
txtpas.Text = ”"
End Sub
Private Sub Label6_Click()
End
End Sub
②编写员工登陆界面的代码:
Private Sub Form_Load()
opt1.Value = False
opt2.Value = False
End Sub
Private Sub Image2_Click()
If opt1.Value = True Then
管理员登录.Show: 登录.Hide
ElseIf opt2.Value = True Then
员工登录.Show: 登录.Hide
End If
End Sub
Private Sub Image6_Click()
'退出程序
End
End Sub
Private Sub Label1_Click()
End
End Sub
(3)建立数据库,将搜索的旅游信息、数据,放入数据库中,与程序进行链接。
(4)运行程序。
3.实验心得
这次实验中我运用了Visual Basic 以及Access数据库及其与程序的链接等软件,制作出了一个简单的旅游资源管理及路线设计系统。
在这个系统的制作过程中,许多过程是我所不熟识的,所以,系统的制作,对我来说,是一个挑战。同时,我也从中学到好多,比如将零散的知识在系统中运用,让它们体现出自身的价值。再者,我认识到知识只有在实际中才能发挥作用。还有自己知识的短缺。
因此,我会记住这次试验,它让我了解到好多从未发现的东西。在以后的学习中,改变自身的缺点,尽量让这种不足减少或消失。争取以后能熟练的应用VB语言及数据库的应用。
第四篇: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用户登录管理系统
软件开发环境与工具
实验报告
实验二
实验题目:用户登录及管理系统 实验地点:软件实验室一 指导老师:王琦 实验类型:设计型
系 班:计算机科学与技术系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数据库连接访问数据库,提高了安全性,为以后的学习打下了很好的基础。