Академический Документы
Профессиональный Документы
Культура Документы
1. Definition
1.1 Overview of Educational Institution:
Himalaya International Model School is a secondary school situated at Eastern part of Katmandu, Nepal. It has about 1200 students studying at different grades from Nursery to 10. This institution follows the curriculum prescribed by the Government of Nepal. Since this curriculum requires vast resource, the school has a spacious and big library that contains many useful resources. It includes about 6000 books from different categories and has a single staff, the librarian: Mr. Yadhunath Acharya, to manage all these books. The students from grades one and higher are given the permission of using this library, since last two years. About 100 books are issued weekly by it and most of them are issued to the fifth grader or higher. The librarian relies on manual method for keeping the record of books and its transactions. He keeps the record of the issued books and the total books in the register provided by the school. In addition, he is planning to divide the books into Reference and Non-fiction.
Bishwanath Parajuli
Bishwanath Parajuli
Manual system always has some problem. This system has the problems as listed below: The library has no record of the total book it consists and the member linked to it. Issue process is very time consuming and chances of getting mistakes is high. Besides the same book may be issued twice by a borrower or more than three books may be issued at a time. Calculating fine is also very tedious process and can be collected by anyone. Searching the records of issue is very difficult and tedious. Searching the availability of book is difficult. Checking the validity of the card is time consuming Writing issue details makes the borrower to wait in queue As the records are kept manually, there are chances of losing the records.
Bishwanath Parajuli
Issue a book
Calculate fine Rs. 2 until 7 days and Rs. 5 for rest of the time.
Bishwanath Parajuli
2.2
Analysis:
After having an understanding of the current system, information was to be collected about the problems the user faced and the effect of the problems upon the management. A detail of the survey has been included below:
Bishwanath Parajuli
Bishwanath Parajuli
Bishwanath Parajuli
Computerized system with barcode: Bar-Code system is a popular solution for this type of problem. Mr. Acharya will find it convenient to make issue or renew/return through the help of this system. However, there are lots of disadvantage in using this system. Some of them are: 1. Requires faster and more efficient computers due to which the computers available will require an upgrade that is not economically feasible. 2. Operating the new system will obviously require some training and description of the computer peripherals that will be not be operationally feasible. 3. Developing such software requires much time and such problems are very difficult to deal with.
Bishwanath Parajuli
Bishwanath Parajuli
10
Crystal Report : After the application development program and the database solution, output method was needed. Despite Crystal Reports powerful interface, it was not considered as a best choice because it required large amount of disk space. Besides, the library would not need much more stylish reports as produced by it. Data Report: After Crystal Report, Data Report in VB was considered. The feature available in Data Report would allow the developer and the user to make the effective output. Besides, feature available in Data Report could make a suitable output. Therefore, Data Report was considered the best choice.
Bishwanath Parajuli
11
Schedule Feasibility:
The Gantt chart included above was regarded as a schedule for completing the project. However, the school sought the complete software within 2 months from the date of commencement of the project. 2.5.5
Legal Feasibility:
The copyright is preserved in the name of the programmer and the solution till the date didnt clash any cyber laws stated by the country.
Bishwanath Parajuli
12
According to the analysis carried in the investigation phase and outcomes agreed, the system needed to have a complete and easy library-managing interface. The system should be able to input the data like member/book/Publisher and Author records. Additionally, it should include the feature of maintaining Supplier records. It should be able to store the records of issue, renew/return, reserve. It should also be able of calculating the fine the member needs to pay and the due days. The feature of calculating total fine by the administrator will be welcomed. The access to the program should be prevented from the unauthorized users. Besides, use of message boxes in various tasks should be friendly and well directing. 2.6.2
Hardware Requirements:
The system requires a mouse for selecting data, a keyboard for entering data. It also requires a CD-ROM drive and a general printer for printing the hard-copy output. 2.6.3
Software Requirements:
The new system requires an IBM compatible windows version 9.x or similar series of later operating systems. Besides, it requires all the modules required by VB including Microsoft Office Package installed in it.
3. System Design
Bishwanath Parajuli 13
3.1
Allow the authorized user to add new records regarding books, members, publisher, author and suppliers, and allow editing/removing them. Allow easier and convenient searching of data from various data tables. Allow the authorized user to carry out routine library tasks such as issue, renew/return and reserve. Allow only authorized user to get into the system and allow provision for a single administrator only. Allow to add new authorized users according to the rights specified. Also provide the feature of deleting the user or changing the password. Allow the administrator to control all the library tasks. Also allow provision of General User who can carry out major library tasks in absence of administrator. Prevent the user from issuing a reference book. Prevent from issuing reserved books, issuing more than three books at a time or issuing same book at a time. Allow the same provision in reserving. Prevent the member from issuing, reserving, renewing or returning the book who has fine to pay or whose membership has expired. Allow the user to cancel reservation if demanded. Prompt the authorized user to cancel the reservation, if made, while the borrower is about to issue reserved book. Cancel all the reservation that has crossed its due date at the startup of the program. Allow automatic calculation of the fine and allow printing a fine report. Only allow the administrator to collect the total fine. Prompt the authorized user to collect and clear fine (No partial payment allowed) from the borrower if any borrowed book has crossed its due date. Allow printing/viewing the details of the member, books, reservation and due books in the form of reports. Allow viewing the due books at startup, if configured.
Bishwanath Parajuli
14
Allow to contact the suppliers through the means of email. Allow viewing the history of issued books for further reference. Allow the authorized user to keep the records of book requested in the library. Allow the authorized user to view issued books and membership status of the borrower.
Bishwanath Parajuli
15
3.2
Design Specification:
tblbookdetails:
Field Book_Code (Primary Key) Title Edition Type_of_Book Number_of_Copies Published_Year ISBN Price Shelf_Number Data Type Long Integer Text (Max Size=80) Text (Max Size=25) Text (Max Size =15) Long Integer Long Integer Text (Max Size =13) Long Integer Long Integer Description A unique code assigned to each book (auto-number). Stores the title of the book Stores the edition of book Stores the book type Stores the total number of the book in library Stores the year when the book was published Stores the ISBN of the book Stores the total price of the book Stores, to which shelf the book belongs Example 201 HTML Practice 3rd Reference 3 2004 13x744744480 45 2
Bishwanath Parajuli
16
tblmember:
Field ID (Primary Key) First_Name Middle_Name Sur_Name Date_of_Birth Education_Level Contact Gender Activation_Date Expiry_Date path Data Type Long Integer Text (Max Size=30) Text (Max Size=30) Text (Max Size=30) Date/Time Text (Max Size=20) Text (Max Size=30) Text (Max Size=6) Date/Time Date/Time Text (Max Size=30) Description A unique ID of each member (auto-number) Stores the initial part of the borrowers Name. Stores the middles of the borrowers name Stores the sur name of the borrowers name Stores the birth date of the borrower Stores the grade or category of the borrower Stores the contact number/address of borrower Stores the information of gender of borrower Stores the membership activation date of the borrower Stores the membership expiry date Stores the path for picture of the borrower Example 401 Kumar Prasad Lama 5/6/2007 10 4488555 Male 5/6/2006 5/6/2008 ama_6.jpg
tblusers:
Field User_Name (Primary Key) User_Type Password Data Type Text (Max Size=8) Text (Max Size=30) Text (Max Size=8 Description Stores the username of a user Stores the user type Stores password for the user Example Lamia General User qwerty
Bishwanath Parajuli
17
tblauthor:
Field Author_ID (Primary Key) Author_Name Contact Country Book_ID Data Type Long Integer Text (Max Size=60) Text (Max Size=100) Text (Max Size=25) Long Integer Description Stores the unique ID for each author(auto-code) Stores the name of author Stores the contact number/ web-address of the author Stores the name of the country the author belongs Stores the book code of the authors book Example 201 Samrat Upadhaya 4488888 Nepal 101
tblpublisher:
Field Publisher _ID (Primary Key) Publisher_Name Contact Book_ID Data Type Long Integer Text (Max Size=60) Text (Max Size=100) Long Integer Description Stores the unique ID for each publisher(auto-code) Stores the name of publishers title Stores the contact number/web-address of the publisher Stores the book code of the book published by it Example 501 Ekta Publication www.ekta.com 101
tblreserve:
Field Reservation_ID (Primary Key) Book_Code Borrower_ID Reservation_Date
Date_Cancel_Reserve
Description Stores a unique ID for each reservation(auto-code) Stores the book code of the reserved book Stores the ID of the borrower Stores the date when the reservation was made Stores the date when the reservation cancels
Bishwanath Parajuli
18
tblissue:
Field Name Issue_ID (Primary Key) BookCode Borrowers_ID Date_of_Issue Returning_Date Student_Memo Status Book_Type Data Type Long Integer Long Integer Long Integer Date/Time Date/Time Text (Max Size=30) Text (Max Size=3) Text (Max Size=12) Description Stores a unique number (auto-code) for every issue that is made Stores the code assigned for each book(Mandatory) Stores the ID assigned to member making the issue (Mandatory) Stores the issue date(System Date) Stores the returning date of the issued book Stores about the borrowing activity of the student Stores the whether the book has crossed its due date or not. Stores the type of book Example 101 201 401 4/3/2007 4/10/2007 Returns Late Yes Non-fiction
tblfine:
Field Name Fine_ID (Primary Key) Book_Code Member_ID Overdays Fine(Rs) Data Type Long Integer Long Integer Long Integer Text (Max Size=15) Long Integer Description Stores a unique ID (auto-code) for each fine record Stores the book code of the borrowed book that has crossed its due date Stores the member ID of the member who needs to pay fine Stores the number of days after the due date, until the book had been returned Stores the total fine amount for the member Example 111 201 401 5 10
tblorderbooklist:
Field Name Book_Title (Primary Key) Data Type Text (Max Size=80) Description Stores the title of the requested book Example War and Peace
Bishwanath Parajuli
19
tblsupplier
Field Name Supplier_ID (Primary Key) Supplier Address Contact Data Type Long Integer Description Stores a Unique ID (auto-code) for every supplier Example 444 Ekta Publication Kapan www.ekta.com
Text Stores the name of the supplier (Max Size=80) Text Stores the address of the supplier (Max Size=80) Text Stores contact number/web-address of the supplier (Max Size=40)
tblsettings:
Field Name Quickbook Quickmem Compact Inform Backup Data Type Text (Max Size=5) Text (Max Size=5) Text (Max Size=5) Text (Max Size=5) Text (Max Size=5) Description Stores data, whether or not to show frmreminders Stores data, whether or not to show frmovrmem Stores data, whether or not to compact the database at the termination of the application Stores data, whether or not to tell the user about the total fine collected when the application loads Stores data, whether or not to backup the database at the termination of the application Example Yes No Yes Yes No
tblhistory:
Field Name History_Code (Primary Key) Book_ID Member_ID Issue_Date Returned_Date Comments Data Type Long Integer Long Integer Long Integer Date/Time Date/Time Text (Max Size=5) Description Stores a unique code for the storing an issue done in the past Stores the book code for the book issued in the past Stores the member id for the member that issued book(s) in the past Stores the date when issue was made Stores the date when the book was returned Stores the comments on the member Example 801 201 401 2/3/2007 2/10/2007 No Comments
Bishwanath Parajuli
20
Bishwanath Parajuli
21
Query
SQL Code
SELECT tblissue.BookCode, tblbookdetails.Title, tblissue.[Borrower's_ID], ([First_Name] & " " & [Middle_Name] & " " & [Sur_Name]) AS Name, tblissue.Date_of_Issue, tblissue.Returning_Date
qryissue
FROM tblmember INNER JOIN (tblbookdetails INNER JOIN tblissue ON tblbookdetails.Book_Code = tblissue.BookCode) ON tblmember.ID = tblissue. [Borrower's_ID]; SELECT tblbookdetails.Book_Code, tblbookdetails.Title, tblbookdetails.Type_of_Book, tblmember.ID, ([First_Name] & " " & [Middle_Name] & " " & [Sur_Name]) AS Name, tblmember.Contact, tblfine.Overdays, tblfine.[Fine(Rs)] FROM tblmember INNER JOIN (tblbookdetails INNER JOIN tblfine ON tblbookdetails.Book_Code=tblfine.Book_Code) ON tblmember.ID=tblfine.Member_ID; SELECT tblreserve.Book_Code, tblbookdetails.Title, tblreserve.Borrower_ID, ([First_Name] & " " & [Middle_Name] & " " & [Sur_Name]) AS Name, tblreserve.Reservation_Date, tblreserve.Date_Cancel_Reserve
qryfine
qryreserve
FROM tblmember INNER JOIN (tblbookdetails INNER JOIN tblreserve ON tblbookdetails.Book_Code=tblreserve.Book_Code) ON tblmember.ID=tblreserve.Borrower_ID; SELECT tblissue.BookCode, tblbookdetails.Title, tblbookdetails.Type_of_Book, tblissue.[Borrower's_ID], ([First_Name] & " " & [Middle_Name] & " " & [Sur_Name]) AS Name, tblmember.Expiry_Date, tblissue.Date_of_Issue, tblissue.Returning_Date, tblissue.Status
qrydue
FROM tblmember INNER JOIN (tblbookdetails INNER JOIN tblissue ON tblbookdetails.Book_Code=tblissue.BookCode) ON tblmember.ID=tblissue. [Borrower's_ID] WHERE (((tblissue.Status) Like 'No'));
Query
SQL Code
SELECT tblhistory.History_Code, tblhistory.Book_ID, tblbookdetails.Title, tblhistory.Member_ID, ([First_Name] & " " & [Middle_Name] & " " & [Sur_Name]) AS Name, tblhistory.Issue_Date, tblhistory.Returned_Date, tblhistory.Comments FROM tblmember INNER JOIN (tblbookdetails INNER JOIN tblhistory ON tblbookdetails.Book_Code=tblhistory.Book_ID) ON tblmember.ID=tblhistory.Member_ID; SELECT tblbookdetails.Book_Code, tblbookdetails.Title, tblbookdetails.Edition, tblbookdetails.Number_of_Copies, tblbookdetails.Published_Year, tblbookdetails.Price, tblbookdetails.Shelf_Number, tblpublisher.Publisher_Name, tblauthor.Author_Name
qryhistory
qrybookdetails
22
Bishwanath Parajuli
23
Users
History
Settings
Fine
Authors and Books have many to one relationship because many authors can write a book. Publishers and Books have one to one relationship because only one publisher publishes a book. Book and Issues have one to many relationships because a book can be issued many times. Book and Reserves have one to many relationships because a book can be reserved many times. Member and Issues have one to many relationships because a member can issue many books. Member and Reserves have one to many relationships because a member can reserve many books.
The box without any lines shows, it does not have any relationship.
Bishwanath Parajuli
24
Open database and data tables referring the connection link Avialable Options Add New Records Save Records Check Validation Sorting Records Editing Records Deleting Records Searching Records Exporting Data Populating Records Printing Records Select case Available Options Case Add New Record Step 1: Clear text boxes Step 2: Move record pointer to the end of file Step 3: Copy record number Step 4: Generate code number by adding 1 to the record number Step 5: Reserve a space in the database for saving an record Case Save Record Step 1: Read data in the text boxes Step 2: Check the data validation Step 3: If invalid data is found, then display error message Step 4: Else, set the value/data to the specified fields in the table Step 5: Save the data. Step 6: Display message as directed. Case Check Validation
Bishwanath Parajuli
25
Step 1: Check if the field is empty Step 2: If not, compare the data with the rule specified Step 3: If rule and data matches continue with ongoing task Step 4: Else, display an error message and terminate the process. Case Sorting Records Step 1: Step 2: Compare the data with one another. Keep the data in correct place as requirements
Case Editing Records Step 1: Step 2: Step 3: Step 4: Step 5: Step 6: Step 7: Move to the first record Check until the end of the file. Compare key field of the record to be edited with that on the database. If matched, set the new data to the specified fields. Update the new data/record. If not, move to next record and continue matching. Display message as directed.
Case Deleting Records Step 1: Move to the first record Step 2: Check until the end of the file. Step 3: Compare key field of record to be deleted with that on the database. Step 4: If found, delete the records from the database. Step 5: If not, move to next record. Step 6: Display message as directed.
Step 1: Move to the first record Step 2: Check until the end of the file. Step 3: Compare the search code in the specified table. Step 4: If found, display the records in specified fields of the forms. Step 5: If not, move to next record. Step 6: Display message as directed. Case Exporting Data Step 1: Declare, for the ongoing task, the required variables and controls. Step 2: Specify the form fields for the data to be exported. Step 3: Open the requested window or do the requested task. Case Populating Records Step 1: Move to the first record. Step 2: Check until the end of the file. Step 3: Populate the data from the specified fields. Step 4: Move to next data for populating Step 5: Continue until all the records are populated. Case Printing Records Step 1: Read the data to be printed Step 2: Open requested/concerned application or form to print the data through it. Step 3: Print the report
Bishwanath Parajuli
27
3.3.2
Pseudocode :
Calculating Fine: Begin Declare variables x = returning date y = returned date If y-x < 1 then duedays = 0 day Elseif y-x = 1 then duedays = 1 day Elseif y-x >1 then duedays = y-x days End if If y-x <= 0 then fine = 0 Elseif y-x < 7 then fine = (y - x) * 2 Elseif y-x >= 7 fine = (7 * 2 + (y - x - 7) * 5) End if
Bishwanath Parajuli
28
3.3.3
Flowcharts :
1. For Adding new records: Start Clear textboxes Move record pointer to last record Copy pointer value Add 1 to the pointer value Reserve a space in database with keyfield, the value of pointer End
Bishwanath Parajuli
29
2. For Saving records: Start Read data into textboxes Check Validation Set the datas in the specified fields of the table. Save the record. Display message. End
Bishwanath Parajuli
30
Yes
Yes
Bishwanath Parajuli
31
4.
For sorting data: Start Compare the list of data with one another. Keep the data in correct position as directed. End
Bishwanath Parajuli
32
Yes
Display messag e
No
Set the new datas in the specified fields. Update the record. Display message. End
Bishwanath Parajuli
33
Yes
Display messag e
No
Bishwanath Parajuli
34
Yes
Display messag e
No
Bishwanath Parajuli
35
Start Declare the variables and controls. Copy the required data from the form to the form fields. Open the required application window or do the requested task. End
Bishwanath Parajuli
36
Yes
Display messag e
Add data into the listbox or combo-box Move to next record. End
Bishwanath Parajuli
37
10.
Start Read the data to be printed Open the application or form to print the data Print the report End
Bishwanath Parajuli
38
11.
For calculating fine: Start Decalre variables Assign the value of dater.
Convert dater and system date into integer. Calculate difference between dater and system date. Case 1 Case 2
Difference? <7
<=0 Label = difference*2
Difference? >1 1
Label = 1 Day Label = difference Days
<1
Label = 0 Day
>7
Label = Blank
Label = (7 * 2 + (difference - 7) * 5)
End
Bishwanath Parajuli
39
Category/Grade _____________ Number/Mail Address _____________ Gender Male Female _____________ _____________ Renew Membership Option button
Add
Save
Delete
Modify
Cancel
Erase
First
Previous
Next
Last
Command buttons
Bishwanath Parajuli
40
Code Title Types of Book Edition Copies ISBN Volume Price Shelf Number
Change Code
Add Modify
Save Cancel
Delete Erase
First
Previous
Next
Last
Bishwanath Parajuli
41
Book Code
Combo box
Title of Book
Author ID Author Name Author Contact Country
New Author New Author Save Author Save Author Cancel Saving Cancel Saving Delete Author Delete Author Modify Modify
Bishwanath Parajuli
42
Publisher Tabs:
Title of Book
Publisher ID Publisher Name Publisher Contact
Save Publisher Save Publisher Cancel Saving Cancel Saving Delete Publisher Delete Publisher Modify Modify
Bishwanath Parajuli
43
Supplier Details:
Supplier ID
_____________ _____________
Save Supplier Save Supplier Delete Delete Modify Modify Refresh Refresh Mails Mails
_____________
Tabular View
Check box
Bishwanath Parajuli
44
Clear
Bishwanath Parajuli
45
Clear
Bishwanath Parajuli
46
______________ ______________
Delete User
Bishwanath Parajuli
47
Comments
Bishwanath Parajuli
48
Reservation Form:
Book Code
Borrower's ID
Title of Book
Reservation Date
Name of Borrower
Reservation Cancels On Reserve Cancel Reservation
View Details
View Books View Reservation
Tabular View
Bishwanath Parajuli
49
Borrower Name Contact Membership Expiry List View Status Bar Photo
Bishwanath Parajuli
50
Search Form: Search Criteria Issues Authors Members Publishers Books Reserves
Search category (appears according to search criteria) Search Text _____________ Tabular View
Search Sort
Sort Form:
Sort Fields
Ascending Descendin g
Unload
Filter Text
Filter
___________
Bishwanath Parajuli
51
Fine Form:
Total Fine
Calculate fine paid by a member
Collect Fine
Bishwanath Parajuli
52
Tabular View
Bishwanath Parajuli
53
View Details
Request Form:
Title of Book
__________
Name of Books
Bishwanath Parajuli
54
Overview of Library: Total Memeber Total Books Total Issues Librays Net Value Preference Form: Preference Form: As a whole Categorywis e
OK
Compact and Repair database at the termination. Create Backup at the termination of the program. Create Backup at the termination of the program. Create Backup at the termination of the program. Create Backup at the termination of the program. Cancel Cancel Apply Apply
__________ __________
OK
Overview Form: Tabular view of issued books that have crossed their due date
Bishwanath Parajuli
55
Books Report:
Bishwanath Parajuli
56
Fine Reports:
Reservation Reports:
Due Reports:
Bishwanath Parajuli
57
Bishwanath Parajuli
58
3.7
Menu Design
Management Menu:
Book Details Member Details
Publisher and Author Details
File Menu:
Issue
Renew/Return
Edit Menu:
Search Fine History Request New Book Overview General Overview
Settings Menu:
Database Utilities Security Preference
Report Menu:
Memebers Books Fine Reservation Due
Help Menu:
About Contents
Reservation Exit
Supplier Details
Bishwanath Parajuli
59
4. Intended Benefits:
The proposed benefits from the implementation of new computerized system in library management are: 1. The routine task of the library will be easier and efficient. 2. Searching the records will be very quick and easy. The books can be searched based on the shelf number too. 3. Maintaining records of supplier will be very quick. 4. Reports can be generated and printed to manage the daily transaction and status of the library. 5. The user will be informed about the ongoing activities through the help of suitable message boxes, which will possibly reduce the frequency of errors. 6. History of issued books can be viewed easily. 7. The due books can be seen at the startup of the program, if configured. 8. Additional feature is provided in the system as mentioned in the system. 9. The system will be password protected. The access right is divided into three users Administrator or Head Librarian, General User and Visitor. The visitor is allowed to search records and to view data only. The General User can carry out major library tasks but cannot modify records.
Bishwanath Parajuli
60
Bishwanath Parajuli
61
tblbookdetails: Book_Code = 4 bytes, Title = 80 bytes, Edition = 25 bytes, Type_of_Book = 15 bytes, Number_of_Copies: 4 bytes, Published_Year = 4 bytes, ISBN = 13 bytes, = 4 bytes
Total size = 161 bytes; Expected Books = 6000; Total size of the table = 966 KB tblusers:
Author_ID: 4 bytes, Author_Name = 60 bytes, contact = 100 bytes, country = 25 bytes, Book_ID = 4 bytes
Total Size = 193 bytes; Expected Authors = 1500; Total size of table = 289.5 KB
Bishwanath Parajuli
62
tblpublisher:
Publisher _ID = 4 bytes, Publisher_Name = 60 bytes, Contact = 100 bytes, Book_ID = 4 bytes
Total Size = 168 bytes; Expected publishers = 1000; Total size of table = 168 KB tblreserve:
Reservation_ID = 4 bytes, Book_Code = 4 bytes, Borrower_ID = 4 bytes, Reservation_Date = 8 bytes, Date_Cancel_Reserve = 8 bytes
Total size = 28 bytes; Expected Reservation per day = 5; Total increment in the size of the table = 0.14 KB per day or 4.2 KB per month
tblissue: Issue_ID = 4 bytes, BookCode = 4 bytes, Borrowers_ID = 4 bytes, Date_of_Issue = 8 bytes, Returning_Date = 8 bytes, Student_Memo = 30 bytes, Status = 3 bytes, Book_Type = 12 bytes
Total size = 73 bytes; Expected increment in size of table = 1.09 KB per day or 32.7 KB per month tblfine:
Fine_ID = 4 bytes, Book_Code = 4 bytes, Member_ID = 4 bytes, Overdays = 15 bytes, Fine (Rs) = 4 bytes
Total size = 31 bytes; Expected Records = 15, Total size of table = 0.45 KB per month
Bishwanath Parajuli
63
tblsettings: Quickbook = 5 bytes, Quickmem = 5 bytes, Compact = 5 bytes, Inform = 5 bytes, Backup = 5 bytes
tblhistory: History_Code = 4 bytes, Book_ID = 4 bytes, Member_ID = 4 bytes, bytes, Returned_Date = 8 bytes, Comments = 30 bytes
Total size = 58 bytes, Expected returns = 15, Total increment in size of table = 0.87 KB per day or 26.1 KB per month
Issue_Date = 8
6. Development
6.1 Database Development
The database for this software was developed using Microsoft Office Access 2003. The preview of back-end is shown below:
Tables Design:
Bishwanath Parajuli
65
Bishwanath Parajuli
66
Bishwanath Parajuli
67
Bishwanath Parajuli
68
Bishwanath Parajuli
69
Bishwanath Parajuli
70
Bishwanath Parajuli
71
Bishwanath Parajuli
72
Bishwanath Parajuli
73
Bishwanath Parajuli
74
Bishwanath Parajuli
75
Bishwanath Parajuli
76
Query Design:
Queries are the fundamental data source of the new system. Many forms and reports depend on queries. The design of the queries was done in SQL view so the preview of every query is not necessary. However, the SQL codes are included in technical documentation and a preview of SQL code is given below along with query design:
Bishwanath Parajuli
77
6.2.1
Form Design:
Toolbox:
Main Window:
Purpose: - This window provides link with all the forms plus the database utilities. Table used tblmember, tblissue, tblorderbooklist, tblsettings, tblreserve Member Details:
Bishwanath Parajuli
78
Purpose: - This window allows managing the member records. Table used tblmember
Bishwanath Parajuli
79
Fine Form:
Purpose: - This window allows calculating total fine and fine collected from a member Table/Query used tblfine/qryfinerecset
Bishwanath Parajuli
80
Purpose: - This window allows managing book records. Table used tblbookdetails
Bishwanath Parajuli
81
Login Form:
Purpose: - It allows entering username and password to authenticate access. Table used tblusers, tblsettings Sort Form:
Bishwanath Parajuli
82
Purpose: - It allows viewing issued books and books that will cross or have crossed its due date. Query used qryissuerecset Linking Form:
Bishwanath Parajuli
83
Security Form:
Purpose: - It allows adding new user, modifying, and deleting the user. Table used tblusers General Overview Form:
Purpose: - It allows at-a-glance status of the library. Table used tblbookdetails, tblissue, tblmember
Bishwanath Parajuli
84
About Form:
Purpose: - It allows the user to modify the application according to the taste of user. Table used tblsettings
Bishwanath Parajuli
85
Purpose: - It allows managing the records of the publishers and the authors. Table used tblpublisher, tblauthor, tblbookdetails
Bishwanath Parajuli
86
Issue Form:
Purpose: - It allows maintaining detail record about issues. Table used tblissue, tblreserve, tblmember, tblbookdetails
Bishwanath Parajuli
87
Bishwanath Parajuli
88
Reminder Form:
Purpose: - It allows viewing the books that have crossed due date. Query used qryissuerecset
Bishwanath Parajuli
89
Search Form:
Purpose: - It allows searching the record from the database. Table/Query used qryissue, qryreserve, tblmember, tblbookdetails, tblauthor, tblpublisher
Bishwanath Parajuli
90
Supplier Form:
Purpose: - It allows overseeing the records of books supplier Table used tblsupplier
Bishwanath Parajuli
91
Renew/Return Form:
Purpose: - It allows managing records related to issues i.e. renew or return. Table used tblissue, tblreserve, tblmember, tblbookdetails, tblhistory, tblfine
Bishwanath Parajuli
92
Reservation Form:
Purpose: - It allows maintating reservation records. Table used tblissue, tblreserve, tblmember, tblbookdetails
Bishwanath Parajuli
93
Purpose: - It allows maintating records of the book requested in the library. Table used tblorderbooklist
Bishwanath Parajuli
94
History Form:
Purpose: - It allows viewing the records of the books issued previously. Query used qryhistory
Bishwanath Parajuli
95
E-mail Form:
Bishwanath Parajuli
96
Bishwanath Parajuli
97
6.2.2.2
Finished View:
Bishwanath Parajuli
98
The help system was produced through Microsoft Help Workshop provided in Microsoft Visual Studio 6.0.
Bishwanath Parajuli
99
Input
Processing
Output Reports
Reservation
Return
Renew
Issues
Search
Book
Member
Supplier
Book Request
Fine
Bishwanath Parajuli
100
7. Testing
Result of testing of application is shown below. The evidence is included in Appendix I I.
Application Startup:
Tests Database is modified or removed from the path where application is stored. Unknown database is placed in the application path with the name Library Management System.mdb Database is opened exclusively when the application is run. Results Displays an error message showing that database was not found. Display an error message showing that tblusers was not found. Terminate the program. Display error message showing file already in use. Evidence 1 2 3
Display invalid password message. Unload the login dialog and open Splash screen but disable Management and Fine menu. Unload the login dialog, open Splash screen and enable all the menus. Unload the login dialog, open Splash screen but enable specified menus only.
Bishwanath Parajuli
101
Issue Form:
Tests Press Update without selecting book code or/and member ID. Try to issue reference book 102. Try to issue a book whose all copies are issued already. Try to issue more than 3 books for a member with ID 202. Try to issue book a book with code 105 by a borrower with ID 206, twice. Try to issue a reserved book, 106. Try to issue a book by a member who has to pay fine. Try to issue a book by a member whose membership has expired. Try to issue a book 105 by a borrower 203. Try to issue a book 106 that had been reserved by borrower 206. Results Display, enter the required fields, message. Display error message. Display, no more books, error message Display, already issued 3 books, message and terminate issue. Display, already issued the book, message. Terminate issue Display, already reserved, message Prompt the user to collect fine. Deny to issue if selected No. Prompt the user to renew membership. Make the issue and save it in table tblissue. Prompt the user whether to issue the reserved book. Evidence 7 8 9 10 11 12 13 & 14 15 & 16 17
Renew/Return Form:
Tests Try to renew/return book(s) for a member who has fine to pay. Try to renew/return book(s) for a member whose membership has expired. Renew a book with code 103. Try renewing a book that has been reserved Returns a book successfully Results Prompt the user to charge fine to a borrower who has fine to pay. If denied cancel renew/return process and display error message Prompt the user to renew the membership. If denied cancel renew/return process and display error message Increase the returning date 10/23/2007 to 10/30/2007. Display error message, book is reserved. Ask if the book is received and display, return completed, message if received. Evidence 18 and 19
20 and 21 22 23 and 24
Bishwanath Parajuli
102
Reservation Form:
Tests Try to reserve a book that has already been issued by the borrower. Try to reserve a book by a borrower that has fine to pay. Try to reserve a book by a borrower whose membership has expired. A member 206 tries to reserve a book 105 twice. A member tries to reserve more than 3 books at a time. A member tries to reserve a reference book 102. A book is reserved successfully. A reservation is cancelled. Results Display message, book already issued. Prompt the user to collect fine. If denied terminate reservation. Prompt the user to renew membership. If denied terminate renew/return task. Display message, already reserved the book. Display message, already reserved three books. Display message, cannot reserve reference book. Display, reservation saved, message. Prompt user and cancel reservation. Evidence 25 26 & 27 28 and 29 30 31 32 33 34 and 35
Bishwanath Parajuli
103
Bishwanath Parajuli
104
Try to search the non-existing record. Try to enter numbers less than 7 and greater than 10 when check box is checked and try to enter a number when Validate Contact is unchecked or enter alphabet without character .. Delete the record successfully.
54
Display error message. Prompt the user to delete the record and delete if directed by user. Display the record in the relevant fields. Prompt the user whether or not to modify the record and change the record if directed. Export the data to Microsoft Word and allow printing it. Generate an auto ID for member and save the record after filling required fields. Display the record in grids. The selected record is exported into form view, from where the data can be modified.
55 and 56 57 and 58
Try to search the record. Try to modify grade of a member with ID 207 to 9. Try to print a library card. Add new record and save it successfully. Click on Grid View tab. Click on grid to edit the data.
59 and 60 61 62 -
Bishwanath Parajuli
105
Bishwanath Parajuli
106
Search Form:
Tests Try to search data without entering/selecting search data. Try to view all the data in a particular table by selecting View all option. Select the search criteria, the search field, enter the search data and click on find icon. Open the sort form and try to sort the title of the book descending. Open the sort form and try to sort the title of the book ascending. Try to filter the first name of the member with initials b. Try to search a data by selecting View all option. Try to search data from the table that has no records. Try to sort or filter the data from a table not displayed currently. Results Display message, enter search data. Display all the data stored in the table in the grid and enable Sort button. Point the cursor towards the selected data. Sort the data descending in the search form. Sort the data ascending in the search form. Filter the data with initials b. Display error message. Display error message. Display error message. Evidence 82 83 84 85 86 87 88 89 90
History Form:
Tests Try to view those books that were issued already. Check View Details box. Results Display the brief information on the left hand side of the window. Expand the form to tabular view. Evidence 94 -
Try to queue a book without filling the title of book. Try to request a book already requested. Try to request a book, Barron's SAT I, already in library. Try to delete the book SAT II from the queue. Try to store the data Basic Computing in queue. Try to print the data.
Display error message. Display error message. Display error message. Prompt the user to delete the book and show confirmation message if responded Yes. Populate the data into list box. Display a report window listing the name of the requested book.
95 96 97 98 and 99 -
Database Utilities:
Tests Try to create a back up of database at the desktop. Try to restore the database from the desktop. Try to Compact and Repair database. Results Create a database backup and inform the user. Restore the database from the desktop. Reduce the size of the database and create a fresh copy. Results Evidence 103 -
Email Form:
Tests Evidence
Bishwanath Parajuli
108
Try to send mail without including @ or in address. Try to send mail to a supplier.
Display error message. Display a dialog box asking permission some cases only) (in
104 105
Security Form:
Tests Try to add user/change password/delete user without filling the text boxes. Try to add a user by entering unlike passwords. Try to add a user as Head Librarian. Try to add another user as Head Librarian. Try to change password for a non-existing user, Bijay. Try to set a new password for wrong old password. Try to set a new password by entering new unlike passwords. Try to change password for the user Rajeev from scythe to raj. Try to delete a non-existing user, Urgen. Try to delete user by entering wrong password. Try to delete a user Rajeev. Results Display error message. Display error message. Add the user. Display error message. Display error message. Display error message. Display error message. Display process completion message. Display error message. Display error message. Prompt the user to delete the username and display, process complete. Evidence 106 107 108 109 110 111 112 113 114 115 116 and 117
Preference Form:
Tests Select various option and click on Apply button. Results Apply the settings and carry out the directed activities. Evidence -
Bishwanath Parajuli
109
Reminders Form:
Results Display the books that have crossed their due date at startup if configured.
Mother Window:
Tests Unload the form when configured to compact or backup database Load the form, when a reservation has expired. Results Create a backup or compact the data base Display message. Evidence 119
Bishwanath Parajuli
110
8. Implementation:
Since the prevailing system of the school was very time consuming and troublesome, the user preferred direct implementation but some discussion with the end user lead him to implement the system in parallel mode. According to it, the user will maintain both, the computerized system and the manually system simultaneously. The three steps of the implementation plan of the system are given below: 1) Concise Course Training 2) Parallel Implementation 3) Full phase Implementation 1) Concise Course Training: Since the computerized system was very handy, the training period was very brief. The user required some illustrations about working out with the system. Besides, the user was well used to the packaged application such as word processors and database management system. The user will be made familiar about operating the main controls of the system. The user will also be given a brief introduction about various errors that could occur on different cases, especially during the ill management of the system such as database mishandling or destruction of the associated files. 2) Parallel Implementation: During direct implementation of the system, many faults may be discovered in the new system due to which serious problems of data loss may occur. So to prevent this sort of cases parallel implementation will be brought to use. The end user mainly will focus on the computerized system for data entry and will write the details manually too. Despite the time consumed on maintaining the entry of the transaction both the way, the user will be able to compare the effectiveness of the system at end and will be able to move towards the full phased implementation.
Bishwanath Parajuli
111
3)
Full phase Implementation: After the satisfactory results from parallel implementation, the user will move to
Bishwanath Parajuli
112
Bishwanath Parajuli
113
Bishwanath Parajuli
114
10. Evaluation of the degree of success of the system over its objectives:
Allow the authorized user to add new records regarding books, members, publisher, author and suppliers, and allow editing/removing them. Reference: Appendix II, Evidence No. 6.1, 6.2, 6.3 Allow easier and convenient searching of data from various data tables. Reference: Appendix II, Evidence No. 82-87 Allow the authorized user to carry out routine library tasks such as issue, renew/return and reserve. Reference: Appendix II, Evidence No. 6.1, 6.2, 6.3 Allow only authorized user to get into the system and allow provision for a single administrator only. Reference: Appendix II Allow to add new authorized users according to the rights specified. Also, provide the feature of deleting the user or changing the password. Reference: Appendix II, Evidence No. 106-117 Allow the administrator to control all the library tasks. Also, allow provision of General User who can carry out major library tasks in absence of administrator. Reference: Appendix II Prevent the user from issuing a reference book. Reference: Appendix II, Evidence No. 8 Prevent from issuing reserved books, issuing more than three books at a time or issuing same book at a time. Allow the same provision in reserving. Reference: Appendix II, Evidence No. 10, 11, 12 Prevent the member from issuing, reserving, renewing or returning the book who has fine to pay or whose membership has expired. Reference: Appendix II Allow the user to cancel reservation if demanded.
Bishwanath Parajuli
115
Reference: Appendix II, Evidence No. 34, 35 Prompt the authorized user to cancel the reservation, if made, while the borrower is about to issue reserved book. Reference: Appendix II, Evidence No. 17 Cancel all the reservation that has crossed its due date at the startup of the program. Reference: Program Listings Allow automatic calculation of the fine and allow printing a fine report. Reference: Appendix II, Evidence No. 91, 92, 93 Only allow the administrator to collect the total fine. Reference: Appendix II Prompt the authorized user to collect and clear fine (No partial payment allowed) from the borrower if any borrowed book has crossed its due date. Reference: Appendix II, Evidence No. 18, 19 Allow printing/viewing the details of the member, books, reservation and due books in the form of reports. Reference: Appendix II, Evidence No. 118 Allow viewing the due books at startup, if configured. Reference: Appendix II Allow to contact the suppliers through the means of email. Reference: Appendix II, Evidence No. 104, 105 Allow viewing the history of issued books for further reference. Reference: Appendix II, Evidence No. 94 Allow the authorized user to keep the records of book requested in the library. Reference: Appendix II Allow the authorized user to view issued books and membership status of the borrower. Reference: Appendix II, Evidence No. 100, 101
Bishwanath Parajuli
116
Bishwanath Parajuli
117
11.2 Evidence:
The written evidence from the user has been included in Appendix I.
Bishwanath Parajuli
118
Bishwanath Parajuli
119
13. Documentation:
13.1
Technical Documentation:
This document includes all the technical aspects of Easy Library Management System. It includes database specifications and list of all the codes.
Back End:
The back-end of this application is created with Microsoft Access (Library Management System.mdb). The list of the tables and queries along with their description are listed below:
List of Tables
Name of Table Description
Bishwanath Parajuli
120
tblbookdetails:
Field Book_Code (Primary Key) Title Edition Type_of_Book Number_of_Copies Published_Year ISBN Price Shelf_Number Data Type Long Integer Text (Max Size=80) Text (Max Size=25) Text (Max Size =15) Long Integer Long Integer Text (Max Size =13) Long Integer Long Integer Description A unique code assigned to each book (auto-number). Stores the title of the book Stores the edition of book Stores the book type Stores the total number of copies of the book in library Stores the year when the book was published Stores the ISBN of the book Stores the total price of the book Stores, to which shelf the book belongs
tblmember:
Field ID (Primary Key) First_Name Middle_Name Sur_Name Date_of_Birth Education_Level Contact Gender Activation_Date Expiry_Date path Data Type Long Integer Text (Max Size=30) Text (Max Size=30) Text (Max Size=30) Date/Time Text (Max Size=20) Text (Max Size=30) Text (Max Size=6) Date/Time Date/Time Text (Max Size=30) Description A unique number assigned to each member. (auto-number) Stores the initial part of the borrowers Name. Stores the middles of the borrowers name Stores the sur name of the borrowers name Stores the birth date of the borrower Stores the grade or category of the borrower Stores the contact number/address of borrower Stores the information of gender of borrower Stores the membership activation date of the borrower Stores the membership expiry date Stores the path for picture of the borrower
Bishwanath Parajuli
121
tblusers:
Field User_Name (Primary Key) User_Type Password Data Type Text (Max Size=8) Text (Max Size=30) Text (Max Size=8 Description Stores the username of a user Stores the user type Stores password for the user
tblauthor:
Field Author_ID (Primary Key) Author_Name Contact Country Book_ID Book_Title Data Type Long Integer Text (Max Size=60) Text (Max Size=100) Text (Max Size=25) Long Integer Text (Max Size=80) Description Stores the unique ID for each author(auto-code) Stores the name of author Stores the contact number/ web-address of the author Stores the name of the country the author belongs Stores the book code of the authors book Stores the book title of the authors book
tblpublisher:
Field Publisher _ID (Primary Key) Publisher_Name Contact Book_ID Book_Title Data Type Long Integer Text (Max Size=60) Text (Max Size=100) Long Integer Text (Max Size=80) Description Stores the unique ID for each publisher(auto-code Stores the name of publishers title Stores the contact number/web-address of the publisher Stores the book code of the book published by it Stores the book title of the book published by it
tblreserve:
Field Reservation_ID (Primary Key) Book_Code Borrower_ID Reservation_Date
Date_Cancel_Reserve
Description Stores a unique ID for each reservation (auto-code) Stores the book code of the reserved book Stores the ID of the borrower Stores the date when the reservation was made Stores the date when the reservation cancels
Bishwanath Parajuli
122
tblissue:
Field Name Issue_ID (Primary Key) BookCode Borrowers_ID Date_of_Issue Returning_Date Student_Memo Status Book_Type Data Type Long Integer Long Integer Long Integer Date/Time Date/Time Text (Max Size=30) Text (Max Size=3) Text (Max Size=12) Description Stores a unique number (auto-code) for every issue that is made Stores the code assigned for each book (Mandatory) Stores the ID assigned to member making the issue(Mandatory) Stores the issue date (System Date) Stores the returning date of the issued book Stores about the borrowing activity of the student Stores the whether the book has crossed its due date or not. Stores the type of book
tblfine:
Field Name Fine_ID (Primary Key) Book_Code Member_ID Overdays Fine(Rs) Data Type Long Integer Long Integer Long Integer Text (Max Size=15) Long Integer Description Stores a unique ID (auto-code) for each fine record Stores the book code of the borrowed book that has crossed its due date Stores the member ID of the member who needs to pay fine Stores the number of days after the due date, until the book had been returned Stores the total fine amount for the member
tblorderbooklist:
Field Name Book_Title (Primary Key) Data Type Text (Max Size=80) Description Stores the title of the requested book
tblsupplier
Field Name Supplier_ID (Primary Key) Supplier Address Contact Data Type Long Integer Text (Max Size=80) Text (Max Size=80) Text (Max Size=40) Description Stores a Unique ID (auto-code) for every supplier Stores the name of the supplier Stores the address of the supplier Stores contact number/web-address of the supplier.
Bishwanath Parajuli
123
tblsettings:
Field Name Quickbook Quickmem Compact Inform Backup Data Type Text (Max Size=5) Text (Max Size=5) Text (Max Size=5) Text (Max Size=5) Text (Max Size=5) Description Stores data, whether to show frmreminders Stores data, whether to show frmovmem Stores data, whether to compact the database at the termination of the application Stores data, whether to tell the user about the total fine collected when the application loads. Stores data, whether to backup the database at the termination of the application
tblhistory:
Field Name History_Code (Primary Key) Book_ID Member_ID Issue_Date Returned_Date Comments Data Type Long Integer Long Integer Long Integer Date/Time Date/Time Text (Max Size=30) Description Stores a unique code for the storing an issue done in the past Stores the book code for the book issued in the past. Stores the member id for the member that issued book(s) in the past Stores the date when issue was made Stores the date when the book was returned Stores the comments on the borrower
Bishwanath Parajuli
124
List of Queries
Query Description
Query
SQL Code
SELECT tblissue.BookCode, tblbookdetails.Title, tblissue.[Borrower's_ID], ([First_Name] & " " & [Middle_Name] & " " & [Sur_Name]) AS Name, tblissue.Date_of_Issue, tblissue.Returning_Date
qryissue
FROM tblmember INNER JOIN (tblbookdetails INNER JOIN tblissue ON tblbookdetails.Book_Code = tblissue.BookCode) ON tblmember.ID = tblissue. [Borrower's_ID]; SELECT tblbookdetails.Book_Code, tblbookdetails.Title, tblbookdetails.Type_of_Book, tblmember.ID, ([First_Name] & " " & [Middle_Name] & " " & [Sur_Name]) AS Name, tblmember.Contact, tblfine.Overdays, tblfine.[Fine(Rs)] FROM (tblfine INNER JOIN tblbookdetails ON tblfine.Book_Code=tblbookdetails.Book_Code) INNER JOIN tblmember ON tblfine.Member_ID=tblmember.ID; SELECT tblreserve.Book_Code, tblbookdetails.Title, tblreserve.Borrower_ID, ([First_Name] & " " & [Middle_Name] & " " & [Sur_Name]) AS Name, tblreserve.Reservation_Date, tblreserve.Date_Cancel_Reserve
qryfine
qryreserve
FROM tblmember INNER JOIN (tblbookdetails INNER JOIN tblreserve ON tblbookdetails.Book_Code=tblreserve.Book_Code) ON tblmember.ID=tblreserve.Borrower_ID; SELECT tblissue.BookCode, tblbookdetails.Title, tblbookdetails.Type_of_Book, tblissue.[Borrower's_ID], ([First_Name] & " " & [Middle_Name] & " " & [Sur_Name]) AS Name, tblmember.Expiry_Date, tblissue.Date_of_Issue, tblissue.Returning_Date, tblissue.Status
qrydue
FROM tblmember INNER JOIN (tblbookdetails INNER JOIN tblissue ON tblbookdetails.Book_Code=tblissue.BookCode) ON tblmember.ID=tblissue. [Borrower's_ID] WHERE (((tblissue.Status) Like 'No'));
Bishwanath Parajuli
125
Query
SQL Code
SELECT tblhistory.History_Code, tblhistory.Book_ID, tblbookdetails.Title, tblhistory.Member_ID, ([First_Name] & " " & [Middle_Name] & " " & [Sur_Name]) AS Name, tblhistory.Issue_Date, tblhistory.Returned_Date, tblhistory.Comments FROM tblmember INNER JOIN (tblbookdetails INNER JOIN tblhistory ON tblbookdetails.Book_Code=tblhistory.Book_ID) ON tblmember.ID=tblhistory.Member_ID; SELECT tblbookdetails.Book_Code, tblbookdetails.Title, tblbookdetails.Edition, tblbookdetails.Number_of_Copies, tblbookdetails.Published_Year, tblbookdetails.Price, tblbookdetails.Shelf_Number, tblpublisher.Publisher_Name, tblauthor.Author_Name FROM (tblbookdetails INNER JOIN tblauthor ON tblbookdetails.Book_Code=tblauthor.Book_ID) INNER JOIN tblpublisher ON tblbookdetails.Book_Code=tblpublisher.Book_ID;
qryhistory
qrybookdetails
Bishwanath Parajuli
126
Note:
(Line) denotes relationship. denotes many relationships. denotes single relationship. denotes one to one relationship. denotes one to many relationship. The bold digits signify a primary key. Each box is a symbolic representation of the table. The boxes, not joint by line, show they dont have any relationship.
Bishwanath Parajuli
127
Member Details
Member id, Name, Gender, Grade, Membership Expiry date, e.t.c
Issue book
Memberid, Name, Bookid, Title, etc
Reserve a book
Memberid, Name, Bookid, Title, etc
Members Details
If membership expires
Calculate fine Rs. 2 until 7 days and Rs. 5 for rest of the time. Memberid, Name, Bookid, Title, etc
Display Report
Bishwanath Parajuli
128
Issued three books or issued the book already and have fine to pay
Yes
No
Yes
Generate codeusing record postion. Save the data in relevant fields End Bishwanath Parajuli 129
Reserved three books or reserved the book already and have fine to pay
Yes
No
Yes
Generate codeusing record postion. Save the data in relevant fields End Bishwanath Parajuli 130
Yes
No
Increase the return date of the book, if renewed and delete the book from issue table to return the book. Sort data according to keyfield If returned, save the data in the history table. End
Calculate fine
Bishwanath Parajuli
131
Data Dictionary:
Name of Variable Variable Type Data Type Purpose
lpExistingFileName lpNewFileName bFailIfExists connect precord, bdrecord, mrecord, lrecord, brecord, hrecord, srecord, nrecord result stTempDBfile origin, final checkb, checkblank Control vali last deletedata find wa wd expire frmsOutlook frmsMailItem id fine lstitem check (frmissue), idcheck countn, countr, br a checklib ColumnHeader recno, codeno countissue check (frmreserve) dater X, Y supname checkmem, checkbook Bishwanath Parajuli
Global Global Global Global Global Private Private Private Public Private Private Private Private Private Private Private Private Private Private Private Private Private Public Private Private Public Private Private Private Public Private Private Private Private
String String Long ADODB connection ADODB recordset String Long Boolean Object String String Integer Integer/String Word Application Word Document Object Object Integer Integer ListItem Boolean Integer Integer Boolean
MSComctlLib ColumnHeader
System Variable System Variable System Variable Specifies data path & provider Specifies the record table and type Stores name of the backup/restore Stores name of existing file Stores size of old/new file Stores if any field is blank Signifies the field Stores the name/code of book Stores the last letter of the field Stores member ID to be deleted Stores the data to be found Declares MS Word application Declares MS Word document Stores the difference in 2 dates Specifies MS Outlook application Specifies MS Outlook document Stores the member ID to be found Stores calculated fine Specifies items in list view Matches data to conditions to borrow/reserve book Stores number of reserved book Stores if current book is already issued/reserved by the member Checks if Head Librarian exists Stores column index of list view Stores the ID/ name of author/publisher respectively Stores number of issued books
Checks if member had reserved book
Stores date retrieved from source Stores date converted to integer Stores name/code of supplier Stores the data retrieved from tblsettings for show/hide form(s) 132
Note: o Variables like count (integer), i (integer), code (integer/string/long) etc are used in many forms for different purposes so they are not included in above table. o Variables used in frmAbout too, are not included in the above table.
Bishwanath Parajuli
133
Front End:
Mother Window (mdimain)
Bishwanath Parajuli
134
Control(s) mnuexit mnubackupdb mnucompactandrepairdb mnurestore mnuhlp Other menus (Form) (Form) mditime cmdissue cmdexpmem cmdrequest Control(s) tbrmain tbrmain tbrmain
Event(s) Click Click Click Click Click Click QueryUnload Load Timer Click Click Click
Purpose/Description Terminate the form. Create a backup. Initialize DAO and DBEngine to compact and repair database. Copy the specified file from the specified location to application path. Open the help file, Easy Library Management System.hlp, associated to this application. Open the respective forms. Call functions; backupdatabase and CompactCurrentDatabase, if indicated. Update the value of the 12th field of tblissue and 4th field of tblreserve. Display time in Status Bar Display form to view issued books. Display form to view expired membership. Display form to view requested books.
Event(s) Button Menu Click Button Click Button Menu Click (Change User)
Purpose Open respective forms as mentioned in caption. Open respective forms as mentioned in caption. Hide mdimain and display frmLogin.
Functions:
Name of Function backup compact Purpose Make a copy of database in required path. Initialize DAO.DBEngine to compact and repair database.
Bishwanath Parajuli
135
Input Data:
Book Details (frmbookdet)
Field(s) txtcode txttitle txtedition txtdatep, txtcopies, txtprice, txtsno, txtvolume cmdaddnew
Purpose Show cmdchange and unlock txtcode if txtcode is not empty. Enable fracontrols, franavigate, cmdclear, txttitle; unlock txtcode, if locked; show cmdchange, if hidden. Allow numeric characters only. Check whether the title exists already and display message, if found. Extract last letter from txtedition and assign specified letters to value in the box. Allow numeric characters only. Assign a code (auto-number) for the book and allow saving new record. Shift the focus to txtcode.
Bishwanath Parajuli
136
cmdsave cmddelete cmdcancel cmdmodify cmdsearch cmdchange cmdclear cmdbegin, cmdprevious, cmdnext, cmdlast booktimer tabs bookgrid Form
Click Click Click Click Click Click Click Click Timer KeyPress Click Load
Call function checkblanks and enablecontrols. Store the record in tblbookdetails. Delete the record from tblbookdetails. Cancel process of adding new book. Edit the data stored in tblbookdetails except book code. Find the data through ID or title of the book. Change the code of the book. Reset all the textboxes. Move to first record, previous record, next record and last record, respectively. Refresh Adodc, adobook and Datagrid, bookgrid. Set focus to cmdaddnew, if Form View tab is selected, on pressing [Enter]. Load the selected information into textboxes in Form View tab, from the Datagrid, bookgird. Call the functions required by the form and configure adobook from tblbookdetails.
Functions:
Name of Function enablecontrols disablecontrols checkrecords clear display Purpose Enable/disable the command buttons and franavigate. Enable/disable the command buttons and franavigate. Check whether the tblbookdetails is empty and if empty disable franavigate. Reset all the textboxes. Extract the data from tblbookdetails and show the data in assigned fields.
Bishwanath Parajuli
137
Field(s) txtbrid txtfname, txtsname txtcontact chkrestrict lbldatee frapicture memimage cmdfind cmdaddnew cmdsave cmdcancel cmddelete cmdmodify
Event(s) LostFocus Change LostFocus Click Change Click Click Click Click KeyPress Click Click Click Click
Purpose Check whether the ID exists already and display if found. Display the text written on the text boxes in lblfname and lblsname. Call function, checkrestrict. Call function, checkrestrict. Check whether the date displayed on the label is greater or smaller than system date. Clear the image displayed in memimage and lblpic, which contains the address of the picture file. Open common dialog-box; display the selected image in memimage and save the picture in application path. Displays an input-box to enter an ID to be found. Generate a member ID and membership acquired date and allow saving new record. Shift focus to txtbrid. Save the record of the details in tblmember. Cancel adding new record in database. Display a input box to enter the member ID and delete the member if found. Edit the data in tblmember.
Bishwanath Parajuli
138
cmdprint gridtimer expiredtime cmdclear memebergrid tabs cmdbegin, cmdprevious, cmdnext, cmdlast Form
Open Microsoft Word and export required data like members name, grade, etc. to allow the user to print a library card. Refresh Adodc adomember and memebergrid. Change the background color of picx if membership has expired. Reset all the textboxes, option buttons, etc. Load the selected information into textboxes in Form View tab, from the Datagrid - memebergrid. Shift focus to cmdaddnew if [Enter] is pressed. Move to first record, previous record, next record and last record, respectively. Call all the required functions and configure adomember. Unload frmreserve, frmissue and frmrnunreturn.
Functions:
Name of Function enablenavigation disablenavigation checkblanks checkrecords clear display checkrestrict Purpose Enable/disable the command buttons and franavigation. Enable/disable the command buttons and franavigation. Check if any field is left unchecked. Check whether the tblmember is empty and if empty disable franavigate. Reset all the textboxes. Extract the data from tblmember and show the data in assigned fields. Check if txtcontact contains, the character @ or ., while chkrestrict is unchecked and contains 7-10 character, if chkrestrict is checked.
Bishwanath Parajuli
139
Bishwanath Parajuli
140
Click Click
cmdaddnew, cmdnewpub cmdcancelauth, cmdcancel cmddelete, cmddeletep cmdmodifyauthor, cmdmodifypub cmdpub cmdauth cmdbeginauth., cmdpreviousauth, cmdnextauth, cmdlastauth, cmdbeginpub, cmdpreviouspub, cmdnextpub, cmdlastpub timeauth timepub Form
Purpose Load title of book into lbltitle. Shift focus to txtauthcontact or txtpubcontact if [Enter] pressed, according to the button pressed. Check for repetition of author or publisher name. Shift focus to txtcountry on pressing [Enter]. Shift focus to cmdsaveauth on pressing [Enter]. Use Instr function to modify the data in the textbox if required criteria are met, on pressing [Enter]. Call function, clear, disable, checkauthrecords and save record in tblauthor; Shift focus to cmdaddnew on pressing cmdsaveauth. Else call function, clear, disable, checkpubrecords and save the data into tblpublisher and shift focus to cmdnewpub. Generate an author ID / publisher ID (auto number) and allow adding new record. Shift focus to txtauthname if cmdaddnew is pressed. Else, shift focus to txtpubname, on pressing [Enter]. Cancel adding new data into tblauthor on pressing cmdcancelauth. Else, cancel adding new data into tblpublisher on pressing cmdcancel. Delete the author if cmddelete is pressed or publisher if cmddeletep is pressed. Allow modifying data in tblauthor or tblpublisher, respectively. Show pubgrid for publisher detail and show cmdauth. Show authgrid for author detail and show cmdpub. Move to first record, previous record, next record and last record, respectively. Move to first record, previous record, next record and last record, respectively. Refresh authgrid and adoauth. Refresh pubgrid and adopub. Configure adopub, adoauth and call the functions required by the form.
Bishwanath Parajuli
141
Functions:
Name of Function checkpubrecords checkauthrecords viewdatapub viewdataauth enable disable clear Purpose Check whether the tblpublisher is empty and if empty disable franavigatepub. Check whether the tblauthor is empty and if empty disable franavigateauth. Extract the data from tblpublisher and show the data in assigned textboxes. Extract the data from tblauthor and show the data in assigned fields. Enable/disable the command buttons. Enable/disable the command buttons. Reset all the textboxes.
Bishwanath Parajuli
142
Field(s) txtsname chkdet suppliertimer cmdbegin, cmdprevious, cmdnext, cmdlast cmdmail cmdrefresh cmdsearch cmdsave cmddelete cmdmodify Form
Event(s) LostFocus Click Timer Click Click Click Click LostFocus Click Click Click Load
Purpose Check whether the supplier name already exists in the database. Allow viewing supgrid, if checked. Refresh and configure adosupplier and supgrid after adding/deleting the data. Move to first record, previous record, next record and last record, respectively. Open frmemail and exports the address in txtcontact into the form, to allow sending mails to the supplier. Resets all the textboxes Opens an inputbox to allow entering supplier name/code so that the required supplier can be searched. Hide cmdsearch button. Save the supplier into tblsupplier. Delete the supplier record from tblsupplier. Allows the user to edit the supplier record from tblsupplier. Call the functions required by the form and configure adosupplier.
Functions:
Bishwanath Parajuli 143
Purpose Check if tblsupplier is empty and if so disable franavigate. Extract required data from tblsupplier and display in assigned fields.
Bishwanath Parajuli
144
Purpose Call the functions; checkrepeat and checklist. Stores the record/book name in tblorderbooklist. Opens a report window that contains the list of the books, requested in the library. Allows removing the selected book from tblorderbooklist. Configure ADODB connection and call the required functions.
Bishwanath Parajuli
145
Security (frmnuserandcpass)
Field(s) txtusername cmbusertype txtpassword txtcpassword cmdaddnewuser txtuser txtopass txtnpass txtcpass cmdchngpass txtusern txtpassd cmddelete cmdclear, cmdclear1 Form
Purpose If [Enter] is pressed, shift focus to cmbusertype. If [Enter] is pressed, shift focus to txtpassword. Checks whether user with same name already exists. If [Enter] is pressed, shift focus to txtcpassword. If [Enter] is pressed, shift focus to cmdaddnewuser. Check whether txtpassword and txtcpassword matches and if matched, store in tblusers. Shift focus back to txtusername. KeyPress If [Enter] is pressed, shift focus to txtopass. GotFocus Check whether the username exists in the database. KeyPress If [Enter] is pressed, shift focus to txtnpass. GotFocus Check whether the password exists in the database. KeyPress If [Enter] is pressed, shift focus to txtcpass. LostFocus Check whether the text in txtnpass and txtcpass matches. KeyPress If [Enter] is pressed, shift focus to cmdchngpass. If txtuser and txtopass match with database record, update the Click Password field of tblusers with txtnpass. If [Enter] is pressed, shift focus to txtpassd. KeyPress If [Enter] is pressed, shift focus to cmddelete. GotFocus Check whether the username exists in the database. GotFocus Check whether the password matches with that on tblusers. Click Delete the username from database and shift focus to txtusern. Click Reset all the textboxes. Load Call all the function required by the tblusers.
Bishwanath Parajuli
146
Functions: Name of Function clearallfields checklibrarian Purpose Clear all textboxes. Clear and fill items into cmbusertype. Check if an Administrator already exists.
Bishwanath Parajuli
147
Processing Data:
Issue Form (frmissue)
Event(s) Click Got Focus Click Click Got Focus Click Change Load
Purpose Load title, type and returning date of the book. Call functions bremain and clear Load issue ID (auto number). Load name and photo of the member. Call functions check_reserve and clear. Save the required data about the issue in tblissue. Call functions borrower_check and clear Load text No comments on txtmemo if empty. Call function, clear, to reset all the fields. Specify the date of issue according to the text displayed. Load different sub procedures and functions.
Functions:
Name of Function additemid check_reserve borrower_check bremain clear Purpose Add book code and member ID into cmbbrid and cmbbid. Check reservation details of the book. Check details of the borrower including fine left to pay. Check remaining copies of book that can be issued. Reset all the labels, combo-boxes and text-box.
Bishwanath Parajuli
148
Field(s) cmbbrid
cmbcode cmdrenew cmdreturn chkdetails cmdcollect mnulinker Form KeyPress Click Click Click Click Click Load
Purpose Load name, contact, membership expiry date and photo of the member. Call functions check_expire. Shift focus to cmbcode, if [Enter] is pressed.. Load title, issue and returning date of the book. Call functions bremain and clear Shift focus to cmdrenew or cmdreturn, if [Enter] is pressed. Update the value of 4th field of tblissue, if found. Delete the record from tblissue, if found. Expand the form view if checked and constrict when unchecked. Delete the record from tblissue and store the required information in tblfine for further processing. Holds a shortcut [Delete] for loading frmlinker. Call all the functions, required by the form; clear and add item into cmbbcode and cmbbrid.
Bishwanath Parajuli
149
Functions:
Name of Function list finecalc structure restructure check_expire checkid history Purpose Add item into list view (lstview). Calculate due days and the total fine the borrower has to pay. Show frafine and change its position. Hide frafine and change its position. Check if membership has expired. Check if the borrower has fine to pay and if the book to be renewed is reserved then cancel renewing process. Save required information about the issue, made into tblhistory, for future reference.
Bishwanath Parajuli
150
cmdreserve cmdcancelres cmdreserved cmdbook chkdet timereserve Form Click Click Click Click Timer Load
Purpose Load title of book and check whether the book is available. Enable cmbsid. Shift focus to cmbsid, if [Enter] is pressed. Load name of the borrower and call functions borrower_check, fine_check and mem_check. Shift focus to cmdreserve, if [Enter] is pressed. Obtain an auto ID for reservation; call functions check_issue, borrower_check, fine_check and mem_check and save the reservation. Shift focus to cmbbcode. Delete the record form tblreserve. Show reservegrid. Show bookgrid. Change the height of the form. Refresh Adodc, adoreserve and Datagrid, reservegrid. Call the functions required by the form.
Bishwanath Parajuli
151
Functions:
Name of Function check_issue mem_check borrower_check cmbid fine_check Purpose Check if the member already issues the book. Check if membership has expired. Check if the member ahs already reserved the book or reserved 3 books. Add item into cmbbcode and cmbsid. Check if the member has fine to pay.
Bishwanath Parajuli
152
Event(s) Purpose Click Unload frmLogin and mdimain. Configure the settings, enabling and disabling the menu items Click according to the user that has logged in, displaying the user name in status bar (sbrmain) of mdimain. Load Call all the functions required by frmLogin.
frmlinker:
Purpose Open frmrnunreturn, display cmdrenew and hide cmdreturn. Open frmrnunreturn, display cmdreturn and hide cmdrenew.
Bishwanath Parajuli
153
Preference (frmprefer):
Purpose Unload the form. Save the settings into tblsettings. Initialize the settings saved into tblsettings.
Bishwanath Parajuli
154
Purpose Checks whether the character . and @ are present in the text written in txtadd. Export the data to Microsoft Outlook for sending mail item.
Bishwanath Parajuli
155
frmSplash:
Purpose Manage the value of ProgressBar2. At maximum value unload the form, and show mdimain. Hide/Show shp1, shp2, shp3 and shp4. Call all the required functions. Load the settings from tblsettings and carry out operations; calculating total fine, showing/hiding frmreminders and frmovmem, accordingly.
Bishwanath Parajuli
156
Output Data:
Total Fine (frmfine):
Purpose Allow viewing finegrid by expanding the form. Configure and refresh adofine and finegrid. Delete all the records from tblfine. Display an inputbox to calculate the sum of 7th field of qryfine if matched with searched data. Call all the functions required by the form and display the sum of Fine (Rs) field in lblfine.
Search (frmsearch):
Bishwanath Parajuli 157
Field(s)
Event(s)
Purpose
Bishwanath Parajuli
158
optissue optmem optbook optauth optpub optreserve optdaters, optfname, optisbn, optmid, optpid, optpname, optsid, optsno, optaid, optaname, optbcode, optbid, optbtitle, optdatea, optdatei, optdater optgender, optlevel, opttype optrall, optaall, optball, optiall, optmall, optpall cmdsearch cmdsort Form
Show and enable frame (fraissue) only. Show and enable frame (framem) only. Show and enable frame (frabook) only. Show and enable frame (fraauth) only. Show and enable frame (frapub) only. Show and enable frame (frares) only.
Click Click
Call the function combovisible. Fill the combobox (cmbtype) with the texts specified. Click Configure Adodc1, with the tables or queries, as specified. Click Configure Adodc1 to search data. GotFocus Enable cmdsort if txtsearch is not empty. Click Open frmsort and disable frmsearch. Load Configure Adodc1.
Functions:
Name of Function disable1 disable2 disable3 disable5 disable6 disable7 textboxvisible combovisible typeb typel typeg Purpose Show and enable fraissue only from frasearch. Show and enable frabook only from frasearch. Show and enable framem only from frasearch. Show and enable fraauth only from frasearch. Show and enable frapub only from frasearch. Show and enable frares only from frasearch. Show/enable txtsearch and hide/disable cmbtype. Show/enable cmbtype and hide/disable txtsearch. Clear cmbtype and add specified item into it. Clear cmbtype and add specified item into it. Clear cmbtype and add specified item into it.
Sort (frmsort):
Bishwanath Parajuli 159
Purpose Enable frasort and txtfilter. Sort the data ascending, through frmsearchs Adodc1 with the respect to text displayed in combo-box. Sort the data descending, through frmsearchs Adodc1 with the respect to text displayed in combo-box. Filter the data in the field specified in accordance to the text written in txtfilter. Close the form. Fill the combo-box with the texts specified if the required criteria meet. Enable frmsearch.
Bishwanath Parajuli
160
Purpose Enable cmbdays and call function add if unchecked. Else, disable cmbdays and call function listings. Click Display the books that will/not expire after the days shown in the combos text and change the fore-color of lsvbook into Red, if expired. ColumnClick Sort the items displayed in column of the list view. Load Call the functions required by the form.
Event(s) Click
Functions:
Name of Function add listings Purpose Clear and add item into cmbdays. Clear list view (lsvbook) and add item into it from qryissuerecset.
Bishwanath Parajuli
161
Purpose Enable DTPicker and clear the list view if unchecked. Else, disable and refresh DTPicker and call function listdatas. Display the memberships that will/not expire after the days Change shown in the DTPicker and change the fore-color of lsvmem into Red, if expired. ColumnClick Sort the items displayed in column of the list view. Load Call the functions required by the form and disable DTPicker.
Event(s) Click
Functions:
Name of Function listdatas Purpose Clear list view (lsvmem) and add item into it from memeberrecset.
Bishwanath Parajuli
162
Purpose Unload the form. Display fralevel and hide fradet. Display fradet and hide fralevel. Use Adodc3 to calculate the total number of member in the category displayed in the cmblevel. Configure Adodc1, Adodc2, and Adodc3 and use Adodc2 to evaluate the sum of 8th field of tblbookdetails.
Bishwanath Parajuli
163
Event(s) Purpose ColumnClick Sort the data ascending or descending. Call all the functions required by the form, compare the 5th Load field of qryissue with system date and list those data that are less than the system date.
Bishwanath Parajuli
164
History (frmhistory):
Purpose Allow view of gridhistory by expanding the form. Display the details of the records in specified labels. Configure adohistory and add item into lstbooks.
Bishwanath Parajuli
165
The help file for this program Easy Library Management System Help.hlp was created using Help Workshop. It is summary and e-version of the User Documentation included in the document.
Bishwanath Parajuli
166
Modules:
usermodule:
The main function of this module is to Establish a new global ADODB connection named connect and declare ADODB record sets relating to various tables and queries. These record sets are specified in the form of functions usually called in forms (as written above) to make the relation between the data and database (tables and queries are explained above). The list of functions is given below: Name of Function connection bookrecset, memeberrecset, issuerecset, security, author, publisher, reserverecset, finerecset, supplierrecset, preferrecset, booklistrecset, historyrecset qryissuerecset, qryfinerecset
Purpose Sets new record sets and connection and specifies the provid and data source.
Specify the data source to each required record set from the different tables in data source.
Specify the data source to qryissuerecset from qryissue and qryfinerecset from qryfine.
This module also declares a new function, apiCopyFile, used while copying file from one location to another.
Code Listings:
Complete code listing is included in appendix III.
Bishwanath Parajuli
167
13.2
User Documenation:
This document has been written to serve the user to know about the interface of Easy Library Management System (ELMS). It is produced in order to help the user to understand the working environment, as this documentation includes all the user interfaces, steps of dealing with the complexities usually faced while working under this fully automated system. The interface has been described and previewed below:
Login Window
This designed unauthorized access of this software. Type the username and password in the relevant fields and click on OK button or hit the enter button for further processing. Visitors can just hit the enter button or press OK button for further processing. window in (fig 1) has been order to prevent
Bishwanath Parajuli
168
Mother Window
Fig 2 The mother window (Fig 2) is the main window of this application. It provides a list of interactive menus through which all the tasks related to this application can be carried out.
Bishwanath Parajuli
169
Management menu
Context Book Details Member Details Description Opens a form for adding details about new books, deleting or modifying it Opens a form for adding details about new member, deleting or modifying the old members, etc. Opens a form for adding new publisher and author and deleting the records of publisher and author Opens a form for adding details about supplier and deleting them Shortcuts Ctrl + B Ctrl + M Ctrl + A Ctrl + K
Bishwanath Parajuli
170
Edit menu
Context Search Calculate total Fine View History Request a New book Description Opens a form to allow searching, sorting and filtering data using various search criteria and options Opens a form to calculate the total amount of fine left to be collected, if the user is an administrator Opens a form that allows viewing the past records of issued books Opens a form to list the Books on demand in the library Sub Context Description Opens a form to Issued Books overview issued books Opens a form to Membership overview the membership period Opens a form for over viewing details of library Shortcuts Ctrl + F
Ctrl + H Ctrl + N
Overview
Ctrl + O
General Overview
Settings Menu
Context Description Sub Context Description Backup Allows creating a Database backup of the database Restore Allows restoring the previously made backup Compact and Allows repairing Repair and decreasing the Database size of database Opens a form to add new user, change password, or delete user. Opens a form to customize the function of the application Shortcuts
Database Utilities
Ctrl + S
Security Preference
171
Bishwanath Parajuli
Reports Menu
Context Member Report Book Report Fine Report Reservation Report Description Opens a report window that allows printing and exporting details of all the members Opens a report window that allows printing and exporting details of all the books Opens a report window that allows printing and exporting fine details Opens a report window, which allows printing and exporting details of the entire reserved book Opens a report window that allows printing and exporting list of books that have crossed their due date Shortcuts
Due Report
Help Menu
Context Help content About ELMS Description Opens a window that includes help for this program Opens a form that includes a short description of this product Shortcuts F1
Bishwanath Parajuli
172
Description
Sub Context Description Issue Opens Issues form Renew or Return Opens Renew/Return/Fine form Reserve Opens Reservation form Book Opens Book Details form Member Opens Member Details form Publisher/Author Opens Publisher and Author Details form Supplier Opens Supplier Details form User Details Opens Security form Change User Opens Login window Opens Search window Opens form for sending e-mails
Bishwanath Parajuli
173
Left Key
Bishwanath Parajuli
174
A preview of interface of Easy Library Management System for issuing the book has been shown above. The process of making book issues has been listed below: Entry Method: Select the book code listed in the drop-down list. Since this system is fully automated, the title of book, its type and date of issue along with its returning date will automatically be seen on the screen. Press [Tab] button to shift focus to borrowers ID or just click on the borrowers ID field. (Note that returning date is according to the book type.) Similarly, select the borrowers ID from the other dropdown list and you will have the details of the member like his full name and his photo will appear in the
Bishwanath Parajuli
175
screen. You can also add comment (optional) (Max size = 30) about the borrower, especially regarding his borrowing activities, if you like. Press [Tab] to shift focus to Update button. Press Update button to make an issue. If issue is not made appropriate message will be displayed. If the issue is successful, it shifts the focus again to books code field. Navigating Press Clear button to re-enter the data, after navigation has been completed, to enable the fields.
Bishwanath Parajuli
176
Renew/Return form
When you click the Renew/Return menu from the menu bar or toolbar, the user will firstly be taken to the window that is shown below. Click on any of the options and a form will open for the respective task.
Selecting Renew a Book option will open a form given below. On selecting, Return a Book option, this same window will open but Renew button will be replaced with Return button. When the user presses Delete button from keyboard, this window will close down and the window shown above will be loaded again. Preview of Return button is given overleaf:
Bishwanath Parajuli
177
Bishwanath Parajuli
178
Entry Method: The process of entering data in this form is same as adding data in issue form. The entire borrower ID is populated in the combo box. First, you have to select the borrowers ID from it. All the required information regarding the borrower like his name, contact number and membership expiry date, etc are displayed automatically. Press [Enter] to shift focus on the book code fields. In the same way, select the book code and the required information like, title of the book, issue date of the book and its returning date is displayed automatically. You can also find that if the borrower has issued the book, as Book is not issued will appear in a label. Press [Enter] to shift focus on Renew, Return button. To return to select Renew/Return menu, press [Delete] key. Press Renew, Return button as shown on the screen and respective task will be carried out. If the task is not successful, appropriate message box with reason will be displayed and the buttons will be disabled. In case the borrower has fine to pay, the form expands and the preview of the form will be as shown overleaf. A message box (Page 192, msg 1) will appear showing the total fine amount and asking whether to charge the fine or not. If you want to charge the fine, press Collect Fine button and the book will be ready for issuing again. Bishwanath Parajuli 179
(The Administrator/General User is allowed to collect the fine. The fine rate is Rs. 2 per day, until 7 days and Rs. 5 for the extended period as per discussed in the survey.)
Bishwanath Parajuli
180
Bishwanath Parajuli
181
Reservation form
Easy Library Management System allows reserving the books
with some clicks. Entry Method: Select the book code from the drop-down combo-box. Press [Enter] to shift focus to Member ID drop-down list Select the member ID from the list and the first name of member will automatically appear. Press [Enter] to shift focus to Reserve button Press [Enter] and the reservation will be made. If unsuccessful, appropriate message will be shown with reason. If successful, the focus will shift back to book code list. Bishwanath Parajuli 182
To cancel the reservation, press Cancel Reservation after selecting the book code and Member ID.
Output of Data: Reservation form has two grids-for viewing the reserved books and for viewing book details. On pressing the View Reserved Book button, a grid for viewing reserved book is seen which updates in every reservation or cancellation. The other grid, which contains the book details, is displayed by pressing the View Book Details button.
Bishwanath Parajuli
183
Significance: Allows adding record of new book in the database Allows deleting the record of book from the database Allows modifying the record of book present in the database Allows the user to see the records of book directly from grid
Bishwanath Parajuli
184
Entry Method: To add a new record, first select Form View tab and press [Enter]. The focus will shift to New Record button Press [Enter] or New Record button to shift focus to enter a book code. A code (Max- length = 5) for the book will automatically appear in the Code text-box. You also can change the auto code of the book and use a preferred code instead of it. Press [Tab] and the focus will shift to Title text-box. Type the title of the book (Max length = 80) and press [Tab] to shift the focus to Edition textbox. Type the edition in the field. The quick load feature of ELMS will automatically set the required closings. For example, type 1 and press [Tab] and the edition will automatically be 1st. Pressing [Tab] will also shift focus to Type of Book field. Select the type of book from the option by using mouse or by using direction keys. Press [Tab] to shift focus to Number of Copies field. Type the number of books (Max length = 2) with the current book title in the library and press [Tab] to shift focus to ISBN Number Fields. Bishwanath Parajuli 185
Type the ISBN number of the book (Max length = 13) and press [Tab] to shift focus to Published Year Fields.
Type the year of publication of the book (Max length = 4) and press [Tab] to shift focus to Volume of Book field.
Type the volume of the current book (Max length = 3) and press [Tab] to shift focus to Price of Book field.
Type the price of book (Max length = 5) and press [Tab] to shift focus to Shelf Number field.
Type the number of shelf (Max length = 3) and press [Tab] to shift focus to Save Record button.
Press Save Record and the book will be saved and focus will shift to Code field. Press Clear button to empty all the fields, if needed.
If you do not want to save the record, press Cancel button in order to cancel adding new record.
Navigation The user can use the buttons described above (page 5) for moving through the records. Bishwanath Parajuli Press icon to search records and view them.
186
Editing Method: To delete a record, press Delete button. An Input box will appear. Type the book code or Title of the book, to delete. Press [Enter] or OK button in Input box and a message will be displayed asking whether to delete the data. Press, Yes in the message box or [Enter], and the record will be deleted. To modify a data, press Modify button after you have edited the existing record. The entry method is given above. To modify the Book Code, search the data using navigation button or . After the data required editing
appears. Double Click on Book Code field and type the new code. Mean while button
appears. After typing the new code press, Change Code, button a message box will appear asking whether or not you are sure of it. Press Yes or OK and the book code will be changed. Select Tabular View tab to view the data in grid. If you want select the data to edit from there, click on the data you want to edit, and the data will appear in Form View tab. Edit the data where needed and press Modify button to save modifications.
Bishwanath Parajuli
187
Bishwanath Parajuli
188
Significance: Allows the user to keep details of all the necessary information of the members Allows the user to check membership expiry date of every member
Bishwanath Parajuli
189
Allows the user to delete, modify and save the records of members Allows the user to print a Library Card Allows the user to View all the data through grid Entry Method: To add a new record, Select Form View tab and press [Enter] to shift focus to Add New Member button. Press [Enter] or Add New Member button and the focus will shift to Member ID field. An auto code (Max length = 5) for the student will appear in the screen. Press [Tab] to shift focus to First Name. The user can also specify it. Type the First Name (Max length = 30) and Press [Tab] to shift the focus to Middle Name (Max length = 30) field. Type the data (optional) in the field and Press [Tab] again to shift the focus Last Name (Max length = 30) and type the last name. Continue the process to shift the focus of cursor to Date
of Birth field. Press on the dropdown menu to select the date. The date is in the format (MM/DD/YYYY). Alternatively, use the direction key to select the date. For example, use Up/Down key to select the month, use Right key to shift focus to day and use Up/Down key to select the day. In the same, way select year.
Bishwanath Parajuli
190
Up/Down key to select the grade or category of the borrower. Alternatively, use dropdown menu. Press [Tab] to shift focus to Contact/Mail Address field.
Be careful about the contact number or mail address. Check Validate Contact box if you are entering the phone/fax/cell number (Max length = 13\0). If you are entering other addresses like, G.P.O Box, email address or other means of mailing, uncheck the check box (Max length = 30). (Note: It is mandatory to include . in the Contact/Mail Address field if you are not checking the Validate Contact box. ) Press [Tab] to shift focus to Gender field. Select the
gender using direction key. Click on the frame to insert the picture of the member. A
dialog box will appear allowing you to choose the picture. Select the picture from the desired location and press [Enter] or press Open button. The picture will be seen in the frame. If you want to choose another picture, click on the frame again. The Membership Acquired Date is set automatically to
current system date and Membership Expiry date is set two years front from todays. The symbol, by the side of Membership
Expiry date, denotes that the membership has expired already whereas symbol denotes that the expiry date has not expired
Bishwanath Parajuli
191
press [Enter] or press Save Member button. The record will be saved and focus will shift back to Members ID field. Press Erase to reset all the fields, if needed. Editing Method: To delete a record, press Delete button. An Input box will appear. Type the Member ID, to delete. Press [Enter] or OK button in Input box and a message will be displayed asking whether to delete the data. Press, Yes in the message box or [Enter], and the record will be deleted. To modify a data, press Modify button after you have edited the existing record. The entry method is given above. Select Grid View tab to view the data in grid. If you want select the data to edit from there, click on the data you want to edit, and the data will appear in Form View tab. Edit the data where needed and press Modify button to save modifications. Record Viewing Methods: Use the Navigation buttons to view and move through the records.
Press
Bishwanath Parajuli
192
Other Functions in the form: Press Issue button to jump to Issues form. Press Renew Membership button, to renew the membership period two years from todays date. This feature is available only, when the membership of the member expires. Press Print a Library Card to jump to Microsoft Word in order to print a library card. This function is activated only while using navigation buttons. The required information of the member, currently displayed in the screen, will be exported to Microsoft word. The preview of the card is shown below:
Bishwanath Parajuli
193
Publisher Form
and
Author
Details
A preview of the interface for keeping publishers and authors of the book is shown below:
Entry Method: Select the book code from the drop down list. The title of the book will automatically appear and focus will shift on the tabs. Click on the tabs or select the tabs using direction keys for respective tasks. o Methods for working in Author Details Press New Author button and focus will automatically shift to Author Name field. All other tabs will be invisible.
Bishwanath Parajuli
194
Type the author name (Max length = 60) and press [Enter] to shift the focus to Contact field. Type contact (Max length = 100) (optional) and press [Enter] to shift focus to Country field button. Type the authors nationality and press [Enter] to shift focus to Save Author button. Press Save Author button or [Enter] to save record and focus will automatically shift to New Author button. All other tabs will be visible. Press Cancel Saving to cancel saving new record. Press Delete Author button and input box will appear. Type the code or name of the author you want to delete and press [Enter] or OK. The record will be deleted. To modify a record, press Modify after performing the necessary editing.
Bishwanath Parajuli
195
o Methods for working in Publisher Details Press New Publisher button and
focus will automatically shift to Publisher Name field. All other tabs will be invisible. Type the publisher name (Max
length = 60) and press [Enter] to shift the focus to Contact field. Type contact (Max length =
100) and press [Tab] to shift focus to Save Publisher button. If you typing the publishers website then write the domain, name and press [Enter]. The quick load feature will automatically add the rest. For e.g. if publishers site is www.abcd.com then just type abcd and press [Enter], the site will automatically change into www.abcd.com. Press Save Publisher button or
[Enter] to save record and focus will automatically shift to New Publisher button. All other tabs will be visible. Press Cancel Saving to cancel saving new record.
Bishwanath Parajuli
196
and input box will appear. Type the code or name of the publisher you want to delete and press [Enter] or OK. The record will be deleted and a message will be displayed. To modify a record, press
editing.
View Data: Press View Authors to view all authors and View Publishers to view all publishers in grids, after selecting View Publishers and Authors tab.
Bishwanath Parajuli
197
The preview of interface of ELMSs supplier details form is shown in the left side of the page:
Entry Method: Enter the name (Max length = 80) of the supplier and press [Tab] to shift focus to Address field. Type the address of the supplier (Max length = 80) and press [Tab] to shift focus to Contact field. Type the contact or address (Max length = 40) of the supplier and press [Tab] to shift focus to Save Supplier button. Bishwanath Parajuli 198
Press Save Supplier button and the data will be saved. Press Refresh to reset all the fields.
Press Delete button and an input box will appear. Enter the supplier code or name and press [Enter] or OK. The record will be deleted and a message will be displayed.
Other Functions in the form: Press button and Mail form will open. The data in
contact field will automatically be exported to Mail form (Page 40) to enable the user to send e-mail to the supplier. Check View Suppliers box to see all the suppliers and their required details. Use supplier. Press button to search the
appear. Enter the supplier code or name and press [Enter] or OK. If the record is found it will be displayed in the respective fields.
Bishwanath Parajuli
199
Bishwanath Parajuli
200
Search Form
Preview of the interface for searching data is shown below:
Entry Method: The focus will automatically be shifted to Issued Books field. Select the Search Criteria using direction key. The Search Details will appear according to the Search Criteria you select. Press [Tab] button to set focus to Search Details By, fields.
Bishwanath Parajuli
201
Use the direction key to select the search details. The search field will appear according to the selected search details i.e. while selecting Member ID, What do you want to Search? field is text-box but while selecting Level, the field changes to drop-down box. Press [Tab] to shift focus to this field.
Type the search text, if a textbox appears and select the search type, if combo box appears. Press [Tab] to shift focus to button. button and the searched data will appear, if
Press
Bishwanath Parajuli
202
Other Functions in the form: ELMS provides the function of sorting and filtering the data too. Press button (Note: This feature is available
only if you select View All options from Search Details By field) to sort the data and another form will appear in front of the screen allowing you the user to sort and filter the data. The preview of the form is shown below:
Entry Method:
o Press form.
o Select the sort option from the drop-down box. This will enable all other fields. Press [Tab] to shift focus to Sort By field. o To sort the data in Search form select sorting option from Sort By field and the data will be sorted accordingly. Press [Tab] to shift focus to Filter field.
Bishwanath Parajuli
203
o Type the filtering word for filtering the sort option and Press [Tab] to shift focus to Filter Containing button. o Press Filter Containing button and the data will be filtered in the Search form i.e. if you type filter text S for First Name than all the data starting with S will be displayed.
Operating Method:
Bishwanath Parajuli
204
This feature is only available for Administrator. Press Collect Fine button and a message-box will appear that will ask whether the fines have been collected or not. Press Yes or [Enter] and all the records will be deleted from the fine record. You can view the total fine in the Total Fine field. To view Details about the fine collected, check View Details box. To calculate the total fine paid by a member, click on Calculate fine for a member button. Enter the borrower ID of the borrower in the inputbox and press OK or [Enter]. The total fine paid will be displayed.
Bishwanath Parajuli
205
(Max length = 80) field. Type the title of book and press [Tab] to shift focus to Queue it Button list. Editing Method: Double Click on the title of book, shown in the list, Press [Enter] or Queue it Button to keep the book in
which you want to delete. A message-box will appear asking, if you want to delete the data. Press Yes or [Enter] to delete the data. Bishwanath Parajuli 206
Printing Method: Press button and a report window will appear that consists
the list of the all the requested book. Press on the print icon ( ) from that window and the list will be printed or press button to export the data into another formats. A preview of this Report window is shown below:
Bishwanath Parajuli
207
Overview Forms
The preview of interfaces to check the due books and membership expiry date is shown below: Issued Book: This form allows the user to view the books that have crossed their due date, already. It also allows the user to see the books that will expire after certain days.
Operating Method: Open this form and list of members who have issued books will be shown. Those rows that are highlighted with red color signify the books that have crossed the
Bishwanath Parajuli
208
Check the check box seen in this form to view the books that will probably expire within few days. Press [Tab] to shift focus to Days field.
Select the days, using direction key or drop-down button, to see which books expire in and in between the selected period.
Bishwanath Parajuli
209
Membership: This form allows the user to view the memberships that have crossed their due date, already. It also allows the user to see, when the membership will expire.
Bishwanath Parajuli
210
Operating Method: Open this form and list of members and their membership expiry date will be shown. Those rows that are highlighted with red color signify memberships that have expired already. Click on the to sort them, if needed. Select the check box seen in this form to see when the membership will expire. Press [Tab] to shift focus to Date picker.
Press on the dropdown menu to select the date. The date is in the format
Bishwanath Parajuli
211
(MM/DD/YYYY). Alternatively, use the direction key to select the date. For example, use Up/Down key to select the month, use Right key to shift focus to day and use Up/Down key to select the day. In the same, way select year. To return to original view uncheck the check box. To sort the records, click on the column heading, if needed.
Bishwanath Parajuli
212
Operating Method: Open this form to have a quick view in the total numbers of book, members, issued books and value of library. Press [Tab] to view the number of members linked in various grade or category. Press [Tab] to set focus on the Grade/Category field. Use direction key or mouse to select the grade/category. The number of members in each grade/category will be shown below.
Bishwanath Parajuli
213
Bishwanath Parajuli
214
History Form:
A preview of interface for viewing history records is given below:
Operating Method: Click on the History Code list box and find the data you want to check. The description of the data will be shown in right side of the form. Check View Details box to view the records in tabular form.
Bishwanath Parajuli
215
Database Utilities
ELMS helps to create backup of the database and allows to compact and repair the database too. The user needs to click on simple menus on the mother window and rest will be done automatically. It is recommended that the user create backups and compact the database frequently to prevent loss of data. The preview of menu is shown below.
Click on Backup Database and a dialog box will appear which will allow you to select the path for creating backups. Click on Restore and a dialog box will appear to select the backup you want to use. Click on Compact and Repair Database and the size of the database will be reduced and database will be repaired.
Bishwanath Parajuli
216
Bishwanath Parajuli
217
Security Form:
ELMS provides 3 different access rights on the basis of user. A preview of interface is shown below:
Entry Method: Select Add New User tab and press [Tab] to set focus on username field. Type the username (Max length = 8) and press [Enter] to set focus on user type field. Select the user type from the drop-down list by using direction keys or mouse click. There are two different user types: - i) Administrator and ii) General User. Select the type and press [Enter] to set focus to password fields.
Bishwanath Parajuli
218
Type the password (Max length = 8) in this field. Passwords are denoted by * characters. Press [Enter] to set focus to Confirm Password fields.
Type the same password (Max length = 8), as typed above, in this field and press [Enter] to shift focus to Add New User button.
Press Add New User button and the username will be saved. The cursor moves back to username field. Use button to reset all the fields.
Editing Method: Changing password Select Change Password tab and press [Tab] to set focus on username field. Type the username and press [Enter] to set focus on Old Password fields. Type the old password and press [Enter] to set focus on New Password fields. Type the new password (Max length = 8) and press [Enter] to set focus on Confirm Password fields. Type the new password again and press [Enter] to set focus on Change Password button.
Bishwanath Parajuli
219
Press Change Password button and the password will be changed. The cursor moves back to username field. Use fields. button to reset all the
Deleting Username Select Delete User tab and press [Tab] to set focus on username field. Type the username and press [Enter] to set focus on password fields. Type the password and press [Enter] to set focus Delete User field. Press Delete User button and the user will be
deleted. Data in all the fields will be erased and the cursor will move back to username field.
Bishwanath Parajuli
220
Preference Form:
ELMS provides the customization feature to the user. The user (Administrator only) can change the options of the application. A preview of this form is given below:
Operating Method: Check Load Quick View for due books, at Startup to automatically load a form showing due books (see page 191) when the application starts. Check Load Quick View for Membership books, at Startup to automatically load Membership form at startup. Check Create backup at termination of this program to automatically create backups. Check Compact and Repair database at termination to automatically compact and repair database. Check Inform me about total fine collected, at startup to show a message box displaying total fines left to be collected.
Bishwanath Parajuli
221
Bishwanath Parajuli
222
Reports:
Reports are the proof of the regular activities. ELMS allows the user to generate reports on regarding various matters. Use the menus in the mother window to generate report. To print a Report press on report or press icon, found in every
to export the report into other format. page 31. The user
It is a preview from main menu. Click on any of them and a report will be generated.
Bishwanath Parajuli
223
E-Mail:
This form is designed for the purpose of sending mails to the suppliers.
Entry Method: Type the email address in To fields and press [Tab] to shift focus to Subject fields. Type the subject of the mail and press [Tab] to shift focus to main text area of the form. Type the mail and press [Tab] to shift focus to Microsoft Office Outlook.) button. Press
Bishwanath Parajuli
224
Bishwanath Parajuli
225
Reminders Form:
This form is activated only when Load Quick View for due books, at Startup option from Preferences (See page 188) form is selected. This form contains the list of due books.
Bishwanath Parajuli
226
Code repetition
Bishwanath Parajuli
227
Delete
Book already
Glossary: Combo box = Drop down list box Check box = box that contain right sign when clicked. List box = box containing list of data Form = window/interface Label = an area for displaying text. Field = text area Input box = a box for entering required value. Grid = table containing records. Date Picker = a drop down list that is used to select date. Auto number/code = number/code that automatically increases in its value. ELMS = Easy Library Management System.
Bishwanath Parajuli
228
A dialog box as shown below appears on clicking. Click on the installation icon to begin installation or to change the location for keeping the installed components press Change Directory button.
Bishwanath Parajuli
229
Press Continue or type the name that you want to indicate the program to appear in the start menu. A box as shown below appears when installation begins.
Bishwanath Parajuli
230
When the installation ends, a box as shown below appears which indicates the installation is over.
Bishwanath Parajuli
231
Click on Yes to remove the application from computer. After a while, another message box appears as shown below:
This message box signifies the removal process has completed. Press OK to return to Add or Remove Programs window. Note: Click on Control Panel menu available at the Start menu available in Windows XP to select Add or Remove Programs option.
Bishwanath Parajuli
232
C
Calculate total Fine Form............204 Changing Password.....................219 Controls for navigation................173 Creating new user........................218
Q
Quickly Loading publisher's site. 196
R
Renew/Return Entry....................179 Renew/Return form.....................177 Renewing Membership................193 Report Printing Method...............207 Reports Generation......................223 Reports Menu...............................172 Request a New book Form..........206 Requesting new book...................206 Reservation Entry........................182 Reservation form.........................182
D
Database Utilities.........................216 Deleting Book request.................206 Deleting Username......................220 Direction Key (On Keyboard).....173
E
Edit menu.....................................171
F
File menu.....................................170 Filtering Data...............................204 Fine Collection.............................204
S
Search Entry.................................201 Search Form.................................201 Security Form..............................218 Settings Menu..............................171 Significance of Book Details Form ................................................184 Significance of Memeber Details Form.......................................189 Sorting Data.................................203 Supplier Details Form..................198 Supplier Entry..............................198
G
General Overview Form..............213 Glossary.......................................228 Guide for Installing/Uninstalling the product....................................229
H
Help Menu...................................172 History Form................................215
I
Installing the Product...................229 Issue Entry...................................175 Issued Book.................................208 Issues form...................................175
T
to loading member status at startupLoad Quick View for Membership............................221 Toolbar and their Functions.........173
L
Load Due Books at startup..........221 Login Window.............................168
U
Uninstalling the product..............232
V
View Due Books..........................226 Viewing Issued Books.................208 Viewing Membership..................211
M
Mailing.........................................224 Management menu.......................170 Member Details form...................189 Member Entry..............................190 Membership.................................210 Menus and their Function............170 Mother Window...........................169
N
Navigation buttons.......................173
O
Overall view of Library...............213 Overview Forms..........................208
P
Preference Form...........................221 Preview of Message boxes used in ELMS.....................................227 Printing a Library Card................193
Bishwanath Parajuli
233
Appendix I
I)
SA:
the current system? Mr. Acharya: The system is very boring to work with. Besides, there are no particular records of any students or books and searching the records of issue is very time consuming. In addition, sometimes a student issues more than single book or issues the same book twice. SA: So, what do you expect to be in the new system?
Mr. Acharya: It must be able to hold all the information required in the library. I mean, it must be able to hold the information of books, members, publishers and authors and all other activities or materials related with library. SA: Being specific, what information should it hold on about the books? Mr. Acharya: It must be able to hold the title of book, its ISBN, edition, shelf number, price and number of books. Besides, it must be able to generate auto code for every book and it must be possible to modify the code if needed. Bishwanath Parajuli 234
SA:
Mr. Acharya: The new system must hold information like member name, the grade or category, contact number and most necessarily, the membership expiration date. The member also needs to have a unique member id that is automatically assigned. SA: What about issue?
Mr. Acharya: This system must be able to make issues quickly, by selecting the book code and the member id. SA: Do not you think that just entering the book code and member id can bring errors in some cases? Mr. Acharya: In that case, it would be easier if the system will show the details of the books and the members. It also must check if the student has already issued three books or issued the same book. Besides, the system must restrict issuing a reference book or issuing a book to a borrower that has fine to pay. The member whose membership has expired shouldnt be able to make issues. SA: Bishwanath Parajuli And the reservations? 235
Mr. Acharya: It must be able to reserve, of course. It also must notify if the book is available in the library. The rest of the features must be similar to that of issue. SA: How do you renew/return the books?
Mr. Acharya: I just mark the records to signify, either of the activities. SA: And, how do you think it must operate in the new system? Mr. Acharya: According to me, the user must be able to select the borrower id and book code so that the system could process the data and carry out the acts. The user must be able to see if the book is really issued and if issued has the book crossed its due date. If the book has crossed the due date, it must be able to calculate fine for that particular borrower. SA: At what rate, do you think, the new system should charge the fines? Mr. Acharya: I think Rs. 2 for a week and Rs. 5 for rest of the time will be appropriate since I am using the same rate in the old system. SA: How do you think the searching must be?
Bishwanath Parajuli
236
Mr. Acharya: Searching must be very easier. Just some clicks and types should show the required data. Series of options should guide the user to required data. SA: What about sorting and filtering?
Mr. Acharya: Of course, the system must sort the data because sorting is very useful in searching the data. And, filtering is the best option because, in case, if the whole name is unknown, for example, filtering can easily search the data. Therefore, sorting and filtering are both necessary. SA: What else do you expect to be in the new system?
Mr. Acharya: Well, it must have access rights. Only authorized user should be able to enter the system and the system must be able to hold the list of books that are requested to be brought in the library. And, there must be provision of collecting and calculating fine. And, the user must be able to view if the details of the issue and membership status. It would better to have provision of book history for future referencing,
Bishwanath Parajuli
237
SA:
Mr. Acharya: Well, the system must have access rights divided by the head librarian. There must be a single, head librarian for maintaining the records of members or visitors. There must be a provision for general user who can work in absence of head librarian. There must be provision for adding new user or deleting them. There should be provision for changing the password for smooth administration. SA: And the back up? What about it?
Mr. Acharya: It must have the feature of backing up the data. And, if the data can be compacted too, it would be more efficient. SA: What measure do you prefer for output of data?
Mr. Acharya: Whatever be the measure, the user must be able to generate and print the reports of members, books, reservations and due books. Moreover, the user should be able to print the list of requested books too. SA: Thank you, Mr. Acharya, for your valuable suggestions and time. I will try my best to base the new system upon your suggestions. Bishwanath Parajuli 238
Bishwanath Parajuli
239
Book Card
Membership Card
Bishwanath Parajuli 240
Bishwanath Parajuli
241
6.1
6.2
6.3
10
Bishwanath Parajuli
242
11
12
13
14
15
16
Bishwanath Parajuli 243
17
18
19
20
21
22
Bishwanath Parajuli 244
23
24
25
Bishwanath Parajuli
245
26
27
28
29
Bishwanath Parajuli
246
30
31
32
33
Bishwanath Parajuli
247
34
35
36
Bishwanath Parajuli 248
37
38
39.1
Bishwanath Parajuli
249
39.2
40
Bishwanath Parajuli
250
41
42
Bishwanath Parajuli
251
43
44
45
46
Bishwanath Parajuli
252
47
48
49
50
Bishwanath Parajuli
253
51
52
53
54
Bishwanath Parajuli 254
55
56
57
58
Bishwanath Parajuli
255
59
60
Bishwanath Parajuli
256
61
62
Bishwanath Parajuli 257
63
64
65
66
Bishwanath Parajuli 258
67
68
69
70
Bishwanath Parajuli 259
71
72
73
74
Bishwanath Parajuli
260
75
76
77
78
Bishwanath Parajuli
261
79
80
81
Bishwanath Parajuli
262
82
83
84
Bishwanath Parajuli
263
85
86
87
Bishwanath Parajuli
264
88
89
Bishwanath Parajuli
265
90
91
Bishwanath Parajuli
266
92
93
94
95
96
Bishwanath Parajuli
267
97
98
99
100
101
102
Bishwanath Parajuli 268
103
104
105
106
Bishwanath Parajuli
269
107
108
109
110
Bishwanath Parajuli
270
111
112
113
114
Bishwanath Parajuli
271
115
116
117
118
Bishwanath Parajuli
272
(Note: All the reports are designed in a format similar to that of above.)
Bishwanath Parajuli
273
119
Bishwanath Parajuli
274
Private Sub cmdSysInfo_Click() Call StartSysInfo End Sub Private Sub cmdok_Click() Unload Me End Sub Public Sub StartSysInfo() On Error GoTo SysInfoErr Dim rc As Long Dim SysInfoPath As String ' Try To Get System Info Program Path\Name From Registry... If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) Then ' Try To Get System Info Program Path Only From Registry... ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) Then ' Validate Existance Of Known 32 Bit File Version If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then SysInfoPath = SysInfoPath & "\MSINFO32.EXE" ' Error - File Can Not Be Found... Else GoTo SysInfoErr End If ' Error - Registry Entry Can Not Be Found... Else GoTo SysInfoErr End If Call Shell(SysInfoPath, vbNormalFocus) Exit Sub SysInfoErr: MsgBox "System Information Is Unavailable At This Time", vbOKOnly End Sub Bishwanath Parajuli 276
Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean Dim i As Long ' Loop Counter Dim rc As Long ' Return Code Dim hKey As Long ' Handle To An Open Registry Key Dim hDepth As Long ' Dim KeyValType As Long ' Data Type Of A Registry Key Dim tmpVal As String ' Tempory Storage For A Registry Key Value Dim KeyValSize As Long ' Size Of Registry Key Variable '-----------------------------------------------------------' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...} '-----------------------------------------------------------rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Error... tmpVal = String$(1024, 0) Variable Space KeyValSize = 1024 Size ' Allocate ' Mark Variable
'-----------------------------------------------------------' Retrieve Registry Key Value... '-----------------------------------------------------------rc = RegQueryValueEx(hKey, SubKeyRef, 0, _ KeyValType, tmpVal, KeyValSize) ' Get/Create Key Value If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Errors If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then ' Win95 Adds Null Terminated String... tmpVal = Left(tmpVal, KeyValSize - 1) ' Null Found, Extract From String Else ' WinNT Does NOT Null Terminate String... Bishwanath Parajuli 277
tmpVal = Left(tmpVal, KeyValSize) ' Null Not Found, Extract String Only End If '-----------------------------------------------------------' Determine Key Value Type For Conversion... '-----------------------------------------------------------Select Case KeyValType ' Search Data Types... Case REG_SZ ' String Registry Key Data Type KeyVal = tmpVal ' Copy String Value Case REG_DWORD ' Double Word Registry Key Data Type For i = Len(tmpVal) To 1 Step -1 ' Convert Each Bit KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1))) ' Build Value Char. By Char. Next KeyVal = Format$("&h" + KeyVal) ' Convert Double Word To String End Select GetKeyValue = True Success rc = RegCloseKey(hKey) Registry Key Exit Function ' Return ' Close ' Exit
GetKeyError: ' Cleanup After An Error Has Occured... KeyVal = "" ' Set Return Val To Empty String GetKeyValue = False ' Return Failure rc = RegCloseKey(hKey) ' Close Registry Key End Function
Bishwanath Parajuli
278
frmbookdet: Option Explicit Dim checkb As Boolean 'declare variable Private Sub cmdaddnew_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed txtcode.SetFocus 'shift focus End If End Sub Private Sub cmdcancel_Click() 'This procedures deletes the space for adding new data precord.CancelUpdate 'cancel update Call enablecontrols 'call functions Call checkrecords Call clear End Sub Private Sub cmdchange_Click() 'This prcedure is used to change the key field of tblbookdetails On Error GoTo errhandle: If MsgBox("Are you sure you want change the code?", vbQuestion + vbYesNo, "Change...") = vbYes Then If precord.RecordCount <> 0 Then 'if is not the value of precord nothing then precord.MoveFirst 'move recordpointer to first record While Not precord.EOF 'until the end of file continue the process: If precord.Fields(1) = txttitle.Text Then 'compare the value precord.Fields(0) = txtcode.Text 'set the value precord.Update 'update the record and continue with: MsgBox "Book Code updated successfully.", vbInformation, "Change" txtcode.Locked = True fracontrols.Enabled = True franavigate.Enabled = True cmdclear.Enabled = True txttitle.Enabled = True cmdchange.Visible = False End If precord.MoveNext 'move to next record Wend 'repeat Bishwanath Parajuli 279
End If Else txtcode.Locked = True 'lock controls fracontrols.Enabled = True 'enable controls franavigate.Enabled = True cmdclear.Enabled = True txttitle.Enabled = True cmdchange.Visible = False 'hide command button End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdmodify_Click() 'This procedure is used to change the data 'in the fields of tblbookdetails On Error GoTo errhandle: If precord.RecordCount <> 0 Then 'if the recordset is not empty If MsgBox("Are you sure you want to modify the record?", vbYesNo, "Modify?") = vbYes Then precord.MoveFirst 'move to first record While Not precord.EOF 'repeat until the end of file If precord.Fields(0) = txtcode.Text Then 'compare the value and if the value matches 'set the data into record fields precord.Fields(1) = txttitle precord.Fields(2) = txtedition If optfiction.Value = True Then precord.Fields(3) = "Fiction" ElseIf optnonfiction.Value = True Then precord.Fields(3) = "Non Fiction" ElseIf optperiodical.Value = True Then precord.Fields(3) = "Periodical" ElseIf optreference.Value = True Then precord.Fields(3) = "Reference" End If precord.Fields(4) = txtcopies precord.Fields(5) = txtdatep precord.Fields(6) = txtisbn precord.Fields(7) = txtvolume precord.Fields(8) = txtprice precord.Fields(9) = txtsno precord.Fields(10) = txtpages precord.Update 'save the record Bishwanath Parajuli 280
MsgBox "Modification saved sucessfully.", vbInformation, "Modification" End If precord.MoveNext 'move to the next record Wend 'repeat End If End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdsearch_Click() 'This procedure searches for the record Dim vali As String 'declare variable vali = InputBox("Enter the ID or Title of the book you want to find.", "Find") 'allow to input data through an input box If precord.RecordCount <> 0 Then 'if the recordset is not empty precord.MoveFirst 'move the record position to first record While Not precord.EOF 'until the end of the file If precord.Fields(0) = vali Or precord.Fields(1) = vali Then 'compare the field value with find and if matched Call display 'call function Exit Sub 'exit End If precord.MoveNext 'move to next record Wend 'repeat the process MsgBox "Record not found.", vbInformation, "Search" End If End Sub Private Sub bookgrid_Click() 'This procedure sets the data from particular column of datagrid 'to the specified columns If adobook.Recordset.RecordCount <> 0 Then 'set the data into form field from column of datagrid Me.txtcode = bookgrid.Columns(0) Me.txttitle = bookgrid.Columns(1) Me.txtedition = bookgrid.Columns(2) If bookgrid.Columns(3) = "Fiction" Then Me.optfiction.Value = True ElseIf bookgrid.Columns(3) = "Non Fiction" Then Bishwanath Parajuli 281
Me.optnonfiction.Value = True ElseIf bookgrid.Columns(3) = "Periodical" Then Me.optperiodical.Value = True ElseIf bookgrid.Columns(3) = "Reference" Then Me.optreference.Value = True End If Me.txtcopies = bookgrid.Columns(4) Me.txtdatep = bookgrid.Columns(5) Me.txtisbn = bookgrid.Columns(6) Me.txtvolume = bookgrid.Columns(7) Me.txtprice = bookgrid.Columns(8) Me.txtsno = bookgrid.Columns(9) txtpages = bookgrid.Columns(10) tabs.TabVisible(1) = False 'hide tab tabs.TabVisible(1) = True 'show tab End If End Sub Private Sub Form_Load() 'This procedure configures ADODC and ADODB controls Call connection 'call function Call bookrecset adobook.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" 'configure provider and application path adobook.CommandType = adCmdUnknown adobook.RecordSource = "select * from tblbookdetails" 'specify the recordsource adobook.Refresh 'refresh adodc Call enablecontrols 'call function Call checkrecords End Sub Sub display() 'This procedure assigns the value to form field 'from corresponding value in record field txtcode = precord.Fields(0) txttitle = precord.Fields(1) txtedition = precord.Fields(2) If precord.Fields(3) = "Fiction" Then optfiction.Value = True ElseIf precord.Fields(3) = "Non Fiction" Then optnonfiction.Value = True ElseIf precord.Fields(3) = "Periodical" Then optperiodical.Value = True Bishwanath Parajuli 282
ElseIf precord.Fields(3) = "Reference" Then optreference.Value = True End If txtcopies = precord.Fields(4) txtdatep = precord.Fields(5) txtisbn = precord.Fields(6) txtvolume = precord.Fields(7) txtprice = "$ " & precord.Fields(8) txtsno = precord.Fields(9) txtpages = precord.Fields(10) lblrecordnumber.Caption = precord.AbsolutePosition & " Of " & precord.RecordCount & " Records" End Sub Private Sub cmdaddnew_Click() 'This procedure creates a space for adding new record Dim code As Long 'declare variable Call disablecontrols 'call functions Call clear If precord.RecordCount = 0 Then 'if the recordset is empty code = 101 'specify code = 101 Else precord.MoveLast 'move the pointer to last record code = precord.Fields(0) + 1 'increase the value of code by 1 compared to last record End If precord.AddNew 'ADD NEW RECORD txtcode.Text = code 'set code into textbox End Sub Private Sub cmdsave_Click() 'This procedure saves the data in the database If (optfiction.Value = False And optnonfiction.Value = False And optperiodical.Value = False And optreference.Value = False) Then 'if the options button specified above are unselected MsgBox "Please Select the Category of Book", vbInformation, "Information" Exit Sub 'exit End If checkb = False 'set the value of the boolean to false checkb = checkblanks() 'extract the value of the boolean from function(checkblanks) Bishwanath Parajuli 283
If checkb = False Then 'if the function returns with the value false 'set the data in the particular fields of record precord.Fields(0) = txtcode precord.Fields(1) = txttitle precord.Fields(2) = txtedition If optfiction.Value = True Then precord.Fields(3) = "Fiction" ElseIf optnonfiction.Value = True Then precord.Fields(3) = "Non Fiction" ElseIf optperiodical.Value = True Then precord.Fields(3) = "Periodical" ElseIf optreference.Value = True Then precord.Fields(3) = "Reference" End If precord.Fields(4) = txtcopies precord.Fields(5) = txtdatep precord.Fields(6) = txtisbn precord.Fields(7) = txtvolume precord.Fields(8) = Val(txtprice) precord.Fields(9) = Val(txtsno) precord.Fields(10) = Val(txtpages) MsgBox "Record Saved Successfully.", vbInformation, "Information" txtcode.SetFocus precord.Update 'save the record booktimer.Enabled = True 'enable timer Call enablecontrols 'call function End If End Sub Private Sub cmddelete_Click() 'This procedure deletes a record form the database On Error GoTo errhandler: Dim code As String 'declare variable code = InputBox("Enter the Book ID or Title of the Book, you want to delete.", "Delete") 'allow to enter book code through input box If code = "" Then 'if input box not empty MsgBox "Select the item to delete", vbInformation, "Error" Exit Sub 'exit ElseIf precord.RecordCount <> 0 Then 'if the recordset is not empty precord.MoveFirst 'move to first record While Not precord.EOF 'until eof Bishwanath Parajuli 284
If precord.Fields(0) = code Or precord.Fields(1) = code Then 'compare the value of code with record field 'if matched If MsgBox("Are you sure you want to delete the record?", vbYesNo + vbQuestion, "Delete") = vbYes Then precord.Delete 'delete record booktimer.Enabled = True 'enable timer Call clear 'call functions MsgBox "Record Deleted.", vbInformation, "Information" Call checkrecords precord.Close 'close the recordset precord.Open 'open the recordset End If End If If precord.RecordCount <> 0 Or precord.EOF = False Or precord.BOF = False Then 'if the record set is not empty 'or record pointer is not at eof or bof precord.MoveNext 'move to next record Call display End If Wend 'repeat End If Exit Sub errhandler: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdbegin_Click() 'This procedure moves pointer to first record If precord.BOF = True Then 'if recordpointer is at bof MsgBox "This is First record.", vbOKOnly, "Information" precord.MoveFirst 'set the pointer to first record Exit Sub 'exit Else precord.MoveFirst 'move the pointer to first record Call display 'call function End If End Sub Private Sub cmdprevious_Click() 'This procedure moves pointer to relative previous record If precord.AbsolutePosition = adPosEOF Then Bishwanath Parajuli 285
'if record pointer is at eof precord.MoveFirst 'move the pointer to first record Exit Sub 'exit ElseIf precord.BOF = True Then 'if record pointer is at bof MsgBox "This is First record.", vbOKOnly, "Information" precord.MoveFirst 'move the pointer to first record Exit Sub Else Call display 'call function precord.MovePrevious 'move backwards End If End Sub Private Sub cmdnext_Click() 'This procedure moves pointer to relative next record If precord.AbsolutePosition = adPosBOF Then 'if recordpointer is at bof precord.MoveLast 'move the pointer to last record Exit Sub 'exit sub ElseIf precord.EOF = True Then 'if recordpointer is at eof MsgBox "This is Last record", vbOKOnly, "Information" precord.MoveLast 'move the pointer to last record Exit Sub Else Call display 'call function precord.MoveNext 'move pointer forward End If End Sub Private Sub cmdlast_Click() 'This procedure moves pointer to last record If precord.EOF = True Then 'if record pointer is at eof MsgBox "This is Last record", vbOKOnly, "Registration" precord.MoveLast 'move to last record Exit Sub 'exit Else precord.MoveLast 'move to last record Call display 'call function End If End Sub Sub clear() Bishwanath Parajuli 286
'This procedure is used to reset the data in the fields txtcode = "" txttitle = "" txtedition = "" optfiction.Value = False optnonfiction.Value = False optperiodical.Value = False optreference.Value = False txtcopies = "" txtdatep = "" txtisbn = "" txtvolume = "" txtprice = "" txtsno = "" txtpages = "" End Sub Private Sub Form_Unload(Cancel As Integer) Unload frmissue 'unload form End Sub Private Sub booktimer_Timer() 'This procedure is used to refresh the datagrid bookgrid.Refresh 'refresh grid adobook.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" 'configure provider and data source adobook.CommandType = adCmdUnknown 'specify the record source adobook.RecordSource = "select * from tblbookdetails" adobook.Refresh 'refresh adodc bookgrid.Refresh 'refresh grid booktimer.Enabled = False 'disable timer End Sub Private Sub tabs_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed If tabs.Caption = "Form View" Then 'if tab caption is Form View Me.cmdaddnew.SetFocus 'shift focus End If End If End Sub Private Sub txtcode_Change() Bishwanath Parajuli 287
If txtcode.Text = "" Then 'if the textbox is empty cmdchange.Visible = False 'hide button End If If txtcode.Text <> "" Then 'if the textbox is not empty txtcode.Locked = False 'lock textbox End If End Sub Private Sub txtcode_DblClick() If txtcode.Text <> "" Then 'if the textbox is not empty cmdchange.Visible = True 'show the button fracontrols.Enabled = False 'disable controls franavigate.Enabled = False Me.cmdclear.Enabled = False txttitle.Enabled = False End If End Sub Private Sub txtcode_KeyPress(KeyAscii As Integer) 'accept those keypresses which are numeric and backspaces only If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8) Then KeyAscii = 0 End If End Sub Private Sub txtedition_LostFocus() 'This procedure sets character in the field 'according to the condition satisfied Dim last As String 'declare variable If txtedition <> "" Then 'if the textbox is not empty last = Mid(txtedition, Len(txtedition), Len(txtedition)) 'extract the last letter from the text area Select Case last Case 1 'if the last character is as specified txtedition = txtedition & "st" 'set the value, adding some characters, to textbox Case 2 txtedition = txtedition & "nd" Case 3 Bishwanath Parajuli 288
txtedition = txtedition & "rd" Case Is < 9 txtedition = txtedition & "th" Case Else txtedition = txtedition End Select End If End Sub Private Sub txtpages_KeyPress(KeyAscii As Integer) 'accept those keypresses which are numeric and backspaces only If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8) Then KeyAscii = 0 End If End Sub Private Sub txttitle_LostFocus() 'This procedure checks for repetition of the book code If Me.cmdaddnew.Enabled = False Then 'if the button is disabled If precord.RecordCount <> 0 Then 'if the recordset is not empty precord.CancelUpdate 'cancel update precord.MoveFirst 'move pointer to first record While Not precord.EOF 'continue until the end of file If precord.Fields(0) = txtcode Or precord.Fields(1) = txttitle.Text Then 'check the field's value with the textbox's 'if data in textbox and record field matches Call display 'call function cmdsave.Enabled = False 'disable button MsgBox "This book exists in the database.", vbInformation, "Book Details" Exit Sub 'exit Else cmdsave.Enabled = True 'enable button End If precord.MoveNext 'move the pointer to next close record Wend 'repeat this process precord.AddNew 'add new record End If End If End Sub Private Sub txtdatep_KeyPress(KeyAscii As Integer) Bishwanath Parajuli 289
'accept those keypresses which are numeric and backspaces only If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8) Then KeyAscii = 0 End If End Sub Private Sub txtcopies_KeyPress(KeyAscii As Integer) 'accept those keypresses which are numeric and backspaces only If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8) Then KeyAscii = 0 End If End Sub Private Sub txtprice_KeyPress(KeyAscii As Integer) 'accept those keypresses which are numeric and backspaces only If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8) Then KeyAscii = 0 End If End Sub Private Sub txtsno_KeyPress(KeyAscii As Integer) 'accept those keypresses which are numeric and backspaces only If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8) Then KeyAscii = 0 End If End Sub Private Sub txtvolume_KeyPress(KeyAscii As Integer) 'accept those keypresses which are numeric and backspaces only If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8) Then KeyAscii = 0 End If End Sub Private Sub cmdclear_Click() Call clear 'call function Bishwanath Parajuli 290
End Sub Function checkblanks() As Boolean 'check for any fields left unattended Dim Control As Object 'declare variable For Each Control In frmbookdet 'for every such variables in the form If TypeOf Control Is TextBox Then 'if the variable is text box If Control.Text = "" Then 'if any textbox is empty checkblanks = True 'specify the value of boolean as true MsgBox "Please fill all the fields.", vbInformation, "Book Details" Control.SetFocus 'shift focus to that control End If Exit Function 'exit End If Next End Function Sub checkrecords() 'This procedure enable/disables the navigation buttons If precord.RecordCount = 0 Then 'if the record set is empty Me.franavigate.Enabled = False 'disable the frame ElseIf precord.RecordCount <> 0 Then 'if the record set is not empty Me.franavigate.Enabled = True 'enable the frame End If End Sub Sub enablecontrols() 'This procedure enables the conrols specified below Me.franavigate.Enabled = True 'enable controls Me.cmdclear.Enabled = True cmdaddnew.Enabled = True cmddelete.Enabled = True cmdmodify.Enabled = True cmdsave.Enabled = False 'disable controls cmdcancel.Enabled = False End Sub
Bishwanath Parajuli
291
Sub disablecontrols() 'This procedure disables the conrols specified below Me.franavigate.Enabled = False 'disable controls Me.cmdclear.Enabled = False cmdaddnew.Enabled = False cmddelete.Enabled = False cmdmodify.Enabled = False cmdsave.Enabled = True 'enable controls cmdcancel.Enabled = True End Sub
Bishwanath Parajuli
292
frmbooklist: Private Sub cmdorder_Click() 'This procedure saves the data in the database If txtnew.Text = "" Then: MsgBox "Enter a Book you want to order.", vbExclamation, "Error": Exit Sub nrecord.AddNew 'add new record 'set the value of fields to the record nrecord.Fields(0) = txtnew.Text nrecord.Update 'update the record lstbook.AddItem (txtnew) 'add the item to listbox txtnew.Text = "" End Sub Private Sub cmdprint_Click() 'This procedure shows the report listreport.Refresh 'refresh report listreport.Show 'show report End Sub Private Sub Form_Load() 'This procedure configures ADODB and 'adds the data from souce to listbox Call connection 'call the required functions Call booklistrecset Call bookrecset If nrecord.RecordCount <> 0 Then nrecord.MoveFirst 'move to first record While Not nrecord.EOF 'continue until the end of file lstbook.AddItem (nrecord.Fields(0)) 'add item to the listbox from recordsource nrecord.MoveNext 'move to next record Wend 'repeat End If End Sub Private Sub lstbook_DblClick() 'delete the record If lstbook.ListIndex > -1 Then 'until the listbox is empty If MsgBox("Delete '" & lstbook.Text & "'?", vbQuestion + vbYesNo) = vbYes Then 'ask whether the user wants to delete the record 'if the response is yes then find the data and delete it If nrecord.RecordCount <> 0 Or txtnew.Text <> "" Then nrecord.MoveFirst 'move to first record Bishwanath Parajuli 293
While Not nrecord.EOF 'until the end of file If nrecord.Fields(0) = lstbook.Text Then 'if the record fields has the same data as selected in listbox nrecord.Delete 'delete the record and continue with: MsgBox "Record Deleted from the queue.", vbInformation, "Delete" txtnew.Text = "" End If nrecord.MoveNext 'move to next record Wend 'repeat End If lstbook.RemoveItem lstbook.ListIndex 'move the same item from listbox too End If End If End Sub Private Sub txtnew_LostFocus() 'This procedure checks an existing data If precord.RecordCount <> 0 Then precord.MoveFirst 'move to first record While Not precord.EOF 'continue until the end of file If precord.Fields(1) = txtnew.Text Then 'compare the value of textbox with the fields 'if matched continue with: MsgBox "A book with this name is in the Library.", vbInformation, "Record Exists" cmdorder.Enabled = False Exit Sub 'exit Else 'if data doesn't match then: cmdorder.Enabled = True End If precord.MoveNext 'move to next record Wend 'repeat End If If nrecord.RecordCount <> 0 Then nrecord.MoveFirst 'move to first record While Not nrecord.EOF 'continue until end of file If nrecord.Fields(0) = txtnew.Text Then 'compare the data in record fields 'if the data in textbox and record field matches then continue with: MsgBox "This book has already been requested.", vbInformation, "Record Exist" Bishwanath Parajuli 294
cmdorder.Enabled = False 'enable combo Exit Sub 'exit Else cmdorder.Enabled = True End If nrecord.MoveNext 'move to next record Wend 'repeat End If End Sub
Bishwanath Parajuli
295
frmborrowerdetails: Dim checkblank As Boolean Sub checkrestrict() 'This procedure checks the validity of the data 'by checking the total length of the numeric characters 'by checking if the character, ., is present If txtcontact <> "" Then 'check for the invalid contact If chkrestrict.Value = vbChecked Then 'if the checkbox is checked then If Len(txtcontact) < 7 Or Len(txtcontact) > 10 Then 'if the length of data in textbox is <7 and >10 MsgBox "Enter a valid number", vbExclamation, "Error" txtcontact.SetFocus 'shift focus to the specified field Exit Sub 'exit End If ElseIf chkrestrict.Value = vbUnchecked Then 'if the checkbox is unchecked then If InStr(1, txtcontact, ".") Then 'if the textbox has the character optmale.SetFocus Else MsgBox "Enter a valid address.", vbExclamation, "Error" txtcontact.SetFocus End If End If End If End Sub Private Sub chkrestrict_Click() Call checkrestrict 'call required function End Sub Private Sub cmdaddnew_Click() 'This procedure creates space for adding new data 'and generates key-field Dim code As Long 'declare code as integer Call disablenavigation 'call required function Call clear txtbrid.Locked = False 'lock the field If mrecord.RecordCount = 0 Then 'if there is no record Bishwanath Parajuli 296
code = 201 'set code = 201 Else mrecord.MoveLast 'move to last record code = mrecord.Fields(0) + 1 'set code = keyfield of last record +1 End If mrecord.AddNew 'addnew record txtbrid = code lbldatea = VBA.Date 'assign the textbox with system date lbldatee = Month(VBA.Date) & "/" & Day(VBA.Date) & "/" & Year(VBA.Date) + 2 'assign the textbox with date, 2years after the system date End Sub Private Sub cmdaddnew_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed txtbrid.SetFocus End If End Sub Private Sub cmdbegin_Click() 'This procedure moves pointer to the first record On Error GoTo errhandler: If mrecord.BOF = True Then 'if recordpointer is at bof MsgBox "This is First record.", vbOKOnly, "Information" mrecord.MoveFirst 'move to first data Exit Sub Else mrecord.MoveFirst 'move recordpointer to first record Call display End If Exit Sub errhandler: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdbegin_GotFocus() cmdprint.Visible = True End Sub Private Sub cmdcancel_Click() 'This procedure deletes the space reserved for saving the data Bishwanath Parajuli 297
'created during addnew process mrecord.CancelUpdate 'cancel update Call enablenavigation 'call required functions Call checkrecords Call clear txtbrid.Locked = True End Sub Private Sub cmdclear_Click() Call clear 'call function End Sub Private Sub cmddelete_Click() 'This procedure deletes the record from the database Dim deletedata As Integer 'declare variable On Error GoTo errhandler: deletedata = Val(InputBox("Enter the member ID of the member you want to delete.", "Delete")) 'show an inputbox to enter the data to be deleted If deletedata <> 0 Then If MsgBox("Are you sure you want to delete the record?", vbYesNo + vbQuestion, "Delete Record?") = vbYes Then If mrecord.RecordCount <> 0 Then 'if the recordset is not empty mrecord.MoveFirst 'move to first record While Not mrecord.EOF 'until eof If mrecord.Fields(0) = deletedata Then 'compare the data with that on the database mrecord.Delete 'delete the record gridtimer.Enabled = True 'enable the timer MsgBox "Record Deleted.", vbInformation, "Information" Call clear 'call the functions Call checkrecords mrecord.Close 'close the adodb record connection mrecord.Open 'open the connection End If If mrecord.RecordCount <> 0 Then mrecord.MoveNext 'move to next record End If Wend End If End If End If Exit Sub Bishwanath Parajuli 298
errhandler: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdfind_Click() 'This procedure finds a particular record Dim find As Integer find = Val(InputBox("Enter the Member ID you want to find.", "Borrower's Details")) 'show an input box to enter the data to be found If mrecord.RecordCount <> 0 Then 'if the recordset is not empty mrecord.MoveFirst 'move the record position to first record While Not mrecord.EOF 'until the end of the file If mrecord.Fields(0) = find Then 'compare the data with find Call display 'if found display the record Exit Sub 'exit End If mrecord.MoveNext 'move to next record Wend 'repeat the process MsgBox "Record not found.", vbInformation, "Search" End If End Sub Private Sub cmdlast_Click() 'This procedure moves to the pointer to last record On Error GoTo errhandler: If mrecord.EOF = True Then 'if recordpointer is at eof MsgBox "This is Last record", vbOKOnly, "Registration" mrecord.MoveLast 'move to last record Exit Sub Else mrecord.MoveLast 'move record postion to last record Call display 'call the function End If Exit Sub 'exit errhandler: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdlast_GotFocus() cmdprint.Visible = True 'show the command button Bishwanath Parajuli 299
End Sub Private Sub cmdmodify_Click() 'This procedure alters data from the database checkblank = False 'set the boolean value to false checkblank = checkblanks() 'retrive the value of the boolean from the function If checkblank = False Then 'if boolean is false If mrecord.RecordCount <> 0 Then 'if the recordset is not empty If MsgBox("Are you sure you want to modify?", vbYesNo) = vbYes Then mrecord.MoveFirst 'move to first record While Not mrecord.EOF 'until all the records are read If mrecord.Fields(0) = txtbrid.Text Then 'if the record and textbox matches then 'set the fields with the specified records mrecord.Fields(1) = txtfname mrecord.Fields(2) = txtmname mrecord.Fields(3) = txtsname mrecord.Fields(4) = dobpicker mrecord.Fields(5) = cmblevel If optmale.Value = True Then mrecord.Fields(7) = "Male" Else mrecord.Fields(7) = "Female" End If mrecord.Fields(6) = txtcontact mrecord.Fields(10) = lblpic.Caption mrecord.Update 'UPDATE record txtfname.SetFocus 'shift focus to the textbox MsgBox "Record Updated Sucessfully.", vbInformation, "Modify" End If mrecord.MoveNext 'move to next record Wend 'repeat End If End If End If End Sub Private Sub cmdnext_Click() 'This procedure moves pointer to relative next record On Error GoTo errhandler: If mrecord.AbsolutePosition = adPosBOF Then 'if the recordpointer is at bof Bishwanath Parajuli 300
mrecord.MoveLast 'move to last record Exit Sub 'exit ElseIf mrecord.EOF = True Then 'if the recordpointer is at eof MsgBox "This is Last record", vbOKOnly, "Information" mrecord.MoveLast 'move to last record Exit Sub Else Call display 'call the function mrecord.MoveNext 'move recordpointer forward End If Exit Sub errhandler: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdnext_GotFocus() cmdprint.Visible = True End Sub Private Sub cmdprevious_Click() 'This procedure moves pointer to relative previous record On Error GoTo errhandler: If mrecord.AbsolutePosition = adPosEOF Then 'if recordpointer is at eof mrecord.MoveFirst 'move the recordpointer to first record Exit Sub ElseIf mrecord.BOF = True Then 'if recordpointer is at bof MsgBox "This is First record.", vbOKOnly, "Information" mrecord.MoveFirst 'move the recordpointer to first record Exit Sub Else Call display 'call the function mrecord.MovePrevious 'move recordpointer backward End If Exit Sub errhandler: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdprevious_GotFocus() cmdprint.Visible = True End Sub Private Sub cmdprint_Click() Bishwanath Parajuli 301
'This procedure exports data from the field 'to Microsoft Word On Error GoTo errhandle: Static wa As Word.Application Static wd As Word.Document Set wa = New Word.Application Set wd = wa.Documents.add(App.Path & "\Library_Card.doc") 'set the path of worddocument 'set the value of textboxes to the specified fields of word document wd.FormFields("txtbrid").Range = txtbrid wd.FormFields("txtfname").Range = txtfname wd.FormFields("txtmname").Range = txtmname wd.FormFields("txtsname").Range = txtsname wd.FormFields("txtlevel").Range = cmblevel wd.FormFields("txtdatea").Range = lbldatea wd.FormFields("txtdatee").Range = lbldatee wa.Visible = True 'show word application Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" wa.Quit End Sub Private Sub cmdprint_LostFocus() cmdprint.Visible = False End Sub Private Sub cmdrenew_Click() 'This procedure modifies,only the 9th field of the table If MsgBox("Do you want to renew the membership?", vbQuestion + vbYesNo, "Renew") = vbYes Then 'if message boxes are responded yes lbldatee = Month(VBA.Date) & "/" & Day(VBA.Date) & "/" & Year(VBA.Date) + 2 'set the value of textbox If mrecord.RecordCount <> 0 Then 'if the recordset is not empty mrecord.MoveFirst 'move to first record While Not mrecord.EOF 'until all the records are read If mrecord.Fields(0) = Val(txtbrid) Then 'compare the value of textbox with that on the record 'if the record is found then mrecord.Fields(9) = lbldatee 'set the value of fields equal to that of tha label 'assign the value of textbox to particular fields Bishwanath Parajuli 302
mrecord.Update 'update the existing record MsgBox "Membership Renewed Sucessfully.", vbInformation, "Renew" End If mrecord.MoveNext 'move to next record Wend 'repeat cmdrenew.Visible = False 'hide command button expiredtime.Enabled = False picx.Visible = False picy.Visible = True 'hide pictures Exit Sub End If End If End Sub Private Sub cmdrenew_LostFocus() cmdrenew.Visible = False End Sub Private Sub cmdsave_Click() 'This procedure saves the data in the database checkblank = False 'set the boolean to false checkblank = checkblanks() 'retrive the value of boolean from the function If checkblank = False Then 'if value of boolean is false 'set the value of the fields from the specified controls mrecord.Fields(0) = txtbrid mrecord.Fields(1) = txtfname mrecord.Fields(2) = txtmname mrecord.Fields(3) = txtsname mrecord.Fields(4) = dobpicker mrecord.Fields(5) = cmblevel mrecord.Fields(6) = txtcontact If optmale.Value = True Then mrecord.Fields(7) = "Male" Else mrecord.Fields(7) = "Female" End If mrecord.Fields(8) = lbldatea mrecord.Fields(9) = lbldatee mrecord.Fields(10) = lblpic.Caption mrecord.Update 'SAVE record and continue: gridtimer.Enabled = True 'enable timer txtbrid.Locked = True 'lock the textbox MsgBox "Record Saved.", vbInformation, "Information" Bishwanath Parajuli 303
Call enablenavigation 'call function txtbrid.SetFocus 'shift focus to textbox End If End Sub Private Sub Form_Unload(Cancel As Integer) 'unload the form given below Unload frmissue Unload frmrnunreturn Unload frmreserve End Sub Private Sub memebergrid_Click() 'This procedure exports the data from datagrid to the fields If adomember.Recordset.RecordCount <> 0 Then txtbrid = memebergrid.Columns(0) txtfname = memebergrid.Columns(1) txtmname = memebergrid.Columns(2) txtsname = memebergrid.Columns(3) dobpicker = memebergrid.Columns(4) cmblevel = memebergrid.Columns(5) txtcontact = memebergrid.Columns(6) If memebergrid.Columns(7) = "Male" Then optmale.Value = True Else optfemale.Value = True End If lbldatea = memebergrid.Columns(8) lbldatee = memebergrid.Columns(9) lblpic.Caption = memebergrid.Columns(10) memimage = LoadPicture(lblpic.Caption) tabs.TabVisible(1) = False txtfname.SetFocus tabs.TabVisible(1) = True End If End Sub Private Sub Form_Load() 'This procedure configures ADODB and ADODC controls Call connection Call memeberrecset Call clear Call enablenavigation Call checkrecords
Bishwanath Parajuli
304
adomember.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" 'configure provider and application path adomember.CommandType = adCmdUnknown adomember.RecordSource = "select * from tblmember" 'specify the table adomember.Refresh 'refresh adodc End Sub Private Sub frapicture_Click() memimage = LoadPicture("") 'clear picture lblpic.Caption = "" 'clear labels lbl2.Visible = False End Sub Private Sub memimage_Click() 'This procedure opens a dialog box for displaying image 'and saves image in the application path commdialog.Filter = "*.jpgfile|*.jpg" 'filter filetypes with extension '.jpg' Me.commdialog.ShowOpen 'open common dialog box If Me.commdialog.FileName <> "" Then 'if filename is specified 'assign the label with filename memimage = LoadPicture(Me.commdialog.FileName) 'load picture from the location in filename SavePicture memimage, App.Path & "\" & Me.commdialog.FileTitle 'save the picture to application path lblpic.Caption = commdialog.FileTitle End If If lblpic.Caption = "" Then lbl2.Visible = False Else lbl2.Visible = True End If End Sub Private Sub gridtimer_Timer() 'This procedure refreshes the datagrid memebergrid.Refresh adomember.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" Bishwanath Parajuli 305
'configure provider and application path adomember.CommandType = adCmdUnknown adomember.RecordSource = "select * from tblmember" 'specify the table adomember.Refresh 'refresh adodc memebergrid.Refresh 'refresh datagrid gridtimer.Enabled = False End Sub Private Sub expiredtime_Timer() 'This procedure changes background color of the picture box Dim count As Integer 'declare the variable count = 0 'specify the background colour of the image If picx.BackColor = &HC0C0FF Then picx.BackColor = &H80000004 ElseIf picx.BackColor = &H80000004 Then picx.BackColor = &HC0C0FF End If End Sub Private Sub tabs_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed If tabs.Caption = "Form View" Then 'and the tab caption is Form View cmdaddnew.SetFocus 'shift focus to the command button End If End If End Sub Private Sub txtbrid_KeyPress(KeyAscii As Integer) 'accept those keypresses which are numeric and backspaces only If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8) Then KeyAscii = 0 End If End Sub Private Sub txtbrid_LostFocus() 'This procedure searches for any existing keyfield Dim find As Long 'declare 'find' as long find = Val(txtbrid) 'assign find with textbox If cmdaddnew.Enabled = False Then If mrecord.RecordCount <> 0 Then mrecord.CancelUpdate 'cancel the saving process Bishwanath Parajuli 306
'if there is record in record named 'mrecord' mrecord.MoveFirst 'move the record position to first record While Not mrecord.EOF 'until the end of the file If mrecord.Fields(0) = find Then 'compare the record with find Call display 'call the function txtbrid.SetFocus 'shift focus to the textbox MsgBox "This ID exists already.", vbInformation End If mrecord.MoveNext 'move to next record Wend 'repeat the process mrecord.AddNew 'resume the saving process End If End If End Sub Private Sub lbldatee_Change() 'This procedure checks if the data in the specified label 'match the condition belo If txtbrid.Text <> "" Then expire = DateDiff("d", lbldatee, VBA.Date) 'Find the difference in the value of date If expire > 0 Then MsgBox "Your membership has expired. Please Renew!", vbInformation, "Expiration" expiredtime.Enabled = True 'configure controls picy.Visible = False picx.Visible = True cmdrenew.Visible = True Exit Sub Else expiredtime.Enabled = False picx.Visible = False picy.Visible = True cmdrenew.Visible = False Exit Sub End If End If End Sub Private Sub txtcontact_KeyPress(KeyAscii As Integer) If Me.chkrestrict.Value = vbChecked Then 'if checkbox is checked Me.txtcontact.MaxLength = 10 'set the maximum available space in the textbox to 10 Bishwanath Parajuli 307
'accept those keypresses which are numeric and backspaces only If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 8) Then KeyAscii = 0 End If ElseIf Me.chkrestrict.Value = vbUnchecked Then 'if checkbox is unchecked Me.txtcontact.MaxLength = 30 'set the maximum available space in the textbox to 30 End If End Sub Private Sub txtcontact_LostFocus() Call checkrestrict 'call the function End Sub Private Sub txtfname_Change() If txtfname = "" Then lblfname.Caption = "" Else lblfname.Caption = txtfname End If End Sub Sub display() 'This procedure assigns the data in specified fields 'from the record source On Error GoTo handle: txtbrid = mrecord.Fields(0) txtfname = mrecord.Fields(1) txtmname = mrecord.Fields(2) txtsname = mrecord.Fields(3) dobpicker = mrecord.Fields(4) cmblevel = mrecord.Fields(5) txtcontact = mrecord.Fields(6) If mrecord.Fields(7) = "Male" Then optmale.Value = True Else optfemale.Value = True End If lbldatea = mrecord.Fields(8) lbldatee = mrecord.Fields(9) lblpic.Caption = mrecord.Fields(10) memimage = LoadPicture(App.Path & "/" & mrecord.Fields(10)) 'load picture Bishwanath Parajuli 308
lblrecordnumber.Caption = mrecord.AbsolutePosition & " Of " & mrecord.RecordCount & " Records" Exit Sub handle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub txtsname_Change() If txtsname = "" Then lblsname.Caption = "" Else lblsname = txtsname End If End Sub Sub clear() 'This procedure resets all the fields lbl2.Visible = False lblsname = "" lblfname = "" expiredtime.Enabled = False picx.Visible = False picy.Visible = False txtbrid = "" txtfname = "" txtmname = "" txtsname = "" txtdob = "" txtcontact = "" dobpicker = VBA.Date lbldatea.Caption = "" lbldatee.Caption = "" optmale.Value = False optfemale.Value = False cmblevel.clear chkrestrict.Value = vbUnchecked For i = 1 To 10 cmblevel.AddItem i Next i cmblevel.AddItem "Teachers and Staffs" lblpic.Caption = "" memimage = LoadPicture("") End Sub Sub checkrecords() 'This procedure enables/disables the navigation buttons Bishwanath Parajuli 309
If mrecord.RecordCount = 0 Then franavigation.Enabled = False 'disable frame ElseIf mrecord.RecordCount <> 0 Then franavigation.Enabled = True 'enable frame End If End Sub Sub enablenavigation() 'This procedure enables command controls franavigation.Enabled = True cmddelete.Enabled = True cmdaddnew.Enabled = True cmdsave.Enabled = False cmdcancel.Enabled = False cmdmodify.Enabled = True End Sub Sub disablenavigation() 'This procedure disables command controls franavigation.Enabled = False cmddelete.Enabled = False cmdaddnew.Enabled = False cmdsave.Enabled = True cmdcancel.Enabled = True cmdmodify.Enabled = False End Sub Function checkblanks() As Boolean 'This procedure checks for any unattended fields in the form If txtbrid = "" Or txtfname = "" Or txtsname = "" Or dobpicker = "" Or txtcontact = "" Or lblpic.Caption = "" Then 'if the textboxes specified above are blank MsgBox "Please fill all the required fields.", vbExclamation, "Error" checkblanks = True 'set the boolean value to true Exit Function 'exit End If If (optmale.Value = False And optfemale.Value = False) Then 'if the options above are unchecked MsgBox "Please, specify the gender.", vbExclamation, "Error" checkblanks = True Exit Function End If End Function Bishwanath Parajuli 310
frmemail: Private Sub cmdsend_Click() 'This procedure sends the data to specified address through 'Microsoft Outlook On Error GoTo errhandle If txtadd.Text = "" Or txtsubject.Text = "" Or txtbody.Text = "" Then 'if the textboxes specified above are blank MsgBox "Please fill in all the fields.", vbExclamation, "Error" Exit Sub 'exit End If Dim frmsOutlook As Object 'declare the objects Dim frmsMailItem As Object Set frmsOutlook = CreateObject("Outlook.Application") 'open outlook Set frmsMailItem = frmsOutlook.CreateItem(0) 'create a new mail window frmsMailItem.Recipients.add txtadd.Text 'set the value of txtadd as address of the recipent frmsMailItem.Subject = txtsubject.Text 'set the subject frmsMailItem.Body = txtbody.Text 'set the body frmsMailItem.Send 'send the mail Set frmsOutlook = Nothing 'close outlook Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub txtadd_LostFocus() 'This procedure checks if the required characters are present 'in the field specified below If InStr(1, txtadd, ".") And InStr(1, txtadd, "@") Then 'if the the textbox has character . and @ txtsubject.SetFocus 'shift focus to subject box Else MsgBox "Enter a valid email address.", vbExclamation, "Error" txtadd.SetFocus 'shift focus to the same box End If Bishwanath Parajuli 311
End Sub
Bishwanath Parajuli
312
frmfinecollection: Private Sub chkdet_Click() If chkdet.Value = vbChecked Then 'if the checkbox is checked Me.Height = 5490 'set the specified height ElseIf chkdet.Value = vbUnchecked Then 'if the checkbox is unchecked Me.Height = 2385 End If End Sub Private Sub cmdcalculate_Click() 'This procedure find the item with similar fields 'and sums up the 7th field of the record to display it Dim id, fine As Integer 'declare variables id = Val(InputBox("Enter the Borrower ID.", "Fine")) 'show input box to input a data If id <> 0 Then 'if the variable do have some data If srecord.RecordCount <> 0 Then 'if the recordset is not empty srecord.MoveFirst 'move to first record While Not srecord.EOF 'until end of file If srecord.Fields(3) = id Then 'compare the value of variable and data in recordsource fine = srecord.Fields(7) + fine 'add the value of fields for matched data End If srecord.MoveNext 'move to next record Wend 'repeat End If MsgBox "The borrower has fine of Rs." & fine & " paid.", vbInformation, "Fine" End If End Sub Private Sub cmdcollect_Click() 'This procedure deletes all the records from the table On Error GoTo errhandle: If srecord.RecordCount <> 0 Then 'show input box to input a data If MsgBox("Have you received all the money collected?", vbYesNo + vbQuestion, "Collection") = vbYes Then 'if messagebox returns with yes response then brecord.MoveFirst 'move to first record While Not brecord.EOF 'until all the records are read Bishwanath Parajuli 313
brecord.Delete 'delete all the record finetime.Enabled = True 'enable timer brecord.MoveNext 'move to next record Wend 'repeat MsgBox "All the records in fine table has been deleted.", vbInformation, "Collection" End If End If Exit Sub errhandle: MsgBox Err.Description, vbExclamation, "Error" End Sub Private Sub Form_Load() 'This procedure configures ADODB and ADODC 'and displays the sum of 7th field of the table at startup Dim fine As Integer 'declare variable Call connection 'call the function Call qryfinerecset Call finerecset fine = 0 If srecord.RecordCount <> 0 Then srecord.MoveFirst 'move to first record While Not srecord.EOF 'until all the records are read, fine = srecord.Fields(7) + fine 'sum up all the data in the specfied field srecord.MoveNext 'move to next record Wend 'repeat ElseIf srecord.RecordCount = 0 Then cmdcollect.Enabled = False 'disable the button End If lblfine.Caption = fine 'set the value of variable in label adofine.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" 'configure provider and application path adofine.CommandType = adCmdUnknown adofine.RecordSource = "Select * from qryfine" 'specify the query adofine.Refresh 'refresh adodc End Sub Private Sub finetime_Timer() 'This procedure refreshes the datagrid finegrid.Refresh 'refresh the datagrid Bishwanath Parajuli 314
adofine.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" 'configure provider and application path adofine.CommandType = adCmdUnknown adofine.RecordSource = "Select * from qryfine" 'specify the query adofine.Refresh 'refresh adodc finegrid.Refresh finetime.Enabled = False End Sub
Bishwanath Parajuli
315
frmglance: Sub add() 'This procedure adds data in the combo box cmbdays.clear For i = 2 To 30 cmbdays.AddItem i Next i End Sub Private Sub chkshow_Click() If chkshow.Value = vbChecked Then lsvbook.ListItems.clear 'clear listview Call add cmbdays.Enabled = True ElseIf chkshow.Value = vbUnchecked Then cmbdays.Enabled = False Call listings End If End Sub Private Sub cmbdays_Click() 'This procedure adds the data selected from the box 'with today's data and alters the color of the text 'if those data have the value of 5th field less than the sum lsvbook.ListItems.clear 'clear listview If bdrecord.RecordCount <> 0 Then Dim lstitem As ListItem 'declare lstitem as listview's items bdrecord.MoveFirst 'move to first record of 'bdrecord' While Not bdrecord.EOF 'until all the records are read Set lstitem = lsvbook.ListItems.add(, , bdrecord!Title) 'set the value in first column header 'add the items from the fields of the 'bdrecord' lstitem.SubItems(1) = bdrecord.Fields(3) If bdrecord.Fields(5) < VBA.Date + Day(cmbdays) Then lstitem.SubItems(2) = "Crossed its due date." 'set the color of the text to red lstitem.ForeColor = vbRed lstitem.ListSubItems(1).ForeColor = vbRed lstitem.ListSubItems(2).ForeColor = vbRed ElseIf bdrecord.Fields(5) >= VBA.Date + Day(cmbdays) Then 'if the fields has value more than lstitem.SubItems(2) = "Valid till today." Bishwanath Parajuli 316
End If bdrecord.MoveNext 'move to next record Wend 'repeat End If End Sub Private Sub Form_Load() 'This procedure configure ADODB Call add 'call the function Call connection Call qryissuerecset Call listings cmbdays.Enabled = False 'enable combo End Sub Sub listings() 'This procedure list the data into the list view lsvbook.ListItems.clear 'clear list view If bdrecord.RecordCount <> 0 Then 'if the recordset is not empty Dim lstitem As ListItem 'declare lstitem as listview's items bdrecord.MoveFirst 'move to first record While Not bdrecord.EOF 'until end of file Set lstitem = lsvbook.ListItems.add(, , bdrecord!Title) 'set the value of first column header 'add the items from the fields of the 'bdrecord' lstitem.SubItems(1) = bdrecord.Fields(3) If bdrecord.Fields(5) < VBA.Date Then 'if the data in the field is less than system date 'specify the text and color for the sub-items lstitem.SubItems(2) = "Crossed its due date." lstitem.ForeColor = vbRed lstitem.ListSubItems(1).ForeColor = vbRed lstitem.ListSubItems(2).ForeColor = vbRed Else lstitem.SubItems(2) = "Valid till today." End If bdrecord.MoveNext 'move to next record Wend 'repeat End If End Sub Private Sub lsvbook_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader) 'This procedure toggles the clicked column's sort order 'only if the active column is clicked Bishwanath Parajuli 317
If (lsvbook.SortKey = ColumnHeader.Index - 1) Then ColumnHeader.Tag = Not Val(ColumnHeader.Tag) End If 'set sort order to that of the respective ListSortOrderConstants value lsvbook.SortOrder = Abs(Val(ColumnHeader.Tag)) 'get the zero-based index of the clicked column. lsvbook.SortKey = ColumnHeader.Index - 1 'sort the column lsvbook.Sorted = True End Sub
Bishwanath Parajuli
318
frmhistory: Private Sub chkdet_Click() If chkdet.Value = vbChecked Then 'if checkbox is unchecked Me.Height = 7800 'set the height of the form ElseIf chkdet.Value = vbUnchecked Then 'if checkbox is unchecked Me.Height = 3900 End If End Sub Private Sub Form_Load() 'This procedure configures ADODB and ADODC 'and adds item to the listbox adohistory.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" 'configure provider and application path adohistory.CommandType = adCmdUnknown adohistory.RecordSource = "select * from qryhistory" 'specify the query adohistory.Refresh 'refresh the adodc If adohistory.Recordset.RecordCount <> 0 Then 'if the recordset is not empty adohistory.Recordset.MoveFirst 'move to first record While Not adohistory.Recordset.EOF 'until eof lstbooks.AddItem (adohistory.Recordset.Fields(0)) 'populate the list box adohistory.Recordset.MoveNext 'move to next record Wend 'repeat End If End Sub Private Sub lstbooks_Click() 'This procedure shows the data, with that keyfield, 'clicked in the listbox If lstbooks.ListIndex >= 0 Then 'if there is atleast a data in listbox If adohistory.Recordset.RecordCount <> 0 Then adohistory.Recordset.MoveFirst 'move to first record While Not adohistory.Recordset.EOF 'until eof If lstbooks.Text = adohistory.Recordset.Fields(0) Then 'if the text selected is found 'set the value from the recordset to specified fields lblbcode.Caption = adohistory.Recordset.Fields(1) Bishwanath Parajuli 319
lbltitle.Caption = adohistory.Recordset.Fields(2) lblsid.Caption = adohistory.Recordset.Fields(3) lblname.Caption = adohistory.Recordset.Fields(4) lbldatei.Caption = adohistory.Recordset.Fields(5) lblcomments.Caption = "Comments:- " & adohistory.Recordset.Fields(7) End If adohistory.Recordset.MoveNext 'move to next record Wend 'repeat End If End If End Sub
Bishwanath Parajuli
320
frmissue: Option Explicit Dim check As Boolean 'declare the variable Private Sub cmbbid_Click() 'This procedure displays the details of the data linked_ 'with the item clicked in the box If precord.RecordCount <> 0 Then 'if the recordset is not empty precord.MoveFirst 'move to first record While Not precord.EOF 'until eof If precord.Fields(0) = cmbbid Then 'compare the field and combo 'specify the fields with the corresponding field value lblbtitle.Caption = precord.Fields(1) lbltype.Caption = precord.Fields(3) If precord.Fields(3) = "Reference" Then 'if the field value is as specified above MsgBox "A reference book is prohibited to issue.", vbInformation, "Error" cmdsave.Enabled = False 'disable the button Call clear 'call the function Exit Sub 'exit End If End If precord.MoveNext 'move to next record Wend 'repeat End If Call bremain 'call the function End Sub Private Sub cmbbid_GotFocus() Dim code As Integer 'decalre the variable If bdrecord.RecordCount = 0 Then 'if there is no record in the recordset code = 301 'set the specified value of code Else bdrecord.MoveLast 'move record pointer to last record code = bdrecord.Fields(0) + 1 'increase the value of code by 1 with respect to last data End If lblissueid = code 'set the value of code in the label End Sub Private Sub cmbbrid_Click() Bishwanath Parajuli 321
'This procedure displays the details of the data linked_ 'with the item clicked in the box On Error GoTo errhandler: If mrecord.RecordCount <> 0 Then mrecord.MoveFirst 'move to first record While Not mrecord.EOF 'until eof If mrecord.Fields(0) = Int(cmbbrid) Then 'compare the combo and field value 'set the value of field in specified field of form if matched lblbrfname.Caption = mrecord.Fields(1) lblbrmname.Caption = mrecord.Fields(2) lblbrsname.Caption = mrecord.Fields(3) If mrecord.Fields(5) = "Teachers and Staffs" Then lblbtype.Caption = "The member is a Teacher or a Staff." Else lblbtype.Caption = "The member is at " & mrecord.Fields(5) & " class." End If lblpic.Caption = App.Path & "/" & mrecord.Fields(10) imgpic = LoadPicture(lblpic.Caption) 'load the picture If mrecord.Fields(9) < VBA.Date Then 'if field has date less than system date cmdsave.Enabled = False 'disable the command button If MsgBox("Memebership has expired. Do you want to renew membership?", vbCritical + vbYesNo, "Error") = vbYes Then Me.Hide 'hide the form frmborrowerdetails.Show 'show the form frmborrowerdetails.display 'call a function from the new form Exit Sub Else MsgBox "Issue cannot be continued.", vbCritical, "Error" Call clear 'call function End If Exit Sub 'exit End If End If mrecord.MoveNext 'move to next record Wend 'repeat End If Call check_reserve 'call function Exit Sub Bishwanath Parajuli 322
errhandler: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdsave_Click() 'This procedure saves the required data in database If cmbbid.Text = "" Or cmbbrid.Text = "" Then 'if the text areas in combo are empty MsgBox "Please, enter the required Fields.", vbExclamation, "Error" Exit Sub 'exit End If check = False 'set the value of boolean to false check = borrower_check() 'check for the value of boolean If check = False Then 'if the value of boolean returns with the value false bdrecord.AddNew 'add new record 'specify the value of form fields to recordset's field bdrecord.Fields(0) = lblissueid.Caption bdrecord.Fields(1) = Val(cmbbid) bdrecord.Fields(2) = Val(cmbbrid) bdrecord.Fields(3) = lbldatei.Caption bdrecord.Fields(4) = lbldater.Caption bdrecord.Fields(5) = txtmemo.Text bdrecord.Fields(6) = "Yes" bdrecord.Fields(7) = Me.lbltype bdrecord.Update 'save record MsgBox "Record Saved.", vbInformation, "Information" cmdsave.Enabled = False 'disable controls cmbbrid.Enabled = False Me.cmbbid.SetFocus 'shift focus to combo Call clear 'call function End If End Sub Private Sub cmdclear_Click() Call clear 'call function End Sub Private Sub cmdsave_GotFocus() If txtmemo.Text = "" Then 'if textbox is empty txtmemo.Text = "No comments" 'set the value as specified above Bishwanath Parajuli 323
End If End Sub Private Sub Form_Load() 'This procedure configures ADODB connection Call connection 'call the function Call bookrecset Call memeberrecset Call issuerecset Call reserverecset Call additemid lbldatei.Caption = VBA.Date 'set system date in label End Sub Sub clear() 'This procedure resets the value of fields txtmemo.Text = "" cmbbrid.clear cmbbid.clear Call additemid 'call the function lbltype.Caption = "" lblbtitle = "" lblbrfname = "" lblbrmname = "" lblbrsname = "" lbldater.Caption = "" lblpic.Caption = "" imgpic = LoadPicture("") End Sub Sub bremain() 'This procedure checks "books that can be issued" Dim count, countr, br As Integer 'declare variable count = 0 countr = 0 If bdrecord.RecordCount <> 0 Then bdrecord.MoveFirst 'move to first record While Not bdrecord.EOF 'until eof If bdrecord.Fields(1) = cmbbid Then 'compare the combo with field value 'if matched increase count by 1 count = count + 1 End If bdrecord.MoveNext 'move to next record Wend 'repeat End If Bishwanath Parajuli 324
If lrecord.RecordCount <> 0 Then lrecord.MoveFirst While Not lrecord.EOF If lrecord.Fields(1) = cmbbid Then countr = countr + 1 End If lrecord.MoveNext Wend End If If precord.RecordCount <> 0 Then precord.MoveFirst While Not precord.EOF br = precord.Fields(4) - (countr + count) 'find the value of br using calculation given above If precord.Fields(0) = cmbbid Then If count >= precord.Fields(4) Then 'compare the value of count with specified field 'if equal or greater than fields MsgBox "All the books of this code has been issued.", vbInformation, "Issue" Me.cmdsave.Enabled = False 'disable control Exit Sub ElseIf br > 0 Then Me.cmdsave.Enabled = True 'enable control ElseIf br <= 0 Then MsgBox "This book has been reserved.", vbInformation, "Issue" Me.cmdsave.Enabled = False End If End If precord.MoveNext Wend End If End Sub Function borrower_check() As Boolean 'This procedure checks "due status and issue status of borrower" Dim count, a As Integer 'declare the variable count = 0 a=0 If bdrecord.RecordCount <> 0 Then 'if the recordset does have some record bdrecord.MoveFirst 'move to first record Bishwanath Parajuli 325
While Not bdrecord.EOF 'until end of file If bdrecord.Fields(2) = cmbbrid Then 'if field and combo matches 'increase the value of count by 1 count = count + 1 If bdrecord.Fields(4) < VBA.Date Then 'if the field value is less than system date borrower_check = True 'set boolean value to true cmdsave.Enabled = False 'disable button If MsgBox("This borrower has fine to pay. Do you want to fine him/her?.", vbYesNo, "Issue") = vbYes Then Unload Me 'close the form frmrnunreturn.Show frmrnunreturn.cmdrenew.Enabled = False frmrnunreturn.cmdreturn.Enabled = False Exit Function 'exit Else MsgBox "This borrower can issue no more books.", vbExclamation, "Error" cmdsave.Enabled = False End If Else cmdsave.Enabled = True End If End If bdrecord.MoveNext 'move to next record Wend 'repeat End If If bdrecord.RecordCount <> 0 Then bdrecord.MoveFirst While Not bdrecord.EOF If bdrecord.Fields(1) = cmbbid And bdrecord.Fields(2) = Int(cmbbrid) Then a=a+1 End If bdrecord.MoveNext Wend End If If count >= 3 Then borrower_check = True MsgBox "This borrower has already borrowed 3 books. Issue will be cancelled.", vbCritical, "Issue" cmdsave.Enabled = False Exit Function Bishwanath Parajuli 326
Else cmdsave.Enabled = True 'enable command button End If If a >= 1 Then borrower_check = True MsgBox "A borrower cannot borrow two same books at time. Issue will be cancelled.", vbCritical, "Issue" cmdsave.Enabled = False Exit Function Else cmdsave.Enabled = True End If End Function Sub check_reserve() 'This procedure checks if the book to be issued_ 'is reserved by other member or by the same borrower Dim countn As Integer 'declare variable countn = 0 If lrecord.RecordCount <> 0 Then 'if the recordset is not empty lrecord.MoveFirst 'move to first record While Not lrecord.EOF 'until eof If lrecord.Fields(1) = cmbbid.Text Then 'compare the field's and combo's value 'if matched If lrecord.Fields(1) = cmbbid.Text And lrecord.Fields(2) = Int(cmbbrid.Text) Then If MsgBox("This book has been reserved by the current borrower. Do you want to delete the record?", vbQuestion + vbYesNo, "Reservation") = vbYes Then lrecord.Delete 'delete the record Exit Sub 'exit Else cmdsave.Enabled = False 'disable button Exit Sub End If End If End If lrecord.MoveNext 'move to next record Wend 'repeat End If If precord.RecordCount <> 0 Then precord.MoveFirst Bishwanath Parajuli 327
While Not precord.EOF If precord.Fields(0) = cmbbid Then If countn >= precord.Fields(4) Then 'compare the value of variable and field data MsgBox "All the books of this code has been Reserved. Issue cannot be completed.", vbInformation, "Issue" cmdsave.Enabled = False Exit Sub ElseIf countn < precord.Fields(4) Then cmdsave.Enabled = True 'enable button End If End If precord.MoveNext Wend End If End Sub Private Sub lbltype_Change() 'This procedure changes the value of the label_ 'according to the text displayed If lbltype.Caption = "Non Fiction" Then 'if the label's caption is as specified lbldater.Caption = VBA.Date + Day(7) 'set label's value 7 days more than system date ElseIf lbltype.Caption = "Periodical" Then lbldater.Caption = VBA.Date + Day(7) ElseIf lbltype.Caption = "Reference" Then lbldater.Caption = "Issue Prohibited" ElseIf lbltype.Caption = "Fiction" Then lbldater.Caption = VBA.Date + Day(14) End If End Sub Sub additemid() 'This procedure adds item into combo-boxes If precord.RecordCount <> 0 Then 'if recordset is not empty precord.MoveFirst 'move to first record While Not precord.EOF 'until eof cmbbid.AddItem precord.Fields(0) 'populate data into combo precord.MoveNext 'move to next record Wend 'repeat End If If mrecord.RecordCount <> 0 Then Bishwanath Parajuli 328
mrecord.MoveFirst While Not mrecord.EOF cmbbrid.AddItem mrecord.Fields(0) mrecord.MoveNext Wend End If End Sub
Bishwanath Parajuli
329
frmlinker: 'This form is used to display the form_ 'based on the users selection Private Sub optrenew_Click() Unload Me 'unload the form frmrnunreturn.Show 'show the form frmrnunreturn.cmdrenew.Visible = True frmrnunreturn.cmdreturn.Visible = False End Sub Private Sub optreturn_Click() Unload Me frmrnunreturn.Show frmrnunreturn.cmdrenew.Visible = False frmrnunreturn.cmdreturn.Visible = True End Sub
Bishwanath Parajuli
330
frmLogin: Private Sub cmdcancel_Click() Unload Me 'unload the form Unload mdimain End Sub Private Sub cmdok_Click() 'This procedure determines the access rights of the user 'based upon usertype If txtusername = "" And txtpassword = "" Then 'if the textbox are empty mdimain.Hide 'hide mdi window mdimain.sbrmain.Panels(3).Text = "User :- Visitor" 'specify the data to be displayed in statusbar 'continue with disabling the menu items: mdimain.mnumanagement.Enabled = False mdimain.mnusettings.Enabled = False mdimain.mnureserve.Enabled = False mdimain.mnuissue.Enabled = False mdimain.mnurenewreturn.Enabled = False mdimain.mnutotalfine.Enabled = False mdimain.mnureports.Enabled = False mdimain.mnurequest.Enabled = False mdimain.mnuprefer.Enabled = False mdimain.tbrmain.Buttons(1).Enabled = False mdimain.tbrmain.Buttons(3).Enabled = False mdimain.tbrmain.Buttons(5).Enabled = False mdimain.tbrmain.Buttons(9).Enabled = False Unload Me frmSplash.Show 'show the form Exit Sub 'exit ElseIf precord.RecordCount <> 0 Then 'if recordset is not empty precord.MoveFirst 'move to first record While Not precord.EOF 'until eof If txtusername = precord.Fields(0) Then 'compare the data and field value and if matched If txtpassword = precord.Fields(2) And precord.Fields(1) = "Administrator/Head Librarian" Then mdimain.Hide mdimain.sbrmain.Panels(3).Text = "User :Administrator (" & txtusername.Text & ")" Unload Me frmSplash.Show 'show form Exit Sub Bishwanath Parajuli 331
ElseIf txtpassword = precord.Fields(2) And precord.Fields(1) = "General User" Then mdimain.Hide mdimain.sbrmain.Panels(3).Text = "User :- General User (" & txtusername.Text & ")" mdimain.mnumanagement.Enabled = False mdimain.mnutotalfine.Enabled = False mdimain.mnuprefer.Enabled = False mdimain.tbrmain.Buttons(3).Enabled = False Unload Me frmSplash.Show Exit Sub Else 'if username doesn't match then MsgBox "Invalid Password, try again!", vbCritical, "Login" txtpassword.SetFocus 'shift focus to the textbox Exit Sub End If End If precord.MoveNext 'move to next record Wend 'repeat MsgBox "Invalid Username, try again!", vbCritical, "Login" txtusername.SetFocus End If End Sub Private Sub Form_Load() 'This procedure configures ADODB connection On Error GoTo errhandle: 'if error occurs read errhandle Call connection 'call the functions Call security Call preferrecset Exit Sub 'exit errhandle: MsgBox Err.Description & "#" & Err.Number & ". The application will now terminate. Sorry for the inconvenience.", vbCritical, "Fatal Error" Unload Me 'unload the form End Sub
Bishwanath Parajuli
332
frmnuserandcpass: Dim checklib As Boolean Private Sub cmbusertype_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed txtpassword.SetFocus 'shift focus to the field End If End Sub Private Sub cmdaddnewuser_Click() 'This procedure creates space for saving data 'and saves the data in it If txtpassword = "" Or txtusername = "" Or txtcpassword = "" Then 'if textareas are empty MsgBox "Please, fill the fields.", vbExclamation, "Error" Exit Sub 'exit End If If txtpassword <> txtcpassword Then 'if the data in the textboxes dont match MsgBox "Your Passwords don't match.", vbInformation, "Error" Exit Sub 'exit Else checklib = False 'set the boolean to false checklib = checklibrarian() 'get the value of boolean from the function specified 'if the boolean returns with the value false then If checklib = False Then precord.AddNew 'add new record 'set field value with the data from specified object precord.Fields(0) = txtusername precord.Fields(1) = cmbusertype precord.Fields(2) = txtpassword precord.Update 'save the record txtusername.SetFocus MsgBox "Username Updated.", vbInformation, "Library Management" End If End If End Sub Private Sub cmdexit_Click() Unload Me 'unload the form End Sub Bishwanath Parajuli 333
Private Sub cmdclear_Click() Call clearallfields 'call function End Sub Private Sub cmdclear1_Click() 'This procedure clears the fields located in the tabs txtuser = "" txtopass = "" txtnpass = "" txtcpass = "" End Sub Private Sub cmddelete_Click() 'This procedure deletes the record from the specified record table If txtusern.Text = "" Or txtpassd.Text = "" Then 'if the textboxes are empty MsgBox "Please, fill the fields.", vbExclamation, "Error" Exit Sub 'exit End If If precord.RecordCount <> 0 Then 'if recordset is not empty precord.MoveFirst 'move to first record While Not precord.EOF 'until eof If precord.Fields(0) = txtusern Then 'compare field value and textbox's value and if matched If MsgBox("Are you sure you want to delete this record?", vbYesNo + vbQuestion, "Delete User") = vbYes Then precord.Delete 'delete the data MsgBox "User deleted sucessfully", vbInformation, "Memeber Deleted" txtusern.Text = "" txtpassd.Text = "" txtusern.SetFocus 'shift focus to textbox End If End If precord.MoveNext 'move to next record Wend 'repeat End If End Sub Private Sub cmddelete_GotFocus() 'This procedure checks if the data in the fields match_ 'with that on the database Bishwanath Parajuli 334
Dim find As String 'declare variable find = txtpassd 'se the variable with textbox's data If precord.RecordCount <> 0 Then 'if the recordset is not empty precord.MoveFirst 'move to the first record While Not precord.EOF 'until end of file If precord.Fields(0) = Me.txtusern And precord.Fields(2) = find Then 'if the data and field value match cmddelete.SetFocus 'shift focus Exit Sub 'exit End If precord.MoveNext 'move to next record Wend 'repeat MsgBox "Your password doesn't match with that on database.", vbInformation, "Information" txtpassd.SetFocus End If End Sub Private Sub Form_Load() 'This procedure configures ADODB connection Call connection 'call the functions Call security Call clearallfields End Sub Private Sub txtcpass_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed Me.cmdchngpass.SetFocus 'shift focus End If End Sub Private Sub txtcpassword_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cmdaddnewuser.SetFocus End If End Sub Private Sub txtnpass_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Me.txtcpass.SetFocus End If End Sub Private Sub txtopass_KeyPress(KeyAscii As Integer) Bishwanath Parajuli 335
If KeyAscii = 13 Then Me.txtnpass.SetFocus End If End Sub Private Sub txtpassd_GotFocus() 'This procedure checks if the key field exist already Dim find As String 'declare variable If precord.RecordCount <> 0 Then 'if the recordset is not empty find = txtusern 'set variable with form's field value precord.MoveFirst 'move to first record While Not precord.EOF 'until eof If precord.Fields(0) = find Then 'if the data and field value match txtpassd.SetFocus 'shift focus Exit Sub 'exit End If precord.MoveNext 'move to next record Wend 'repeat MsgBox "No such username.", vbExclamation, "Error" txtusern.SetFocus 'shift focus End If End Sub Private Sub txtpassd_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Me.cmddelete.SetFocus End If End Sub Private Sub txtpassword_GotFocus() 'This procedure checks if the key field exist already Dim find As String 'declare variable If precord.RecordCount <> 0 Then 'if the recordset is not empty find = txtusername 'set variable with form's field value precord.MoveFirst 'move to first record While Not precord.EOF 'until eof If precord.Fields(0) = find Then 'if the data and field value match MsgBox "This Username exists already.", vbInformation, "Information" txtusername.SetFocus 'shift focus Exit Sub 'exit End If Bishwanath Parajuli 336
precord.MoveNext 'move to next record Wend 'repeat End If End Sub Private Sub txtopass_GotFocus() 'This procedure checks if the key field exist already Dim find As String find = txtuser If precord.RecordCount <> 0 Then precord.MoveFirst While Not precord.EOF If precord.Fields(0) = find Then txtopass.SetFocus Exit Sub End If precord.MoveNext Wend MsgBox "No such username.", vbInformation, "Error" txtusername.SetFocus End If End Sub Private Sub txtnpass_GotFocus() 'This procedure checks if the data in the specified field match_ 'with the field of the database Dim find As String find = txtopass If precord.RecordCount <> 0 Then precord.MoveFirst While Not precord.EOF If precord.Fields(0) = Me.txtuser And precord.Fields(2) = find Then txtnpass.SetFocus Exit Sub End If precord.MoveNext Wend MsgBox "Your password doesn't match with that on database.", vbInformation, "Information" txtopass.SetFocus End If End Sub Private Sub txtcpass_LostFocus() 'This procedure compares the data in two fields Bishwanath Parajuli 337
If txtnpass <> txtcpass Then 'if texboxes value dont match MsgBox "Your Passwords don't match.", vbInformation, "Error" Exit Sub 'exit End If End Sub Private Sub cmdchngpass_Click() 'This procedure changes data in the specified field of database If txtuser = "" Or txtopass = "" Or txtnpass = "" Or txtcpass = "" Then 'if the textboxes are empty MsgBox "Please, fill the fields.", vbExclamation, "Error" Exit Sub 'exit End If If precord.RecordCount <> 0 Then 'if the recorset is not empty precord.MoveFirst 'move to first record While Not precord.EOF 'until eof If precord.Fields(0) = Me.txtuser And precord.Fields(2) = txtopass Then 'if the data and field value matches 'set the textboxes data as new data into the field precord.Fields(2) = txtnpass.Text precord.Update 'save it Me.txtuser.SetFocus 'shift focus MsgBox "Password updated.", vbInformation, "Update Complete" End If precord.MoveNext 'move to next record Wend 'repeat End If End Sub Sub clearallfields() 'This procedure resets all the fields under a tab txtpassword = "" txtusername = "" txtcpassword = "" cmbusertype.clear 'clear combo cmbusertype.AddItem "Administrator/Head Librarian" cmbusertype.AddItem "General User" 'populate combo End Sub
Bishwanath Parajuli
338
Function checklibrarian() As Boolean 'This function checks for redundancy of the data If precord.RecordCount <> 0 Then 'if the recordset is not empty precord.MoveFirst 'move to first record While Not precord.EOF 'until eof If cmbusertype.Text = "Administrator/Head Librarian" Then 'if the data in combo is as specified If precord.Fields(1) = "Administrator/Head Librarian" Then 'and if the field value matches the data checklibrarian = True 'set boolean value to true MsgBox "There is already a Head Librarian. Please delete the librarian if you want to add new.", vbCritical, "Error" Exit Function 'exit ElseIf precord.Fields(1) <> "Administrator/Head Librarian" Then 'and if the field value doesn't match the data checklibrarian = False 'set boolean value to false End If End If precord.MoveNext 'move to next record Wend 'repeat End If End Function Private Sub txtpassword_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed txtcpassword.SetFocus 'shift focus End If End Sub Private Sub txtuser_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Me.txtopass.SetFocus End If End Sub Private Sub txtusern_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Me.txtpassd.SetFocus End If End Sub Private Sub txtusername_KeyPress(KeyAscii As Integer) Bishwanath Parajuli 339
Bishwanath Parajuli
340
frmoverview: Private Sub cmblevel_Click() 'This procedure checks the total records having the value 'specified in the combo box, by the user Dim count As Integer 'declare variable If Adodc3.Recordset.RecordCount <> 0 Then 'if the recordset is not empty Adodc3.Recordset.MoveFirst 'move to first record While Not Adodc3.Recordset.EOF 'until eof If Adodc3.Recordset.Fields(5) = cmblevel.Text Then 'compare field value and combo's data and if matched count = count + 1 'increase value of count by 1 End If Adodc3.Recordset.MoveNext 'move to next record Wend 'repeat End If If count <> 0 Then lbltotal.Caption = count 'set the value in label ElseIf count = 0 Then lbltotal.Caption = 0 End If End Sub Private Sub cmdok_Click() Unload Me 'close the form End Sub Private Sub Form_Load() 'This procedure configures ADODC connection 'and calculates the sum of specified field of having connection Dim cost As Integer 'declare variable cost = 0 Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" 'configure provider and application path Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblissue" 'specify the data source Adodc1.Refresh 'refresh adodc Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" Bishwanath Parajuli 341
Adodc2.CommandType = adCmdUnknown Adodc2.RecordSource = "Select * from tblbookdetails" Adodc2.Refresh Adodc3.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" Adodc3.CommandType = adCmdUnknown Adodc3.RecordSource = "Select * from tblmember" Adodc3.Refresh lbltotalissue.Caption = Adodc1.Recordset.RecordCount 'set the value in the label lbltotalbooks.Caption = Adodc2.Recordset.RecordCount lbltotalmem.Caption = Adodc3.Recordset.RecordCount If Adodc2.Recordset.RecordCount <> 0 Then 'if the recorset is not empty Adodc2.Recordset.MoveFirst 'move to first record While Not Adodc2.Recordset.EOF 'until eof cost = Adodc2.Recordset.Fields(8) + cost 'sum up all the data in the specified field Adodc2.Recordset.MoveNext 'move to next record Wend 'repeat End If lblprice.Caption = "Rs. " & cost For i = 1 To 10 cmblevel.AddItem i 'populate the data in combo Next i cmblevel.AddItem "Teachers and Staffs" End Sub Private Sub optlevel_Click() fradet.Visible = False 'show the frame fralevel.Visible = True 'hide the frame End Sub Private Sub optwhole_Click() fradet.Visible = True fralevel.Visible = False End Sub
Bishwanath Parajuli
342
frmovmem: Private Sub chklist_Click() If chklist.Value = vbChecked Then 'if checkbox is checked DTPicker.Enabled = True 'enable datpicker lsvmem.ListItems.clear 'clear listview ElseIf chklist.Value = vbUnchecked Then 'if checkbox is unchecked DTPicker.Enabled = False 'disable datpicker DTPicker.Refresh 'refresh it DTPicker.Value = VBA.Date 'set datapicker in system date lsvmem.ListItems.clear Call listdatas 'call function End If End Sub Private Sub DTPicker_Change() 'This procedure compares the data with the date selected 'alters the color of the text 'if the data have value of 9th field less than date selected lsvmem.ListItems.clear 'clear list view If mrecord.RecordCount <> 0 Then 'if recordset is not empty Dim lstitem As ListItem 'declare lstitem as listview's items mrecord.MoveFirst 'move to first record While Not mrecord.EOF 'until eof Set lstitem = lsvmem.ListItems.add(, , mrecord!id) 'set the value of first column header 'add the data into the field from specified recordset lstitem.SubItems(1) = mrecord.Fields(1) lstitem.SubItems(2) = mrecord.Fields(2) lstitem.SubItems(3) = mrecord.Fields(3) lstitem.SubItems(4) = mrecord.Fields(9) If mrecord.Fields(9) < DTPicker Then 'if value of datepicker is less than field's value 'specify the text and font's color lstitem.SubItems(5) = "MEMBERSHIP EXPIRED." lstitem.ForeColor = vbRed lstitem.ListSubItems(1).ForeColor = vbRed lstitem.ListSubItems(2).ForeColor = vbRed lstitem.ListSubItems(3).ForeColor = vbRed lstitem.ListSubItems(4).ForeColor = vbRed lstitem.ListSubItems(5).ForeColor = vbRed Else Bishwanath Parajuli 343
lstitem.SubItems(5) = "Valid till today." End If mrecord.MoveNext 'move to next record Wend 'repeat End If End Sub Private Sub Form_Load() 'This procedure configure ADODB Call connection 'call functions Call memeberrecset Call listdatas DTPicker.Enabled = False 'disable datapicker End Sub Sub listdatas() 'This procedure list the data into the list view If mrecord.RecordCount <> 0 Then 'if recordset is not empty Dim lstitem As ListItem 'declare lstitem as listview's items mrecord.MoveFirst 'move to first record While Not mrecord.EOF 'until eof Set lstitem = lsvmem.ListItems.add(, , mrecord!id) 'set the value of first column header 'add the data into the field from specified recordset lstitem.SubItems(1) = mrecord.Fields(1) lstitem.SubItems(2) = mrecord.Fields(2) lstitem.SubItems(3) = mrecord.Fields(3) lstitem.SubItems(4) = mrecord.Fields(9) If mrecord.Fields(9) < VBA.Date Then 'if value of datepicker is less than field's value 'specify the text and font's color lstitem.SubItems(5) = "MEMBERSHIP EXPIRED." lstitem.ForeColor = vbRed lstitem.ListSubItems(1).ForeColor = vbRed lstitem.ListSubItems(2).ForeColor = vbRed lstitem.ListSubItems(3).ForeColor = vbRed lstitem.ListSubItems(4).ForeColor = vbRed lstitem.ListSubItems(5).ForeColor = vbRed Else lstitem.SubItems(5) = "Valid till today." End If mrecord.MoveNext Wend End If End Sub Bishwanath Parajuli 344
Private Sub lsvmem_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader) 'This procedure toggles the clicked column's sort order 'only if the active column is clicked If (lsvmem.SortKey = ColumnHeader.Index - 1) Then ColumnHeader.Tag = Not Val(ColumnHeader.Tag) End If 'set sort order to that of the respective ListSortOrderConstants value lsvmem.SortOrder = Abs(Val(ColumnHeader.Tag)) 'get the zero-based index of the clicked column. lsvmem.SortKey = ColumnHeader.Index - 1 'sort the column lsvmem.Sorted = True End Sub
Bishwanath Parajuli
345
frmprefer: Private Sub cmdapply_Click() 'This procedure changes the data in the specified field If srecord.RecordCount <> 0 Then 'if recorset is not empty srecord.MoveFirst 'move to first record While Not srecord.EOF 'until eof srecord.Delete 'delete the record srecord.MoveNext 'move to next record Wend 'repeat End If srecord.AddNew 'add new record If Me.chkbook.Value = vbChecked Then 'if checkbox is checked srecord.Fields(0) = "Yes" 'set field value to Yes ElseIf Me.chkbook.Value = vbUnchecked Then 'if checkbox is unchecked srecord.Fields(0) = "No" 'set field value to No End If If Me.chkmem.Value = vbChecked Then srecord.Fields(1) = "Yes" ElseIf Me.chkmem.Value = vbUnchecked Then srecord.Fields(1) = "No" End If If Me.chkcompaq.Value = vbChecked Then srecord.Fields(2) = "Yes" ElseIf Me.chkcompaq.Value = vbUnchecked Then srecord.Fields(2) = "No" End If If Me.chkinform.Value = vbChecked Then srecord.Fields(3) = "Yes" ElseIf Me.chkinform.Value = vbUnchecked Then srecord.Fields(3) = "No" End If If Me.chkcreate.Value = vbChecked Then srecord.Fields(4) = "Yes" ElseIf Me.chkcreate.Value = vbUnchecked Then srecord.Fields(4) = "No" End If srecord.Update 'save the record Unload Me 'close the form End Sub
Bishwanath Parajuli
346
Private Sub cmdcancel_Click() Unload Me 'close the form End Sub Private Sub Form_Load() 'This procedure configures ADODB connection 'and configures check boxes according to the value of field Call connection 'call function Call preferrecset If srecord.Fields(0) = "Yes" Then 'if field value to Yes Me.chkbook.Value = vbChecked 'check the checkbox ElseIf srecord.Fields(0) = "No" Then 'if field value to No Me.chkbook.Value = vbUnchecked 'uncheck the checkbox End If If srecord.Fields(1) = "Yes" Then Me.chkmem.Value = vbChecked ElseIf srecord.Fields(1) = "No" Then Me.chkmem.Value = vbUnchecked End If If srecord.Fields(2) = "Yes" Then Me.chkcompaq.Value = vbChecked ElseIf srecord.Fields(2) = "No" Then Me.chkcompaq.Value = vbUnchecked End If If srecord.Fields(3) = "Yes" Then Me.chkinform.Value = vbChecked ElseIf srecord.Fields(3) = "No" Then Me.chkinform.Value = vbUnchecked End If If srecord.Fields(4) = "Yes" Then Me.chkcreate.Value = vbChecked ElseIf srecord.Fields(4) = "No" Then Me.chkcreate.Value = vbUnchecked End If End Sub
Bishwanath Parajuli
347
frmpubnauth: Dim code As Integer Private Sub cmbcode_Click() 'This procedure adds item to combobox tabs.Enabled = True 'enable tab control If precord.RecordCount <> 0 Then 'if the record set is not empty precord.MoveFirst 'move to first record While Not precord.EOF 'until eof If precord.Fields(0) = cmbcode Then 'if field value and combo matches lbltitle.Caption = precord.Fields(1) 'set label with the data in field tabs.SetFocus 'shift focus End If precord.MoveNext 'move to next record Wend 'repeat End If End Sub Private Sub cmdauth_Click() cmdauth.Visible = False 'hide object cmdpub.Visible = True 'show object authgrid.Visible = True pubgrid.Visible = False End Sub Private Sub cmdbeginauth_Click() 'This procedure moves pointer to first record On Error GoTo errhandle If bdrecord.BOF = True Then 'if the record pointer is at bof then MsgBox "This is First record", vbInformation, "Information" bdrecord.MoveFirst 'move record pointer to first record Exit Sub ElseIf bdrecord.AbsolutePosition = adPosBOF Then 'if absolute position of the record is at bof then bdrecord.MoveFirst 'move record pointer to last record Exit Sub Else Call viewdataauth 'call the function bdrecord.MoveFirst 'move pointer to first record Bishwanath Parajuli 348
End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdbeginpub_Click() 'This procedure moves pointer to first record On Error GoTo errhandle If brecord.BOF = True Then 'if the record pointer is at bof MsgBox "This is First record", vbInformation, "Information" brecord.MoveFirst 'move record pointer to first record Exit Sub ElseIf brecord.AbsolutePosition = adPosBOF Then 'if absolute position of the record is at bof then brecord.MoveFirst 'move record pointer to last record Exit Sub Else Call viewdatapub 'call the function brecord.MoveFirst 'move pointer to first record End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdcancel_Click() 'This procedure deletes the space reserved for saving new record 'created during addnew process brecord.CancelUpdate tabs.TabVisible(0) = True 'show the tabs tabs.TabVisible(2) = True Call disable 'call functions Call checkpubrecords End Sub Private Sub cmdcancelauth_Click() 'This procedure deletes the space reserved for saving new record 'created during addnew processbdrecord.CancelUpdate tabs.TabVisible(1) = True 'show the tabs tabs.TabVisible(2) = True Bishwanath Parajuli 349
Call disable 'call functions Call checkauthrecords End Sub Private Sub cmddelete_Click() 'This procedure deletes the record from the specified recordset Dim recno As String 'declare variable recno = InputBox("Enter the code or name of the author, you want to delete?", "Delete") 'allow the user to enter the data into inputbox If recno <> "" Then 'if inputbox wasn't empty If bdrecord.RecordCount <> 0 Then 'if the recordset is not empty bdrecord.MoveFirst 'move to first record While Not bdrecord.EOF 'until eof If bdrecord.Fields(0) = recno Or bdrecord.Fields(1) = recno Then 'if field value and the variable match bdrecord.Delete 'delete the record timeauth.Enabled = True 'enable timer Call checkpubrecords 'call functions Call clear MsgBox "Author Deleted.", vbInformation, "Deleted" End If bdrecord.MoveNext 'move to next record Wend 'repeat End If End If End Sub Private Sub cmddeletep_Click() 'This procedure deletes the record from the specified recordset Dim codeno As String 'declare variable codeno = InputBox("Enter the code or name of the publisher, you want to delete?", "Delete") 'allow the user to enter the data into inputbox If codeno <> "" Then 'if inputbox wasn't empty If brecord.RecordCount <> 0 Then 'if the recordset is not empty brecord.MoveFirst 'move to first record While Not brecord.EOF 'until eof If brecord.Fields(0) = codeno Or brecord.Fields(1) = codeno Then 'if field value and the variable match brecord.Delete 'delete the record timepub.Enabled = True 'enable timer Bishwanath Parajuli 350
Call checkpubrecords 'call functions MsgBox "Publisher Deleted.", vbInformation, "Deleted" End If brecord.MoveNext 'move to next record Call clear Wend 'repeat End If End If End Sub Private Sub cmdlastauth_Click() 'This procedure moves pointer to last record On Error GoTo errhandle If bdrecord.EOF = True Then 'if record pointer is at eof then MsgBox "This is Last record", vbInformation, "Information" bdrecord.MoveLast 'move record pointer to last record Exit Sub Else Call viewdataauth 'call function bdrecord.MoveLast 'move record pointer to last record End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdlastpub_Click() 'This procedure moves pointer to last record On Error GoTo errhandle If brecord.EOF = True Then 'if record pointer is at eof then MsgBox "This is Last record", vbInformation, "Information" brecord.MoveLast 'move record pointer to last record Exit Sub Else Call viewdatapub 'call function brecord.MoveLast 'move record pointer to last record End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Bishwanath Parajuli 351
Private Sub cmdmodifyauthor_Click() 'This procedure modify's the data related to "author" On Error GoTo errhandle: If bdrecord.RecordCount <> 0 Then 'if the recordset is not empty If MsgBox("Are you sure you want to modify the record?", vbYesNo) = vbYes Then bdrecord.MoveFirst 'move to first record While Not bdrecord.EOF 'until eof If bdrecord.Fields(0) = lblauthid Then 'compare the field and label and if matched 'set label with the data in the textboxes spcified below bdrecord.Fields(1) = txtauthname bdrecord.Fields(2) = txtauthcontact bdrecord.Fields(3) = txtcountry bdrecord.Update 'save the record MsgBox "Record updated.", vbInformation End If bdrecord.MoveNext 'move to next record Wend 'repeat End If End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdmodifypublisher_Click() 'This procedure modify's the data related to "publisher" On Error GoTo errhandle: If brecord.RecordCount <> 0 Then 'if the recordset is not empty If MsgBox("Are you sure you want to modify the record?", vbYesNo) = vbYes Then brecord.MoveFirst 'move to first record While Not brecord.EOF 'until eof If brecord.Fields(0) = lblauthid Then 'compare the field and label and if matched 'set label with the data in the textboxes spcified below brecord.Fields(1) = txtauthname brecord.Fields(2) = txtauthcontact brecord.Update 'save the record MsgBox "Record updated.", vbInformation End If brecord.MoveNext 'move to next record Bishwanath Parajuli 352
Wend 'repeat End If End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdnewauth_Click() 'This procedure creates space for adding new data 'and creates a value of keyfield On Error GoTo errhandle: Call clear 'call function Call enable If bdrecord.RecordCount = 0 Then 'if the recordset is empty code = 401 'set code = 401 Else bdrecord.MoveLast 'else move to last record code = bdrecord.Fields(0) + 1 'increase code by 1 compared to the last data End If lblauthid = code 'set code in label bdrecord.AddNew 'allow to add new record tabs.TabVisible(1) = False 'hide the tabs tabs.TabVisible(2) = False txtauthname.SetFocus 'shift focus Exit Sub 'exit errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdnewauth_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed Me.txtauthname.SetFocus 'shift focus End If End Sub Private Sub cmdnewpub_Click() 'This procedure creates space for adding new data 'and creates a value of keyfield Call clear 'call function If brecord.RecordCount = 0 Then 'if the recordset is empty code = 501 'set code = 401 Else Bishwanath Parajuli 353
brecord.MoveLast 'else move to last record code = brecord.Fields(0) + 1 'increase code by 1 compared to the last data End If brecord.AddNew 'allow to add new record lblpubid = code 'set code in label Call enable tabs.TabVisible(0) = False 'hide the tabs tabs.TabVisible(2) = False txtpubname.SetFocus 'shift focus End Sub Private Sub cmdnewpub_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Me.txtpubname.SetFocus End If End Sub Private Sub cmdnextauth_Click() 'This procedure moves pointer to relative next record On Error GoTo errhandle If bdrecord.AbsolutePosition = adPosBOF Then 'if absolute position of the record is at bof then bdrecord.MoveLast 'move record pointer to last record Exit Sub ElseIf bdrecord.EOF = True Then 'if recordpointer is at eof then MsgBox "This is Last record", vbInformation, "Information" bdrecord.MoveLast 'move to last record Exit Sub Else Call viewdataauth 'call function bdrecord.MoveNext 'move record pointer to next record End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdnextpub_Click() 'This procedure moves pointer to relative next record On Error GoTo errhandle If brecord.AbsolutePosition = adPosBOF Then 'if absolute position of the record is at bof then brecord.MoveLast 'move record pointer to last record Bishwanath Parajuli 354
Exit Sub ElseIf brecord.EOF = True Then 'if recordpointer is at eof then MsgBox "This is Last record", vbInformation, "Information" brecord.MoveLast 'move to last record Exit Sub Else Call viewdatapub 'call function brecord.MoveNext 'move record pointer to next record End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdpreviousauth_Click() 'This procedure moves pointer to relative previous record On Error GoTo errhandle If bdrecord.AbsolutePosition = adPosEOF Then 'if record pointer is at eof then bdrecord.MoveFirst 'move record pointer to first record Exit Sub ElseIf bdrecord.BOF = True Then 'if record pointer is at bof MsgBox "This is First record", vbInformation, "Information" bdrecord.MoveFirst 'move to first record Exit Sub Else Call viewdataauth 'call function bdrecord.MovePrevious 'move record pointer to previous record End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdpreviouspub_Click() 'This procedure moves pointer to relative previous record On Error GoTo errhandle If brecord.AbsolutePosition = adPosEOF Then 'if record pointer is at eof then brecord.MoveFirst 'move record pointer to first record Exit Sub Bishwanath Parajuli 355
ElseIf brecord.BOF = True Then 'if record pointer is at bof MsgBox "This is First record", vbInformation, "Information" brecord.MoveFirst 'move to first record Exit Sub Else Call viewdatapub 'call function brecord.MovePrevious 'move record pointer to previous record End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdpub_Click() 'show/hide controls cmdauth.Visible = True cmdpub.Visible = False authgrid.Visible = False pubgrid.Visible = True End Sub Private Sub cmdsaveauth_Click() 'This procedure saves the specified data into the database On Error GoTo errhandle: If cmbcode.Text = "" Or txtauthname = "" Or txtcountry = "" Then 'if the combo, textboxes are empty MsgBox "Please enter all the fields.", vbExclamation, "Error" Exit Sub 'exit End If 'set the value of label into field bdrecord.Fields(0) = lblauthid bdrecord.Fields(1) = txtauthname bdrecord.Fields(2) = txtauthcontact bdrecord.Fields(3) = txtcountry bdrecord.Fields(4) = Int(cmbcode.Text) bdrecord.Update 'save the record timeauth.Enabled = True 'enable timer MsgBox "New Author Saved.", vbInformation, "Library Management" Call clear 'call function Call disable Bishwanath Parajuli 356
tabs.TabVisible(1) = True 'show tabs tabs.TabVisible(2) = True Call checkauthrecords cmdnewauth.SetFocus 'shift focus Exit Sub errhandle: MsgBox Err.Description, vbCritical, "" End Sub Private Sub cmdsavepub_Click() 'This procedure saves the specified data into the database If txtpubname = "" Or txtpubcontact = "" Or cmbcode.Text = "" Then 'if the combo, textboxes are empty MsgBox "Please enter all the fields.", vbExclamation, "Error" Exit Sub 'exit End If 'set the value of label into field brecord.Fields(0) = lblpubid brecord.Fields(1) = txtpubname brecord.Fields(2) = txtpubcontact brecord.Fields(3) = cmbcode.Text brecord.Update 'save the record timepub.Enabled = True 'enable timer MsgBox "New Publisher Saved.", vbInformation, "Library Management" Call clear 'call function Call disable Call checkpubrecords tabs.TabVisible(0) = True 'show tabs tabs.TabVisible(2) = True cmdnewpub.SetFocus 'shift focus End Sub Private Sub Form_Load() 'This procedure configures ADODC and ADODB connection Call connection 'call function Call author Call publisher Call bookrecset Call checkauthrecords Call checkpubrecords Call cmbbookid
Bishwanath Parajuli
357
adoauth.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" 'configure provider and application path adoauth.CommandType = adCmdUnknown adoauth.RecordSource = "select * from tblauthor" 'specify the recordsource adoauth.Refresh 'refresh adodc adopub.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" adopub.CommandType = adCmdUnknown adopub.RecordSource = "select * from tblpublisher" adopub.Refresh pubgrid.Columns(0).Locked = True 'lock columns of datagrid authgrid.Columns(0).Locked = True Call disable End Sub Sub clear() 'This procedure resets the fields txtauthname = "" txtauthcontact = "" txtpubname = "" txtpubcontact = "" txtcountry = "" End Sub Sub cmbbookid() 'This procedure adds the item to combobox If precord.RecordCount <> 0 Then 'if the recordset is not empty precord.MoveFirst 'move to first record While Not precord.EOF 'until eof cmbcode.AddItem (precord.Fields(0)) 'populate combo precord.MoveNext 'move to next record Wend 'repeat End If End Sub Private Sub tabs_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed If tabs.Caption = "Author Details" Then 'if the tabs caption is as specified Me.cmdnewauth.SetFocus 'shift focus Bishwanath Parajuli 358
ElseIf tabs.Caption = "Publisher Details" Then Me.cmdnewpub.SetFocus End If End If End Sub Private Sub timeauth_Timer() 'This procedure refreshes the datagrid adoauth.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" 'configure provider and application path adoauth.CommandType = adCmdUnknown adoauth.RecordSource = "select * from tblauthor" 'specify the record source adoauth.Refresh 'refresh adodc and datagrid authgrid.Refresh timeauth.Enabled = False 'disable timer Call disable 'call function pubgrid.Columns(0).Locked = True 'lock the columns of datagrid authgrid.Columns(0).Locked = True End Sub Private Sub timepub_Timer() 'This procedure refreshes the datagrid adopub.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" adopub.CommandType = adCmdUnknown adopub.RecordSource = "select * from tblpublisher" adopub.Refresh pubgrid.Refresh timepub.Enabled = False Call disable pubgrid.Columns(0).Locked = True authgrid.Columns(0).Locked = True End Sub Private Sub txtauthcontact_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed txtcountry.SetFocus 'shift focus End If End Sub Private Sub txtauthname_KeyPress(KeyAscii As Integer) Bishwanath Parajuli 359
If KeyAscii = 13 Then txtauthcontact.SetFocus End If End Sub Private Sub txtauthname_LostFocus() 'This procedure checks if the record exist already On Error GoTo errhandle: If bdrecord.RecordCount <> 0 Then 'if the recordset is not empty If cmdnewauth.Enabled = False Then 'if the command button is disabled bdrecord.CancelUpdate 'cancel the addnew process bdrecord.MoveFirst 'move to first record While Not bdrecord.EOF 'until eof If bdrecord.Fields(1) = txtauthname.Text _ And bdrecord.Fields(4) = cmbcode.Text Then 'if recordset's field and form field match MsgBox "Record already existed.", vbExclamation cmdsaveauth.Enabled = False 'disable button Exit Sub Else cmdsaveauth.Enabled = True 'enable button End If bdrecord.MoveNext 'move to next record Wend 'repeat bdrecord.AddNew 'continue to ADD NEW record End If End If Exit Sub errhandle: MsgBox Err.Description, vbCritical End Sub Private Sub txtpubname_LostFocus() 'This procedure checks if the record exist already If brecord.RecordCount <> 0 Then If cmdnewpub.Enabled = False Then brecord.CancelUpdate 'CANCEL the addnew process brecord.MoveFirst While Not brecord.EOF ' If brecord.Fields(3) = cmbcode.Text And brecord.Fields(1) = txtpubname Then MsgBox "Record already existed.", vbExclamation cmdsavepub.Enabled = False Exit Sub Bishwanath Parajuli 360
Else cmdsavepub.Enabled = True End If brecord.MoveNext Wend brecord.AddNew 'continue to ADD NEW record End If End If End Sub Sub disable() 'This procedure configures the controls cmdnewauth.Enabled = True cmdsaveauth.Enabled = False cmddelete.Enabled = True cmdcancelauth.Enabled = False Me.cmdmodifyauthor.Enabled = True Me.cmdnewpub.Enabled = True Me.cmdsavepub.Enabled = False Me.cmddeletep.Enabled = True Me.cmdmodifypublisher.Enabled = True Me.cmdcancel.Enabled = False End Sub Sub enable() 'This procedure configures the controls cmdnewauth.Enabled = False cmdsaveauth.Enabled = True Me.cmdmodifyauthor.Enabled = False cmddelete.Enabled = False cmdcancelauth.Enabled = True Me.cmdnewpub.Enabled = False Me.cmdsavepub.Enabled = True Me.cmdmodifypublisher.Enabled = False Me.cmddeletep.Enabled = False Me.cmdcancel.Enabled = True End Sub Private Sub txtcountry_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed cmdsaveauth.SetFocus 'shift focus End If End Sub Private Sub txtpubcontact_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Bishwanath Parajuli 361
If txtpubcontact <> "" Then 'if the textbox is not empty If InStr(1, txtpubcontact, "www.") Or InStr(1, txtpubcontact, ".com") Then 'if the text box contains www. or .com Else txtpubcontact = "www." & txtpubcontact & ".com" End If End If End If End Sub Private Sub txtpubname_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed txtpubcontact.SetFocus 'shift focus End If End Sub Sub viewdataauth() 'This procedure sets the value of fields from database into_ 'specified form fields lblauthid = bdrecord.Fields(0) txtauthname = bdrecord.Fields(1) txtauthcontact = bdrecord.Fields(2) cmbcode.Text = bdrecord.Fields(4) If precord.RecordCount <> 0 Then 'if recordset is not empty precord.MoveFirst 'move to first record While Not precord.EOF 'until eof If precord.Fields(0) = cmbcode.Text Then 'if field and combo value match lbltitle.Caption = precord.Fields(1) 'set the field value into label End If precord.MoveNext 'move to next record Wend 'repeat End If txtcountry = bdrecord.Fields(3) End Sub Sub viewdatapub() 'This procedure sets the value of fields from database into_ 'specified form fields lblpubid = brecord.Fields(0) txtpubname = brecord.Fields(1) txtpubcontact = bdrecord.Fields(2) Bishwanath Parajuli 362
cmbcode.Text = brecord.Fields(3) If precord.RecordCount <> 0 Then precord.MoveFirst While Not precord.EOF If precord.Fields(0) = cmbcode.Text Then lbltitle.Caption = precord.Fields(1) End If precord.MoveNext Wend End If End Sub Sub checkauthrecords() 'This procedure enables/disables navigation buttons If bdrecord.RecordCount = 0 Then 'if the recordset is empty franavigateauth.Enabled = False 'disable the frame Else franavigateauth.Enabled = True End If End Sub Sub checkpubrecords() 'This procedure enables/disables navigation buttons If brecord.RecordCount = 0 Then franavigatepub.Enabled = False Else franavigatepub.Enabled = True End If End Sub
Bishwanath Parajuli
363
frmreminders: Private Sub Form_Load() 'This procedure configures ADODB and add data into listiew Call connection 'call function Call qryissuerecset On Error GoTo errhandle: Dim lstitem As ListItem 'declare lstitem as listview's items If bdrecord.RecordCount <> 0 Then 'if recordset is not empty bdrecord.MoveFirst 'move to first record While Not bdrecord.EOF 'until eof If VBA.Date > bdrecord.Fields(5) Then 'if the field value is less than system date Set lstitem = lstview.ListItems.add(, , bdrecord!Title) 'set the value of first column header lstitem.SubItems(1) = bdrecord.Fields(3) 'set the subitem of the list view End If bdrecord.MoveNext 'move to next record Wend 'repeat End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub lstview_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader) 'This procedure toggles the clicked column's sort order 'only if the active column is clicked If (lstview.SortKey = ColumnHeader.Index - 1) Then ColumnHeader.Tag = Not Val(ColumnHeader.Tag) End If 'set sort order to that of the respective ListSortOrderConstants value lstview.SortOrder = Abs(Val(ColumnHeader.Tag)) 'set the zero-based index of the clicked column. lstview.SortKey = ColumnHeader.Index - 1 'sort the column lstview.Sorted = True End Sub
Bishwanath Parajuli
364
frmreserve: Dim check As Boolean Private Sub chkdet_Click() If chkdet.Value = vbChecked Then 'if the checkbox is checked Me.Height = 6720 'set the height of the window ElseIf chkdet.Value = vbUnchecked Then 'if the checkbox is unchecked Me.Height = 2835 End If End Sub Private Sub cmbbcode_Click() 'This procedure displays the details of the data linked_ 'with the item clicked in the box 'and checks if the "book is avialable" Dim count, countissue As Integer 'declare variables count = 0 countissue = 0 If precord.RecordCount <> 0 Then 'if the recordset is not empty precord.MoveFirst 'move to the first record While Not precord.EOF 'until end of file If precord.Fields(0) = cmbbcode Then If precord.Fields(3) = "Reference" Then 'if the field has the value specified above cmdreserve.Enabled = False 'disable command buttons cmbsid.Enabled = False MsgBox "Reserving a reference book is prohibited.", vbCritical, "Error" Exit Sub 'exit Else cmbsid.Enabled = True 'enable command buttons End If lbltitle.Caption = precord.Fields(1) 'set caption in label from record field End If precord.MoveNext 'move to next record Wend 'repeat End If If precord.RecordCount <> 0 Then Bishwanath Parajuli 365
precord.MoveFirst While Not precord.EOF If precord.Fields(0) = cmbbcode Then 'if the field and combo match 'set the value of field in the variable count count = precord.Fields(4) End If precord.MoveNext Wend End If If bdrecord.RecordCount <> 0 Then bdrecord.MoveFirst While Not bdrecord.EOF If bdrecord.Fields(1) = cmbbcode Then 'if the field data and combo match countissue = countissue + 1 'increase the value of count by 1 End If bdrecord.MoveNext Wend End If If count - countissue > 0 Then 'if the difference is less than 0 MsgBox "This book is available.", vbInformation, "Reservation" Exit Sub End If End Sub Private Sub cmbbcode_GotFocus() cmbsid.Enabled = True 'enable button End Sub Private Sub cmbbcode_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed cmbsid.SetFocus 'shift focus End If End Sub Private Sub cmbsid_Click() 'This procedure displays the details of the data linked_ 'with the item clicked in the box If mrecord.RecordCount <> 0 Then 'if the recordset is not empty Bishwanath Parajuli 366
mrecord.MoveFirst 'move to first record While Not mrecord.EOF 'until end of file If mrecord.Fields(0) = Int(cmbsid) Then 'if the field data and combo data match lblname.Caption = mrecord.Fields(1) & " " & mrecord.Fields(3) 'set the caption in label from record field End If mrecord.MoveNext 'move to next record Wend 'repeat End If Call borrower_check 'call functions Call fine_check Call mem_check End Sub Private Sub cmbsid_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed cmdreserve.SetFocus 'shift focus End If End Sub Private Sub cmdbook_Click() cmdreserved.Visible = True 'show the object cmdbook.Visible = False 'hide the object reservegrid.Visible = False bookgrid.Visible = True End Sub Private Sub cmdcancelres_Click() 'This procedure deletes the record from the table If cmbbcode.Text = "" Or cmbsid.Text = "" Then 'if the combo is empty MsgBox "Select the book and member ID to cancel reservation.", vbExclamation, "Error" Exit Sub 'exit End If If lrecord.RecordCount <> 0 Then 'if the recordset is not empty lrecord.MoveFirst 'move to first record While Not lrecord.EOF 'until eof If lrecord.Fields(1) = cmbbcode.Text And lrecord.Fields(2) = Int(cmbsid.Text) Then 'if the field data and combo data match If MsgBox("Do you want to cancel this reservation?", vbYesNo + vbQuestion, "Cancel Reservation") = vbYes Then Bishwanath Parajuli 367
lrecord.Delete 'delete the record timereserve.Enabled = True 'enable timer MsgBox "Reservation Cancelled.", vbInformation, "Reserve" Exit Sub 'exit Else MsgBox "Reservation cancellation was interrupted before completion.", vbInformation, "Reserve" End If Exit Sub End If lrecord.MoveNext 'move to next record Wend 'repeat End If End Sub Private Sub cmdreserve_Click() 'This procedure adds new record, specifys the value of key field 'and save it Dim code As Integer 'declare variable If cmbbcode.Text = "" Or cmbsid.Text = "" Then 'if the combo is empty MsgBox "Select the IDs.", vbExclamation, "Reservation" Exit Sub 'exit End If If lrecord.RecordCount = 0 Then 'if the recordset is empty code = 601 'set code = 601 Else lrecord.MoveLast 'move to last record code = lrecord.Fields(0) + 1 'set code 1 more than the value of keyfield of last record End If check = True 'set boolean value as true check = check_issue() 'retrive the value of booelan from specified function If check = True Then 'if the boolean value is true Call borrower_check 'call the functions Call fine_check Call mem_check lrecord.AddNew 'allow to addnew record 'set the specified value in corresponding fields lrecord.Fields(0) = code lrecord.Fields(1) = Val(cmbbcode.Text) Bishwanath Parajuli 368
lrecord.Fields(2) = Val(cmbsid.Text) lrecord.Fields(3) = lbldaters.Caption lrecord.Fields(4) = lbldatersc.Caption lrecord.Update 'save the data MsgBox lbltitle & " is reserved.", vbInformation, "Reservation" timereserve.Enabled = True 'enable timer cmdreserve.Enabled = False 'disable buttons cmbsid.Enabled = False Me.cmbbcode.SetFocus 'shift focus to combo End If End Sub Private Sub cmdreserved_Click() cmdreserved.Visible = False 'hide control cmdbook.Visible = Truel 'show control reservegrid.Visible = True bookgrid.Visible = False End Sub Private Sub Form_Load() 'This procedure configures ADODC and ADODB connection Call connection 'call functions Call reserverecset Call bookrecset Call memeberrecset Call issuerecset adobook.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" 'configure provider and application path adobook.CommandType = adCmdUnknown 'select command type adobook.RecordSource = "Select * from tblbookdetails" 'specify the record source adobook.Refresh 'refresh adodc adoreserve.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" adoreserve.CommandType = adCmdUnknown adoreserve.RecordSource = "Select * from tblreserve" adoreserve.Refresh lbldaters.Caption = VBA.Date Bishwanath Parajuli 369
'set system date in the label lbldatersc.Caption = VBA.Date + Day(4) 'set a date 4 days ahead of system date in the label Call cmbid 'call function End Sub Sub cmbid() 'This procedure adds item to combobox If mrecord.RecordCount <> 0 Then 'if the recordset is not empty mrecord.MoveFirst 'move to first record While Not mrecord.EOF 'until eof cmbsid.AddItem (mrecord.Fields(0)) 'populate the combo mrecord.MoveNext 'move to next record Wend 'repeat End If If Me.adobook.Recordset.RecordCount <> 0 Then adobook.Recordset.MoveFirst While Not Me.adobook.Recordset.EOF cmbbcode.AddItem (adobook.Recordset.Fields(0)) adobook.Recordset.MoveNext Wend End If End Sub Sub borrower_check() 'This procedure checks "reserve status of borrower" Dim a, countn As Integer 'declare variable countn = 0 a=0 If lrecord.RecordCount <> 0 Then 'if the recordset is not empty lrecord.MoveFirst 'move to first record While Not lrecord.EOF 'until eof If lrecord.Fields(2) = Int(cmbsid.Text) Then 'if the field value and combo value match countn = countn + 1 'increase the value of countn by 1 End If lrecord.MoveNext 'move to next record Wend 'repeat End If
Bishwanath Parajuli
370
If lrecord.RecordCount <> 0 Then lrecord.MoveFirst While Not lrecord.EOF If lrecord.Fields(1) = cmbbcode.Text And lrecord.Fields(2) = Int(cmbsid.Text) Then 'if the field value and combo value match a=a+1 'increase the value of a by 1 End If lrecord.MoveNext Wend End If If countn >= 3 Then 'if the value of countn is greater and equal to 3 MsgBox "This borrower has already reserved 3 books. Reservation cannot be continued.", vbExclamation, "Reserve" cmdreserve.Enabled = False 'disable control Exit Sub ElseIf countn < 3 Then 'if the value of countn is less than 3 cmdreserve.Enabled = True 'enable control End If If a >= 1 Then MsgBox "A borrower cannot reserve two same book at a time.", vbInformation, "Reservation" cmdreserve.Enabled = False Exit Sub ElseIf a < 1 Then cmdreserve.Enabled = True End If End Sub Sub mem_check() 'This procedure checks "account status of borrower" If mrecord.RecordCount <> 0 Then 'if the recordset is not empty mrecord.MoveFirst 'move to first record While Not mrecord.EOF 'until eof If mrecord.Fields(0) = Int(cmbsid.Text) Then 'compare the value of field and combo and if matched If mrecord.Fields(9) < VBA.Date Then 'if the value of system date is greater than field value cmdreserve.Enabled = False 'disable button
Bishwanath Parajuli
371
If MsgBox("Memebership has expired. Do you want to renew membership?", vbCritical + vbYesNo, "Error") = vbYes Then frmborrowerdetails.display 'call the function related to frmborrowerdetails frmborrowerdetails.Show 'show frmborrowerdetails Me.Hide 'hide the form Exit Sub 'exit Else MsgBox "Reservation Failed.", vbCritical, "Error" End If Exit Sub End If End If mrecord.MoveNext 'move to next record Wend 'repeat End If End Sub Sub fine_check() 'This procedure checks "due status of borrower" If bdrecord.RecordCount <> 0 Then 'if the recordset is not empty bdrecord.MoveFirst 'move to first record While Not bdrecord.EOF 'until eof If bdrecord.Fields(2) = Int(cmbsid) Then 'if field value and combo value match If bdrecord.Fields(4) < VBA.Date Then 'if field value is less than system date cmdreserve.Enabled = False 'disable object If MsgBox("This borrower has fine to pay. Do you want to fine him/her?.", vbYesNo, "Issue") = vbYes Then Me.Hide 'hide form frmrnunreturn.Show 'show frmrnunreturn frmrnunreturn.cmdrenew.Enabled = False 'disable object frmrnunreturn.cmdreturn.Enabled = False Exit Sub 'exit Else MsgBox "This borrower can reserve no more books.", vbExclamation, "Error" End If Exit Sub End If End If bdrecord.MoveNext 'move to next record Bishwanath Parajuli 372
Wend 'repeat End If End Sub Function check_issue() As Boolean 'This procedure if the record exist in the next recordset If bdrecord.RecordCount <> 0 Then 'if the recordset is not empty bdrecord.MoveFirst 'move to first record While Not bdrecord.EOF 'until eof If bdrecord.Fields(1) = Me.cmbbcode And bdrecord.Fields(2) = Me.cmbsid Then 'match combo value and field value check_issue = False 'set the value of boolean to false MsgBox "This book has already been issued by the reserver.", vbExclamation, "Reservation" Exit Function 'exit Else check_issue = True 'set the boolean value to true End If bdrecord.MoveNext 'move to next record Wend 'repeat End If End Function Private Sub timereserve_Timer() 'This procedure refreshes the datagrid reservegrid.Refresh 'refresh grid adoreserve.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" 'configure provider and application path adoreserve.CommandType = adCmdUnknown adoreserve.RecordSource = "Select * from tblreserve" 'specify the record source adoreserve.Refresh 'refresh adodc reservegrid.Refresh timereserve.Enabled = False 'disable timer End Sub
Bishwanath Parajuli
373
frmrnunreturn: Dim find As Integer 'declare variables Dim idcheck As Boolean Private Sub chkdetails_Click() If chkdetails.Value = vbChecked Then 'if the checkbox is checked Me.Height = 7420 'set the value of the window height ElseIf chkdetails.Value = vbUnchecked Then 'if the checkbox is unchecked Me.Height = 2645 End If End Sub Private Sub cmbbrid_Click() 'This procedure displays the details of the data linked_ 'with the item clicked in the box On Error GoTo errhandler: If mrecord.RecordCount <> 0 Then 'if the recordset is not empty mrecord.MoveFirst 'move to first record While Not mrecord.EOF 'until eof If mrecord.Fields(0) = cmbbrid.Text Then 'if the field value and combo value match 'set the data from field into label lblfname.Caption = mrecord.Fields(1) lblmname.Caption = mrecord.Fields(2) lblsname.Caption = mrecord.Fields(3) lblcontact.Caption = mrecord.Fields(6) lblexpiry.Caption = mrecord.Fields(9) imgpic = LoadPicture(App.Path & "/" & mrecord.Fields(10)) 'load image End If mrecord.MoveNext 'move to next record Wend 'repeat End If Call check_expire 'call function Exit Sub 'exit errhandler: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmbbrid_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed Bishwanath Parajuli 374
Me.cmbcode.SetFocus 'shift focus End If End Sub Private Sub cmbcode_Click() 'This procedure displays the details of the data linked_ 'with the item clicked in the box On Error GoTo errhandle Dim lstitem As ListItem 'declare lstitem as listview's items If precord.RecordCount <> 0 Then 'if the recordset is not empty precord.MoveFirst 'move to first record While Not precord.EOF 'until eof If precord.Fields(0) = cmbcode.Text Then 'if the field value and combo value match lbltitle.Caption = precord.Fields(1) 'set the field value into label caption End If precord.MoveNext 'move to next record Wend 'repeat End If Call list 'call function Exit Sub 'exit errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmbcode_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if enter is pressed If Me.cmdrenew.Visible = True Then 'if the specified command button is visible cmdrenew.SetFocus 'shift focus ElseIf Me.cmdreturn.Visible = True Then cmdreturn.SetFocus End If End If End Sub Private Sub cmdcollect_Click() 'This procedure adds new record, specifys key field and saves it Dim code As Integer 'declare variable If brecord.RecordCount = 0 Then 'if the recordset is empty code = 11 'set specified code value Else Bishwanath Parajuli 375
brecord.MoveLast 'move to last record code = brecord.Fields(0) + 1 'increase the value of code by 1 compared to the last record End If If lblfine.Caption <> "" Then 'if the label is not empty brecord.AddNew 'allow to add new record 'set the data into specified field of record source brecord.Fields(0) = code brecord.Fields(1) = cmbcode brecord.Fields(2) = cmbbrid.Text brecord.Fields(3) = lbloverdate.Caption brecord.Fields(4) = lblfine brecord.Update 'save the data End If If bdrecord.RecordCount <> 0 Then 'if the recordset is not empty bdrecord.MoveFirst 'move to first record While Not bdrecord.EOF 'until eof If bdrecord.Fields(1) = cmbcode.Text And bdrecord.Fields(2) = cmbbrid.Text Then 'if the combo's content and field value match If MsgBox("This book has crossed its due date.Do you want to fine it?", vbExclamation + vbYesNo, "Fine") = vbYes Then bdrecord.Delete 'DELETE the record Call history 'call the fucntion cmdrenew.Enabled = True 'enable control cmdreturn.Enabled = True MsgBox "Book ready for issuing.", vbInformation, "Fine" Call restructure 'call the fucntion End If End If bdrecord.MoveNext 'move to next record Wend 'repeat End If End Sub Private Sub cmdrenew_Click() 'This procedure changes the existing record Dim find As Integer idcheck = False 'set the boolean value to false
Bishwanath Parajuli
376
idcheck = checkid() 'find the value of boolean by comparing with the function If idcheck = False Then 'if the function returns with value false then If bdrecord.RecordCount <> 0 Then 'if the recordset is not empty bdrecord.MoveFirst 'move to first record While Not bdrecord.EOF 'until eof If bdrecord.Fields(1) = cmbcode.Text And bdrecord.Fields(2) = cmbbrid.Text Then 'if the combo's content and field value match If bdrecord.Fields(7) = "Fiction" Then 'if the field value is as specified bdrecord.Fields(4) = VBA.Date + Day(14) 'set the value of field 14 days ahead of system date bdrecord.Update 'save the data ElseIf bdrecord.Fields(7) = "Non Fiction" Then bdrecord.Fields(4) = VBA.Date + Day(7) bdrecord.Update ElseIf bdrecord.Fields(7) = "Periodical" Then bdrecord.Fields(4) = VBA.Date + Day(7) bdrecord.Update End If Call list 'call the function MsgBox "Book Renewed Sucessfully.", vbInformation, "Renew" cmbbrid.SetFocus 'shift focus Exit Sub 'exit End If bdrecord.MoveNext 'move to next record Wend 'repeat End If End If End Sub Private Sub cmdreturn_Click() 'This procedure deletes the record idcheck = False 'set the boolean value to false idcheck = checkid() 'find the value of boolean by comparing with the function If idcheck = False Then 'if the function returns with value false then If bdrecord.RecordCount <> 0 Then 'if the recordset is not empty bdrecord.MoveFirst 'move to first record While Not bdrecord.EOF 'until eof Bishwanath Parajuli 377
If bdrecord.Fields(1) = Val(cmbcode) And bdrecord.Fields(2) = cmbbrid.Text Then 'if the combo's content and field value match If MsgBox("Are you sure you have received the book?", vbInformation + vbYesNo, "Return") = vbYes Then bdrecord.Delete 'delete the record Call history 'call function MsgBox "Book Returning process Completed.", vbInformation, "Information" cmbbrid.SetFocus 'shift focus Else MsgBox "Return is cancelled.", vbInformation, "Error" cmbbrid.SetFocus Exit Sub End If End If bdrecord.MoveNext 'move to next record Wend 'repeat End If End If End Sub Private Sub Form_KeyPress(KeyAscii As Integer) If KeyPress = 27 Then 'if delete is pressed frmlinker.Show 'show form End If End Sub Private Sub Form_Load() 'This procedure configures ADODB and adds item into combo box Call connection 'call functions Call memeberrecset Call bookrecset Call reserverecset Call issuerecset Call restructure Call historyrecset Call finerecset cmbbrid.clear 'clear the combo If mrecord.RecordCount <> 0 Then 'if the recordset is not empty mrecord.MoveFirst 'move to first record While Not mrecord.EOF 'until eof Bishwanath Parajuli 378
cmbbrid.AddItem mrecord.Fields(0) 'populate combo mrecord.MoveNext 'move to next record Wend 'repeat End If cmbcode.clear If precord.RecordCount <> 0 Then precord.MoveFirst While Not precord.EOF cmbcode.AddItem precord.Fields(0) precord.MoveNext Wend End If End Sub Function checkid() As Boolean 'This procedure checks for "current status of borrower" If cmdrenew.Visible = True And cmdreturn.Visible = False Then 'if the specified control is visible If lrecord.RecordCount <> 0 Then 'if the recordset is not empty lrecord.MoveFirst 'move to first record While Not lrecord.EOF 'until eof If lrecord.Fields(1) = cmbcode Then 'if the field value and the combo content match MsgBox "This book has been reserved. Renew cannot continue", vbExclamation, "Reserved" checkid = True 'set boolean value to true cmdrenew.Enabled = False 'disable command button Exit Function 'exit Else cmdrenew.Enabled = True 'enable command button End If lrecord.MoveNext 'move to next record Wend 'repeat End If End If If bdrecord.RecordCount <> 0 Then bdrecord.MoveFirst While Not bdrecord.EOF If bdrecord.Fields(1) = Val(cmbcode.Text) And bdrecord.Fields(2) = cmbbrid.Text Then Bishwanath Parajuli 379
Call finecalc 'call the function If bdrecord.Fields(4) < VBA.Date Then 'if the field value is older than system date checkid = True 'set boolean value to true If MsgBox("This borrower has fine of Rs. " & lblfine.Caption & " .Do you want to Fine him/her?", vbExclamation + vbYesNo, "Renew/Return") = vbYes Then cmdreturn.Enabled = False 'disable objects cmdrenew.Enabled = False Call structure 'call function Exit Function 'exit Else cmdrenew.Enabled = False cmdreturn.Enabled = False MsgBox "Renew/return process cannot not be completed", vbCritical, "Renew/Return" Exit Function End If Else cmdrenew.Enabled = True 'enable objects cmdreturn.Enabled = True End If Exit Function End If bdrecord.MoveNext 'move to next record Wend 'repeat End If End Function Sub check_expire() 'This procedure checks for "memebership expiry" If mrecord.RecordCount <> 0 Then 'if the recordset is not empty mrecord.MoveFirst 'move to first record While Not mrecord.EOF 'until eof If mrecord.Fields(0) = cmbbrid.Text Then 'if the field value and the combo content match If mrecord.Fields(9) < VBA.Date Then 'if the field value is older than system date cmdreturn.Enabled = False 'disable controls cmdrenew.Enabled = False If MsgBox("Memebership has expired. Do you want to renew membership?", vbCritical + vbYesNo, "Error") = vbYes Then Me.Hide 'hide the form frmborrowerdetails.Show 'show form Bishwanath Parajuli 380
frmborrowerdetails.display 'call the form's function Else MsgBox "Returning/Renewing process couldnot be completed", vbCritical, "Error" End If Exit Sub 'exit Else cmdreturn.Enabled = True 'enable objects cmdrenew.Enabled = True Exit Sub End If End If mrecord.MoveNext 'move to next record Wend 'repeat End If End Sub Sub restructure() 'This procedure resizes the form frafine.Visible = False 'hide objects imgexc.Visible = False frmrnunreturn.frabook.Left = 2280 'set window width End Sub Sub structure() 'This procedure resizes the form imgexc.Visible = True 'show objects frafine.Visible = True frabook.Left = 120 'set window width End Sub Sub finecalc() 'This procedure manipulates difference between "date of issue" and system date Dim X, Y As String 'declare variables Dim dater As Date dater = bdrecord.Fields(4) 'set variable with system date X = (Year(dater) * 365) + (Month(dater) * 30) + Day(dater) Y = (Year(VBA.Date) * 365) + (Month(VBA.Date) * 30) + Day(VBA.Date) 'convert the system date and date in field to numerical form Select Case (Y - X) 'calculate difference Case Is < 1 'if the difference is less than 1 lbloverdate.Caption = 0 & " Day" Bishwanath Parajuli 381
'set specified label caption Case 1 'if the difference is 1 lbloverdate.Caption = 1 & " Day" Case Is > 1 'if the difference is more than 1 lbloverdate.Caption = (Y - X) & " Days" End Select Select Case (Y - X) 'calculate difference Case Is <= 0 'if the difference is less than equal to 0 lblfine.Caption = "" 'leave label caption blank Case Is < 7 'if the difference is less than 7 lblfine.Caption = (Y - X) * 2 Case Is >= 7 'if the difference is greater than equal to 7 lblfine.Caption = (7 * 2 + (Y - X - 7) * 5) End Select End Sub Sub list() 'This procedure populates the data into listview 'and modifys text color, by comparing the data with system date, if necessary If bdrecord.RecordCount <> 0 Then 'if the recordset is not empty bdrecord.MoveFirst 'move to first record While Not bdrecord.EOF 'until eof If bdrecord.Fields(1) = Val(cmbcode.Text) And _ bdrecord.Fields(2) = Val(cmbbrid.Text) Then 'if field value and combo content matches lstview.ListItems.clear 'clear listview Set lstitem = lstview.ListItems.add(, , bdrecord! BookCode) 'set the header of the list view 'set the subitems for list view from field value lstitem.SubItems(3) = bdrecord.Fields(2) lstitem.SubItems(5) = bdrecord.Fields(3) lstitem.SubItems(6) = bdrecord.Fields(4) lstitem.SubItems(7) = bdrecord.Fields(5) If precord.RecordCount <> 0 Then precord.MoveFirst While Not precord.EOF If precord.Fields(0) = cmbcode.Text Then 'set the subitems for list view from field value lstitem.SubItems(1) = precord.Fields(1) Bishwanath Parajuli 382
lstitem.SubItems(2) = precord.Fields(3) End If precord.MoveNext Wend End If If mrecord.RecordCount <> 0 Then mrecord.MoveFirst While Not mrecord.EOF If mrecord.Fields(0) = cmbbrid.Text Then 'set the subitems for list view from field value lstitem.SubItems(4) = mrecord.Fields(1) & " " & mrecord.Fields(2) & " " & mrecord.Fields(3) End If mrecord.MoveNext Wend End If If bdrecord.Fields(4) < VBA.Date Then 'if the field value is less than system date 'specify the color of the text lstitem.ForeColor = vbRed lstitem.ListSubItems(1).ForeColor = vbRed lstitem.ListSubItems(2).ForeColor = vbRed lstitem.ListSubItems(3).ForeColor = vbRed lstitem.ListSubItems(4).ForeColor = vbRed lstitem.ListSubItems(5).ForeColor = vbRed lstitem.ListSubItems(6).ForeColor = vbRed lstitem.ListSubItems(7).ForeColor = vbRed End If lbldatei.Caption = bdrecord.Fields(3) 'set the label caption from field value lbldater.Caption = bdrecord.Fields(4) Exit Sub Else lstview.ListItems.clear 'clear list view lbldatei.Caption = "Book is Not issued" lbldater.Caption = "Book is Not issued" End If bdrecord.MoveNext 'move to next record Wend 'repeat End If End Sub Sub history() 'This procedure adds record, specifys the key field and saves the data Bishwanath Parajuli 383
Dim code As Integer 'declare variable If hrecord.RecordCount = 0 Then 'if the recordset is empty code = 11 'set code = 11 Else hrecord.MoveLast 'move to last record code = hrecord.Fields(0) + 1 'increase the value of code by 1 compared to last record End If hrecord.AddNew 'allow to addnew record 'set the value of record field from specified form fields hrecord.Fields(0) = code hrecord.Fields(1) = cmbcode.Text hrecord.Fields(2) = cmbbrid.Text hrecord.Fields(3) = lbldatei.Caption hrecord.Fields(4) = VBA.Date If bdrecord.RecordCount <> 0 Then 'if the recordset is not empty bdrecord.MoveFirst 'move to first record While Not bdrecord.EOF 'until eof If bdrecord.Fields(1) = cmbcode Then 'if the field value and combo content match hrecord.Fields(5) = bdrecord.Fields(5) 'set the field value from specified record source End If bdrecord.MoveNext 'move to next record Wend 'repeat End If hrecord.Update 'save the record End Sub Private Sub mnulinker_Click() Unload Me 'unload form frmlinker.Show 'show the form End Sub
Bishwanath Parajuli
384
frmsearch: Option Explicit Private Sub cmdsearch_Click() 'This procedure searches the data search data On Error GoTo errorhandling: If txtsearch = "" And cmbtype = "" Then MsgBox "Select a data to search.", vbExclamation, "Search" Exit Sub End If 'if any option is selected 'configure ADODC control accordingly 'display the data in the datagrid If optissue.Value = True Then 'if the specified option button is selected If optdatei.Value = True Then Call textboxvisible 'call function Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from qryissue where Date_of_Issue = Cdate('" & txtsearch & "')" 'specify the data source and the field Adodc1.Refresh 'refresh adodc ElseIf optdater.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from qryissue where Returning_Date = Cdate('" & txtsearch & "')" Adodc1.Refresh Else MsgBox "Select the means of searching issue details.", vbOKOnly, "Search" End If ElseIf optbook.Value = True Then If optbid.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblbookdetails where Book_Code = int('" & txtsearch & "')" Adodc1.Refresh ElseIf optbtitle.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblbookdetails where Title = ('" & txtsearch & "')" Bishwanath Parajuli 385
Adodc1.Refresh ElseIf opttype.Value = True Then Call combovisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblbookdetails where Type_of_Book = ('" & cmbtype & "')" Adodc1.Refresh ElseIf optisbn.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblbookdetails where ISBN = int('" & txtsearch & "')" Adodc1.Refresh ElseIf optsno.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblbookdetails where Shelf_Number = int('" & txtsearch & "')" Adodc1.Refresh Else MsgBox "Select the means of searching book.", vbOKOnly, "Search" End If ElseIf optmem.Value = True Then If optmid.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblmember where ID = Int('" & txtsearch & "')" Adodc1.Refresh ElseIf optfname.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblmember where First_Name = ('" & txtsearch & "')" Adodc1.Refresh ElseIf optlevel.Value = True Then Call combovisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblmember where Education_Level = ('" & cmbtype & "')" Adodc1.Refresh ElseIf optgender.Value = True Then Call combovisible Adodc1.CommandType = adCmdUnknown
Bishwanath Parajuli
386
Adodc1.RecordSource = "Select * from tblmember where Gender = ('" & cmbtype & "')" Adodc1.Refresh ElseIf optdatea.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblmember where Activation_Date = Cdate('" & txtsearch & "')" Adodc1.Refresh Else MsgBox "Select the means of searching the memeber.", vbOKOnly, "Search" End If ElseIf optauth.Value = True Then If optaid.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblauthor where Author_ID = int('" & txtsearch & "')" Adodc1.Refresh ElseIf optaname.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblauthor where Author_Name = ('" & txtsearch & "')" Adodc1.Refresh Else MsgBox "Select the means of searching the author.", vbOKOnly, "Search" End If ElseIf optpub.Value = True Then If optpid.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblpublisher where Publisher_id = int('" & txtsearch & "')" Adodc1.Refresh ElseIf optpname.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblpublisher where Publisher_Name = ('" & txtsearch & "')" Adodc1.Refresh Else MsgBox "Select the means of searching the publisher.", vbOKOnly, "Search" Bishwanath Parajuli 387
End If ElseIf optreserve.Value = True Then If optdaters.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from qryreserve where Reservation_Date = int('" & txtsearch & "')" Adodc1.Refresh ElseIf optbcode.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from qryreserve where Book_Code = int('" & txtsearch & "')" Adodc1.Refresh ElseIf optsid.Value = True Then Call textboxvisible Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from qryreserve where Borrower_ID = int('" & txtsearch & "')" Adodc1.Refresh Else MsgBox "Select the means of searching the Reserved book.", vbOKOnly, "Search" End If End If If Adodc1.Recordset.RecordCount = 0 Then 'if there is no reord in the recordset then 'display message MsgBox "There is no record in this field.", vbInformation, "Search" End If Exit Sub errorhandling: MsgBox "Error No. > " & Err.Number & " / " & Err.Description, vbCritical, "Fatal Error" End Sub Private Sub cmdsearch_GotFocus() If txtsearch.Text <> "" Then 'if textbox is empty cmdsort.Enabled = True 'disable command button End If End Sub Private Sub cmdsort_Click() frmsort.Show 'show form Bishwanath Parajuli 388
frmsearch.Enabled = False 'disable form End Sub Private Sub Form_Load() 'This procedure configures ADODC path and provider Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" End Sub Private Sub optaall_Click() 'if the option is selected then 'configure adodc to view record of the specified table If optaall.Value = True Then 'if option is selected Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblauthor" 'specify the data table Adodc1.Refresh 'refresh adodc End If cmdsort.Enabled = True End Sub Private Sub optball_Click() 'if the option is selected then 'configure adodc to view record of the specified table If optball.Value = True Then Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblbookdetails " Adodc1.Refresh End If cmdsort.Enabled = True End Sub Private Sub optiall_Click() 'if the option is selected then 'configure adodc to view record of the specified table If optiall.Value = True Then Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from qryissue " Adodc1.Refresh End If cmdsort.Enabled = True End Sub Private Sub optmall_Click() Bishwanath Parajuli 389
'if the option is selected then 'configure adodc to view record of the specified table If optmall.Value = True Then Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblmember" Adodc1.Refresh End If cmdsort.Enabled = True End Sub Private Sub optpall_Click() 'if the option is selected then 'configure adodc to view record of the specified table If optpall.Value = True Then Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from tblpublisher" Adodc1.Refresh End If cmdsort.Enabled = True End Sub Private Sub optrall_Click() 'if the option is selected then 'configure adodc to view record of the specified table If optrall.Value = True Then Adodc1.CommandType = adCmdUnknown Adodc1.RecordSource = "Select * from qryreserve" Adodc1.Refresh End If cmdsort.Enabled = True End Sub Private Sub optaid_Click() Call textboxvisible 'call function End Sub Private Sub optaname_Click() Call textboxvisible End Sub Private Sub optauth_Click() Call disable5 End Sub Private Sub optbcode_Click() Call textboxvisible Bishwanath Parajuli 390
End Sub Private Sub optbid_Click() Call textboxvisible End Sub Private Sub optbook_Click() Call disable2 End Sub Private Sub optbtitle_Click() Call textboxvisible End Sub Private Sub optdatea_Click() Call textboxvisible End Sub Private Sub optdatei_Click() Call textboxvisible End Sub Private Sub optdater_Click() Call textboxvisible End Sub Private Sub optdaters_Click() Call textboxvisible End Sub Private Sub optfname_Click() Call textboxvisible End Sub Private Sub optgender_Click() Call combovisible Call typeg End Sub Private Sub optisbn_Click() Call textboxvisible End Sub Private Sub optissue_Click() Call disable1 End Sub
Bishwanath Parajuli
391
Private Sub optlevel_Click() Call combovisible Call typel End Sub Private Sub optmem_Click() Call disable3 End Sub Private Sub optmid_Click() Call textboxvisible End Sub Private Sub optpid_Click() Call textboxvisible End Sub Private Sub optpname_Click() Call textboxvisible End Sub Private Sub optpub_Click() Call disable6 End Sub Private Sub optreserve_Click() Call disable7 End Sub Private Sub optsid_Click() Call textboxvisible End Sub Private Sub optsno_Click() Call textboxvisible End Sub Private Sub opttype_Click() Call combovisible Call typeb End Sub Sub typeb() 'This procedure clear addsitem in combobox cmbtype.clear 'clear combo 'populate combo Bishwanath Parajuli 392
cmbtype.AddItem "Fiction" cmbtype.AddItem "Non Fiction" cmbtype.AddItem "Periodical" cmbtype.AddItem "Reference" End Sub Sub typeg() 'This procedure clear addsitem in combobox cmbtype.clear cmbtype.AddItem "Male" cmbtype.AddItem "Female" End Sub Sub typel() 'This procedure clear addsitem in combobox Dim i As Integer cmbtype.clear For i = 1 To 10 cmbtype.AddItem i Next i cmbtype.AddItem "Teachers and Staffs" End Sub Sub textboxvisible() 'This procedure shows textbox and hides combobox txtsearch.Visible = True txtsearch.Enabled = True cmbtype.Visible = False cmbtype.Enabled = False End Sub Sub combovisible() 'This procedure shows combobox and hides textbox txtsearch.Visible = False txtsearch.Enabled = False cmbtype.Visible = True cmbtype.Enabled = True End Sub Sub disable1() 'This procedure shows/hides the frame specified below 'enables/disables the frame specified below fraissue.Enabled = True fraissue.Visible = True frabook.Enabled = False frabook.Visible = False Bishwanath Parajuli 393
framem.Enabled = False framem.Visible = False fraauth.Visible = False fraauth.Enabled = False frapub.Enabled = False frapub.Visible = False frares.Visible = False frares.Enabled = False End Sub Sub disable2() 'This procedure shows/hides the frame specified below 'enables/disables the frame specified below fraissue.Enabled = False fraissue.Visible = False frabook.Enabled = True frabook.Visible = True framem.Enabled = False framem.Visible = False fraauth.Visible = False fraauth.Enabled = False frapub.Enabled = False frapub.Visible = False frares.Visible = False frares.Enabled = False End Sub Sub disable3() 'This procedure shows/hides the frame specified below 'enables/disables the frame specified below fraissue.Enabled = False fraissue.Visible = False frabook.Enabled = False frabook.Visible = False framem.Enabled = True framem.Visible = True fraauth.Visible = False fraauth.Enabled = False frapub.Enabled = False frapub.Visible = False frares.Visible = False frares.Enabled = False End Sub Sub disable4() 'This procedure shows/hides the frame specified below 'enables/disables the frame specified below Bishwanath Parajuli 394
fraissue.Enabled = False fraissue.Visible = False framem.Enabled = False framem.Visible = False fraauth.Visible = False fraauth.Enabled = False frapub.Enabled = False frapub.Visible = False frabook.Enabled = False frabook.Visible = False frares.Visible = False frares.Enabled = False End Sub Sub disable5() 'This procedure shows/hides the frame specified below 'enables/disables the frame specified below fraissue.Enabled = False fraissue.Visible = False framem.Enabled = False framem.Visible = False frapub.Enabled = False frapub.Visible = False frabook.Enabled = False frabook.Visible = False fraauth.Visible = True fraauth.Enabled = True frares.Visible = False frares.Enabled = False End Sub Sub disable6() 'This procedure shows/hides the frame specified below 'enables/disables the frame specified below fraissue.Enabled = False fraissue.Visible = False framem.Enabled = False framem.Visible = False fraauth.Enabled = False fraauth.Visible = False frabook.Enabled = False frabook.Visible = False frapub.Enabled = True frapub.Visible = True frares.Visible = False frares.Enabled = False Bishwanath Parajuli 395
End Sub Sub disable7() 'This procedure shows/hides the frame specified below 'enables/disables the frame specified below fraissue.Enabled = False fraissue.Visible = False framem.Enabled = False framem.Visible = False fraauth.Enabled = False fraauth.Visible = False frabook.Enabled = False frabook.Visible = False frapub.Enabled = False frapub.Visible = False frares.Visible = True frares.Enabled = True End Sub
Bishwanath Parajuli
396
frmsort: Private Sub cmbsort_Click() frasort.Enabled = True 'enable controls txtfilter.Enabled = True End Sub Private Sub cmdfilter_Click() 'This procedure filters the recordset's record On Error GoTo errorhandling: If cmbsort.Text = "" Or frmsearch.Adodc1.Recordset.RecordCount = 0 Then 'if the combo is empty or recordset is empty MsgBox "Select Sort Option", vbInformation, "Select" ElseIf cmbsort.Text <> "" Or frmsearch.Adodc1.Recordset.RecordCount <> 0 Then frmsearch.Adodc1.Recordset.Filter = cmbsort & " like '" & txtfilter.Text & "%'" 'if all of the fields are attended then filter 'filter by selecting fieldlist from combobox and filter item from textbox Exit Sub 'exit End If Exit Sub errorhandling: MsgBox "Error No. > " & Err.Number & " / " & Err.Description, vbCritical, "Fatal Error" End Sub Private Sub cmdunload_Click() Unload Me End Sub Private Sub Form_Load() 'This procedure adds item to combobox 'if the fields below are selected from 'frmsearch' If frmsearch.optauth.Value = True Then 'if the specified option button is selected cmbsort.clear 'clear combo cmbsort.AddItem "Author_Name" 'populate combo ElseIf frmsearch.optpub.Value = True Then cmbsort.clear cmbsort.AddItem "Publisher_Name" ElseIf frmsearch.optmem.Value = True Then cmbsort.clear cmbsort.AddItem "First_Name" Bishwanath Parajuli 397
cmbsort.AddItem "Gender" ElseIf frmsearch.optbook.Value = True Then cmbsort.clear cmbsort.AddItem "Title" cmbsort.AddItem "Type_of_Book" cmbsort.AddItem "ISBN" End If End Sub Private Sub Form_Unload(Cancel As Integer) frmsearch.Enabled = True 'enable form End Sub Private Sub optasc_Click() 'This procedure sorts the record ascending On Error GoTo errhandle: If frmsearch.Adodc1.Recordset.RecordCount <= 1 Then 'if the recordset has 1 or less than 1 data MsgBox "Sorting failed. No or only one record.", vbOKOnly + vbExclamation, "Sorting..." Else frmsearch.Adodc1.Recordset.Sort = Me.cmbsort.Text 'sort ascending End If Exit Sub errhandle: MsgBox "Error No. > " & Err.Number & " / " & Err.Description, vbCritical, "Error" End Sub Private Sub optdsc_Click() 'This procedure sorts the record descending On Error GoTo errhandle: If frmsearch.Adodc1.Recordset.RecordCount <= 1 Then 'if the recordset has 1 or less than 1 data MsgBox "Sorting failed. No or only one record.", vbOKOnly + vbExclamation, "Sorting..." Else frmsearch.Adodc1.Recordset.Sort = Me.cmbsort.Text & " desc" 'Sort descending End If Exit Sub errhandle: MsgBox "Error No. > " & Err.Number & " / " & Err.Description, vbCritical, "Error" Bishwanath Parajuli 398
End Sub
Bishwanath Parajuli
399
frmSplash: Option Explicit Private Sub Form_Load() 'This procedure configures ADODB connection Call connection 'call function Call preferrecset Call finerecset End Sub Private Sub Form_Unload(Cancel As Integer) 'This procedure displays message on "total fine collected", 'and shows form as specified Dim fine, count As Integer 'declare variable Dim checkmem, checkbook As String If mdimain.sbrmain.Panels(3).Text <> "User :- Visitor" Then 'if the status bar doesn't have text as specified If srecord.RecordCount <> 0 Then 'if the recordset is not empty srecord.MoveFirst 'move to first record While Not srecord.EOF 'until eof If srecord.Fields(3) = "Yes" Then 'if field value is yes If brecord.RecordCount <> 0 Then brecord.MoveFirst While Not brecord.EOF fine = brecord.Fields(4) + fine 'sum up all the data in the field brecord.MoveNext Wend End If MsgBox "You have Rs." & fine & " left to be collected.", vbInformation, "Fine" End If If srecord.Fields(0) = "No" Then 'if the field value is no checkbook = "No" 'set variable = no ElseIf srecord.Fields(0) = "Yes" Then checkbook = "Yes" End If If srecord.Fields(1) = "No" Then checkmem = "No" ElseIf srecord.Fields(1) = "Yes" Then checkmem = "Yes" End If srecord.MoveNext 'move to next record Bishwanath Parajuli 400
Wend 'repeat End If If checkmem = "Yes" Then frmovmem.Show End If If checkbook = "Yes" Then frmreminders.Show End If End If End Sub Private Sub Timer1_Timer() 'This procedure changes the value of progressbar Static pv As Integer 'declare variable pv = pv + 1 'increase value of variable by 1 ProgressBar2.Value = pv 'set the value to progress bar If pv = 100 Then 'set variable to 100 pv = 0 Unload Me 'close the form mdimain.Show End If End Sub Private Sub Timer2_Timer() 'This procedure shows/hides the shapes as configured If shp1.Visible = True Then shp1.Visible = False shp2.Visible = True shp3.Visible = False shp4.Visible = False ElseIf shp2.Visible = True Then shp2.Visible = False shp3.Visible = True shp1.Visible = False shp4.Visible = False ElseIf shp3.Visible = True Then shp3.Visible = False shp1.Visible = False shp2.Visible = False shp4.Visible = True ElseIf shp4.Visible = True Then shp3.Visible = False shp1.Visible = True shp2.Visible = False shp4.Visible = False End If Bishwanath Parajuli 401
End Sub
Bishwanath Parajuli
402
frmsupplier: Private Sub chkdet_Click() If chkdet.Value = vbChecked Then 'if the checkbox is checked Me.Height = 7650 'set the height ElseIf chkdet.Value = vbUnchecked Then 'if the checkbox is checked Me.Height = 4200 End If End Sub Private Sub cmddelete_Click() 'This procedure deletes the record from the recordset Dim supname As String 'declare variable supname = InputBox("Enter the supplier's name or code you want to delete?", "Delete") 'display input box to enter data If srecord.RecordCount <> 0 Then 'if the recordset is not empty srecord.MoveFirst 'move to first record While Not srecord.EOF 'until eof If srecord.Fields(1) = supname Or srecord.Fields(0) = supname Then 'if field value and variable match srecord.Delete 'delete the record Call checknavigation 'call the function Me.suppliertimer.Enabled = True 'enable timer MsgBox "Record Deleted.", vbInformation, "Deleted" End If srecord.MoveNext 'move to next record Wend 'repeat End If End Sub Private Sub cmdmail_Click() frmemail.Show 'show the form frmemail.txtadd = Me.txtcontact 'set the textarea in the new window End Sub Private Sub cmdmodify_Click() 'This procedure modifies the record of the specified recordset If srecord.RecordCount <> 0 Then 'if the recordset is not empty
Bishwanath Parajuli
403
If MsgBox("Are you sure you want to do this?", vbYesNo) = vbYes Then srecord.MoveFirst 'move to first record While Not srecord.EOF 'until eof If srecord.Fields(0) = Me.lblcode Then 'if field and label match 'set the field with new data srecord.Fields(1) = txtsname.Text srecord.Fields(2) = txtadd srecord.Fields(3) = txtcontact srecord.Update 'save the data suppliertimer.Enabled = True 'enable timer MsgBox "Record edited sucessfully.", vbInformation, "Update" End If srecord.MoveNext 'move to next record Wend 'repeat End If End If End Sub Private Sub cmdrefresh_Click() 'This procedure resets all the fields txtsname = "" txtadd = "" txtcontact = "" txtsname.Enabled = True txtadd.Enabled = True txtcontact.Enabled = True End Sub Private Sub cmdsave_Click() 'This procedure adds new record, assigns key field and saves it Dim code As Integer 'declare variable If txtsname.Text = "" Or txtadd.Text = "" Or txtcontact.Text = "" Then 'if the textboxes are empty MsgBox "Please, fill all the fields.", vbExclamation, "Error" Exit Sub 'exit End If If srecord.RecordCount = 0 Then 'if recordset is empty code = 801 'set code =801 Else srecord.MoveLast ' move to last record Bishwanath Parajuli 404
code = srecord.Fields(0) + 1 'set code by increasing the value of last record by 1 End If srecord.AddNew 'add new record 'set the data in record field srecord.Fields(0) = code srecord.Fields(1) = txtsname.Text srecord.Fields(2) = txtadd srecord.Fields(3) = txtcontact srecord.Update 'save the data suppliertimer.Enabled = True 'enable timer MsgBox "Record saved successfully.", vbInformation, "Supplier" Call checknavigation 'call function End Sub Private Sub cmdsearch_Click() 'This procedure displays the searched data Dim supname As String 'declare variable supname = InputBox("Enter the supplier's name or code you want to Find?", "Find") 'allow to enter the data If srecord.RecordCount <> 0 Then srecord.MoveFirst 'move to first record While Not srecord.EOF 'until eof If srecord.Fields(1) = supname Or srecord.Fields(0) = supname Then 'if field and variable match Me.txtsname = srecord.Fields(1) 'set the field value into specified objects txtsname.Enabled = False 'disabel controls Me.txtadd = srecord.Fields(2) txtadd.Enabled = False Me.txtcontact = srecord.Fields(3) txtcontact.Enabled = False End If srecord.MoveNext 'move to next record Wend End If End Sub Private Sub cmdsearch_LostFocus() cmdsearch.Visible = False 'hide button End Sub
Bishwanath Parajuli
405
Private Sub Form_Load() 'This procedure configures ADODB and ADODC connection Call connection 'call function Call supplierrecset adosupplier.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" 'configure provider and application path adosupplier.CommandType = adCmdUnknown adosupplier.RecordSource = "select * from tblsupplier" 'specify the data source adosupplier.Refresh 'refresh adodc Call checknavigation 'call function End Sub Private Sub suppliertimer_Timer() 'This procedure refreshes the datagrid On Error GoTo errhandler: supgrid.Refresh 'refresh data grid adosupplier.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source = " & App.Path & "\Library Management System.mdb" 'configure provider and application path adosupplier.CommandType = adCmdUnknown adosupplier.RecordSource = "select * from tblsupplier" 'specify the data source adosupplier.Refresh 'refresh adodc supgrid.Refresh 'refresh grid suppliertimer.Enabled = False 'disable timer Exit Sub errhandler: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub txtsname_Change() If txtsname = "" Then 'if textbox is empty Me.cmdsearch.Visible = True 'show button End If End Sub Private Sub txtsname_LostFocus() 'This procedure checks for any exixting data If srecord.RecordCount <> 0 Then 'if the recorset is not empty srecord.MoveFirst 'move to first record Bishwanath Parajuli 406
While Not srecord.EOF 'until eof If srecord.Fields(1) = txtsname.Text Then 'compare textbox and field value and if matched MsgBox "This Supplier Exists already.", vbInformation, "Supplier Details" txtsname.SetFocus 'shift focus cmdsave.Enabled = False 'disable button Exit Sub Else cmdsave.Enabled = True 'enable button End If srecord.MoveNext 'move to next record Wend 'repeat End If End Sub Private Sub cmdnext_Click() On Error GoTo errhandle 'This procedure moves pointer to next relative record If srecord.AbsolutePosition = adPosBOF Then 'if absolute position of the record is at bof then srecord.MoveLast 'move record pointer to last record Exit Sub ElseIf srecord.EOF = True Then MsgBox "This is Last record", vbInformation, "Information" srecord.MoveLast Exit Sub Else Call viewdata 'call function srecord.MoveNext 'move record pointer to next record End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdprevious_Click() 'This procedure moves pointer to previous relative record On Error GoTo errhandle If srecord.AbsolutePosition = adPosEOF Then 'if record pointer is at eof then srecord.MoveFirst 'move record pointer to first record Exit Sub ElseIf srecord.BOF = True Then 'if record pointer is at bof then continue with: Bishwanath Parajuli 407
MsgBox "This is First record", vbInformation, "Information" srecord.MoveFirst 'move to first record Exit Sub Else Call viewdata 'call function srecord.MovePrevious 'move record pointer to previous record End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Sub viewdata() 'This procedure assigns value to form fields from the recordset Me.lblcode = srecord.Fields(0) Me.txtsname = srecord.Fields(1) Me.txtadd = srecord.Fields(2) Me.txtcontact = srecord.Fields(3) End Sub Private Sub cmdbegin_Click() 'This procedure moves pointer to first record On Error GoTo errhandle If srecord.BOF = True Then 'if the record pointer is at bof then MsgBox "This is First record", vbInformation, "Information" srecord.MoveFirst 'move record pointer to first record Exit Sub ElseIf srecord.AbsolutePosition = adPosBOF Then 'if absolute position of the record is at bof then srecord.MoveFirst 'move record pointer to last record Exit Sub Else Call viewdata 'call function srecord.MoveFirst 'moves pointer to first record End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Private Sub cmdlast_Click() Bishwanath Parajuli 408
'This procedure moves pointer to last record On Error GoTo errhandle If srecord.EOF = True Then 'if record pointer is at eof then MsgBox "This is Last record", vbInformation, "Information" srecord.MoveLast 'move record pointer to last record Exit Sub Else Call viewdata 'call function srecord.MoveLast 'move record pointer to last record End If Exit Sub errhandle: MsgBox Err.Description, vbCritical, "Error" End Sub Sub checknavigation() 'This procedure enables/disables navigation buttons If srecord.RecordCount = 0 Then 'if recordset is empty franavigate.Enabled = False 'disable frame ElseIf srecord.RecordCount <> 0 Then 'if recordset is not empty franavigate.Enabled = True 'enable frame End If End Sub
Bishwanath Parajuli
409
mdimain: Dim checkdb As Boolean 'declare checkdb as boolean Private Sub MDIForm_Load() 'This procedure configures the ADODB connection 'and deletes record from the connection 'lrecord' if necessary Dim count As Integer 'declare variable Call connection 'call functions Call issuerecset Call reserverecset Call memeberrecset Call booklistrecset If bdrecord.RecordCount <> 0 Then 'if the recordset is not empty bdrecord.MoveFirst 'move to first record While Not bdrecord.EOF 'until eof If bdrecord.Fields(4) <= VBA.Date Then 'if the field value is older than system date bdrecord.Fields(6) = "No" 'set field value to No ElseIf bdrecord.Fields(4) > VBA.Date Then 'if the field value is not older than system date bdrecord.Fields(6) = "Yes" 'set field value to yes End If bdrecord.MoveNext 'move to next record Wend 'repeat End If If lrecord.RecordCount <> 0 Then lrecord.MoveFirst While Not lrecord.EOF If lrecord.Fields(4) < VBA.Date Then 'if the records are older than system date lrecord.Delete 'delete record MsgBox "Reservation that had crossed its due" & vbCrLf &_ "have been deleted.", vbInformation, "" End If lrecord.MoveNext Wend End If End Sub Private Sub mnubackupdb_Click() Call backup 'call functions Bishwanath Parajuli 410
End Sub Private Sub mnuabout_Click() frmAbout.Show 'show form End Sub Private Sub mnubookdetail_Click() frmbookdet.Show End Sub Private Sub mnubookrpt_Click() bookreport.Show 'show report End Sub Private Sub mnubooksupplier_Click() frmsupplier.Show End Sub Private Sub mnucompactandrepairdb_Click() sbrmain.Panels(4) = "Compacting and Repairing Database.." 'set text for status bar Call compact 'call function End Sub Private Sub mnuexit_Click() 'This procedure displays messagebox 'and if messagebox returns with response yes then 'unloads this form If MsgBox("Do you want to exit?", vbYesNo + vbQuestion, "Exit") = vbYes Then Unload Me Else mdimain.Show End If End Sub Private Sub mnugeneral_Click() frmoverview.Show End Sub Private Sub mnuhistory_Click() frmhistory.Show End Sub Private Sub mnuissue_Click() frmissue.Show End Sub Bishwanath Parajuli 411
Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer) 'This procedure displays messagebox 'and if messagebox returns with response yes then 'unloads this form and creates backup or compacts the database if configured Call connection 'call function Call preferrecset If mdimain.Visible = True Then If MsgBox("Are you sure you want to quit?", vbQuestion + vbYesNo, "Quit") = vbNo Then UnloadMode = 1 'set unload mode to 1 Cancel = 1 'and cancel status to 1 Exit Sub 'exit End If Else Unload Me If srecord.RecordCount <> 0 Then 'if the record set is not empty srecord.MoveFirst 'move to first record While Not srecord.EOF 'until eof If srecord.Fields(2) = "Yes" Then 'if field value is yes Call compact 'call function End If If srecord.Fields(4) = "Yes" Then Call backup End If srecord.MoveNext 'move to next record Wend 'repeat End If End If End Sub Private Sub mnumemberdetail_Click() frmborrowerdetails.Show End Sub Private Sub mnuissueoverview_Click() frmglance.Show End Sub Private Sub mnumembershipoverview_Click() frmovmem.Show End Sub Bishwanath Parajuli 412
Private Sub mnumemrpt_Click() detailreport.Show End Sub Private Sub mnuprefer_Click() frmprefer.Show End Sub Private Sub mnurequest_Click() frmbooklist.Show End Sub Private Sub mnupublisherauthor_Click() frmpubnauth.Show End Sub Private Sub mnurenewreturn_Click() frmlinker.Show End Sub Private Sub mnureserverpt_Click() reservereport.Show End Sub Private Sub mnuduerpt_Click() duereport.Show End Sub Private Sub mnufinerpt_Click() finereport.Show End Sub Private Sub mnureserve_Click() frmreserve.Show End Sub Private Sub mnurestore_Click() 'This procedure defines the destination file 'and copies the file into the destination Dim result 'declare variable sbrmain.Panels(4) = "Restoring Backup..." 'set caption for panels in status bar cdlg.Filter = "Microsoft Access File|*.mdb" 'filter filetypes with extension '.jpg' cdlg.ShowOpen 'show common dialog box with open button Bishwanath Parajuli 413
If cdlg.FileName <> "" Then result = apiCopyFile(cdlg.FileName, App.Path & "\Library Management System.mdb", False) 'copy file from source file to destination file. MsgBox "Backup restored sucessfully.", vbInformation, "Restore" End If sbrmain.Panels(4) = "" End Sub Private Sub mnusecurity_Click() frmnuserandcpass.Show End Sub Private Sub mnusearch_Click() frmsearch.Show End Sub Private Sub mditime_timer() Me.sbrmain.Panels(2) = VBA.Time End Sub Private Sub tbrmain_ButtonClick(ByVal Button As MSComctlLib.Button) 'This procedure displays form according to the button menu index clicked Select Case Button.Index 'load the button indexes Case 7 'if button index is as specified frmsearch.Show 'open specified form Case 9 frmemail.Show End Select End Sub Private Sub tbrmain_ButtonMenuClick(ByVal ButtonMenu As MSComctlLib.ButtonMenu) 'This procedure displays form according to the button menu clicked Select Case ButtonMenu.Text 'load text under button menu Case "Issue" 'if the text is as specified frmissue.Show 'load the specified window Case "Renew or Return" frmlinker.Show Case "Reserve" frmreserve.Show Case "User Details" Bishwanath Parajuli 414
frmnuserandcpass.Show Case "Change User" Me.Hide frmLogin.Show Case "Book" frmbookdet.Show Case "Member" frmborrowerdetails.Show Case "Publisher/Author" frmpubnauth.Show Case "Supplier" frmsupplier.Show End Select End Sub Private Sub mnutotalfine_Click() frmfinecollection.Show End Sub Sub backup() 'This procedure defines the destination file 'and copies the file into the destination Dim result 'declare variable sbrmain.Panels(4) = "Creating Backup..." 'set text for status bar cdlg.ShowSave 'show common dialog box with save button If cdlg.FileName <> "" Then 'if the filename of the dialog box is not empty result = apiCopyFile(App.Path & "\Library Management System.mdb", cdlg.FileName & ".mdb", False) 'copy file from source file as database of the application MsgBox "Backup created sucessfully.", vbInformation, "Backup" End If sbrmain.Panels(4) = "" End Sub Sub compact() 'This procedure compacts the current database 'copies the current database into tempDB 'kills the currentDB 'and renames the tempDB Dim stTempDBfile As String 'declare variables Dim origin, final As Long origin = FileLen(App.Path & "/Library Management System.mdb") 'specify the length of file Bishwanath Parajuli 415
stTempDBfile = App.Path & "/tempDBfile.mdb" 'specify temporary database On Error Resume Next Kill stTempDBfile 'delete the temp file if it already exists, skip errors, if it does not exist create one dao.DBEngine.CompactDatabase App.Path & "/Library Management System.mdb", stTempDBfile Kill currentdbname 'delete the current database FileCopy stTempDBfile, App.Path & "/Library Management System.mdb" 'copy the contents of the file to database in the application path Kill stTempDBfile 'delete the temporarydb dao.DBEngine.RepairDatabase App.Path & "/Library Management System.mdb" 'repair database final = FileLen(App.Path & "/Library Management System.mdb") MsgBox "Database compacted " & ((origin - final) / origin) * 100 & "% " & vbCrLf & _ "and repaired Successfully.", _ vbInformation, "Database Compacted" sbrmain.Panels(4) = "" End Sub
Bishwanath Parajuli
416
Module: Declare Function apiCopyFile Lib "kernel32" Alias "CopyFileA" _ (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, _ ByVal bFailIfExists As Long) As Long 'define all the variables used Global connect As ADODB.connection 'declare the adodb connection Global precord As ADODB.Recordset 'declare adodb recordsets Global bdrecord As ADODB.Recordset Global mrecord As ADODB.Recordset Global lrecord As ADODB.Recordset Global brecord As ADODB.Recordset Global hrecord As ADODB.Recordset Global srecord As ADODB.Recordset Global nrecord As ADODB.Recordset Sub connection() 'set new connection Set connect = New ADODB.connection 'set new recordset Set precord = New ADODB.Recordset Set brecord = New ADODB.Recordset Set bdrecord = New ADODB.Recordset Set mrecord = New ADODB.Recordset Set lrecord = New ADODB.Recordset Set hrecord = New ADODB.Recordset Set srecord = New ADODB.Recordset Set nrecord = New ADODB.Recordset connect.Provider = "Microsoft.jet.OLEDB.4.0" 'set the connection provider connect.ConnectionString = "Data source =" & App.Path & "\Library Management System.mdb " 'set the data source path connect.Open 'open connection with the above password End Sub Sub bookrecset() 'set the recordset by opening it from specified table
Bishwanath Parajuli
417
precord.Open "select * from tblbookdetails", connect, adOpenKeyset, adLockPessimistic End Sub Sub memeberrecset() 'set the recordset by opening it from specified table mrecord.Open "select * from tblmember", connect, adOpenKeyset, adLockPessimistic End Sub Sub issuerecset() 'set the recordset by opening it from specified table bdrecord.Open "select * from tblissue", connect, adOpenKeyset, adLockPessimistic End Sub Sub qryissuerecset() 'set the recordset by opening it from specified table bdrecord.Open "select * from qryissue", connect, adOpenKeyset, adLockPessimistic End Sub Sub security() 'set the recordset by opening it from specified table precord.Open "select * from tblusers", connect, adOpenKeyset, adLockOptimistic End Sub Sub author() 'set the recordset by opening it from specified table bdrecord.Open "select * from tblauthor", connect, adOpenKeyset, adLockPessimistic End Sub Sub publisher() 'set the recordset by opening it from specified table brecord.Open "select * from tblpublisher", connect, adOpenKeyset, adLockPessimistic End Sub Sub reserverecset() 'set the recordset by opening it from specified table lrecord.Open "select * from tblreserve", connect, adOpenKeyset, adLockPessimistic End Sub
Bishwanath Parajuli
418
Sub finerecset() 'set the recordset by opening it from specified table brecord.Open "select * from tblfine", connect, adOpenKeyset, adLockPessimistic End Sub Sub qryfinerecset() 'set the recordset by opening it from specified table srecord.Open "select * from qryfine", connect, adOpenKeyset, adLockPessimistic End Sub Sub supplierrecset() 'set the recordset by opening it from specified table srecord.Open "select * from tblsupplier", connect, adOpenKeyset, adLockPessimistic End Sub Sub preferrecset() 'set the recordset by opening it from specified table srecord.Open "select * from tblsettings", connect, adOpenKeyset, adLockPessimistic End Sub Sub historyrecset() 'set the recordset by opening it from specified table hrecord.Open "select * from tblhistory", connect, adOpenKeyset, adLockPessimistic End Sub Sub booklistrecset() 'set the recordset by opening it from specified table nrecord.Open "select * from tblorderbooklist", connect, adOpenKeyset, adLockPessimistic End Sub
Bishwanath Parajuli
419
dataenv: Private Sub DataEnvironment_Initialize() pconnect.Provider = "Microsoft.jet.OLEDB.4.0" 'specify provider pconnect.ConnectionString = "Data source =" & App.Path & "\Library Management System.mdb" 'specify data source pconnect.Open 'open the connection End Sub
Bishwanath Parajuli
420