Library System
Library System
201130795
201130259
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.
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.
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.
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.
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
37
38
38
38
39
39
39
40
40
41
41
42
49
138
142
143
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.
To design a user friendly graphical user interface which suit the users
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.
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.
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.
Modify Book :User can edit previously saved book details in this
screen.
New Member : This form used to create new library member, user
enter library member details. System generates member id.
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
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.
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 know the English language, as the user interface will be
provided in English.
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
11
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.
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
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
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.
Requirement Analysis
Testing
Maintenance
Coding
Problem
Definition
System testing
Requirement
specification
Planning
and
scheduling
g
Design
Unit
testing
Integration testing
Data Design
Modular
design
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
PHASE
WK2
WK3
WK4
WK5
WK6
requirement
Gathering
requirement
analysis
design
coding
testing
implementation
15
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
5. REQUIREMENT ANALYSIS
In this chapter, we will discuss and analyses about the developing process of Library
Management System including Software Requirement Specification (SRS).
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
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
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.)
19
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:
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.
20
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.
21
library
system
Accesses
DBMS
View
Transcation
Admin
Add
details
User
DBMS
Admin
Adds
Members,
Books
DBMS
22
Enter
Book ID ,
Member ID
Issue Books
Validate
Entry
Save
Transaction
Employee
Enter
Transaction
No
DBMS
Generate
report
Calculate
Late Fine
Validate
Entry
Save
Transaction
Receive Book
23
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
24
25
26
User Master
Add Details
Administrator
Update
Master
Navigate Users
Apply
Validation
27
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
View /
Navigate
Member Data
Validation
User
Add Member
Transaction
Edit Member
Supervisor
Delete
Member Data
Administrator
29
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
Supervisor
System Check
the status
Book Master
Issue Book
Member
Master
31
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
Select
Transaction ID
Transaction
Supervisor
System Check
the status
Book Master
Receive Book
Member
Master
Late Fine
33
Data type
Null/not null
Default value
rules
VARCHAR(45)
not null
VARCHAR(45)
not null
VARCHAR(45)
not null
not null
User _Name
User
_Password
User _Type
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
not null
Book _category
VARCHAR(100)
not null
Book _keyword
VARCHAR(250)
not null
VARCHAR(45)
not null
Null
Book _status
34
3.
4.
VARCHAR(100)
VARCHAR(01)
VARCHAR(1)
Default
value
Null
Null
rules
Null
Null
Null
Null
Transaction table:
Data type
INT(10)
Null/not null
not null
Default
value
Null
rules
not null
not null
not null
Null
Data type
VARCHAR(100
)
Null/not null
Default value
rules
not null
35
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
37
38
39
40
41
42
Main Screen
User Master
43
Change Password
44
Book Master
Search Book
45
Book Status
Member Master
46
Search Member
Issue Book
47
Receive Book
Transaction Report
48
49
});
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
.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
.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
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
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
55
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
//
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
.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");
//
57
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");
//
58
//
59
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");
//
//
60
}
});
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
jMenu5.setIcon(new
javax.swing.ImageIcon("C:\\p2p_library\\source_code\\img\\6.png"));
NOI18N
jMenu5.setText("Help");
//
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
63
}
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
});
}
// 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
}
65
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CL
OSE);
setTitle(" User Master");
addWindowListener(new java.awt.event.WindowAdapter() {
66
67
});
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
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
.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
.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
.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
73
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
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
Statement
stmt1
connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sqlQuery = "select * from lib_user ";
rsuser = stmt1.executeQuery(sqlQuery);
76
}
}
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
78
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
.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
.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
.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
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;
}
pst.executeUpdate(sql);
JOptionPane.showMessageDialog(null,"Password updated.");
this.setVisible(false);
} else {
JOptionPane.showMessageDialog(null,"Old
correct.");
return;
password
are
not
83
} 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
85
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
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
});
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
.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
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
.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
.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
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();
count(*)
from
93
94
95
//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
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
{
//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
}
// 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
}
99
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;
}
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
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
jTable1.getColumnModel().getColumn(0).setHeaderValue("Book
ID");
jTable1.getColumnModel().getColumn(1).setHeaderValue("Title");
jTable1.getColumnModel().getColumn(2).setHeaderValue("Category");
102
jTable1.getColumnModel().getColumn(3).setHeaderValue("Status");
jTable1.getTableHeader().resizeAndRepaint();
// Removing Previous Data
while (jTable1.getRowCount() > 0) {
((DefaultTableModel) jTable1.getModel()).removeRow(0);
}
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
104
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
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
}
});
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
.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
.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
.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
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);
}
111
112
//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
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
count(*)
from
}
/**
* @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
116
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
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
.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
.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
.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
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
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
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
{
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
}
125
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
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
});
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
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
.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
.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
"
} 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
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
} 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
11.
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
//
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
136
.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);
}
137
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
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
Excepted Result
Test
Result
Enter invalid ID
member
140
141
In any system there is always chance for its enhancement and extension.
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.
142
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
Java Tutorial
143