VB图书管理程序模块及程序代码.docx_第1页
VB图书管理程序模块及程序代码.docx_第2页
VB图书管理程序模块及程序代码.docx_第3页
VB图书管理程序模块及程序代码.docx_第4页
VB图书管理程序模块及程序代码.docx_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

主窗体及代码Private Sub chkQuery_Click()If chkQuery.Value = 1 Then txtQueryBookID.Enabled = TrueElse txtQueryBookID.Enabled = FalseEnd IfEnd SubPrivate Sub cmdLendBook_Click()If txtReaderID.Text Then If lblRemain.Caption 0 Then 判断是否已经借满 Set g_rs = g_db.OpenRecordset(lentInfo, dbOpenTable) With g_rs .AddNew .Fields(读者编号) = txtReaderID.Text .Fields(书籍编号) = txtBookID.Text .Fields(借书日期) = dtpLendDate.Value .Update End With Set g_rs = Nothing 更新bookInfo表,设置该书是否借出属性为借出 g_strSql = select * from bookInfo where 书籍编号= & txtBookID.Text & Set g_rs = g_db.OpenRecordset(g_strSql) g_rs.Edit g_rs.Fields(是否借出).Value = True g_rs.Update Set g_rs = Nothing MsgBox 借出完毕!, vbOKOnly, 提示 txtBookID.Text = txtBookName.Text = txtBookPrice.Text = txtBookLeibie.Text = txtBookConcern.Text = txtBookPage.Text = InitDataGrid (False) Else MsgBox 您的书已经借满,不能再借!, vbOKOnly, 提示 End IfElse MsgBox 请先输入读者编号!, vbOKOnly, 提示End IfEnd SubPrivate Sub cmdOK_Click() g_strSql = select * from lentInfo where 书籍编号= & txtBookIDRenew.Text & and 读者编号= & txtReaderIDRenew.Text & and 借书日期=# & txtLendDate.Text & # Set g_rs = g_db.OpenRecordset(g_strSql) g_rs.Edit g_rs.Fields(借书日期).Value = dtpLendDateChange.Value g_rs.Update Set g_rs = Nothing Adodc1.Recordset.Update MsgBox 续借完毕!, vbOKOnly, 提示End SubPrivate Sub cmdReturn_Click() g_strSql = select * from lentInfo where 书籍编号= & txtBookIDReturn.Text & and 读者编号= & txtReadIDReturn.Text & and 借书日期=# & txtLendDateReturn.Text & # Set g_rs = g_db.OpenRecordset(g_strSql) g_rs.Edit g_rs.Fields(还书日期).Value = txtReturnDate.Text g_rs.Fields(超出天数).Value = txtDayCount.Text g_rs.Fields(罚款金额).Value = txtFakuan.Text g_rs.Update Set g_rs = Nothing g_strSql = select * from bookInfo where 书籍编号= & txtBookIDReturn.Text & Set g_rs = g_db.OpenRecordset(g_strSql) g_rs.Edit g_rs.Fields(是否借出).Value = False g_rs.Update Set g_rs = Nothing txtBookIDReturn.Text = txtBookNameReturn.Text = txtBookPriceReturn.Text = txtBookLeibieReturn.Text = txtBookPageReturn.Text = txtReadIDReturn.Text = txtReaderNameReturn.Text = txtLendDateReturn.Text = txtDay.Text = txtReturnDate.Text = txtFactDay.Text = txtDayCount.Text = cmdReturn.Enabled = False MsgBox 归还完毕!, vbOKOnly, 提示End SubPrivate Sub Form_Load()dtpLendDate.Value = DatedtpLendDateChange.Value = Date Set g_ws = DBEngine.Workspaces(0) Set g_db = g_ws.OpenDatabase(App.Path + 图书馆查询管理系统.mdb)End SubPrivate Sub Form_Unload(Cancel As Integer) g_db.Close Set g_db = Nothing g_ws.Close Set g_ws = Nothing EndEnd SubPrivate Sub mnuBookManage_Click()FrmBookManage.ShowEnd SubPrivate Sub mnuBookQuery_Click()FrmBookQuery.ShowEnd SubPrivate Sub mnuLendQuery_Click()FrmLendQuery.ShowEnd SubPrivate Sub mnuSetBasic_Click()FrmSetBasic.ShowEnd SubPrivate Sub mnuSetBook_Click()FrmSetBook.ShowEnd SubPrivate Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)根据点击工具栏按钮的caption属性值进行不同的操作Select Case Button.Caption Case 书库管理 FrmBookManage.Show Case 新书 FrmAddnew.Show Case 借阅列表 FrmLendList.Show Case 书库查询 FrmBookQuery.Show Case 图书类别 FrmSetBook.Show Case 退出 Call Form_Unload(0)End SelectEnd SubPrivate Sub txtBookID_KeyPress(KeyAscii As Integer)判断用户按下回车键并且是否输入读者编号和书籍编号If KeyAscii = 13 And txtReaderID.Text And txtBookID.Text Then g_strSql = select bookInfo.书籍名称,bookInfo.书籍价格,bookInfo.出版社,bookInfo.书籍页码, _ & bookInfo.是否借出,bookType.书籍类别 from bookInfo,bookType where 书籍编号= & txtBookID.Text & _ & and bookInfo.类别代码=bookType.类别代码 Set g_rs = g_db.OpenRecordset(g_strSql) If Not g_rs.EOF Then txtBookName.Text = g_rs!书籍名称 txtBookPrice.Text = g_rs!书籍价格 txtBookLeibie.Text = g_rs!书籍类别 txtBookConcern.Text = g_rs!出版社 txtBookPage.Text = g_rs!书籍页码 If g_rs!是否借出 = True Then MsgBox 该书已经借出,请选择其它图书!, vbOKOnly, 提示 cmdLendBook.Enabled = False Else cmdLendBook.Enabled = True End If Else MsgBox 没有该书信息!, vbOKOnly, 提示 txtBookName.Text = txtBookPrice.Text = txtBookLeibie.Text = txtBookConcern.Text = txtBookPage.Text = End If Set g_rs = Nothing ElseIf KeyAscii = 13 And txtReaderID.Text = Then MsgBox 请先输入读者编号, vbOKOnly, 提示ElseIf KeyAscii = 13 And txtReaderID.Text And txtBookID.Text = Then MsgBox 请先输入书籍编号, vbOKOnly, 提示End IfEnd SubPrivate Sub txtBookIDReturn_KeyPress(KeyAscii As Integer)Dim strSQL As String判断用户按下回车键并且是否输入读者编号和书籍编号 If KeyAscii = 13 And txtBookIDReturn.Text Then strSQL = select lentInfo.读者编号,readerInfo.读者姓名,lentInfo.书籍编号,bookInfo.书籍价格, _ & bookInfo.书籍名称,bookInfo.书籍页码,lentInfo.借书日期,bookType.书籍类别,bookType.借出天数 _ & from readerInfo,bookInfo,lentInfo,bookType where readerInfo.读者编号=lentInfo.读者编号 _ & and bookInfo.书籍编号=lentInfo.书籍编号 and bookInfo.书籍编号= & txtBookIDReturn.Text & _ & and bookInfo.类别代码=bookType.类别代码 g_strSql = strSQL Set g_rs = g_db.OpenRecordset(g_strSql) If Not g_rs.EOF Then cmdLendBook.Enabled = True txtBookNameReturn.Text = g_rs!书籍名称 txtBookPriceReturn.Text = g_rs!书籍价格 txtBookLeibieReturn.Text = g_rs!书籍类别 txtBookPageReturn.Text = g_rs!书籍页码 txtReadIDReturn.Text = g_rs!读者编号 txtReaderNameReturn.Text = g_rs!读者姓名 txtLendDateReturn.Text = g_rs!借书日期 txtDay.Text = g_rs!借出天数 txtReturnDate.Text = Date txtFactDay.Text = CStr(Date - g_rs!借书日期) If CInt(txtFactDay.Text) - CInt(txtDay.Text) 0 Then txtDayCount.Text = CStr(CInt(txtFactDay.Text) - CInt(txtReturnDate.Text) Else txtDayCount.Text = 0 End If Set g_rs = Nothing g_strSql = strSQL Set g_rs = g_db.OpenRecordset(select * from basicSet) txtFakuan.Text = g_rs!罚款 * CInt(txtDayCount.Text) Set g_rs = Nothing cmdReturn.Enabled = True Else Set g_rs = Nothing MsgBox 没有该书信息!, vbOKOnly, 提示 txtBookNameReturn.Text = txtBookPriceReturn.Text = txtBookLeibieReturn.Text = txtBookPageReturn.Text = txtReadIDReturn.Text = txtReaderNameReturn.Text = txtLendDateReturn.Text = txtDay.Text = txtReturnDate.Text = txtFactDay.Text = txtDayCount.Text = cmdReturn.Enabled = False End If ElseIf KeyAscii = 13 And txtBookIDReturn.Text = Then MsgBox 请先输入书籍编号, vbOKOnly, 提示End IfEnd SubPrivate Sub txtReaderID_KeyPress(KeyAscii As Integer)判断用户按下回车键并且是否输入读者编号If KeyAscii = 13 And txtReaderID.Text Then 根据输入的读者编号,查找读者姓名 g_strSql = select * from readerInfo where 读者编号= & txtReaderID.Text & Set g_rs = g_db.OpenRecordset(g_strSql) 进行数据库的查询 判断是否找到 If Not g_rs.EOF Then txtReaderName.Text = g_rs!读者姓名 InitDataGrid (False) 初始化DataGrid控件信息 Else MsgBox 没有该读者信息!, vbOKOnly, 提示 txtReaderName.Text = End If Set g_rs = NothingElseIf KeyAscii = 13 And txtReaderID.Text = Then MsgBox 请先输入读者编号, vbOKOnly, 提示End IfEnd SubPublic Function InitDataGrid(blnRenew As Boolean) 初始化DataGrid控件信息,其中得参数用来区分是正常借书页面还是续借页面Dim strDataSource As StringDim intCount As IntegerDim strReaderID As StringIf blnRenew = False Then strReaderID = txtReaderID.TextElse strReaderID = txtReaderIDRenew.TextEnd IfstrDataSource = select lentInfo.读者编号,readerInfo.读者姓名,lentInfo.书籍编号, _ & bookInfo.书籍名称,bookType.书籍类别,bookInfo.出版社,bookInfo.书籍页码,lentInfo.借书日期, _ & lentInfo.还书日期,lentInfo.超出天数,lentInfo.罚款金额 from readerInfo,bookInfo,lentInfo,bookType _ & where readerInfo.读者编号=lentInfo.读者编号 and bookInfo.书籍编号=lentInfo.书籍编号 and _ & lentInfo.读者编号= & strReaderID & and bookType.类别代码=bookInfo.类别代码 and lentInfo.还书日期 is nullAdodc1.ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= & App.Path & 图书馆查询管理系统.mdb;Persist Security Info=FalseAdodc1.CursorLocation = adUseClientAdodc1.CommandType = adCmdTextAdodc1.RecordSource = strDataSourceAdodc1.RefreshIf blnRenew = False Then 如果是正常借书进行如下操作 Set dtgrdLendBook.DataSource = Adodc1 dtgrdLendBook.Refresh 显示一共借了多少书 lblLendCount.Caption = 所借图书: + CStr(Adodc1.Recordset.RecordCount) 显示还能够借多少书 g_strSql = select * from basicSet Set g_rs

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论