最新vb图书管理系统源代码.doc

上传人:1595****071 文档编号:47526966 上传时间:2022-10-02 格式:DOC 页数:178 大小:251.50KB
返回 下载 相关 举报
最新vb图书管理系统源代码.doc_第1页
第1页 / 共178页
最新vb图书管理系统源代码.doc_第2页
第2页 / 共178页
点击查看更多>>
资源描述

《最新vb图书管理系统源代码.doc》由会员分享,可在线阅读,更多相关《最新vb图书管理系统源代码.doc(178页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-datevb图书管理系统源代码vb图书管理系统源代码Borbook:Public sqltxt As StringPublic rno As String 保存读者借书证号Public bno As String 保存读者图书编号Public xm As String 保存读者姓名Public dw As String 保存读者单位Public rs As ADODB.Rec

2、ordsetPrivate 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 Te

3、xt2(0).Text = rs.Fields(姓名) Text2(1).Text = str(rs.Fields(借书总数) Text2(2).Text = str(rs.Fields(借书总数) - rs.Fields(已借书数) If Val(Trim(Text2(2).Text) 0 Then xm = rs.Fields(姓名) dw = rs.Fields(单位) Comm2.Enabled = True Else MsgBox 该读者已借满图书,不能再借!, vbOKOnly, 信息提示 Comm2.Enabled = False End If End If End IfEnd

4、SubPrivate Sub Comm2_Click() If Val(Trim(Text2(2).Text) = 0 Then MsgBox 该读者已借满图书,不能再借!, vbOKOnly, 信息提示 Comm2.Enabled = False Exit Sub End If bno = Trim(Text1(1).Text) If bno = Then MsgBox 图书编号不能为空,请输入, vbOKOnly, 信息提示 Comm2.Enabled = False Else sqltxt = select * from book where 图书编号= + bno + Set bs =

5、 exesql(sqltxt) If bs.RecordCount = 0 Then MsgBox 图书编号不正确,请重新输入, vbOKOnly, 信息提示 Else If bs.Fields(借否) = 借 Then MsgBox 该图书编号对应的图书已借出,不能再借!, vbOKOnly, 信息提示 Else sqltxt = select * from borrow Set brs = exesql(sqltxt) brs.AddNew brs.Fields(图书编号) = bno brs.Fields(书名) = bs.Fields(书名) brs.Fields(作者) = bs.F

6、ields(作者) brs.Fields(出版社) = bs.Fields(出版社) brs.Fields(借书证号) = rno brs.Fields(姓名) = xm brs.Fields(单位) = dw brs.Fields(借书日期) = Date brs.Update bs.Fields(借否) = 借 bs.Update rs.Fields(已借书数) = rs.Fields(已借书数) + 1 rs.Update Text2(2).Text = str(rs.Fields(借书总数) - rs.Fields(已借书数) End If End If End IfEnd SubPr

7、ivate Sub retCom_Click() Unload MeEnd SubPrivate Sub Form_Load() Comm2.Enabled = FalseEnd SubEdbook:Private Sub DataGrid1_Click()End SubPrivate Sub Form_Load() 说明:为什么使用recs,而不直接使用adodc1.recordset.recordcount?在调用edbook1窗体添加一个记录(确定)后,再 返回到本表单,若不在Form_Activate()事件过程中调用adodc1.refresh进行刷新,adodc1.recordse

8、t.recordcount值 仍未增1,这样调用encomm过程时出错;若在Form_Activate()事件过程中调用adodc1.refresh进行刷新, adodc1.recordset.recordcount值增1了,调用encomm过程时也正确,但返回本窗体时,当前行总是第一行,显然也不行, 因为用户在添加或修改后希望在datagrid1中显示当前操作的那条记录. recs = Adodc1.Recordset.RecordCountEnd SubPrivate Sub Form_Activate() DataGrid1.SetFocus Call encommEnd SubPriv

9、ate Sub Comm1_Click() flag = 1 edbook1.Show vbModalEnd SubPrivate Sub Comm2_Click() flag = 2 edbook1.Show vbModalEnd SubPrivate Sub Comm3_Click() If MsgBox(真的要删除 + Trim(Adodc1.Recordset.Fields(书名) + 吗?, vbYesNo, 信息提示) = vbYes Then Adodc1.Recordset.Delete recs = recs - 1 Call encomm End IfEnd SubPriv

10、ate Sub Comm4_Click() Unload MeEnd SubPrivate 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

11、(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) + Els

12、e 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 book where + str Adodc1.Refresh Else Adodc1.RecordSo

13、urce = select * from book Adodc1.Refresh End If recs = Adodc1.Recordset.RecordCount If recs = 0 Then MsgBox 没有任何满足条件的记录, vbOKOnly, 信息提示 End If Call encommEnd SubPrivate Sub selcmd2_Click() 重置 Text1(0).Text = Text1(1).Text = Text1(2).Text = Text1(3).Text = Text1(4).Text = End SubPrivate Sub encomm()

14、自定义子过程:判断Adodc1中是否存在记录 If recs = 0 Then Comm2.Enabled = False Comm3.Enabled = False Else Comm2.Enabled = True Comm3.Enabled = True End IfEnd SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) Call endata(KeyAscii)End SubEdbook1:Dim rs As ADODB.RecordsetPrivate Sub Form_Load() If fl

15、ag = 2 Then 修改操作 Text1(0).Text = edbook.Adodc1.Recordset.Fields(图书编号) & Text1(1).Text = edbook.Adodc1.Recordset.Fields(分类号) & Text1(2).Text = edbook.Adodc1.Recordset.Fields(书名) & Text1(3).Text = edbook.Adodc1.Recordset.Fields(作者) & DataCombo1.Text = edbook.Adodc1.Recordset.Fields(出版社) & Text1(4).Tex

16、t = edbook.Adodc1.Recordset.Fields(定价) & Text1(5).Text = edbook.Adodc1.Recordset.Fields(入库日期) & Text1(0).Enabled = False Else 添加操作 Text1(5).Text = Date End IfEnd SubPrivate Sub Form_Activate() Adodc1.Refresh 数据源刷新End SubPrivate Sub Comm1_Click() If Trim(Text1(0).Text) = Or Trim(Text1(2).Text) = Or T

17、rim(Text1(3).Text) = Or Trim(Text1(5).Text) = Then MsgBox 加*数据项不能为空,请重新设置, vbOKOnly, 信息提示 Exit Sub End If If flag = 1 Then 添加操作 sqltxt = select * from book where 图书编号= + Trim(Text1(0).Text) + 对book中记录进行判断 Set rs = exesql(sqltxt) If rs.RecordCount 0 Then MsgBox 存在相同的图书编号, vbOKOnly, 信息提示 Text1(0).SetF

18、ocus rs.Close Exit Sub Else rs.Close End If edbook.Adodc1.Recordset.AddNew edbook.Adodc1.Recordset.Fields(图书编号) = Trim(Text1(0).Text) edbook.Adodc1.Recordset.Fields(分类号) = Trim(Text1(1).Text) edbook.Adodc1.Recordset.Fields(书名) = Trim(Text1(2).Text) edbook.Adodc1.Recordset.Fields(作者) = Trim(Text1(3).

19、Text) edbook.Adodc1.Recordset.Fields(出版社) = Trim(DataCombo1.Text) edbook.Adodc1.Recordset.Fields(定价) = Val(Trim(Text1(4).Text) edbook.Adodc1.Recordset.Fields(入库日期) = Format(Trim(Text1(5).Text), yyyy-mm-dd) edbook.Adodc1.Recordset.Fields(借否) = 否 edbook.Adodc1.Recordset.Update recs = recs + 1 Else 修改操

20、作 edbook.Adodc1.Recordset.Fields(图书编号) = Trim(Text1(0).Text) edbook.Adodc1.Recordset.Fields(分类号) = Trim(Text1(1).Text) edbook.Adodc1.Recordset.Fields(书名) = Trim(Text1(2).Text) edbook.Adodc1.Recordset.Fields(作者) = Trim(Text1(3).Text) edbook.Adodc1.Recordset.Fields(出版社) = Trim(DataCombo1.Text) edbook.

21、Adodc1.Recordset.Fields(定价) = Val(Trim(Text1(4).Text) edbook.Adodc1.Recordset.Fields(入库日期) = Format(Trim(Text1(5).Text), yyyy-mm-dd) edbook.Adodc1.Recordset.Update End If Unload MeEnd SubPrivate Sub Comm2_Click() Unload MeEnd SubPrivate Sub selcom_Click() tna = press cap = 出版社 edrec.Show vbModalEnd

22、SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) If Index = 1 Then If KeyAscii = 13 Then sqltxt = select * from book where 分类号= + Trim(Text1(1).Text) + 对book中记录进行判断 Set rs = exesql(sqltxt) If rs.RecordCount 0 Then Text1(2).Text = rs.Fields(书名) Text1(3).Text = rs.Fields(作者) Text1(

23、4).Text = rs.Fields(定价) DataCombo1.Text = rs.Fields(出版社) rs.Close Text1(5).SetFocus Else Call endata(KeyAscii) End If End If Else Call endata(KeyAscii) End IfEnd SubPrivate Sub DataCombo1_KeyPress(KeyAscii As Integer) Call endata(KeyAscii)End SubEdlev:Dim msg As StringPrivate Sub Form_Load() recs =

24、Adodc1.Recordset.RecordCountEnd SubPrivate Sub Form_Activate() Call encommEnd SubPrivate Sub Comm1_Click() flag = 1 edlev1.Show vbModalEnd SubPrivate Sub Comm2_Click() flag = 2 edlev1.Show vbModalEnd SubPrivate Sub Comm3_Click() If MsgBox(真的要删除 + Trim(Adodc1.Recordset.Fields(级别) + 吗?, vbYesNo, 信息提示)

25、 = vbYes Then Adodc1.Recordset.Delete recs = recs - 1 Call encomm End IfEnd SubPrivate Sub Comm4_Click() Unload MeEnd SubPrivate Sub encomm() If recs = 0 Then Comm2.Enabled = False Comm3.Enabled = False Else Comm2.Enabled = True Comm3.Enabled = True End IfEnd SubEdlev1:Dim cond As StringPrivate Sub

26、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 IfEnd SubPrivate Sub Comm1_Click() If Trim(Text1(0).Text) = O

27、r 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 每次从头开始

28、查找 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)

29、 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 每次从头开始查

30、找 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 (n - 1) Text1(0).SetFocus Exit Sub End If edlev.Adodc1.Recordset.Move

31、First 这两个语句恢复原记录位置 edlev.Adodc1.Recordset.Move (n - 1) 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) edl

32、ev.Adodc1.Recordset.Update End If Unload MeEnd SubPrivate Sub Comm2_Click() Unload MeEnd SubEdreader:Private Sub DataGrid1_Click()End SubPrivate Sub Form_Load() recs = Adodc1.Recordset.RecordCountEnd SubPrivate Sub Form_Activate() DataGrid1.SetFocus Call encommEnd SubPrivate Sub Comm1_Click() flag =

33、 1 edreader1.Show vbModalEnd SubPrivate Sub Comm2_Click() flag = 2 edreader1.Show vbModalEnd SubPrivate Sub Comm3_Click() If MsgBox(真的要删除 + Trim(Adodc1.Recordset.Fields(姓名) + 吗?, vbYesNo, 信息提示) = vbYes Then Adodc1.Recordset.Delete recs = recs - 1 Call encomm End IfEnd SubPrivate Sub Comm4_Click() Un

34、load MeEnd SubPrivate 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) + El

35、se 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 级别=

36、 + 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

37、 reader Adodc1.Refresh End If recs = Adodc1.Recordset.RecordCount If recs = 0 Then MsgBox 没有任何满足条件的记录, vbOKOnly, 信息提示 End If Call encommEnd SubPrivate Sub selcmd2_Click() 设置条件重置 Text1(0).Text = Text1(1).Text = Text1(2).Text = Text1(3).Text = Text1(4).Text = End SubPrivate Sub encomm() 自定义子过程:判断Adodc

38、1中是否存在记录 If recs = 0 Then Comm2.Enabled = False Comm3.Enabled = False Else Comm2.Enabled = True Comm3.Enabled = True End IfEnd SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) Call endata(KeyAscii)End SubEdreader1:Dim rs As ADODB.RecordsetPrivate Sub Form_Load() If flag = 2 Then 修改操作 Text1(0).Text = edreader.Adodc1.Recordset.Fields(借书证号)

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 高考资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁