Вы находитесь на странице: 1из 144

Graduation Project Thesis

LIBRARY MANAGEMENT SYSTEM

Sahar Ahmad Rajhi

201130795

Omaima Ali Masmaly

201130259

Somaya Mohsin Alamir 201130701

Supervisor: Mr.A.saahira Ahmad

College of Computer Science & Information Systems


Jazan University, Jazan
Kingdom of Saudi Arabia
1436 / 2015

Library Management System

PREFACE
This project of LIBRARY MANAGEMENT SYSTEM of gives us the complete
information about the library. We can enter the record of new books and retrieve the
details of books available in the library. We can issue the books to the students and
maintain their records and can also check how many books are issued and stock
available in the library.
Throughout the project the focus has been on presenting information and comments in
an easy and intelligible manner. The project is very useful for those who want to know
about Library Management System.

Library Management System

ACKNOWLEDGEMENTS
The satisfaction that accompanies that the successful completion of any task would be
incomplete without the mention of people whose ceaseless cooperation made it
possible, whose constant guidance and encouragement crown all efforts with success.
We are grateful to our project guide Ms. A.Saahira Banu for the guidance, inspiration
and constructive suggestions that helpful us in the preparation of this project. We also
thank our colleagues who have helped in successful completion of the project.

Library Management System

ABSTRACT
Today most of the library is using either manual system for tracking the day to day
activity or they are using desktop, spread sheet like MS Excel application to manage
the day to day activity. In this proposed Library Management System it will run in
client server mode and user can check the book availability, they can search the books,
library staff can issue, receive book, and management can check the report. System will
store historical data. Management can anytime view the total book status, library card
status.
This project of LIBRARY MANAGEMENT SYSTEM of gives us the complete
information about the library. We can enter the record of new books and retrieve the
details of books available in the library. We can issue the books to the students and
maintain their records and can also check how many books are issued and stock
available in the library.

Keywords: library management, automation in library.

Library Management System

TABLE OF CONTENTS

PREFACE.
ACKNOWLEDGEMENTS
ABSTRACT
TABLE OF CONTENTS.............
1. INTRODUCTION..

1.1
1.2
1.3
1.4
1.5

2.
3.

4.

5.

6.

Project Overview Statement:.


Project Goals And Objectives:.
project Scope and Features:..
Limitations and Constraints:
Assumptions:
LITERATURE REVIEW
FEASIBILITY STUDY..
3.1 Purpose Of The Feasibility Study:
3.2 Justification For The Proposed System:...
3.3 Economic Feasibility
3.4 Technical Feasibility:
3.5 esired System Functionality:.
ROJECT PLAN..
4.1 Work Breakdown Structure:.
4.2 Activity And Task List:
4.3 Gantt Charts:.
REQUIREMENT ANALYSIS
5.1 System Requirements Analysis:...
5.2 Hardware Requirements Specification:
5.3 Software Requirements Specification:..
5.4 Other Requirements Specifications:.
SYSTEM DESIGN
6.1 Application Architecture Design:.
Data Flow Diagram:..
Context Level DFD:
0 Level Data Flow Diagram:.
1 Level Data Flow Diagram:
Use Case Diagram..
Use Case description:..
Use Case Model: Manage Users
Use Case Model: Manage Members..
Use Case Model: Issue Book.
Use Case Model: Receive Book ...
6.2 Database Design:..
Data Dictionary:
User table:.
Book master table:.
Member master table.
Transaction table::.
Book category Table:
Library ER Diagram:.
6.3 User Interface Design:.
Library Management System : Login ..
Library Management System : Main Screen...

1
2
3
4
6
6
6
7
9
9
10
12
12
12
13
13
13
14
14
14
15
17
17
19
19
19
21
21
22
22
22
23
24
25
27
29
31
33
34
34
34
34
35
35
35
36
37
37
37

Library Management System

Library Management System : User Master


Library Management System : Change Password...
Library Management System : Book Master .
Library Management System : Search Book ...
Library Management System : Book Status
Library Management System : MemberMaster...
Library Management System : Search Member...
Library Management System : Issue Book ..
Library Management System : Receive Book .
Library Management System : Transaction Report .
Library Management System : About ..
7. REAL SCREEN SHOTS OF DATA ENTRY FORMS AND REPORTS
8. CODING OF IMPORTANT FUNCTIONS AND PROCEDURES OF THE SOFTWARE:.
9. TEST CASES

CONCLUSION AND FUTURE ENHANCEMENT.


REFERENCES ...

37
38
38
38
39
39
39
40
40
41
41
42
49
138
142
143

Library Management System

1. INTRODUCTION
Library Management Software is to handle the entire activity of a library. The
software keeps track of all the information about the books in the library, their complete
details and total number of books available in the Library. The user will find it easy in
this automated system rather than using the manual writing system.
In this chapter, we will explain the objectives, scope, limitations and constraints faced
by library management system.

1.1 Project Overview Statement:


Library Management System is an application refer to other library system and
it is suitable to use by small and medium size library. It is use by librarian and
library admin to manage the library using a computerized system. The system
was developed and designed to help librarian record every book transaction so
that the problem such as file missing or record missing will not happened again.
Throughout the project the focus has been on presenting information and
comments in an easy and intelligible manner. The project is very useful for
those who want to know about Library Management System.

Library management System is a very simple, flexible and user-friendly


Library Management software specially for INDIA, that takes care of all your
requirements relating to managing huge library. Library stores complete
records of the books, members, creates library card, mange transaction,
Computes late fine, search books and generate MIS reports.
It is a complete library solution make this complicated function look much
easier. The software is user-friendly, with user-definable preferences like Book
category and extensive and search facilities, huge library of periodical data to
analyze the trend of issue and receive of books.

1.2 Project Goals And Objectives:


The project aims and objectives that will be achieved after completion of the
system.

To eliminate the paper-work in library

To record every transaction in computerized system so that problem


such as record file missing wont happen again

Library Management System

To design a user friendly graphical user interface which suit the users

To complete the system according to project schedule

To produce technical report that documents the phases, tasks and


deliverables in the project

1.3 project Scope and Features:


The Library Management System is designed & developed for a receipt and
issuance of books in the library along with the students details. The books
received in the library are entered in Books Entry form and the new student is
entered in the student entry form. When the student wants to get the desired
book the same is issued on the availability basis to the student. The issuance
and due date for the returning of the book is also entered into the Book Issue
form under third menu Book Issue.
Any education institute can make use of it for providing information about
author, content of the available books. It can be used in offices and
modifications can be easily done according to requirements
From an end-user perspective, the Library Management System Project
consists of two functional elements: Master and Transaction Module.
Master and Security module
Master and security module includes user security management, login security,
book details, member master, library card, library transaction.

Login :Check the user by user name and password, All user needs to
enter user name and password to access the system, system check the
user name and password and give access the system resource only valid
user.

Main Screen : It display available options, menus and toolbars to the


logged user. System display option as per user rights. It also show the
name of user currently logged in.

Book: includes book master, search book and book status.

New Book : This form used to enter new book details, system generates
book id,. User enters book title, book author, publisher name, book
description, no of pages, book category.

Library Management System

Display Book : It displays all books in grid, user can short the book by
book title, book author, category. User can also print all or selected
book details from this screen.

Book Status: to displays book issue and available.

Modify Book :User can edit previously saved book details in this
screen.

Search Book: Library system needs powerful book search facilities to


find any book. System provides two types of search facilities one is
normal search facilities where user enter book title, author name,
category, keyword, system perform pattern search and display the result
in grid.

New Member : This form used to create new library member, user
enter library member details. System generates member id.

Modify Member: In this screen system users modify existing member


details

Search Member: System provide powerful search facility to search


library member, user can search card by giving various search input like
member id, member name. System can search single for single search
condition or all condition. After search results will display in grid.

Change Password: Currently logged user can change his or her


password from this form, before system validate old password.

User Master: Administrator can creates new system users from this
form, Administrator enters new user name, password and selects user
type to create new user.

Transaction module:
Transaction module includes issuing, receiving book and transaction report.

Issuing Book : This form used to issue book to the member. In this
screen user selects book id, and member id, system display the book
and card history. If book is already issued it display message and details
of last issued details. Same way system display card history for the
member id, if book already available it shows the message. If book is
available and there is no book pending for received then book is issued

Library Management System

and system saves the details. System also has powerful search facility
to find the book and member id.

Receive Book: In this screen user enters the book issued transaction no,
system displays the transaction details and book received status. User
also checks the book condition and enters the remark if needed.

Transaction Reports: In this report system user can generates book


issue and book received details for single member/all members, for
single book/ all books, for the selected date or all days. User can also
short the record by transaction no, type, book id, member id.

1.4 Limitations and Constraints:

The information of all the users must be stored in a database that is


accessible by Library System.

The users access the Online Library System from any computer that has
Internet browsing capabilities and an Internet connection.

The users must have their correct usernames and passwords to enter into
theLibrary System.

1.5 Assumptions:

The users have sufficient knowledge of computers.

The users know the English language, as the user interface will be
provided in English.

Microsoft SQL server to store the database.

Netbans to develop the Product.

Library Management System

2. Literature Review
Library is regarded as the brain of any institute; many institutes understand the
importance of the library to the growth of the institute and their esteem users (students).
Library Management System (LMS) supports the general requirement of the library
like acquisition, cataloguing, circulation. An LMS usually comprises a relational
database, software to interact with that database, and two graphical user interfaces (one
for patrons, one for staff). Most LMSes separate software functions into discrete
programs called modules, each of them integrated with a unified interface. Prior to
computerization, library tasks were performed manually and independently from one
another. Selectors ordered materials with ordering slips, cataloguers manually
catalogued items and indexed them with the card catalog system (in which all
bibliographic data was kept on a single index card), and users signed books out
manually, indicating their name on cue cards which were then kept at the circulation
desk. Early mechanization came in 1936, when the University of Texas began using a
punch card system to manage library circulation. While the punch card system allowed
for more efficient tracking of loans, library services were far from being integrated, and
no other library task was affected by this change.
By the mid to late 2000s, LMS vendors had increased not only then umber of services
offered but also their prices, leading to some dissatisfaction among many smaller
libraries. At the same time, open source ILS was in its early stages of testing. Some
libraries began turning to such open source ILSs as Kohaand Evergreen. Common
reasons noted were to avoid vendor lock in, avoid license fees, and participate in
software development. Freedom from vendors also allowed libraries to prioritize needs
according to urgency, as opposed to what their vendor can offer. Libraries which have
moved to open source ILS have found that vendors are now more likely to provide
quality service in order to continue a partnership since they no longer have the power
of owning the ILS software and tying down libraries to strict contracts. This has been
the case with the SC LENDS consortium. Following the success of Evergreen for the
Georgia PINES library consortium, the South Carolina State Library along with some
local public libraries formed the SCLENDS consortium in order to share resources and
to take advantage of the open source nature of the Evergreen ILS to meet their specific
needs. By October 2011, just 2 years after SC LENDS began operations, 13 public
library systems across 15 counties had already joined the consortium, in addition to the

10

Library Management System

South Caroline State Library. Librarytechnology.org does an annual survey of over


1,500 libraries and noted in 2008, 2% of those surveyed used open source ILS, in 2009
the number increased to 8% and in 2010(most recent year available) 12% of the libraries
polled had adopted open source LMSs.
Library project system that offers many flexible and convenient features, allowing
librarians and library users to maximize time and efficiency. Library System gives the
all detailed information about students, staffs and books. It will track on the how many
books available in library and books issued to the students. It shows popular book
among the students. It will provide book lost in library. It keeps the record of the
suppliers and book binders. It generates MIS reports for management. Our software is
customizable for any library requirement.

11

Library Management System

3. FEASIBILITY STUDY
3.1 Purpose Of The Feasibility Study:
The feasibility study proposes one or more conceptual solution to the problem set of
the project. In fact, it is an evaluation of whether it is worthwhile to proceed with project
or not.
Evaluation of feasibility of such solutions. Such evaluation often
indicates shortcomings in the initial goals. This step is repeated as the
goals are adjusted and the alternative solutions are evaluated.
Feasibility analysis usually considers a number of project alternatives, one that is
chosen as the most satisfactory solution. These alternatives also need to be evaluated in
a broad way without committing too many resources. Various steps involved in
feasibility analysis are:
To propose a set of solution that can realize the project goal. These
solutions are usually descriptions of what the new system should look
like.
3.2 Justification For The Proposed System:
Justification means convincing stakeholders that a certain development makes sense
and that it should be supported. The main justification for the transition towards digital
libraries is that it is inevitable. The entire information scene is moving towards digital,
networked distribution of information. Libraries cannot lag behind or they will be at
risk of extinction.
Is this sufficient justification, however? Certainly not, for it could be argued that in the
networked world of the digital information society there is no need any more for
libraries. More thorough justification is required, and this should be directed towards
the various stakeholders of the library:

For the user of the library, the library system should provide clearly
enhanced services, improving the availability of useful information, the
speed of access and delivery, the usability of information, etc.

For the funders of libraries, the benefits of digital libraries should be


expressed in terms of more effective use of available (financial)
resources.

The final stakeholder is the library itself, or more specifically: the library
staff. Without commitment and involvement of library staff, the move
towards the digital library cannot be successful. Justification in this

12

Library Management System

respect means convincing library staff that the outcome will be a more
stimulating, professional environment in which to work.
Justification of library projects should therefore concentrate on these three aspects:
enhancement of service to the user and added value to the organisation, more efficient
use of funds, and the continuation of a challenging and professional working
environment for library staff. Proposals for library projects should outline their benefits
in terms of these aspects.
3.3 Economic Feasibility
Economic Feasibility an evaluation of development cost weighed against the ultimate
income of benefit derived from the development system of product. In economic
feasibility, cost benefit analysis is done in which expected cost and benefits are
evaluated.
3.4 Technical Feasibility:
Technical Feasibility includes existing and new H/W and S/W requirements that are
required to operate the project using Netbeans. The basic S/W requirement is java in
which the front end of the library management project has been done. The basic entry
forms are developed in Netbeans and the data is stored in the MY SQL.
3.5 Desired System Functionality:
The Library System provides online real time information about the books available in
the Library and the user information. The functions of the system include the system
providing different type of services based on the type of users [Member/Librarian].
The member should be provided with the updated information about the
books catalog.
Provisions for the members to borrow the books they want, if all the other
required rules hold good.
The member is given a provision to check his account information and
change the account information any time in the given valid period.
The members are provided with the books available roster and allowed to
choose the books, which they want to use in the coming up days.
The librarian can get the information about the members who have borrowed
or returned the books.
The librarian is provided with interfaces to add/edit the books available in
the book catalog.

13

Library Management System

4. ROJECT PLAN
Scheduling of a project can be correlated to prioritizing various jobs with
respect to their cost, time and duration. Scheduling can be done with resource
constraint or time constraint in mind.

4.1 Work Breakdown Structure:

Library Management System

Requirement Analysis

Testing
Maintenance
Coding

Problem
Definition

System testing

Requirement
specification

Planning
and
scheduling
g

Design

Unit
testing
Integration testing

Data Design

S/w and h/w


requirement

Modular
design

4.2 Activity And Task List:

Requirement Analysis
Problem Definition
Requirement specification
S/w and h/w requirement
Planning and scheduling
Design
Data Design
Modular
Coding
Testing
Unit testing
System testing
Integration testing

14

Library Management System

4.3 Gantt Charts:

PHASE

TIME REQUIRED(IN weeks)


WK1

WK2

WK3

WK4

WK5

WK6

requirement
Gathering
requirement
analysis
design
coding
testing
implementation

15

Library Management System

Gantt Charts with Details :

Req.Gathering

Analysis

Design

1 Feb 08 Feb 0
Wk 1

08 Feb-15 Feb
Wk2

15 Feb-25 Feb
Wk3+4days

Coding
25 Feb 03 Mar
Wk 4

Testing
03 Mar 13Mar
Wk5+4days

Implementation
13 Mar20Mar
Wk6

16

Library Management System

5. REQUIREMENT ANALYSIS
In this chapter, we will discuss and analyses about the developing process of Library
Management System including Software Requirement Specification (SRS).

5.1 System Requirements Analysis:

General Description

Product Description
Library Management System is a computerized system which can helps user
(librarian) to manage the library daily activity in electronic format. It reduces
the risk of paper work such as file lost, file damaged and time-consuming. It
can help user to manage the transaction or record more effectively and timesaving.
Problem Statement
The problem occurred before having computerized system includes:
File lost :
When no computerizes system is implemented, the file always lost
because of human and environment. Sometimes librarian didnt keep
the record to its original place because of a lot member queue up to
borrow books. After that the file was missing due to messy
environment.
Difficult to search record :
Without computerized system, when member wants to borrow a book,
librarian hard to search for the members record. It will cause timeconsuming when a lot member are waiting to borrow the books.
Cost consuming:
Paper is needed to add every new record. After a long period of time,
the cost to buy a paper can be high. On the other hand, library needs to
employ more staff to solve the long queue problem. If the library only
has one staff, it is not enough time to process the book transaction.

System objectives
Improvement in control and performance
The system was developed to overcome the current problem occurred
in library. The system must be able to validate the user, store the record
and bug free.
Save cost
After implementing the computerized library system, library can only
hire 1 or 2 staff to handle the book transaction process. With the aids of
computerized system, library can save the cost of hire employee and
also save the paper-cost.
Save time

17

Library Management System

Librarian is able to search the record in short time by pressing only few
keys. Compare to previous time before implementing the system,
librarian can save a lot time.
System Requirements:

The following sections summarize features and functionality described by use case.
Please see bellow Library Management System Requirements
Manage Members
Must be able to analyze member data
Must be able to sort member
Must be able to sort member by transactions
Must be able to identify members transaction
Must be able to store employee photo and academic, personal details
Must be able to view history of the member data, must maintain audit trail.
Manage Library Card
Must be able to create new library card.
Must be able to view and edit library card details
Must be able to print the library card details.
Must be able to view the card transaction.
Manage Books
Must be able to maintain book master information.
Must be able to mange publisher details
Must be able to edit book details, includes no of pages, book author name, title,
category, keywords, book publishing details
Must be able to maintain book register
Must able to search book by title, author, keywords
Must able to view book issue and received history
Library Transaction
Must able to issue books after validate the card and book id
Must able to enter receive books.
Must be able to calculate late fees as per late fine charge.
Must able to enter remarks while entering book receive details.
Must able to view all library transaction, by selected book id, library card and selected
date range.
Must able to print, save library transaction.
Network Management
Must be able to monitor the network centrally
Must be able to monitor servers centrally
Must be able to monitor application server software centrally
Must be able to monitor databases centrally
CEO Requirements

18

Library Management System

To support any number of members volume (Looks more like a business goal than a
definable requirement.)
Providing a no single point failure application (Looks more like a business goal than a
definable requirement.)
Reduce our costs by lowering process time (Looks more like a business goal than a
definable requirement.)

5.2 Hardware Requirements Specification:

Processor: 733 MHz Pentium III


RAM: 128 MB
Hard Disk: 10GB
Monitor: 14 VGA COLOR
Keyboard: 104 Keys
Floppy Drive: 1.44 MB
Mouse: Logitech Serial Mouse
Disk Space: 1 GB

5.3 Software Requirements Specification:


Platform: Java (JDK1.6)
Operating System: Microsoft Windows NT 4.0 or Windows 2000 or
XP
Front End: JSP & Servlets
Back End: MySql 5.1
Tools: Netbeans IDE 6.8, Sqlyog

5.4 Other Requirements Specifications:


Business Requirements
The business goal for the application is to support an increase the productivity and
complete automation of existing manual or semi automatic library management
process. Business requirements are discussed in the Scope section, with the following
additional detail:
Improve the search facility and system users should get all the
information in a second.
System should have security features in built.
User must not delete any data, Administrator can only have the rights to
delete the data,
System Administrator must able to control the access rights by each user
as per requirement.
The application should support the capability to use multi user
environment.

19

Library Management System

User Requirements
User requirements are categorized by user type.
System Users
Able to search and view the member details.
Able to find all the information like book details, book and library card
transaction details in one screen to give answer to member query.
Must able to change the his or her own password
Must able to generate reports.
Supervisor
Update book and member details.
Modify library card details if required.
Perform transaction and view transaction reports
Operational Requirements
The following requirements provide a high-level view of how the system will run:

Processor usage should not exceed 80 percent during concurrent uses.

Backups will occur incrementally throughout the day.

Ensure that information is easy to access either, and meaningful for the system
users and the company.

Minimize the technical knowledge that systems users need to access the data
generate ad hoc queries, search and view book, member and transaction
information.

The application should work with the existing communications and


networking infrastructure.

20

Library Management System

6. SYSTEM DESIGN
6.1 Application Architecture Design:
The three tier architecture:
To develop software for Library management system the architecture that we are
implementing is Three Tier Architecture. The User Interface Layer, Application Logic
Layer and Data Storage Layer together called as Three Tier Architecture.

User Interface Layer


The User Interface Layer will consist of everything shown directly to the client. This
Layer will communicate only with the Application Logic Layer. This Layer will also
be responsible for initial validation of any user inputted data. Any validation that
requires communication to the Data Storage Layer will however be completed at the
Logic Layer.
Application Logic Layer
It will be responsible for providing a secure connection to the Data Storage Layer and
formatting information received from the SQL Server for presentation to the User
Interface Layer.

21

Library Management System

Data Storage Layer


The Data Storage Layer will record all information required by the Logic and User
Interface Layer. This data will include Subject details for general user and admin user
information. Within the Data Storage Layer a collection of SQL Queries will provide
access to the data in a meaningful way.

Data Flow Diagram :


Context Level DFD:
Context Flow Diagrams give us the complete details about the inputs and outputs
for a given system.
Login
USER

library
system

Accesses

DBMS

View
Transcation

0 Level Data Flow Diagram

Admin

Add
details

User
DBMS

Admin
Adds
Members,
Books

DBMS

22

Library Management System

1 Level Data Flow Diagram


USER

Enter
Book ID ,
Member ID

Issue Books

Access table: bookmaster


Membermaster
DBMS

Validate
Entry

Save
Transaction

Employee
Enter
Transaction
No

Access table: transaction, bookmaster,


membermaster

DBMS

Generate
report
Calculate
Late Fine

Validate
Entry

Save
Transaction

Receive Book

23

Library Management System

Use Case Diagram

Usage summary use case

User Profiles:
The following user types are expected for the Library Management System:
User
Brief Description of Use Actions
User
Minimum rights to the system, query the information
can add, edit some modules.
Supervisor

System
Administrator

Add / modify book, member and transaction details


generate all reports; however can not delete any
information.
Create new system users, set and alter the role and
privilege to the system users for accessing the system
resource. Can delete the member and book data. Also
responsible to database backup, backend
performance. And overall the system performance.

24

Library Management System

Use Case description:


Manage User:
Description
This function will enable administrator to add new user.
Business Need
This function will enable system users to interact with Library Management
System catalog directly without the intervention of any other employees.
Priority
High
Manage Members
Description
This function allows user of Library Management System to create, maintain,
and delete information about employees in the database that can then be viewed
by other system users.
Business Need
This function will support the system users with accurate and relevant
information, and will also support the transaction and query function by ensuring
up-to-date book information.
Priority
High
Issue Book
Description
This function enables the user to issue book.
Business Need
This function enables user of Library Management System to issue new book to
selected member.
Priority
Medium
Receive Book
Description
This function enables the user to receive book.
Business Need
This function enables user of Library Management System to receive book from
member.
Priority
Medium

25

Library Management System

Use Case : Manage Users


Title:
Manage Users
Abbreviated Title:
Manage Users
Requirement ID:
01
Intent
Manage the user information; modify the contact details of a user.
Scenario Narrative
Administrator may want to add details of a new user.
Assumptions/Preconditions
System users have access rights to add new user details.
Actors
Administrator
Basic Course
Use case begins when the actor decides to add new user information.
System opens the user master information.
Actor navigates the required information from.
Actor press add button and enter the necessary information.
Actor press Save button to save the record in the user master catalog.
Use case ends when the selected information is passed to a method of
delivery.
Alternate Course
If no appropriate user information, system reports this fact.
Use case restarts to enable users to update the type of user
information.
Future Requirements
The system users may want to apply filters to the retrieved data.
The system users may want to sort the data. For example, the system user want
to list the names of user in chronological order based on the entry date.

26

Library Management System

Use Case Model: Manage Users

User Master

Add Details

Administrator

Update
Master

Navigate Users

Apply
Validation

27

Library Management System

Use Case
Manage Members
Title:
Manage Members
Abbreviated Title:
Manage Members
Requirement ID:
02
Intent
Enable actor to View, Add, Modify, Delete member information
Scenario Narrative
Actors want to View, Add, Modify, Delete member information
Assumptions/Preconditions
The actor has rights to access to the Library Management System, and having
rights to view, add, edit and delete the member details.
Actors
User
Supervisor
Administrator
Basic Course:
Use case begins when actor decides to view, add, edit and delete the member
information.
The system displays summary information about the member.
Actor process member data as per his/ her rights.
Use case ends when information is presented to the correct method of delivery.

28

Library Management System

Use Case Model: Manage Members

View /
Navigate
Member Data

Validation

User
Add Member

Transaction
Edit Member
Supervisor
Delete
Member Data

Administrator

29

Library Management System

Use Case
Issue Book
Title:
Issue Book
Abbreviated Title:
Issue Book
Requirement ID:
03
Intent
Enable actor to issue book
Scenario Narrative
An actor wants to issue new book to selected member.
Assumptions/Preconditions
The actor has rights to access to the Library Management System, and having
rights to issue book.
Actor
Supervisor
Basic Course:
Use case begins when actor decides to issue book.
System checks the status of the book and library card.
Systems displays actor the status of book and card, if it already issued,
system warns actor that fact.
Otherwise system updates the transaction.
System display message for confirmation.

30

Library Management System

Use Case Model: Issue Book

Select Book ID,


Member ID
Transaction

Supervisor
System Check
the status

Book Master
Issue Book
Member
Master

31

Library Management System

Use Case
Receive Book
Title:
Receive Book
Abbreviated Title:
Receive Book
Requirement ID:
03
Intent
Enable actor to receive book
Scenario Narrative
An actor wants to issue receive book from selected member.
Assumptions/Preconditions
The actor has rights to access to the Library Management System, and having
rights to receive book.
Actor
Supervisor
Basic Course:
Use case begins when actor decides to receive book.
User enters the transaction number, or find the transaction number
System checks the status of the book and library card.
Systems displays actor the status of book and card, if it already received,
system warns actor that fact.
System calculates the late fine if applicable.
Actor update the remarks, if any fault found.
Otherwise system updates the transaction.
System display message for confirmation.

32

Library Management System

Use Case Model: Receive Book

Select
Transaction ID
Transaction

Supervisor
System Check
the status

Book Master

Receive Book
Member
Master
Late Fine

33

Library Management System

6.2 Database Design:


The LMS implements MySql as the Backend and thus the database schema is
defined and modified through MySQL Query Browser. The LMS consists of five
tables to store all the information, and all the necessary information is extracted
from these tables through appropriate queries in Netbanse.
Data Dictionary:
1. User table:

Table name: Lib _user


Description: store the information of user who used the library system
Fields

Data type

Null/not null

Default value

rules

VARCHAR(45)

not null

VARCHAR(45)

not null

VARCHAR(45)

not null

User _Active VARCHAR(45)

not null

User _Name
User
_Password
User _Type

2. Book master table:


Table name: Lib _book _master
Description: store the information of books
Fields

Data type

Null/not null

Default value

rules

not null

Null

Book _id

INT(10)

Book _title

VARCHAR(100)

Null

Book _author

VARCHAR(100)

not null

Book _publisher

VARCHAR(100)

not null

Book _publish _year VARCHAR(45)

not null

Book _category

VARCHAR(100)

not null

Book _keyword

VARCHAR(250)

not null

VARCHAR(45)

not null

Null

Book _status

34

Library Management System

3.

Member master table:

Table name: Lib _member _master


Description: store the information of member
Fields
Data type
Null/not
null
Mem _id
INT(10)
not null
Mem _name
VARCHAR(100)
Mem _address
VARCHAR(250)
Mem _email _id
Mem _mobile _no
Mem _active

4.

VARCHAR(100)
VARCHAR(01)
VARCHAR(1)

Default
value
Null
Null

rules

Null

Null
Null

Null

Transaction table:

Table name: Lib _transaction


Description: Store for issuing and return books Details
Fields
Trn _id

Data type
INT(10)

Trn _mem _id


INT(10)
Trn _book _id
INT(10)
Trn _issue _dt
DATETIME
Trn _receive _dt
DATETIME

Null/not null
not null

Default
value
Null

rules

not null
not null
not null

Null

5. Book category Table:


Table name: lib _book _category
Description: Classification of types of books
Fields
Book _category

Data type
VARCHAR(100
)

Null/not null

Default value

rules

not null

35

Library Management System

Library ER Diagram:

MEM_NAME
MEM_ID
BOOK_ID
MEM_EMAIL

MEM_ADD

AUTHOR
MEMBER MASTER

Book master

TITLE

ISSUE/
RECEIVE

PROVIDED

PROVIDES

USER

Transaction

User _Password

User _ NAME

Trn _id
ISSUE BOOK_dt

RECEIVE BOOK_dt

36

Library Management System

6.3 User Interface Design:

Library Management System : Login

Library Management System : Main Screen

Library Management System : User Master

37

Library Management System

Library Management System : Change Password

Library Management System : Book Master

Library Management System : Search Book

38

Library Management System

Library Management System : Book Status

Library Management System : MemberMaster

Library Management System : Search Member

39

Library Management System

Library Management System : Issue Book

Library Management System : Receive Book

40

Library Management System

Library Management System : Transaction Report

Library Management System : About

41

Library Management System

7. REAL SCREEN SHOTS OF DATA ENTRY FORMS


AND REPORTS
Login Page:

42

Library Management System

Main Screen

User Master

43

Library Management System

Change Password

44

Library Management System

Book Master

Search Book

45

Library Management System

Book Status

Member Master

46

Library Management System

Search Member

Issue Book

47

Library Management System

Receive Book

Transaction Report

48

Library Management System

8. CODING OF IMPORTANT FUNCTIONS AND


PROCEDURES OF THE SOFTWARE:
1. Login page code :
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;

public class Login extends javax.swing.JFrame {


/** Creates new form Login */
public Login() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
TxtUserName = new javax.swing.JTextField();
CmdOk = new javax.swing.JButton();
CmdClose = new javax.swing.JButton();
TxtPassword = new javax.swing.JPasswordField();
jLabel4 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Login to Library Mangement System");
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}

49

Library Management System

});
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText(" JAVA Library Managemnet System");
jLabel2.setText("User Name:");
jLabel3.setText("Password:");
CmdOk.setText("Ok");
CmdOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdOkActionPerformed(evt);
}
});
CmdClose.setText("Close");
CmdClose.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdCloseActionPerformed(evt);
}
});
jLabel4.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\logan.jpg")); // NOI18N
javax.swing.GroupLayout
jPanel1Layout
javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

new

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(170, 170, 170)
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE,
80,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)

50

Library Management System

.addComponent(TxtUserName,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(180, 180, 180)

130,

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addComponent(jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE,
80,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(70, 70, 70)
.addComponent(TxtPassword,
javax.swing.GroupLayout.PREFERRED_SIZE,
130,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(220, 220, 220)
.addComponent(CmdOk)
.addGap(5, 5, 5)
.addComponent(CmdClose,
javax.swing.GroupLayout.PREFERRED_SIZE,
76,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(60, 60, 60)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
321,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel4))
.addGap(14, 14, 14))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE,
30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(10, 10, 10)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE,
20, javax.swing.GroupLayout.PREFERRED_SIZE)

51

Library Management System

.addComponent(TxtUserName,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(10, 10, 10)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE,
20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TxtPassword,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(10, 10, 10)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addComponent(CmdOk)
.addComponent(CmdClose)))
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 180,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
javax.swing.GroupLayout
layout
=
new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 392,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>
private void CmdCloseActionPerformed(java.awt.event.ActionEvent evt) {
// Close project

52

Library Management System

System.exit(1);
}
private void CmdOkActionPerformed(java.awt.event.ActionEvent evt) {
//validation
String stru="";
stru=TxtUserName.getText();
String strp="";
strp=TxtPassword.getText();
if (stru.isEmpty()==true)
{
JOptionPane.showMessageDialog(null,"Enter User Name");
return;
}
if (strp.isEmpty()==true)
{
JOptionPane.showMessageDialog(null,"Enter Password");
return;
}
try
{
//get database connection details
MainClass mc=new MainClass();
//open connection
Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
String str="";
str="select * from lib_user where user_name =? and user_password =?";
PreparedStatement pst=connection.prepareStatement(str);
pst.setString(1, stru);
pst.setString(2, strp);
ResultSet rs;
rs=pst.executeQuery();
if (rs.next())
{
MainClass.StrUser=TxtUserName.getText();
MainForm m=new MainForm();
m.setVisible(true);
this.setVisible(false);
}

53

Library Management System

else
{
JOptionPane.showMessageDialog(null,"User name or password are not
correct.");
return;
}

}
catch (Exception e)
{
System.err.println(e);
System.exit(1);
}

}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
this.setLocationRelativeTo(null);
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Login().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton CmdClose;
private javax.swing.JButton CmdOk;
private javax.swing.JPasswordField TxtPassword;
private javax.swing.JTextField TxtUserName;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
// End of variables declaration
}

54

Library Management System

2. Main Screen code :


public class MainForm extends javax.swing.JFrame {
/** Creates new form Main */
public MainForm() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
MnuExits = new javax.swing.JMenuItem();
jMenu6 = new javax.swing.JMenu();
jMenuItem7 = new javax.swing.JMenuItem();
jMenuItem8 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
MnuBookMaster = new javax.swing.JMenuItem();
MnuSearchBook = new javax.swing.JMenuItem();
MnuBookStatus = new javax.swing.JMenuItem();
jMenu3 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenu4 = new javax.swing.JMenu();
jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem4 = new javax.swing.JMenuItem();
jMenuItem6 = new javax.swing.JMenuItem();
jMenu5 = new javax.swing.JMenu();

55

Library Management System

jMenuItem5 = new javax.swing.JMenuItem();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE
);
setTitle("Library Mangement System");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
jLabel1.setFont(new java.awt.Font("Rockwell", 1, 60)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("WELCOME");
jLabel2.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\logo.png"));
NOI18N

//

jLabel4.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N


jLabel4.setText("LIBRARY MANGEMENT SYSTEM");
jLabel3.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\mainform.jpg"));
// NOI18N
javax.swing.GroupLayout
jPanel1Layout
javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

new

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(103, 103, 103)
.addComponent(jLabel4,
javax.swing.GroupLayout.PREFERRED_SIZE,
285,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(150, 150, 150)
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE,
170,
javax.swing.GroupLayout.PREFERRED_SIZE))

56

Library Management System

.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(41, 41, 41)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
jPanel1Layout.setVerticalGroup(

380,

710,

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(151, 151, 151)
.addComponent(jLabel4,
javax.swing.GroupLayout.PREFERRED_SIZE,
59,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(190, 190, 190)
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE,
90,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
150,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE,
410,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
jMenuBar1.setBackground(new java.awt.Color(249, 60, 139));
jMenu1.setBackground(new java.awt.Color(249, 60, 139));
jMenu1.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\1.png"));
NOI18N
jMenu1.setText("File");

//

MnuExits.setBackground(new java.awt.Color(249, 60, 139));

57

Library Management System

MnuExits.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\7.png"));
NOI18N
MnuExits.setText("Exit");
MnuExits.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MnuExitsActionPerformed(evt);
}
});
jMenu1.add(MnuExits);

//

jMenuBar1.add(jMenu1);
jMenu6.setBackground(new java.awt.Color(249, 60, 139));
jMenu6.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\2.png"));
NOI18N
jMenu6.setText("Admin");

//

jMenuItem7.setBackground(new java.awt.Color(249, 60, 139));


jMenuItem7.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\8.png"));
//
NOI18N
jMenuItem7.setText("User Master");
jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem7ActionPerformed(evt);
}
});
jMenu6.add(jMenuItem7);
jMenuItem8.setBackground(new java.awt.Color(249, 60, 139));
jMenuItem8.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\9.png"));
//
NOI18N
jMenuItem8.setText("Change Password");
jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem8ActionPerformed(evt);
}
});
jMenu6.add(jMenuItem8);
jMenuBar1.add(jMenu6);

58

Library Management System

jMenu2.setBackground(new java.awt.Color(249, 60, 139));


jMenu2.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\3.png"));
NOI18N
jMenu2.setText("Book Status");

//

MnuBookMaster.setBackground(new java.awt.Color(249, 60, 139));


MnuBookMaster.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\15.png"));
//
NOI18N
MnuBookMaster.setText("Book Master");
MnuBookMaster.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
MnuBookMasterActionPerformed(evt);
}
});
jMenu2.add(MnuBookMaster);
MnuSearchBook.setBackground(new java.awt.Color(249, 60, 139));
MnuSearchBook.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\14.png"));
//
NOI18N
MnuSearchBook.setText("Search Book");
MnuSearchBook.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
MnuSearchBookActionPerformed(evt);
}
});
jMenu2.add(MnuSearchBook);
MnuBookStatus.setBackground(new java.awt.Color(249, 60, 139));
MnuBookStatus.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\18.png"));
//
NOI18N
MnuBookStatus.setText("Book Status");
MnuBookStatus.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
MnuBookStatusActionPerformed(evt);
}
});

59

Library Management System

jMenu2.add(MnuBookStatus);
jMenuBar1.add(jMenu2);
jMenu3.setBackground(new java.awt.Color(249, 60, 139));
jMenu3.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\4.png"));
NOI18N
jMenu3.setText("Member");

//

jMenuItem1.setBackground(new java.awt.Color(249, 60, 139));


jMenuItem1.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\16.png"));
//
NOI18N
jMenuItem1.setText("Member Master");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem1);
jMenuItem2.setBackground(new java.awt.Color(249, 60, 139));
jMenuItem2.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\17.png"));
//
NOI18N
jMenuItem2.setText("Search Mamber");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem2);
jMenuBar1.add(jMenu3);
jMenu4.setBackground(new java.awt.Color(249, 60, 139));
jMenu4.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\5.png"));
NOI18N
jMenu4.setText("Transaction");
jMenu4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenu4ActionPerformed(evt);

//

60

Library Management System

}
});
jMenuItem3.setBackground(new java.awt.Color(249, 60, 139));
jMenuItem3.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\11.png"));
//
NOI18N
jMenuItem3.setText("Issue Book");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem3);
jMenuItem4.setBackground(new java.awt.Color(249, 60, 139));
jMenuItem4.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\12.png"));
//
NOI18N
jMenuItem4.setText("Receive Book");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem4);
jMenuItem6.setBackground(new java.awt.Color(249, 60, 139));
jMenuItem6.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\13.png"));
//
NOI18N
jMenuItem6.setText("Transaction Report ");
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem6ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem6);
jMenuBar1.add(jMenu4);
jMenu5.setBackground(new java.awt.Color(249, 60, 139));

61

Library Management System

jMenu5.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\6.png"));
NOI18N
jMenu5.setText("Help");

//

jMenuItem5.setBackground(new java.awt.Color(249, 60, 139));


jMenuItem5.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\10.png"));
//
NOI18N
jMenuItem5.setText("About");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem5);
jMenuBar1.add(jMenu5);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout
layout
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

new

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>

62

Library Management System

private void MnuExitsActionPerformed(java.awt.event.ActionEvent evt) {


System.exit(1);
}
private void MnuBookMasterActionPerformed(java.awt.event.ActionEvent
evt) {
BookMaster b=new BookMaster();
b.setVisible(true);
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
this.setLocationRelativeTo(null);
}
private void MnuSearchBookActionPerformed(java.awt.event.ActionEvent
evt) {
SearchBook b=new SearchBook();
b.setVisible(true);
}
private void MnuBookStatusActionPerformed(java.awt.event.ActionEvent
evt) {
BookStatus b=new BookStatus();
b.setVisible(true);
}
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt)
{
MemberMaster b=new MemberMaster();
b.setVisible(true);
}
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt)
{
SearchMember b=new SearchMember();
b.setVisible(true);
}
private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt)
{
UserMaster b=new UserMaster();
b.setVisible(true);

63

Library Management System

}
private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt)
{
ChangePassword b=new ChangePassword();
b.setVisible(true);
}
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt)
{
About b=new About();
b.setVisible(true);
}
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt)
{
IssueBook b=new IssueBook();
b.setVisible(true);
}
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt)
{
ReceiveBook b=new ReceiveBook();
b.setVisible(true);
}
private void jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
}
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt)
{
TransactionReport b=new TransactionReport();
b.setVisible(true);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainForm().setVisible(true);
}

64

Library Management System

});
}
// Variables declaration - do not modify
private javax.swing.JMenuItem MnuBookMaster;
private javax.swing.JMenuItem MnuBookStatus;
private javax.swing.JMenuItem MnuExits;
private javax.swing.JMenuItem MnuSearchBook;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenu jMenu5;
private javax.swing.JMenu jMenu6;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem7;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JPanel jPanel1;
// End of variables declaration
}

3. User Master code:


import java.sql.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
/**
*
* @author Administrator
*/

65

Library Management System

public class UserMaster extends javax.swing.JFrame {


MainClass mc=new MainClass();
ResultSet rsuser;
int rspos=0;
int rscount=0;
boolean chadd=false;
/** Creates new form UserMaster */
public UserMaster() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
ChkUserActive = new javax.swing.JCheckBox();
CmbUserType = new javax.swing.JComboBox();
TxtPassword = new javax.swing.JTextField();
TxtUserName = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
LblPosition = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
CmdLast = new javax.swing.JButton();
CmdClose = new javax.swing.JButton();
CmdFirst = new javax.swing.JButton();
CmdPrevious = new javax.swing.JButton();
CmdNext = new javax.swing.JButton();
CmdNew = new javax.swing.JButton();
CmdEdit = new javax.swing.JButton();
CmdSave = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CL
OSE);
setTitle(" User Master");
addWindowListener(new java.awt.event.WindowAdapter() {

66

Library Management System

public void windowOpened(java.awt.event.WindowEvent evt) {


formWindowOpened(evt);
}
});
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel1.setText("Library - User Master");
ChkUserActive.setText("Member Active");
CmbUserType.setModel(new javax.swing.DefaultComboBoxModel(new
String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
TxtPassword.setText("jTextField1");
TxtUserName.setText("jTextField1");
jLabel4.setText("Password :");
jLabel8.setText("User Type :");
jLabel3.setText("User Name :");
LblPosition.setText("position");
CmdLast.setText("Last");
CmdLast.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdLastActionPerformed(evt);
}
});
CmdClose.setText("Close");
CmdClose.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdCloseActionPerformed(evt);
}
});
CmdFirst.setText("Fisrt");
CmdFirst.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdFirstActionPerformed(evt);
}

67

Library Management System

});
CmdPrevious.setText("Previous");
CmdPrevious.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdPreviousActionPerformed(evt);
}
});
CmdNext.setText("Next");
CmdNext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdNextActionPerformed(evt);
}
});
CmdNew.setText("New");
CmdNew.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdNewActionPerformed(evt);
}
});
CmdEdit.setText("Edit");
CmdEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdEditActionPerformed(evt);
}
});
CmdSave.setText("Save");
CmdSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdSaveActionPerformed(evt);
}
});
jLabel2.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\UserMaster.jpg")
); // NOI18N
javax.swing.GroupLayout
jPanel1Layout
javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);

new

68

Library Management System

jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(69, 69, 69)
.addComponent(CmdPrevious)
.addGap(67, 67, 67)
.addComponent(CmdLast)
.addGap(201, 201, 201)
.addComponent(CmdClose))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(284, 284, 284)
.addComponent(CmdNew))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(400, 400, 400)
.addComponent(CmdSave))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(343, 343, 343)
.addComponent(CmdEdit))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(CmdFirst))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(148, 148, 148)
.addComponent(CmdNext))
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE,
680,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addComponent(jLabel2)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(297, 297, 297)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alig
nment.LEADING)
.addComponent(CmdPrevious)
.addComponent(CmdLast)
.addComponent(CmdClose)
.addComponent(CmdNew)

69

Library Management System

.addComponent(CmdSave)
.addComponent(CmdEdit)
.addComponent(CmdFirst)
.addComponent(CmdNext)))
);
javax.swing.GroupLayout
layout
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

new

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
160,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(50, 50, 50)
.addComponent(jLabel3))
.addGroup(layout.createSequentialGroup()
.addGap(130, 130, 130)
.addComponent(CmbUserType,
javax.swing.GroupLayout.PREFERRED_SIZE,
187,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(113, 113, 113)
.addComponent(LblPosition))
.addGroup(layout.createSequentialGroup()
.addGap(130, 130, 130)
.addComponent(TxtPassword,
javax.swing.GroupLayout.PREFERRED_SIZE,
187,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(150, 150, 150)
.addComponent(ChkUserActive))
.addGroup(layout.createSequentialGroup()
.addGap(50, 50, 50)
.addComponent(jLabel4))
.addGroup(layout.createSequentialGroup()
.addGap(130, 130, 130)
.addComponent(TxtUserName,
javax.swing.GroupLayout.PREFERRED_SIZE,
187,
javax.swing.GroupLayout.PREFERRED_SIZE))

70

Library Management System

.addGroup(layout.createSequentialGroup()
.addGap(50, 50, 50)
.addComponent(jLabel8,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(

80,

677,

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
20,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(40, 40, 40)
.addComponent(jLabel3)
.addGap(56, 56, 56)
.addComponent(CmbUserType,
javax.swing.GroupLayout.PREFERRED_SIZE,
25,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(102, 102, 102)
.addComponent(LblPosition))
.addGroup(layout.createSequentialGroup()
.addGap(110, 110, 110)
.addComponent(TxtPassword,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(193, 193, 193)
.addComponent(ChkUserActive))
.addGroup(layout.createSequentialGroup()
.addGap(110, 110, 110)
.addComponent(jLabel4))
.addGroup(layout.createSequentialGroup()
.addGap(80, 80, 80)
.addComponent(TxtUserName,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(150, 150, 150)

71

Library Management System

.addComponent(jLabel8,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
);

20,

pack();
}// </editor-fold>
private void CmdFirstActionPerformed(java.awt.event.ActionEvent evt) {
try {
rsuser.first();
Display();
} catch (Exception e) {
System.err.println(e);
}
}
private void CmdPreviousActionPerformed(java.awt.event.ActionEvent evt)
{
try {
if (rsuser.isFirst()==true) {
JOptionPane.showMessageDialog(null,"Already in first record.");
return;
}
rsuser.previous();
Display();
} catch (Exception e) {
System.err.println(e);
}
}
private void CmdNextActionPerformed(java.awt.event.ActionEvent evt) {
try {
if (rsuser.isLast()==true) {

72

Library Management System

JOptionPane.showMessageDialog(null,"Already in last record.");


return;
}
rsuser.next();
Display();
} catch (Exception e) {
System.err.println(e);
}
}
private void CmdLastActionPerformed(java.awt.event.ActionEvent evt) {
try {
rsuser.last();
Display();
} catch (Exception e) {
System.err.println(e);
//System.exit(1);
}
}
private void CmdNewActionPerformed(java.awt.event.ActionEvent evt) {
chadd=true;
ClearText();
}
private void CmdEditActionPerformed(java.awt.event.ActionEvent evt) {
chadd=false;
}
private void CmdSaveActionPerformed(java.awt.event.ActionEvent evt) {
//validate entry and save record
try {
if (TxtUserName.getText().trim().length()==0 ) {
JOptionPane.showMessageDialog(null,"Enter user name.");
return;
}
if (TxtPassword.getText().trim().length()==0 ) {
JOptionPane.showMessageDialog(null,"Enter password.");

73

Library Management System

return;
}

//String strqr="";
Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
if (chadd==true ) {
rsuser.moveToInsertRow();
rsuser.updateString("user_name",TxtUserName.getText());
rsuser.updateString("user_password",TxtPassword.getText());
rsuser.updateString("user_type",CmbUserType.getSelectedItem().toString());
if (ChkUserActive.isSelected()==true) {
rsuser.updateString("user_active","YES");
} else {
rsuser.updateString("user_active","NO");
}
rsuser.insertRow();
rsuser.last();
Display();
} else {
rsuser.updateString("user_password",TxtPassword.getText());
rsuser.updateString("user_type",CmbUserType.getSelectedItem().toString());
if (ChkUserActive.isSelected()==true) {
rsuser.updateString("user_active","YES");
} else {
rsuser.updateString("user_active","NO");
}

74

Library Management System

rsuser.updateRow();
rsuser.refreshRow();
}
chadd=false;
JOptionPane.showMessageDialog(null,"Record updated.");
} catch (Exception e) {
System.err.println(e);
JOptionPane.showMessageDialog(null,"Unable to save record.");
return;
}
}
private void CmdCloseActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.setVisible(false);
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
try
{
this.setLocationRelativeTo(null);
ClearText();
CmbUserType.removeAllItems();
CmbUserType.addItem("Admin");
CmbUserType.addItem("User");
Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
ResultSet rs;
PreparedStatement stmt;
//get user count
stmt=connection.prepareStatement("select count(*) from lib_user");
rs = stmt.executeQuery();
rs.first();
rscount=rs.getInt(1);
//get user details

75

Library Management System

Statement
stmt1
connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sqlQuery = "select * from lib_user ";
rsuser = stmt1.executeQuery(sqlQuery);

//display first record


rsuser.first();
Display();
}
catch (Exception e)
{
System.err.println(e);
//System.exit(1);
}
}
private void Display()
{
try
{
//clear text of fields for entry/display old data
TxtUserName.setText(rsuser.getString("user_name"));
TxtPassword.setText(rsuser.getString("user_password"));
CmbUserType.setSelectedItem(rsuser.getString("user_type"));
if (rsuser.getString("user_active").equals("YES"))
{
ChkUserActive.setSelected(true);
}
else
{
ChkUserActive.setSelected(false);
}
LblPosition.setText("Record position : " + rsuser.getRow() + "/" +
String.valueOf(rscount));
}
catch (Exception e)
{
System.err.println(e);

76

Library Management System

}
}
private void ClearText()
{
//clear text of fields for entry/display old data
TxtUserName.setText("");
TxtPassword.setText("");
ChkUserActive.setSelected(false);

LblPosition.setText("");
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new UserMaster().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JCheckBox ChkUserActive;
private javax.swing.JComboBox CmbUserType;
private javax.swing.JButton CmdClose;
private javax.swing.JButton CmdEdit;
private javax.swing.JButton CmdFirst;
private javax.swing.JButton CmdLast;
private javax.swing.JButton CmdNew;
private javax.swing.JButton CmdNext;
private javax.swing.JButton CmdPrevious;
private javax.swing.JButton CmdSave;
private javax.swing.JLabel LblPosition;
private javax.swing.JTextField TxtPassword;
private javax.swing.JTextField TxtUserName;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;

77

Library Management System

private javax.swing.JLabel jLabel8;


private javax.swing.JPanel jPanel1;
// End of variables declaration
}

4. Change Password code:


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;

public class ChangePassword extends javax.swing.JFrame {


/** Creates new form ChangePassword */
public ChangePassword() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
CmdOk = new javax.swing.JButton();
CmdClose = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
TxtConfirmPassword = new javax.swing.JPasswordField();
TxtNewPassword = new javax.swing.JPasswordField();
TxtOldPassword = new javax.swing.JPasswordField();
jPanel1 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();

78

Library Management System

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CL
OSE);
setTitle("Change Password");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
CmdOk.setText("Ok");
CmdOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdOkActionPerformed(evt);
}
});
CmdClose.setText("Close");
CmdClose.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdCloseActionPerformed(evt);
}
});
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel1.setText(" Library - Change Password");
jLabel5.setText("Confirm Password:");
jLabel4.setText("New Password:");
jLabel3.setText("Old Password:");
jLabel2.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\ChangePassword.
jpg")); // NOI18N
javax.swing.GroupLayout
jPanel1Layout
javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

new

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)

79

Library Management System

.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
jPanel1Layout.setVerticalGroup(

430,

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE,
240,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
javax.swing.GroupLayout
layout
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

new

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(80, 80, 80)
.addComponent(jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE,
110,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(TxtOldPassword,
javax.swing.GroupLayout.PREFERRED_SIZE,
136,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(80, 80, 80)
.addComponent(jLabel4,
javax.swing.GroupLayout.PREFERRED_SIZE,
120,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(190, 190, 190)
.addComponent(TxtConfirmPassword,
javax.swing.GroupLayout.PREFERRED_SIZE,
136,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(154, 154, 154)
.addComponent(CmdOk)
.addGap(6, 6, 6)

80

Library Management System

.addComponent(CmdClose,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(190, 190, 190)
.addComponent(TxtNewPassword,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(80, 80, 80)
.addComponent(jLabel5,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel1))
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(

76,

136,

120,

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(60, 60, 60)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE,
20,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(TxtOldPassword,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(10, 10, 10)
.addComponent(jLabel4,
javax.swing.GroupLayout.PREFERRED_SIZE,
20,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6, 6)

81

Library Management System

.addComponent(TxtConfirmPassword,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(CmdOk)
.addComponent(CmdClose)))
.addGroup(layout.createSequentialGroup()
.addGap(90, 90, 90)
.addComponent(TxtNewPassword,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(114, 114, 114)
.addComponent(jLabel5,
javax.swing.GroupLayout.PREFERRED_SIZE,
30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(12, 12, 12)
.addComponent(jLabel1))
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>
private void CmdOkActionPerformed(java.awt.event.ActionEvent evt) {
//validation

try {
if (TxtOldPassword.getText().isEmpty()==true) {
JOptionPane.showMessageDialog(null,"Enter Old Password.");
return;
}

82

Library Management System

if (TxtNewPassword.getText().isEmpty()==true) {
JOptionPane.showMessageDialog(null,"Enter New Password.");
return;
}
if
(TxtNewPassword.getText().equals(TxtConfirmPassword.getText()
)==false) {
JOptionPane.showMessageDialog(null,"New and Confirm passwords
are not matched.");
return;
}

//get database connection details


MainClass mc=new MainClass();
//open connection
Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
String str="";
str="select * from lib_user where user_name =? and user_password =?";
PreparedStatement pst=connection.prepareStatement(str);
pst.setString(1, MainClass.StrUser);
pst.setString(2, TxtOldPassword.getText());
ResultSet rs;
rs=pst.executeQuery();
if (rs.next()) {
//Update password
String sql = "UPDATE lib_user SET user_password='" +
TxtNewPassword.getText() + "' WHERE user_name = '" + MainClass.StrUser
+"'";

pst.executeUpdate(sql);
JOptionPane.showMessageDialog(null,"Password updated.");
this.setVisible(false);
} else {
JOptionPane.showMessageDialog(null,"Old
correct.");
return;

password

are

not

83

Library Management System

} catch (Exception e) {
System.err.println(e);
System.exit(1);
}
}
private void CmdCloseActionPerformed(java.awt.event.ActionEvent evt) {
// Close project
this.setVisible(false);
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
this.setLocationRelativeTo(null);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ChangePassword().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton CmdClose;
private javax.swing.JButton CmdOk;
private javax.swing.JPasswordField TxtConfirmPassword;
private javax.swing.JPasswordField TxtNewPassword;
private javax.swing.JPasswordField TxtOldPassword;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
// End of variables declaration
}

84

Library Management System

5. Book Master code:


public class BookMaster extends javax.swing.JFrame {
MainClass mc=new MainClass();
ResultSet rsbook;
int rspos=0;
int rscount=0;
boolean chadd=false;
/** Creates new form BookMaster */
public BookMaster() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
TxtBookID = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
TxtBookTitle = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
TxtAuthor = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
TxtPublisher = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
TxtYear = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
TxtKeywords = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
CmbCategory = new javax.swing.JComboBox();
CmdFirst = new javax.swing.JButton();
CmdPrevious = new javax.swing.JButton();
CmdNext = new javax.swing.JButton();
CmdLast = new javax.swing.JButton();
CmdNew = new javax.swing.JButton();
CmdEdit = new javax.swing.JButton();
CmdSave = new javax.swing.JButton();

85

Library Management System

CmdClose = new javax.swing.JButton();


LblPosition = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jLabel10 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CL
OSE);
setTitle(" Book Master");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel1.setText(" Library - Book Master");
jLabel2.setText("Book ID:");
TxtBookID.setEditable(false);
TxtBookID.setText("jTextField1");
jLabel3.setText("Book Title:");
TxtBookTitle.setText("jTextField1");
jLabel4.setText("Author:");
TxtAuthor.setText("jTextField1");
jLabel5.setText("Publisher:");
TxtPublisher.setText("jTextField1");
jLabel6.setText("Year Publish:");
TxtYear.setText("jTextField1");
jLabel7.setText("Search Keyword:");
TxtKeywords.setText("jTextField1");
jLabel8.setText("Category:");

86

Library Management System

CmbCategory.setModel(new javax.swing.DefaultComboBoxModel(new
String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
CmdFirst.setText("Fisrt");
CmdFirst.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdFirstActionPerformed(evt);
}
});
CmdPrevious.setText("Previous");
CmdPrevious.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdPreviousActionPerformed(evt);
}
});
CmdNext.setText("Next");
CmdNext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdNextActionPerformed(evt);
}
});
CmdLast.setText("Last");
CmdLast.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdLastActionPerformed(evt);
}
});
CmdNew.setText("New");
CmdNew.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdNewActionPerformed(evt);
}
});
CmdEdit.setText("Edit");
CmdEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdEditActionPerformed(evt);
}

87

Library Management System

});
CmdSave.setText("Save");
CmdSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdSaveActionPerformed(evt);
}
});
CmdClose.setText("Close");
CmdClose.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdCloseActionPerformed(evt);
}
});
LblPosition.setText("Book ID:");
jPanel1.setLayout(null);
jLabel10.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\BookMaster.jpg"
)); // NOI18N
jPanel1.add(jLabel10);
jLabel10.setBounds(0, 0, 620, 410);
javax.swing.GroupLayout
layout
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

new

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(87, 87, 87)
.addComponent(jLabel2)
.addGap(68, 68, 68)
.addComponent(TxtBookID,
javax.swing.GroupLayout.PREFERRED_SIZE,
198,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(87, 87, 87)

88

Library Management System

.addComponent(jLabel3)
.addGap(59, 59, 59)
.addComponent(TxtBookTitle,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(87, 87, 87)
.addComponent(jLabel4)
.addGap(72, 72, 72)
.addComponent(TxtAuthor,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(87, 87, 87)
.addComponent(jLabel5)
.addGap(62, 62, 62)
.addComponent(TxtPublisher,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(87, 87, 87)
.addComponent(jLabel6)
.addGap(47, 47, 47)
.addComponent(TxtYear,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(87, 87, 87)
.addComponent(jLabel8)
.addGap(60, 60, 60)
.addComponent(CmbCategory,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(87, 87, 87)
.addComponent(jLabel7)
.addGap(27, 27, 27)
.addComponent(TxtKeywords,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(143, 143, 143)
.addComponent(LblPosition))
.addGroup(layout.createSequentialGroup()

198,

198,

198,

198,

198,

197,

89

Library Management System

.addGap(25, 25, 25)


.addComponent(CmdFirst)
.addGap(85, 85, 85)
.addComponent(CmdNext)
.addGap(6, 6, 6)
.addComponent(CmdLast)
.addGap(63, 63, 63)
.addComponent(CmdNew)
.addGap(7, 7, 7)
.addComponent(CmdEdit)
.addGap(6, 6, 6)
.addComponent(CmdSave)
.addGap(6, 6, 6)
.addComponent(CmdClose))
.addGroup(layout.createSequentialGroup()
.addGap(84, 84, 84)
.addComponent(CmdPrevious))
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(

620,

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(jLabel1)
.addGap(21, 21, 21)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(layout.createSequentialGroup()
.addGap(5, 5, 5)
.addComponent(jLabel2))
.addComponent(TxtBookID,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(layout.createSequentialGroup()
.addGap(1, 1, 1)
.addComponent(jLabel3))

90

Library Management System

.addComponent(TxtBookTitle,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(6, 6, 6)

23,

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jLabel4))
.addComponent(TxtAuthor,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel5)
.addComponent(TxtPublisher,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(2, 2, 2)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel6)
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(TxtYear,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel8)
.addGroup(layout.createSequentialGroup()
.addGap(1, 1, 1)
.addComponent(CmbCategory,
javax.swing.GroupLayout.PREFERRED_SIZE,
25,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(19, 19, 19)

91

Library Management System

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel7)
.addComponent(TxtKeywords,
javax.swing.GroupLayout.PREFERRED_SIZE,
45,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(43, 43, 43)
.addComponent(LblPosition)
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(CmdFirst)
.addComponent(CmdNext)
.addComponent(CmdLast)
.addComponent(CmdNew)
.addComponent(CmdEdit)
.addComponent(CmdSave)
.addComponent(CmdClose)))
.addGroup(layout.createSequentialGroup()
.addGap(345, 345, 345)
.addComponent(CmdPrevious))
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
410,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>
private void CmdCloseActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.setVisible(false);
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
try
{
this.setLocationRelativeTo(null);

92

Library Management System

ClearText();
CmbCategory.removeAllItems();
Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
ResultSet rs;
//fill book category
PreparedStatement stmt=connection.prepareStatement("select * from
lib_book_category order by book_category");
rs = stmt.executeQuery();
while (rs.next()){
CmbCategory.addItem(rs.getString(1));
}
rs.close();

//get book count


stmt=connection.prepareStatement("select
lib_book_master");
rs = stmt.executeQuery();
rs.first();
rscount=rs.getInt(1);

count(*)

from

//get book details


Statement
stmt1
=
connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sqlQuery = "select * from lib_book_master order by book_id";
rsbook = stmt1.executeQuery(sqlQuery);
//display first record
rsbook.first();
Display();
}
catch (Exception e)
{
System.err.println(e);
//System.exit(1);
}
}

93

Library Management System

private void CmdNewActionPerformed(java.awt.event.ActionEvent evt) {


chadd=true;
ClearText();
}
private void CmdNextActionPerformed(java.awt.event.ActionEvent evt) {
try
{
if (rsbook.isLast()==true)
{
JOptionPane.showMessageDialog(null,"Already in last record.");
return;
}
rsbook.next();
Display();
}
catch (Exception e)
{
System.err.println(e);
}
}
private void CmdFirstActionPerformed(java.awt.event.ActionEvent evt) {
try
{
rsbook.first();
Display();
}
catch (Exception e)
{
System.err.println(e);
}
}

94

Library Management System

private void CmdPreviousActionPerformed(java.awt.event.ActionEvent evt)


{
try
{
if (rsbook.isFirst()==true)
{
JOptionPane.showMessageDialog(null,"Already in first record.");
return;
}
rsbook.previous();
Display();
}
catch (Exception e)
{
System.err.println(e);
}
}
private void CmdLastActionPerformed(java.awt.event.ActionEvent evt) {
try
{
rsbook.last();
Display();
}
catch (Exception e)
{
System.err.println(e);
//System.exit(1);
}
}
private void CmdEditActionPerformed(java.awt.event.ActionEvent evt) {
chadd=false;
}
private void CmdSaveActionPerformed(java.awt.event.ActionEvent evt) {

95

Library Management System

//validate entry and save record


try
{
if (TxtBookTitle.getText().trim().length()==0 )
{
JOptionPane.showMessageDialog(null,"Enter book title.");
return;
}
if (TxtAuthor.getText().trim().length()==0 )
{
JOptionPane.showMessageDialog(null,"Enter author.");
return;
}
if (TxtPublisher.getText().trim().length()==0)
{
JOptionPane.showMessageDialog(null,"Enter publisher name.");
return;
}
if (CmbCategory.getSelectedItem().equals(""))
{
JOptionPane.showMessageDialog(null,"Select book category.");
return;
}

//String strqr="";
Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
if (TxtBookID.getText().trim().length()==0 )
{
//strqr="insert into lib_book_master (book_title, book_author,
book_publisher, book_publish_year, book_category, book_keyword) values ('"
+ TxtBookTitle.getText() + "','" + TxtAuthor.getText() +"','"+
TxtPublisher.getText()
+"','"
+
TxtYear.getText()
+
"','"
+
CmbCategory.getSelectedItem().toString() +"','" + TxtKeywords.getText()
+"')";
rsbook.moveToInsertRow();

96

Library Management System

rsbook.updateString("book_title",TxtBookTitle.getText());
rsbook.updateString("book_author",TxtAuthor.getText());
rsbook.updateString("book_publisher",TxtPublisher.getText());
rsbook.updateString("book_publish_year",TxtYear.getText());
rsbook.updateString("book_category",CmbCategory.getSelectedItem().toStrin
g());
rsbook.updateString("book_keyword",TxtKeywords.getText());
rsbook.insertRow();
rsbook.last();
Display();
}
else
{
rsbook.updateString("book_title",TxtBookTitle.getText());
rsbook.updateString("book_author",TxtAuthor.getText());
rsbook.updateString("book_publisher",TxtPublisher.getText());
rsbook.updateString("book_publish_year",TxtYear.getText());
rsbook.updateString("book_category",CmbCategory.getSelectedItem().toStrin
g());
rsbook.updateString("book_keyword",TxtKeywords.getText());
rsbook.updateRow();
rsbook.refreshRow();
}

JOptionPane.showMessageDialog(null,"Record updated.");
}
catch (Exception e)
{
System.err.println(e);
JOptionPane.showMessageDialog(null,"Unable to save record.");
return;
}
}
private void Display()
{
try

97

Library Management System

{
//clear text of fields for entry/display old data
TxtBookID.setText(rsbook.getString("book_id"));
TxtBookTitle.setText(rsbook.getString("book_title"));
TxtAuthor.setText(rsbook.getString("book_author"));
TxtPublisher.setText(rsbook.getString("book_publisher"));
TxtYear.setText(rsbook.getString("book_publish_year"));
CmbCategory.setSelectedItem(rsbook.getString("book_category"));
TxtKeywords.setText(rsbook.getString("book_keyword"));
LblPosition.setText("Record position : " + rsbook.getRow() + "/" +
String.valueOf(rscount));
}
catch (Exception e)
{
System.err.println(e);
}
}
private void ClearText()
{
//clear text of fields for entry/display old data
TxtBookID.setText("");
TxtBookTitle.setText("");
TxtAuthor.setText("");
TxtPublisher.setText("");
TxtYear.setText("");
CmbCategory.setSelectedItem(null);
TxtKeywords.setText("");
LblPosition.setText("");
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new BookMaster().setVisible(true);
}
});

98

Library Management System

}
// Variables declaration - do not modify
private javax.swing.JComboBox CmbCategory;
private javax.swing.JButton CmdClose;
private javax.swing.JButton CmdEdit;
private javax.swing.JButton CmdFirst;
private javax.swing.JButton CmdLast;
private javax.swing.JButton CmdNew;
private javax.swing.JButton CmdNext;
private javax.swing.JButton CmdPrevious;
private javax.swing.JButton CmdSave;
private javax.swing.JLabel LblPosition;
private javax.swing.JTextField TxtAuthor;
private javax.swing.JTextField TxtBookID;
private javax.swing.JTextField TxtBookTitle;
private javax.swing.JTextField TxtKeywords;
private javax.swing.JTextField TxtPublisher;
private javax.swing.JTextField TxtYear;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
// End of variables declaration
}

6. Search Book code:


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try
{
MainClass mc=new MainClass();
Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
ResultSet rs;

99

Library Management System

String StrQr="";
if (TxtBookID.getText().trim().length()>0 )
{
StrQr=StrQr + " and book_id = " + TxtBookID.getText().trim() + " ";
}
if (TxtTitle.getText().trim().length()>0 )
{
StrQr=StrQr + " and book_title like '%" + TxtTitle.getText().trim() +
"%' ";
}
if (TxtKeyword.getText().trim().length()>0 )
{
StrQr=StrQr
+
"
and
book_keyword
TxtKeyword.getText().trim() + "%' ";
}

like

'%"

if (StrQr.length()==0)
{
JOptionPane.showMessageDialog(null,"Enter search critaria.");
return;
}

PreparedStatement stmt=connection.prepareStatement("select book_id,


book_title, book_category, book_keyword from lib_book_master where 1=1 "
+ StrQr + " order by book_id");
rs = stmt.executeQuery();

jTable1.getColumnModel().getColumn(0).setHeaderValue("Book
ID");
jTable1.getColumnModel().getColumn(1).setHeaderValue("Title");
jTable1.getColumnModel().getColumn(2).setHeaderValue("Category");
jTable1.getColumnModel().getColumn(3).setHeaderValue("Keyword");
jTable1.getTableHeader().resizeAndRepaint();
// Removing Previous Data
while (jTable1.getRowCount() > 0) {
((DefaultTableModel) jTable1.getModel()).removeRow(0);
}

100

Library Management System

//Creating Object []rowData for jTable's Table Model


int columns = rs.getMetaData().getColumnCount();
while (rs.next())
{
Object[] row = new Object[columns];
for (int i = 1; i <= columns; i++)
{
row[i - 1] = rs.getObject(i); // 1
}
((DefaultTableModel) jTable1.getModel()).insertRow(rs.getRow() 1,row);
}
}
catch (Exception e)
{
System.err.println(e);
//System.exit(1);
}
}
private void CmdCloseActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
TxtBookID.setText("");
TxtTitle.setText("");
TxtKeyword.setText("");
this.setLocationRelativeTo(null);

jTable1.getColumnModel().getColumn(0).setHeaderValue("Book ID");
jTable1.getColumnModel().getColumn(1).setHeaderValue("Title");
jTable1.getColumnModel().getColumn(2).setHeaderValue("Category");
jTable1.getColumnModel().getColumn(3).setHeaderValue("Keyword");
jTable1.getTableHeader().resizeAndRepaint();
// Removing Previous Data

101

Library Management System

while (jTable1.getRowCount() > 0) {


((DefaultTableModel) jTable1.getModel()).removeRow(0);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new SearchBook().setVisible(true);
}
});
}

7. Book Status code:


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
MainClass mc=new MainClass();
Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
ResultSet rs;

PreparedStatement stmt=connection.prepareStatement("select book_id,


book_title, book_category, book_status from lib_book_master order by
book_id");
rs = stmt.executeQuery();

jTable1.getColumnModel().getColumn(0).setHeaderValue("Book
ID");
jTable1.getColumnModel().getColumn(1).setHeaderValue("Title");
jTable1.getColumnModel().getColumn(2).setHeaderValue("Category");

102

Library Management System

jTable1.getColumnModel().getColumn(3).setHeaderValue("Status");
jTable1.getTableHeader().resizeAndRepaint();
// Removing Previous Data
while (jTable1.getRowCount() > 0) {
((DefaultTableModel) jTable1.getModel()).removeRow(0);
}

//Creating Object []rowData for jTable's Table Model


int columns = rs.getMetaData().getColumnCount();
while (rs.next()) {
Object[] row = new Object[columns];
for (int i = 1; i <= columns; i++) {
row[i - 1] = rs.getObject(i); // 1
}
((DefaultTableModel) jTable1.getModel()).insertRow(rs.getRow() 1,row);
}
} catch (Exception e) {
System.err.println(e);
//System.exit(1);
}
}
private void CmdCloseActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {

this.setLocationRelativeTo(null);

jTable1.getColumnModel().getColumn(0).setHeaderValue("Book ID");
jTable1.getColumnModel().getColumn(1).setHeaderValue("Title");
jTable1.getColumnModel().getColumn(2).setHeaderValue("Category");
jTable1.getColumnModel().getColumn(3).setHeaderValue("Status");
jTable1.getTableHeader().resizeAndRepaint();
// Removing Previous Data

103

Library Management System

while (jTable1.getRowCount() > 0) {


((DefaultTableModel) jTable1.getModel()).removeRow(0);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new BookStatus().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton CmdClose;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
// End of variables declaration
}

8. Member Master code:


import java.sql.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
public class MemberMaster extends javax.swing.JFrame {
MainClass mc=new MainClass();
ResultSet rsmem;
int rspos=0;
int rscount=0;
boolean chadd=false;
/** Creates new form MemberMaster */
public MemberMaster() {
initComponents();
}

104

Library Management System

/** This method is called from within the constructor to


* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
TxtMemID = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
TxtName = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
TxtAddress = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
TxtEmailID = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
TxtMobileNo = new javax.swing.JTextField();
LblPosition = new javax.swing.JLabel();
CmdFirst = new javax.swing.JButton();
CmdPrevious = new javax.swing.JButton();
CmdNext = new javax.swing.JButton();
CmdLast = new javax.swing.JButton();
CmdNew = new javax.swing.JButton();
CmdEdit = new javax.swing.JButton();
CmdSave = new javax.swing.JButton();
CmdClose = new javax.swing.JButton();
ChkMemActive = new javax.swing.JCheckBox();
jPanel1 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle(" Member Master");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel1.setText(" Library - Member Master");
jLabel2.setText("Member ID:");
TxtMemID.setEditable(false);
TxtMemID.setText("jTextField1");

105

Library Management System

jLabel3.setText("Name:");
TxtName.setText("jTextField1");
jLabel4.setText("Address:");
TxtAddress.setText("jTextField1");
jLabel5.setText("Email ID:");
TxtEmailID.setText("jTextField1");
jLabel6.setText("Mobile No:");
TxtMobileNo.setText("jTextField1");
LblPosition.setText("Book ID:");
CmdFirst.setText("Fisrt");
CmdFirst.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdFirstActionPerformed(evt);
}
});
CmdPrevious.setText("Previous");
CmdPrevious.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdPreviousActionPerformed(evt);
}
});
CmdNext.setText("Next");
CmdNext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdNextActionPerformed(evt);
}
});
CmdLast.setText("Last");
CmdLast.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdLastActionPerformed(evt);
}
});
CmdNew.setText("New");
CmdNew.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdNewActionPerformed(evt);

106

Library Management System

}
});
CmdEdit.setText("Edit");
CmdEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdEditActionPerformed(evt);
}
});
CmdSave.setText("Save");
CmdSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdSaveActionPerformed(evt);
}
});
CmdClose.setText("Close");
CmdClose.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdCloseActionPerformed(evt);
}
});
ChkMemActive.setText("Member Active");
jPanel1.setLayout(null);
jLabel7.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\membermaster.jpg")); //
NOI18N
jPanel1.add(jLabel7);
jLabel7.setBounds(0, 0, 580, 380);
javax.swing.GroupLayout
layout
=
new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(178, 178, 178)
.addComponent(TxtName, javax.swing.GroupLayout.PREFERRED_SIZE,
198, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(178, 178, 178)
.addComponent(TxtAddress,
javax.swing.GroupLayout.PREFERRED_SIZE,
198,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(178, 178, 178)

107

Library Management System

.addComponent(TxtEmailID,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(95, 95, 95)
.addComponent(jLabel6)
.addGap(33, 33, 33)
.addComponent(TxtMobileNo,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(90, 90, 90)
.addComponent(CmdPrevious)
.addGap(337, 337, 337)
.addComponent(CmdClose))
.addGroup(layout.createSequentialGroup()
.addGap(170, 170, 170)
.addComponent(CmdNext))
.addGroup(layout.createSequentialGroup()
.addGap(95, 95, 95)
.addComponent(jLabel5))
.addGroup(layout.createSequentialGroup()
.addGap(320, 320, 320)
.addComponent(CmdNew))
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(95, 95, 95)
.addComponent(jLabel3))
.addGroup(layout.createSequentialGroup()
.addGap(178, 178, 178)
.addComponent(ChkMemActive))
.addGroup(layout.createSequentialGroup()
.addGap(178, 178, 178)
.addComponent(TxtMemID,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(150, 150, 150)
.addComponent(LblPosition))
.addGroup(layout.createSequentialGroup()
.addGap(95, 95, 95)
.addComponent(jLabel4))
.addGroup(layout.createSequentialGroup()
.addGap(440, 440, 440)
.addComponent(CmdSave))
.addGroup(layout.createSequentialGroup()
.addGap(230, 230, 230)
.addComponent(CmdLast))

198,

198,

198,

108

Library Management System

.addGroup(layout.createSequentialGroup()
.addGap(380, 380, 380)
.addComponent(CmdEdit))
.addGroup(layout.createSequentialGroup()
.addGap(95, 95, 95)
.addComponent(jLabel2))
.addGroup(layout.createSequentialGroup()
.addGap(30, 30, 30)
.addComponent(CmdFirst))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 580,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(76, 76, 76)
.addComponent(TxtName, javax.swing.GroupLayout.PREFERRED_SIZE,
23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6, 6)
.addComponent(TxtAddress,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6, 6)
.addComponent(TxtEmailID,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jLabel6))
.addComponent(TxtMobileNo,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(144, 144, 144)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addComponent(CmdPrevious)
.addComponent(CmdClose)))
.addGroup(layout.createSequentialGroup()
.addGap(330, 330, 330)
.addComponent(CmdNext))
.addGroup(layout.createSequentialGroup()
.addGap(138, 138, 138)
.addComponent(jLabel5))
.addGroup(layout.createSequentialGroup()
.addGap(330, 330, 330)

109

Library Management System

.addComponent(CmdNew))
.addGroup(layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(84, 84, 84)
.addComponent(jLabel3))
.addGroup(layout.createSequentialGroup()
.addGap(204, 204, 204)
.addComponent(ChkMemActive))
.addGroup(layout.createSequentialGroup()
.addGap(47, 47, 47)
.addComponent(TxtMemID,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(310, 310, 310)
.addComponent(LblPosition))
.addGroup(layout.createSequentialGroup()
.addGap(109, 109, 109)
.addComponent(jLabel4))
.addGroup(layout.createSequentialGroup()
.addGap(330, 330, 330)
.addComponent(CmdSave))
.addGroup(layout.createSequentialGroup()
.addGap(330, 330, 330)
.addComponent(CmdLast))
.addGroup(layout.createSequentialGroup()
.addGap(330, 330, 330)
.addComponent(CmdEdit))
.addGroup(layout.createSequentialGroup()
.addGap(52, 52, 52)
.addComponent(jLabel2))
.addGroup(layout.createSequentialGroup()
.addGap(330, 330, 330)
.addComponent(CmdFirst))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 380,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>
private void Display()
{
try
{
//clear text of fields for entry/display old data
TxtMemID.setText(rsmem.getString("mem_id"));
TxtName.setText(rsmem.getString("mem_name"));
TxtAddress.setText(rsmem.getString("mem_address"));

110

Library Management System

TxtEmailID.setText(rsmem.getString("mem_email_id"));
TxtMobileNo.setText(rsmem.getString("mem_mobile_no"));
if (rsmem.getString("mem_active").equals("Y"))
{
ChkMemActive.setSelected(true);
}
else
{
ChkMemActive.setSelected(false);
}

LblPosition.setText("Record position : " + rsmem.getRow() + "/" +


String.valueOf(rscount));
}
catch (Exception e)
{
System.err.println(e);
}
}
private void ClearText()
{
//clear text of fields for entry/display old data
TxtMemID.setText("");
TxtName.setText("");
TxtAddress.setText("");
TxtEmailID.setText("");
TxtMobileNo.setText("");
ChkMemActive.setSelected(false);
LblPosition.setText("");
}
private void CmdFirstActionPerformed(java.awt.event.ActionEvent evt) {
try {
rsmem.first();
Display();
} catch (Exception e) {
System.err.println(e);
}
}
private void CmdPreviousActionPerformed(java.awt.event.ActionEvent evt) {
try {
if (rsmem.isFirst()==true) {

111

Library Management System

JOptionPane.showMessageDialog(null,"Already in first record.");


return;
}
rsmem.previous();
Display();
} catch (Exception e) {
System.err.println(e);
}
}
private void CmdNextActionPerformed(java.awt.event.ActionEvent evt) {
try {
if (rsmem.isLast()==true) {
JOptionPane.showMessageDialog(null,"Already in last record.");
return;
}
rsmem.next();
Display();
} catch (Exception e) {
System.err.println(e);
}
}
private void CmdLastActionPerformed(java.awt.event.ActionEvent evt) {
try {
rsmem.last();
Display();
} catch (Exception e) {
System.err.println(e);
//System.exit(1);
}
}
private void CmdNewActionPerformed(java.awt.event.ActionEvent evt) {
chadd=true;
ClearText();
}
private void CmdEditActionPerformed(java.awt.event.ActionEvent evt) {
chadd=false;
}

112

Library Management System

private void CmdSaveActionPerformed(java.awt.event.ActionEvent evt) {


//validate entry and save record
try {
if (TxtName.getText().trim().length()==0 ) {
JOptionPane.showMessageDialog(null,"Enter member name.");
return;
}
if (TxtAddress.getText().trim().length()==0 ) {
JOptionPane.showMessageDialog(null,"Enter address.");
return;
}
if (TxtEmailID.getText().trim().length()==0) {
JOptionPane.showMessageDialog(null,"Enter email id.");
return;
}
if (TxtMobileNo.getText().trim().length()==0) {
JOptionPane.showMessageDialog(null,"Enter mobile no.");
return;
}

//String strqr="";
Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
if (TxtMemID.getText().trim().length()==0 ) {
rsmem.moveToInsertRow();
rsmem.updateString("mem_name",TxtName.getText());
rsmem.updateString("mem_address",TxtAddress.getText());
rsmem.updateString("mem_email_id",TxtEmailID.getText());
rsmem.updateString("mem_mobile_no",TxtMobileNo.getText());
if (ChkMemActive.isSelected()==true)
{
rsmem.updateString("mem_active","Y");
}
else
{
rsmem.updateString("mem_active","N");
}
rsmem.insertRow();
rsmem.last();

113

Library Management System

Display();
} else {
rsmem.updateString("mem_name",TxtName.getText());
rsmem.updateString("mem_address",TxtAddress.getText());
rsmem.updateString("mem_email_id",TxtEmailID.getText());
rsmem.updateString("mem_mobile_no",TxtMobileNo.getText());
if (ChkMemActive.isSelected()==true)
{
rsmem.updateString("mem_active","Y");
}
else
{
rsmem.updateString("mem_active","N");
}

rsmem.updateRow();
rsmem.refreshRow();
}

JOptionPane.showMessageDialog(null,"Record updated.");
} catch (Exception e) {
System.err.println(e);
JOptionPane.showMessageDialog(null,"Unable to save record.");
return;
}
}
private void CmdCloseActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.setVisible(false);
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
try
{
this.setLocationRelativeTo(null);
ClearText();

Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
ResultSet rs;

114

Library Management System

//get mem count


PreparedStatement stmt;
stmt=connection.prepareStatement("select
lib_member_master");
rs = stmt.executeQuery();
rs.first();
rscount=rs.getInt(1);

count(*)

//get mem details


Statement
stmt1
connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sqlQuery = "select * from lib_member_master order by mem_id";
rsmem = stmt1.executeQuery(sqlQuery);

from

//display first record


rsmem.first();
Display();
}
catch (Exception e)
{
System.err.println(e);
//System.exit(1);
}

}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MemberMaster().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JCheckBox ChkMemActive;
private javax.swing.JButton CmdClose;
private javax.swing.JButton CmdEdit;
private javax.swing.JButton CmdFirst;
private javax.swing.JButton CmdLast;

115

Library Management System

private javax.swing.JButton CmdNew;


private javax.swing.JButton CmdNext;
private javax.swing.JButton CmdPrevious;
private javax.swing.JButton CmdSave;
private javax.swing.JLabel LblPosition;
private javax.swing.JTextField TxtAddress;
private javax.swing.JTextField TxtEmailID;
private javax.swing.JTextField TxtMemID;
private javax.swing.JTextField TxtMobileNo;
private javax.swing.JTextField TxtName;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
// End of variables declaration
}

9. Iusse book code:


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;

public class IssueBook extends javax.swing.JFrame {


/** Creates new form IssueBook */
public IssueBook() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel3 = new javax.swing.JLabel();
TxtMemberID = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
CmdMemberDetails = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();

116

Library Management System

TxtMemberName = new javax.swing.JTextField();


TxtMemberStatus = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
TxtBookID = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
TxtBookStatus = new javax.swing.JTextField();
TxtBookTitle = new javax.swing.JTextField();
CmdIssueBook = new javax.swing.JButton();
CmdClose = new javax.swing.JButton();
CmdBookDetails = new javax.swing.JButton();
CmdReset = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle(" Issue Book");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
jLabel3.setText("Member ID :");
TxtMemberID.setText("jTextField1");
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel1.setText(" Library - Issue Book");
CmdMemberDetails.setText("Details");
CmdMemberDetails.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdMemberDetailsActionPerformed(evt);
}
});
jLabel2.setText("Name :");
TxtMemberName.setEditable(false);
TxtMemberName.setText("jTextField1");
TxtMemberStatus.setEditable(false);
TxtMemberStatus.setText("jTextField1");
jLabel4.setText("Book ID :");
TxtBookID.setText("jTextField1");
jLabel5.setText("Title :");

117

Library Management System

TxtBookStatus.setEditable(false);
TxtBookStatus.setText("jTextField1");
TxtBookTitle.setEditable(false);
TxtBookTitle.setText("jTextField1");
CmdIssueBook.setText("Issue Book");
CmdIssueBook.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdIssueBookActionPerformed(evt);
}
});
CmdClose.setText("Close");
CmdClose.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdCloseActionPerformed(evt);
}
});
CmdBookDetails.setText("Details");
CmdBookDetails.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdBookDetailsActionPerformed(evt);
}
});
CmdReset.setText("Reset");
CmdReset.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdResetActionPerformed(evt);
}
});
jPanel1.setLayout(null);
jLabel6.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\IssueBook.jpg"));
NOI18N
jPanel1.add(jLabel6);
jLabel6.setBounds(0, 0, 430, 310);

//

javax.swing.GroupLayout
layout
=
new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)

118

Library Management System

.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(jLabel3)
.addGap(4, 4, 4)
.addComponent(TxtMemberID,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(10, 10, 10)
.addComponent(CmdMemberDetails))
.addGroup(layout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(jLabel2)
.addGap(33, 33, 33)
.addComponent(TxtMemberName,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(107, 107, 107)
.addComponent(TxtMemberStatus,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addComponent(TxtBookID,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(10, 10, 10)
.addComponent(CmdBookDetails))
.addGroup(layout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(jLabel5)
.addGap(40, 40, 40)
.addComponent(TxtBookTitle,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(107, 107, 107)
.addComponent(TxtBookStatus,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(110, 110, 110)
.addComponent(CmdReset)
.addGap(9, 9, 9)
.addComponent(CmdIssueBook)

229,

229,

229,

229,

119

Library Management System

.addGap(5, 5, 5)
.addComponent(CmdClose))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 430,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(jLabel1)
.addGap(13, 13, 13)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jLabel3))
.addComponent(TxtMemberID,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(CmdMemberDetails))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addComponent(jLabel2)
.addComponent(TxtMemberName,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(6, 6, 6)
.addComponent(TxtMemberStatus,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jLabel4))
.addComponent(TxtBookID,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(CmdBookDetails))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)

120

Library Management System

.addComponent(jLabel5))
.addComponent(TxtBookTitle,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(6, 6, 6)
.addComponent(TxtBookStatus,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(41, 41, 41)

23,

23,

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addComponent(CmdReset)
.addComponent(CmdIssueBook)
.addComponent(CmdClose)))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 310,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>
private void CmdResetActionPerformed(java.awt.event.ActionEvent evt) {
ClearText();
}
private void CmdIssueBookActionPerformed(java.awt.event.ActionEvent evt) {
//issue book
try
{

if (TxtMemberID.getText().trim().length()==0 ) {
JOptionPane.showMessageDialog(null,"Enter member id.");
return;
}
if (TxtBookID.getText().trim().length()==0 ) {
JOptionPane.showMessageDialog(null,"Enter member id.");
return;
}
MainClass mc=new MainClass();
Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
String sql = "insert into lib_transaction (trn_mem_id,trn_book_id,trn_issue_dt)
values (" + TxtMemberID.getText() + "," + TxtBookID.getText() + ",sysdate())";
PreparedStatement pst=connection.prepareStatement(sql);
pst.executeUpdate(sql);

121

Library Management System

sql = "update lib_book_master set book_status='Issued' where book_id=" +


TxtBookID.getText();
pst=connection.prepareStatement(sql);
pst.executeUpdate(sql);

JOptionPane.showMessageDialog(null,"Book Issued");
ClearText();
}
catch (Exception e) {
System.err.println(e);
System.exit(1);
}
}
private void CmdCloseActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
ClearText();
this.setLocationRelativeTo(null);
}
private void CmdMemberDetailsActionPerformed(java.awt.event.ActionEvent evt)
{
//get member deatils
try
{
//get database connection details
MainClass mc=new MainClass();
//open connection
Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
String str="";
str="select * from lib_member_master where mem_id =? ";
PreparedStatement pst=connection.prepareStatement(str);
pst.setString(1, TxtMemberID.getText());
ResultSet rs;
rs=pst.executeQuery();
if (rs.next())
{
TxtMemberName.setText(rs.getString("mem_name"));
//get mem status
str="select * from lib_transaction where trn_mem_id =? and (trn_receive_dt
is null or trn_receive_dt='')";

122

Library Management System

PreparedStatement pst1=connection.prepareStatement(str);
pst1.setString(1, TxtMemberID.getText());
ResultSet rs1;
rs1=pst1.executeQuery();
if (rs1.next())
{
TxtMemberStatus.setText("Book already issued.");
CmdIssueBook.setEnabled(false);
CmdBookDetails.setEnabled(false);
}
else
{
TxtMemberStatus.setText("No book issued.");
CmdIssueBook.setEnabled(true);
CmdBookDetails.setEnabled(true);
}
}
else
{
JOptionPane.showMessageDialog(null,"Invalid member id.");
TxtMemberID.setText("");
TxtMemberName.setText("");
TxtMemberStatus.setText("");
CmdIssueBook.setEnabled(false);
return;
}

}
catch (Exception e)
{
System.err.println(e);
System.exit(1);
}
}
private void CmdBookDetailsActionPerformed(java.awt.event.ActionEvent evt) {
//get member deatils
try
{
//get database connection details
MainClass mc=new MainClass();
//open connection
Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
String str="";
str="select * from lib_book_master where book_id =? ";

123

Library Management System

PreparedStatement pst=connection.prepareStatement(str);
pst.setString(1, TxtBookID.getText());
ResultSet rs;
rs=pst.executeQuery();
if (rs.next())
{
TxtBookTitle.setText(rs.getString("book_title"));
//get mem status
str="select * from lib_transaction where trn_book_id =? and (trn_receive_dt
is null or trn_receive_dt='')";
PreparedStatement pst1=connection.prepareStatement(str);
pst1.setString(1, TxtBookID.getText());
ResultSet rs1;
rs1=pst1.executeQuery();
if (rs1.next())
{
TxtBookStatus.setText("Book not available.");
CmdIssueBook.setEnabled(false);
}
else
{
TxtBookStatus.setText("Book available.");
CmdIssueBook.setEnabled(true);
}
}
else
{
JOptionPane.showMessageDialog(null,"Invalid book id.");
TxtBookID.setText("");
TxtBookTitle.setText("");
TxtBookStatus.setText("");
CmdIssueBook.setEnabled(false);
return;
}

}
catch (Exception e)
{
System.err.println(e);
System.exit(1);
}
}
private void ClearText()

124

Library Management System

{
TxtMemberID.setText("");
TxtMemberName.setText("");
TxtMemberStatus.setText("");
TxtBookID.setText("");
TxtBookTitle.setText("");
TxtBookStatus.setText("");
CmdIssueBook.setEnabled(false);
CmdBookDetails.setEnabled(false);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new IssueBook().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton CmdBookDetails;
private javax.swing.JButton CmdClose;
private javax.swing.JButton CmdIssueBook;
private javax.swing.JButton CmdMemberDetails;
private javax.swing.JButton CmdReset;
private javax.swing.JTextField TxtBookID;
private javax.swing.JTextField TxtBookStatus;
private javax.swing.JTextField TxtBookTitle;
private javax.swing.JTextField TxtMemberID;
private javax.swing.JTextField TxtMemberName;
private javax.swing.JTextField TxtMemberStatus;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
// End of variables declaration
}

10. Receive Book code:


import java.sql.Connection;

125

Library Management System

import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;

public class ReceiveBook extends javax.swing.JFrame {


/** Creates new form ReceiveBook */
public ReceiveBook() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
TxtMemberID = new javax.swing.JTextField();
CmdMemberDetails = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
TxtMemberName = new javax.swing.JTextField();
CmdReset = new javax.swing.JButton();
CmdReceiveBook = new javax.swing.JButton();
CmdClose = new javax.swing.JButton();
TxtBookDetails = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
LblBookID = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOS
E);
setTitle(" Receive Book");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}

126

Library Management System

});
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel1.setText("Library - Receive Book");
jLabel3.setText("Member ID :");
TxtMemberID.setText("jTextField1");
CmdMemberDetails.setText("Details");
CmdMemberDetails.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdMemberDetailsActionPerformed(evt);
}
});
jLabel2.setText("Name :");
TxtMemberName.setEditable(false);
TxtMemberName.setText("jTextField1");
CmdReset.setText("Reset");
CmdReset.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdResetActionPerformed(evt);
}
});
CmdReceiveBook.setText("Receive Book");
CmdReceiveBook.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdReceiveBookActionPerformed(evt);
}
});
CmdClose.setText("Close");
CmdClose.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdCloseActionPerformed(evt);
}
});
TxtBookDetails.setEditable(false);

127

Library Management System

TxtBookDetails.setText("jTextField1");
jLabel4.setText("Book :");
LblBookID.setFont(new java.awt.Font("Tahoma", 0, 8)); // NOI18N
LblBookID.setForeground(java.awt.Color.lightGray);
jLabel5.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\reciveBook.jpg")); //
NOI18N
javax.swing.GroupLayout
jPanel1Layout
javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

new

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE,
410, javax.swing.GroupLayout.PREFERRED_SIZE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE,
300, javax.swing.GroupLayout.PREFERRED_SIZE)
);
javax.swing.GroupLayout
layout
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

new

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
164,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(45, 45, 45)
.addComponent(jLabel3)
.addGap(14, 14, 14)

128

Library Management System

.addComponent(TxtMemberID,
javax.swing.GroupLayout.PREFERRED_SIZE,
53,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(109, 109, 109)
.addComponent(CmdMemberDetails))
.addGroup(layout.createSequentialGroup()
.addGap(45, 45, 45)
.addComponent(jLabel2))
.addGroup(layout.createSequentialGroup()
.addGap(45, 45, 45)
.addComponent(jLabel4)
.addGap(41, 41, 41)
.addComponent(TxtBookDetails,
javax.swing.GroupLayout.PREFERRED_SIZE,
229,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(116, 116, 116)
.addComponent(LblBookID))
.addGroup(layout.createSequentialGroup()
.addGap(116, 116, 116)
.addComponent(CmdReset)
.addGap(6, 6, 6)
.addComponent(CmdReceiveBook)
.addGap(6, 6, 6)
.addComponent(CmdClose))
.addGroup(layout.createSequentialGroup()
.addGap(116, 116, 116)
.addComponent(TxtMemberName,
javax.swing.GroupLayout.PREFERRED_SIZE,
229,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
405, javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(jLabel1)
.addGap(13, 13, 13)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()

129

Library Management System

.addGap(4, 4, 4)
.addComponent(jLabel3))
.addComponent(TxtMemberID,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(CmdMemberDetails))
.addGap(10, 10, 10)
.addComponent(jLabel2)
.addGap(16, 16, 16)

23,

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jLabel4))
.addComponent(TxtBookDetails,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(LblBookID)
.addGap(100, 100, 100)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addComponent(CmdReset)
.addComponent(CmdReceiveBook)
.addComponent(CmdClose)))
.addGroup(layout.createSequentialGroup()
.addGap(68, 68, 68)
.addComponent(TxtMemberName,
javax.swing.GroupLayout.PREFERRED_SIZE,
23,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
299, javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>
private void CmdMemberDetailsActionPerformed(java.awt.event.ActionEvent
evt) {
//get member deatils
try {
//get database connection details

130

Library Management System

MainClass mc=new MainClass();


//open connection
Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
String str="";
str="select * from lib_member_master where mem_id =? ";
PreparedStatement pst=connection.prepareStatement(str);
pst.setString(1, TxtMemberID.getText());
ResultSet rs;
rs=pst.executeQuery();
if (rs.next()) {
TxtMemberName.setText(rs.getString("mem_name"));
//get mem status
str="select * from lib_transaction, lib_book_master where
book_id=trn_book_id and trn_mem_id =? and (trn_receive_dt is null or
trn_receive_dt='')";
PreparedStatement pst1=connection.prepareStatement(str);
pst1.setString(1, TxtMemberID.getText());
ResultSet rs1;
rs1=pst1.executeQuery();
if (rs1.next()) {
TxtBookDetails.setText("Available
Book
rs1.getString("book_title"));
CmdReceiveBook.setEnabled(true);
LblBookID.setText(rs1.getString("book_id"));

"

} else {
TxtBookDetails.setText("No book available.");
CmdReceiveBook.setEnabled(false);
LblBookID.setText("");
}
} else {
JOptionPane.showMessageDialog(null,"Invalid member id.");
TxtMemberID.setText("");
TxtMemberName.setText("");
TxtBookDetails.setText("");
CmdReceiveBook.setEnabled(false);
LblBookID.setText("");

131

Library Management System

return;
}

} catch (Exception e) {
System.err.println(e);
System.exit(1);
}
}
private void CmdResetActionPerformed(java.awt.event.ActionEvent evt) {
ClearText();
}
private void CmdReceiveBookActionPerformed(java.awt.event.ActionEvent
evt) {
//issue book
try {

if (TxtMemberID.getText().trim().length()==0 ) {
JOptionPane.showMessageDialog(null,"Enter member id.");
return;
}
MainClass mc=new MainClass();
Connection connection;
connection=DriverManager.getConnection(mc.StrUrl,mc.StrUid,mc.StrPwd);
String sql = "update lib_transaction set trn_receive_dt = sysdate() where
trn_mem_id= " + TxtMemberID.getText() + " and trn_receive_dt is null and
trn_book_id=" + LblBookID.getText();
PreparedStatement pst=connection.prepareStatement(sql);
pst.executeUpdate(sql);
sql = "update lib_book_master set book_status='Available' where
book_id=" + LblBookID.getText();
pst=connection.prepareStatement(sql);
pst.executeUpdate(sql);

JOptionPane.showMessageDialog(null,"Book Received");
ClearText();

132

Library Management System

} catch (Exception e) {
System.err.println(e);
System.exit(1);
}
}
private void ClearText()
{
TxtMemberID.setText("");
TxtMemberName.setText("");
TxtBookDetails.setText("");
LblBookID.setText("");
CmdReceiveBook.setEnabled(false);
}
private void CmdCloseActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
ClearText();
this.setLocationRelativeTo(null);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ReceiveBook().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton CmdClose;
private javax.swing.JButton CmdMemberDetails;
private javax.swing.JButton CmdReceiveBook;
private javax.swing.JButton CmdReset;
private javax.swing.JLabel LblBookID;
private javax.swing.JTextField TxtBookDetails;
private javax.swing.JTextField TxtMemberID;

133

Library Management System

private javax.swing.JTextField TxtMemberName;


private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
// End of variables declaration
}

11.

About page code:

public class About extends javax.swing.JFrame {


/** Creates new form About */
public About() {
initComponents();
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel2 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
CmdClose = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle(" About");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel2.setText("Contact Us:");
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N

134

Library Management System

jLabel1.setText(" Library System");


jLabel3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
jLabel3.setText("WWW.LMS.COM");
jLabel4.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
jLabel4.setText("LMSTEEM@HOTMAIL.COM");
CmdClose.setText("Close");
CmdClose.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmdCloseActionPerformed(evt);
}
});
jLabel5.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\About.jpg"));
NOI18N
javax.swing.GroupLayout
jPanel1Layout
javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

//

new

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE,
400, javax.swing.GroupLayout.PREFERRED_SIZE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE,
200, javax.swing.GroupLayout.PREFERRED_SIZE)
);
javax.swing.GroupLayout
layout
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

new

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()

135

Library Management System

.addGap(125, 125, 125)


.addComponent(jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE,
180,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(70, 70, 70)
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE,
97,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(127, 127, 127)
.addComponent(jLabel4,
javax.swing.GroupLayout.PREFERRED_SIZE,
170,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(130, 130, 130)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
160,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(280, 280, 280)
.addComponent(CmdClose,
javax.swing.GroupLayout.PREFERRED_SIZE,
76,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(103, 103, 103)
.addComponent(jLabel3,
javax.swing.GroupLayout.PREFERRED_SIZE,
20,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(80, 80, 80)
.addComponent(jLabel2))
.addGroup(layout.createSequentialGroup()
.addGap(129, 129, 129)
.addComponent(jLabel4,
javax.swing.GroupLayout.PREFERRED_SIZE,
20,
javax.swing.GroupLayout.PREFERRED_SIZE))

136

Library Management System

.addGroup(layout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(150, 150, 150)
.addComponent(CmdClose))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>
private void CmdCloseActionPerformed(java.awt.event.ActionEvent evt) {
// Close project
this.setVisible(false);
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
this.setLocationRelativeTo(null);
}

public static void main(String args[]) {


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new About().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton CmdClose;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
// End of variables declaration
}

137

Library Management System

9. TEST CASES
Testing is one of the important steps in the software development phase. Testing is
performed to identify errors and is an integral part of the entire development and
maintenance process. The Library Management System has been put under rigorous
testing so as ensure the correctness of its design. The complete test strategy for the
Library Management System is to perform the following kinds of tests, in sequence:
Component testing: of each component that makes up the Library
Management System
Integration testing of the Library Management System, to ensure the correct
interworking of its components
Validation testing of the Library Management System, to ensure that it works
correctly in a pseudo-live environment
User acceptance testing of the Library Management System, to ensure that
its function is acceptable to its users.

Test Scope
The scope of the user acceptance testing covers:
Version of the Library Management System
User-facing functionality defined by a set of use cases
Administrator-facing functionality defined by a set of use cases
The aim of the testing is to determine how well the application meets its functional
requirements from the perspective of the user, and to identify any issues so they can be
resolved. Also, the testing serves to compile a set of test data and results that can be
used during subsequent test cycles, to test for non-regression of the software in later
releases or after the application is in maintenance.
Working practices might vary from user to user and are considered outside the scope
of the testing.

Test Strategy
The basis of user acceptance testing is that other tests were completed successfully, so
the application and its required infrastructure are considered to be stable and reliable.
Acceptance testing concentrates on the application from the users perspective, that is,
how the application is used and whether it meets the necessary quality criteria.
The customer of the acceptance testing is the System Users, Supervisor and
Administrator for Library Management System. The progress of the acceptance testing
will be reported to the customer, together with any issues that are discovered and their
planned resolutions. Sign-off of the tests, and therefore the acceptance of the
application, will be performed by the customer or a selected representative.

138

Library Management System

Testing Schedules
The user acceptance testing schedules are shown in the project structure
document and resulting Gantt charts.
UNIT TESTING :
What are the requirements of library management system?
User able to register and login.
User can search the added books, and check in or out.
User can change the password and other profile details.
User can add the books.
These are some of the common features expected from the library management system.
So you now have some test scenarios to check for. In addition to these test scenarios,
you have GUI based software to check for the bugs, usability and functionality.
LOGIN TEST:
SL.No Test Case

Excepted Result

Test
Result

Enter valid name and password & Software should display Successful
click on ok button
main window

Enter invalid name and password User name and password successful
not correct

139

Library Management System

ISSUE BOOK TEST:


SL.No Test Case

Excepted Result

Test
Result

Enter invalid ID
member

Software should display invalid Successful


member id

Enter valid ID member


and ID book

Software check if available book successful


or not to issue book

140

Library Management System

141

Library Management System

Conclusion and future enhancement


This project was developed to fulfill user and business requirement; however there are
lots of scopes to improve the performance of the Library Management System in the
area of user interface, database performance, and query processing time. Etc.
So there are many things for future enhancement of this project. The future
enhancements that are possible in the project are as follows.

In any system there is always chance for its enhancement and extension.

This system can also be enhanced with the change facilities.

More facilities can be added to the system for its growth.

There is always scope for enhancements in any system, especially in the ever
changing world of computers. Linking and integration of any legacy system for
accounting.

Integration with LMS database through Web Services

Connection to third-party OLAP applications

Implement Bar code reader

Web interface for members

In the area of data security and system security.

Provide more online tips and help.

To optimize the query which is embedded in the system.

142

Library Management System

REFERENCES
Websites

http://www.google.com

http://www.microsoft.com

http://www.codeproject.com

http://www.msdn.com.

http://www.vb123.com

http://www.vbcode.com

http://www.sqltuner.com

http://tutorialspoint.com/java

http://www.onlinecomputerbooks.com/free-java-books.php

Books

Mini Java reference Manual

Java Tutorial

SQL Bible, 2nd Edition (Paperback)

Database Development in Visual Basic

143

Вам также может понравиться