首页 百科知识 借出图书查询业务

借出图书查询业务

时间:2023-10-21 百科知识 版权反馈
【摘要】:借出图书查询通过输入图书编号,查询图书状态,并计算借阅天数和罚款金额等相关信息,对应数据库的表是“Issue”表。′****************************************************************************Private Sub Txtbookid_KeyPress      txtDaysUsed.Text=″超出最多允许借阅天数″&totalDaysUsed &″天″

5.4.12 借出图书查询业务

借出图书查询通过输入图书编号,查询图书状态,并计算借阅天数和罚款金额等相关信息,对应数据库的表是“Issue”表(见图5-29)。

img59

图5-29 借出图书查询子窗体设计

代码5-15 借出图书查询业务代码

′****************************************************************************

′窗体加载

Private Sub Form_Load()

  lblInfo.Left=Me.ScaleLeft

  lblInfo.Top=Me.ScaleTop

  lblInfo.Width=Screen.Width

  txtFineAmt.Visible=False

  lblFineAmt.Visible=False

  If rsIssueInfo.RecordCount=0Then

    MsgBox″不存在借出记录″,vbInformation,″借出记录″

    Unload Me

  End If

End Sub

′设置活动窗体

Private Sub Form_Activate()

  clear

End Sub

′图书编号旁扩展按钮

Private Sub cmdBookOpen_Click()

  frmBookInfo.Show

  frmBookInfo.SetFocus

End Sub

′借书证号旁扩展按钮

Private Sub cmdMemberOpen_Click()

  frmMemberInfo.Show

  frmMemberInfo.SetFocus

End Sub

′功能函数

Private Sub clear()

  txtIssueDate.Text=″″

  txtBookId.Text=″″

  txtDaysUsed.Text=″″

  txtFineAmt.Text=″″

  txtLibraryId.Text=″″

  txtReturnDate.Text=″″

  txtFineAmt.Visible=False

  lblFineAmt.Visible=False

  txtBookId.SetFocus

End Sub

′键盘回车

Private Sub Txtbookid_KeyPress(KeyAscii As Integer)

  Dim BookNo As String

  Dim issueDate As Date

  Dim currDate As Date

  Dim totalDaysUsed As Integer

  Dim totalFineAmt As Integer

  BookNo=txtBookId.Text

  If KeyAscii=13Then

    clear

    If Not IsNumeric(BookNo)Then

      MsgBox″无效检索″,vbCritical,″检索错误″

      Call clear

      Exit Sub

    End If

    rsIssueInfo.MoveFirst

    For i=0To rsIssueInfo.RecordCount

      If rsIssueInfo.EOF=True Then

        Exit For

      End If

  ′超出天数及罚款金额计算方法和还书业务功能相同

  If rsIssueInfo(0)=Val(Trim$(BookNo))Then

    txtLibraryId.Text=rsIssueInfo(2)

    txtReturnDate.Text=Format(Now,″mm/dd/yy″)

    txtIssueDate.Text=rsIssueInfo(1)

    issueDate=CDate(txtIssueDate.Text)

    currDate=CDate(Format(Now,″mm/dd/yy″))

    totalDaysUsed=DateDiff(″d″,issueDate,currDate)

    If totalDaysUsed>maxDays Then

      txtFineAmt.Visible=True

      lblFineAmt.Visible=True

      totalDaysUsed=totalDaysUsed-maxDays

      totalFineAmt=fineAmt*totalDaysUsed

      txtDaysUsed.ForeColor=vbRed

      txtFineAmt.ForeColor=vbRed

      txtDaysUsed.Text=″超出最多允许借阅天数″&totalDaysUsed &″天″

      txtFineAmt.Text=″img60″&totalFineAmt

    Else

      txtDaysUsed.ForeColor=vbBlack

      txtFineAmt.Visible=False

      lblFineAmt.Visible=False

      txtDaysUsed.Text=totalDaysUsed

    End If

    Exit For

   End If

   rsIssueInfo.MoveNext

  Next

  If txtLibraryId.Text=″″Then

    MsgBox″未找到该图书借出记录!″,vbInformation,″未找到记录″

    clear

  End If

 End If

End Sub

免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。

我要反馈