📄 frmbookinfo.frm
字号:
Private Sub Form_Load()
'these form is practically used to view about the books that are
'in the library and there information and also acquiring new books
'.....................................................................
'when form is loaded into memory some of the command
'buttons that may bring some errors are disabled since
'they are used later in the program
mnusave.Enabled = False
cmdsave.Enabled = False
mnucancel.Enabled = False
cmdcancel.Enabled = False
'clear the text boxes of any info
disable
cmdsave1.Visible = False
mnusaveupdate.Enabled = False
End Sub
Public Sub check()
'check wether the record is complete
'this is the process of validating the books that have
'been acquired by the library
If txtauthor = "" Then
MsgBox ("Some Information is missing")
Exit Sub
ElseIf txtbookname = "" Then
MsgBox ("Some Information is missing")
Exit Sub
ElseIf txtbookisbn = "" Then
MsgBox ("Some Information is missing")
Exit Sub
ElseIf txtdate = "" Then
MsgBox ("Some Information is missing")
Exit Sub
Else:
'if they are correct then they are added to the DBase
borrowedtodatabase
'then disable or enable command buttons and the menu
'buttons that may or may not be needed for agiven time
mnumovenext.Enabled = True
cmdnext.Enabled = True
mnuprevious.Enabled = True
cmdprev.Enabled = True
mnunewbook.Enabled = True
cmdnew.Enabled = True
mnusave.Enabled = False
cmdsave.Enabled = False
mnucancel.Enabled = False
cmdcancel.Enabled = False
disable
mnuedit.Enabled = True
End If
End Sub
Private Sub movenext()
' code or procedure for moving the record pointer to
'the next record if available
If datbook.Recordset.EOF = True Then
datbook.Recordset.MoveLast
MsgBox ("This is the last Record")
Else
datbook.Recordset.movenext
If datbook.Recordset.EOF = True Then
datbook.Recordset.MoveLast
MsgBox ("This is the last Record")
End If
End If
'When found the borrowed info is searched for
getborrowedinfo
End Sub
Private Sub moveprevious()
' code or procedure for moving the record pointer to
'the previous record if available
If datbook.Recordset.BOF = True Then
datbook.Recordset.MoveFirst
MsgBox ("This is the First Record")
Else
datbook.Recordset.moveprevious
If datbook.Recordset.BOF = True Then
datbook.Recordset.MoveFirst
MsgBox ("This is the First Record")
End If
End If
'When found the borrowed info is searched for
getborrowedinfo
End Sub
Private Sub cancel()
'code for cancelling the addnew method
'when the addnew book command or newbook menu is clicked
If datbook.Recordset.EditMode = dbEditAdd Then
datbook.Recordset.CancelUpdate
datbook.Recordset.MoveLast
End If
'then disable or enable command buttons and the menu
'buttons that may or may not be needed for agiven time
cmdUpdate.Enabled = True
mnuupdate1.Enabled = True
mnumovenext.Enabled = True
cmdnext.Enabled = True
mnuprevious.Enabled = True
cmdprev.Enabled = True
mnunewbook.Enabled = True
cmdnew.Enabled = True
mnusave.Enabled = False
cmdsave.Enabled = False
mnucancel.Enabled = False
cmdcancel.Enabled = False
disable
'End If
End Sub
Private Sub addnew()
'code for adding anew record to the books database
'or otherwise the process of accuiring new books
'then disable or enable command buttons and the menu
'buttons that may or may not be needed for agiven time
txtbookname.Enabled = True
txtbookisbn.Enabled = True
txtdate.Enabled = True
txtauthor.Enabled = True
mnucancel.Enabled = True
cmdcancel.Enabled = True
optno.value = True
mnumovenext.Enabled = False
cmdnext.Enabled = False
mnuprevious.Enabled = False
cmdprev.Enabled = False
mnunewbook.Enabled = False
cmdnew.Enabled = False
mnusave.Enabled = True
cmdsave.Enabled = True
cmdUpdate.Enabled = False
mnuupdate1.Enabled = False
mnusaveupdate.Enabled = False
cmdsearch.Enabled = False
'computing for the new id automatically without having to
'have two or more books with the same identity
Dim bookid As Long
bookid = 1
datbook.Recordset.MoveFirst
'bookid = datbook.Recordset.Fields("bookid")
Do While Not datbook.Recordset.EOF
bookid = bookid + 1
datbook.Recordset.movenext
Loop
datbook.Recordset.addnew
'assigning the textbox txtbook id with the new id
txtbookid.Text = "FBCC\book\" & bookid
End Sub
Private Sub checkrecord()
'check wether the record is complete otherwise
'display amessage to the librarian
If txtauthor = "" Then
MsgBox ("Some Information is missing")
Exit Sub
ElseIf txtbookname = "" Then
MsgBox ("Some Information is missing")
Exit Sub
ElseIf txtbookisbn = "" Then
MsgBox ("Some Information is missing")
Exit Sub
ElseIf txtdate = "" Then
MsgBox ("Some Information is missing")
Exit Sub
End If
End Sub
Private Sub search()
Dim a, b, find
'searches trough the records using the criteria as
'as the book name
find = InputBox("book Name", , "find")
If Trim(find) <> "" Then
find = "bookname='" + find + "'"
getborrowedinfo
datbook.Recordset.FindFirst find
End If
'if no match is found then display this message
If datbook.Recordset.NoMatch Then
b = MsgBox("No such name", vbInformation, "Book ID not found")
End If
End Sub
Private Sub mnuborrow_Click()
'command buttond used to access the borrowing form
frmborrowing.Show
End Sub
Private Sub mnuborrowed_Click()
frmbookborrowing_return.Show
End Sub
Private Sub mnucancel_Click()
'equivalent to the command cancel
cancel
End Sub
Private Sub mnuexit1_Click()
'equivalent to the command exit
exitsure
End Sub
Private Sub mnuhorizontal_Click()
'tiles open forms horizontally
mdilibrary.Arrange vbTileHorizontal
End Sub
Private Sub mnumovefirst_Click()
'Moves to the first record
datbook.Recordset.MoveFirst
End Sub
Private Sub mnumovelast_Click()
'moves to the last record
datbook.Recordset.MoveLast
End Sub
Private Sub mnumovenext_Click()
'equivalent to the command Next >
movenext
End Sub
Private Sub mnunewbook_Click()
'equivalent to the command addnew
addnew
End Sub
Private Sub mnuprevious_Click()
'equivalent to the command < Previous
moveprevious
End Sub
Private Sub mnureport_Click()
'opens the report form
Load frmReport
frmReport.Show
End Sub
Private Sub mnuReturn_Click()
'opens the returning of books form
frmreturning.Show
End Sub
Private Sub mnusave_Click()
'equivalent as the command save
check
End Sub
Private Sub mnusearch_Click()
'equivalent as the command search
search
End Sub
Private Sub mnusaveupdate_Click()
'equivalent as the command save1
saveupdate
End Sub
Private Sub mnuupdate1_Click()
'equivalent as the command update
UpdateRecord
End Sub
Private Sub mnuuserdetails_Click()
'opens the user particulars form
frmuserparticulars.Show
End Sub
Private Sub mnuvertical_Click()
'tiles open forms vertically
mdilibrary.Arrange vbTileVertical
End Sub
Private Sub disable()
'disables some of the text boxes
txtbookname.Enabled = False
txtbookisbn.Enabled = False
txtdate.Enabled = False
txtauthor.Enabled = False
mnucancel.Enabled = False
cmdcancel.Enabled = False
'optno.Value = True
End Sub
Private Sub getborrowedinfo()
'returns the borrowed info of the current book
borrowed = datbook.Recordset.Fields("borrowed")
If borrowed = "1" Then
optyes.value = True
Else:
optno.value = True
End If
End Sub
Private Sub borrowedtodatabase()
'saving the borrowed info to the database
'although we donot need it since one has to borrow abook.
'only when new books arrive is then marked as not borrowed.
Dim borrowed1 As Integer
If optyes.value = True Then
borrowed1 = 1
Else:
borrowed1 = 0
End If
datbook.Recordset.Fields("borrowed") = borrowed1
End Sub
Private Sub exitsure()
'determines whetyher auser is sure when he
'clicks command exit or menu exit1.
Dim exits As Integer
exits = MsgBox("Do you really want to Exit", vbYesNoCancel + vbInformation, "Exit")
If exits = vbYes Then
If cmdsave.Enabled = True Then
cancel
Unload Me
ElseIf cmdsave1.Enabled = True Then
Unload Me
End If
ElseIf exits = vbNo Then
If cmdsave1.Enabled = True Then
ElseIf cmdsave.Enabled = True Then
End If
Else
End If
End Sub
Private Sub UpdateRecord()
'code associated when the command update or menu update1
'is clicked
cmdUpdate.Visible = True
mnuupdate1.Enabled = False
txtbookname.Enabled = True
txtbookisbn.Enabled = True
txtdate.Enabled = True
txtauthor.Enabled = True
cmdsave1.Visible = True
mnusaveupdate.Enabled = True
mnuupdate1.Enabled = False
cmdUpdate.Enabled = False
cmdnew.Enabled = False
mnunewbook.Enabled = False
cmdsave.Enabled = False
mnusave.Enabled = False
cmdnext.Enabled = False
mnumovenext.Enabled = False
cmdprev.Enabled = False
mnuprevious.Enabled = False
End Sub
Private Sub saveupdate()
Status = MsgBox("Are you sure you want to update the Book record", vbYesNo + vbInformation, "Update Record")
'saving of the updated record to the database
If Status = vbYes Then
checkrecord
ElseIf Status = vbNo Then
mnuupdate1.Enabled = False
cmdsave1.Visible = False
disable
mnunewbook.Enabled = True
cmdnew.Enabled = True
mnusave.Enabled = False
cmdsave.Enabled = False
mnumovenext.Enabled = True
cmdnext.Enabled = True
mnuprevious.Enabled = True
cmdprev.Enabled = True
End If
mnuupdate1.Enabled = True
cmdUpdate.Enabled = True
cmdnext.Enabled = True
mnumovenext.Enabled = True
cmdprev.Enabled = True
mnuprevious.Enabled = True
cmdsave1.Visible = False
mnusaveupdate.Enabled = False
disable
cmdnew.Enabled = True
mnunewbook.Enabled = True
cmdsave.Enabled = False
mnusave.Enabled = False
mnuedit.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -