?? frmborrowing.frm
字號:
Top = 3600
Width = 3855
End
Begin VB.Label Label1
BackColor = &H80000000&
Caption = "Book ID"
Height = 255
Index = 1
Left = 120
TabIndex = 22
Top = 960
Width = 855
End
Begin VB.Label Label1
BackColor = &H80000000&
Caption = "Date Borrowed"
Height = 255
Index = 2
Left = 120
TabIndex = 21
Top = 1680
Width = 1215
End
Begin VB.Label Label1
BackColor = &H80000000&
Caption = "Date to Return"
Height = 255
Index = 3
Left = 120
TabIndex = 20
Top = 2040
Width = 1215
End
Begin VB.Label Label2
BackColor = &H80000000&
Caption = "Book Name"
Height = 255
Left = 120
TabIndex = 19
Top = 600
Width = 855
End
Begin VB.Label Label3
BackColor = &H80000000&
Caption = "ISBN"
Height = 255
Left = 120
TabIndex = 18
Top = 1320
Width = 855
End
Begin VB.Label lblamount
BackColor = &H80000000&
Caption = "Amount Charged"
Height = 255
Left = 1320
TabIndex = 17
Top = 2400
Width = 1215
End
Begin VB.Label lblfine
BackColor = &H80000000&
Caption = "Fine"
Height = 255
Left = 2880
TabIndex = 16
Top = 2400
Width = 615
End
End
End
Attribute VB_Name = "frmborrowing"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim bookname As String, X As Integer, criteria
Private Sub cbobookname_click()
Dim a, b, find
'searches trough the records using the criteria as the bookname
find = cbobookname.Text
If Trim(find) <> "" Then
find = "bookname='" + find + "'"
datbookinfo.Recordset.FindFirst find
Else ' if no input display this information
a = MsgBox("you must give a name", vbInformation, "Book id")
End If
'if no match display this message
If datbookinfo.Recordset.NoMatch Then
b = MsgBox("no such name", vbInformation, "Book ID not found")
End If
End Sub
Private Sub cbofname_Click()
lstBooksWith.Clear
Dim a, b, find
'searches trough the records using the criteria as the bookname
'and also display the selected book details
find = cbofname.Text
If Trim(find) <> "" Then
find = "studentFName='" + find + "'"
datuserinfo.Recordset.FindFirst find
Else ' if no input display this information
'a = MsgBox("you must give a name", vbInformation, "Book id")
End If
'if no match display this message
If datuserinfo.Recordset.NoMatch Then
b = MsgBox("No such name", vbInformation, "User first name not found")
End If
'lstBooksWith.Clear
listbooksinposession
End Sub
Private Sub cmdcancel_Click()
cancelborrow
End Sub
Private Sub cmdexit_Click()
'call the exit sure procedure so that the user is given another chance
exitsure
End Sub
Private Sub cmdsave_Click()
'for saving the borrowing details to the database
Save
End Sub
Private Sub Form_Activate()
'used to populate the combobox with books that can be borrowed
populate
End Sub
Private Sub Form_Load()
'this form is used for borrowing books from the library
'and only books that are available can be borrowed
End Sub
Private Sub mnubookdetails_Click()
Load frmBookinfo
frmBookinfo.Show
End Sub
Private Sub mnuborrow_Click()
Load frmborrowing
frmborrowing.Show
End Sub
Private Sub mnuborrowed_Click()
Load frmbookborrowing_return
frmbookborrowing_return.Show
End Sub
Private Sub mnucancel_Click()
cancelborrow
End Sub
Private Sub mnuexit_Click()
'to check wether user is sure of the exit
exitsure
End Sub
Private Sub mnuhorizontal_Click()
'tiles open forms horizontally
mdilibrary.Arrange vbTileHorizontal
End Sub
Private Sub mnureport_Click()
Load frmReport
frmReport.Show
End Sub
Private Sub mnuReturn_Click()
Load frmreturning
frmreturning.Show
End Sub
Private Sub mnusave_Click()
'same as command save
Save
End Sub
Private Sub mnuuserdetails_Click()
Load frmuserparticulars
frmuserparticulars.Show
End Sub
Private Sub Save()
'.procedure for saving the details on the database
'and before saving check if everything is in order in other word validate
If cbobookname = "" Or cbofname = "" Then
X = MsgBox("Must Spelect abook Name and auser Name", vbInformation, "Borrowing")
ElseIf txtdateb = "" Then
X = MsgBox("Date Borrowed Must Be Provided", vbInformation, "Borrowing")
ElseIf txtdatetor = "" Then
X = MsgBox("Expected date of Return Must Be Specified", vbInformation, "Borrowing")
ElseIf txtamount = "" Then
X = MsgBox("Amount Charged Must be provided", vbInformation, "Borrowing")
ElseIf txtfine = "" Then
X = MsgBox("Fine Must be stated else assign Zero", vbInformation, "Borrowing")
'if everything is okey then call the saving procedure
Else
CallSave
End If
End Sub
Private Sub mnuvertical_Click()
'tiles open forms vertically
mdilibrary.Arrange vbTileVertical
End Sub
Private Sub CallSave()
'for actually implementing the save operation on the database
'before check wether the amount and the fines are numeric values
If IsNumeric(txtamount) And IsNumeric(txtfine) Then
'do the required in saving the information to the circulation table
'and marking the book as borrowed in the book details table
datborrowed.Recordset.addnew
datborrowed.Recordset.Fields("studentID") = txtbid.Text
datborrowed.Recordset.Fields("bookID") = txtbookid.Text
datborrowed.Recordset.Fields("dateborrowed") = txtdateb.Text
datborrowed.Recordset.Fields("datetoreturn") = txtdatetor.Text
datborrowed.Recordset.Fields("chargelevied") = txtamount.Text
datborrowed.Recordset.Fields("fine") = txtfine.Text
datborrowed.Recordset.Fields("borrowed") = True
datborrowed.Recordset.Update
'explains itself
LookForTheCurrentRecord
'update the bookinfo status eg the book is borrowed and cannot be borrowed
'unless returned to the library by the borrower
datbookinfo.Recordset.Edit
datbookinfo.Recordset.Fields("borrowed") = 1
datbookinfo.Recordset.Update
askuser = MsgBox("Successifull, Want to Borrow Another?", vbYesNoCancel + vbCritical, "Borrowing Book")
If askuser = vbYes Then
cbobookname.Clear
cbofname.Clear
lstBooksWith.Clear
cleartxt
'populate
'Load frmsuccessiful1
'frmsuccessiful1.Show
frmreturning.datborrowedtable.Recordset.Requery
frmsuccessiful.TIMEME.Enabled = True
Unload frmborrowing
ElseIf askuser = vbNo Then
Unload Me
'mdilibrary.Show
End If
Else
MsgBox "Either Amount or Fine is not Currency"
End If
End Sub
Private Sub LookForTheCurrentRecord()
'getting the current record
criteria = cbobookname.Text
'find = cbobookname.Text
If Trim(search) <> "" Then
find = "bookname='" + find + "'"
datbookinfo.Recordset.FindFirst find
End If
End Sub
Private Sub populate()
'populate cbobookname with books that can be borrowed
Dim countbook As Long, c
countbook = 0
datbookinfo.Recordset.MoveFirst
Do While Not datbookinfo.Recordset.EOF
bookname = datbookinfo.Recordset.Fields("bookname")
If datbookinfo.Recordset.Fields("borrowed") = 0 Then
cbobookname.AddItem bookname
countbook = countbook + 1
End If
datbookinfo.Recordset.movenext
Loop
If countbook = 0 Then
c = MsgBox("Books are Out of Stock", vbOKCancel + vbCritical, "Book Borrowing")
Unload Me
ElseIf countbook > 0 Then
datuserinfo.Recordset.MoveFirst
Do While Not datuserinfo.Recordset.EOF
userfname = datuserinfo.Recordset.Fields("studentFName")
If datuserinfo.Recordset.Fields("Active") = True Then
cbofname.AddItem userfname
End If
datuserinfo.Recordset.movenext
Loop
End If
End Sub
Private Sub cancelborrow()
'for now leave it like that
End Sub
Private Sub exitsure()
'asks the user whether he ctually wants to close the form
Dim exits As Integer
exits = MsgBox("Do you really want to Exit", vbYesNoCancel + vbInformation, "Exit")
If exits = vbYes Then
'for yes close form
Unload frmborrowing
ElseIf exits = vbNo Then
Else
'do nothing
End If
End Sub
Private Sub listbooksinposession()
'sub for getting the other books that the borrower has
On Error GoTo Errormoha
datborrowed2.Recordset.MoveFirst
Do While Not datborrowed2.Recordset.EOF
If datborrowed2.Recordset.Fields("studentID") = datuserinfo.Recordset.Fields("studentID") Then
Dim mnu As String
mnu = datborrowed2.Recordset.Fields("bookname")
lstBooksWith.AddItem mnu
Else
End If
datborrowed2.Recordset.movenext
Loop
Errormoha:
End Sub
Private Sub txtdateb_gotfocus()
txtdateb.Text = Date
End Sub
Private Sub txtdatetor_GotFocus()
txtdatetor = Date + 5
End Sub
Private Sub cleartxt()
'for clearing of the textboxes
txtbookid.Text = ""
txtisbn.Text = ""
txtamount.Text = 0
txtfine.Text = 0
txtsn.Text = ""
txttn.Text = ""
txtbid.Text = ""
txtbaddress.Text = ""
txtcity.Text = ""
txtcountry.Text = ""
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -