Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 96

A PROJECT REPORT

Library Management System


By
Harish Bhati
Roll Number: 190730106009
Under the Guidance of
H O D- Hemant Upadhyay

In partial fulfillment of the requirements for Post Graduation degree


of

Bachelors's in Computer Application

College of Education Bilaspur


WINNER-GIZE TECHNOLOGY PVT. LTD

Certificate

This is to certify that the dissertation entitled “Library Management System” carried out by
Mr. Harish Bhati, student of BACHELORS'S IN COMPUTER APPLICATION [2011-
2014], of College of Education Bilaspur, is hereby accepted and approved as a credible work.
Submitted in the partial fulfillment for the requirement of degree of BCA. It’s a bona fide record
of the work done by him under my supervision during his stay as a project trainee at Winner-
Gize Technology Pvt. Ltd. from Jan 10, 2014 to May 25, 2014. The system has been
implemented and running successfully.

Mr. Umesh Kumar Project Head


Winner-Gize Technology Pvt. Ltd
Declaration

I, PRASHANT KUUMAR, hereby declare that the project work entitled “Library
Management System” is an authenticated work carried out by me at WINNER-
GIZE TECHNOLOGY PVT. LTD. Under the guidance of H O D- Hemant
Upadhyay for the partial fulfillment of the award of the degree of BACHELORS'S OF
COMPUTER APPLICATIONS and this work has not been submitted for similar
purpose anywhere else except to College of Education Bilaspur

Date: Name: Harish Bhati


Place: Roll No.: 190730106009
ACKNOWLEDGMENT

It is great pleasure to present this report on the project named “Library


Management System” undertaken by me as part of my M.C.A curriculum.
I am thankful to my college Galgotias college of Engg. & Technology,Gr.Noida
for offering me such a wonderful challenging opportunity and I express my deepest
thanks to my project Guide “Mrs. Meena Sachdeva”, Assistant Professor. She
helped me lot during the development of project. Also, my sincere thanks to all
people who helped me in the development of project either indirectly or directly
without whom this project has been remained as another dream of mine.
My special thanks to Professor (Dr.) Brijesh Kumar Gupta, HOD- Department of Computer
Applications, College of Education Bilaspur, for helping me in the completion of project work
and its report submission.
Lastly I will appreciate my family especially my parent who have encouraged me
for making career in computer arena and also thanks to the almighty God. I am also
thankful to my colleagues in the college who have cooperated with me in making
my project happen.
I dedicated this project to all my Well-wishers who have helped me and have been
helping me yet in every spheres of life.

Name: Harish Bhati


Roll No.: 190730106009

College of Education Bilaspur Page 4


Table of Contents

1. Introduction
1.1 Abstract
1.2 Objective
1.3 Scope/Need of Project

2. Feasibility Study
3. Software Requirements Specification
3.1 Introduction
3.2 Selection of Technology/Specific Requirements
4. Design
4.1 ER Diagram
4.2 Data Flow Diagram
4.3 Modules
4.4 Database
4.5 Input-Output Form(Screen Layout)

5. Coding
6. Implementation Environment
7. Testing & Result
8. Enhancement
9. Limitations
10. Conclusion
11. Bibliography/References

College of Education Bilaspur Page 5


1. Introduction

Borrowing books, returning books or viewing the available books at the Library of the local
University is currently done manually where in the student has to go to the Library and
check the available books at the Library. Students check the list of books available and
borrow the books if the book is a borrow book otherwise it is of waste for the student to
come to the library to come to check for the books if the student doesn’t get the book. Then
the librarian checks the student id and allows the member to check out the book and the
librarian then updates the member database and also the books database. This takes at least
one to two hours if the member is available at the near by place otherwise it may take more
time.

We have decided to investigate the use of an Online Library Management System. This
system would be used by members who may be students or professors of that University to
check the availability of the books and borrow the books, and by the librarian to update the
databases. The purpose of this document is to analyze and elaborate on the high-level needs
and features of the Library Management System. It focuses on the capabilities and facilities
provided by a Library. The details of what all are the needs of the Library Management
System and if it fulfils these needs are detailed in the use-case and supplementary
specifications.

1.1 ABSTRACT

What contribution would the project make?


This project has been developed to simplify the current manual system of library management
system and also at the same time to reduce the time and cost to run the current system. Besides
saving time and cost, this project may also reduce the use of precious paper which is itself a huge
contribution to the environment. The personnel managing this project would also have to learn
about using computer machines which are used everywhere in this world now.

Prime Goal
Today in this fast moving world, everything is directly/indirectly managed through computing
systems which helps to save time, money and environment. This project has been developed to do
all of these and added to that, provide the user with a simple and interactive user interface so a non-
technical person can also use the project for his/her work.

College of Education Bilaspur Page 6


1.2 OBJECTIVES

 Replace manual library management system with enhanced system software.


 Provide easy to use graphical user interface.
 Ease out the management of books, students and issues in the library.
 Reduce number of workers.
 Reduce amount of time to manage library stock and other resources.
 Make processing of a book issue faster.
 Save money on paper, pen, folders and other stationary.
 Support environment friendly system.
 Save physical space which is used to store data on paper.
 Searching and retrieval of records will be much faster.
 Data will be secured from unauthorized access.
 Easy update of records in the database.
 Less scope for errors.

College of Education Bilaspur Page 7


1.3 FEATURES

 Only basic knowledge of computers is required for operation of Library Management


System. As it has user-friendly application interface.
 Project is designed on Java which means it supports all the basic features of java like
security, lightweight, portable, etc.
 Back end of the project is local MySQL database which helps in faster access to the records
and no hassle of network configuration.
 Graphical user interface keeps user from getting fed up of the data entry and provide
interactive communication with the software.
 Searching, updating and deleting of records is easy with just few inputs and couple of mouse
clicks.
 While browsing through student’s records, it also views the books that are issued to that
student.
 Once a book status has been marked ‘returned’, the record from the issues database is
automatically deleted.
 A student is not allowed to be issued more than 5 books which is more than the common
issuable books number.
 MySQL database has been backed up by security features like username and password for
restricting the access to unauthorized user.
 Student enrolment number and book number should always be unique to avoid redundancy
or clashes.

College of Education Bilaspur Page 8


2. Feasibility Study

A feasibility study is conducted to objectively and rationally uncover the strengths and weaknesses
of the existing business or proposed venture, opportunities and threats as presented by the
environment, the resources required to carry through, and ultimately the prospects for success.
The key considerations in feasibility analysis are:
 Economic Feasibility

The proposed project is economically feasible because the cost involved in purchasing the hardware
and the software are within approachable limits. The personal costs like gathering of graphics and
design are also nominal, because images and graphics are freely available on the internet. The
operating environment costs are marginal. The less time involved also helped in its economic
feasibility.

The benefits of this project include:


 Cost Saving Benefits

This project reduces the administrative and operational cost. Because of the reduction in the use of
paper, use of labour, cost also reduces.
 Time Saving Benefits

It saves lots of time and provides you with informational resources. Processing time is minimal
which keeps the records up-to-date all the time.
 Environmental Benefits

Loads of paper and space is saved which can be used to do some other work and saving paper is
the most essential in keeping out environment green and keep us healthy also.

College of Education Bilaspur Page 9


 Technical Feasibility

The project is technically feasible as the hardware and software resources required are easily
available. Development and maintenance of the project is also not complex/large scale task.

3. Software Requirements Specification

3.1 Introduction

This project has been developed to simplify the current manual system of library
management system and also at the same time to reduce the time and cost to run the current
system. Besides saving time and cost, this project may also reduce the use of precious paper
which is itself a huge contribution to the environment. The personnel managing this project
would also have to learn about using computer machines which are used everywhere in this
world now.

3.1.1 Purpose

The purpose of Software Requirements Specification (SRS) document is to describe the


external behavior of the Library Management System. Requirements Specification defines
and describes the operations, interfaces, performance, and quality assurance requirements of
the Library Management System. The document also describes the nonfunctional
requirements such as the user interfaces. It also describes the design constraints that are to
be considered when the system is to be designed, and other factors necessary to provide a
complete and comprehensive description of the requirements for the software. The Software
Requirements Specification (SRS) captures the complete software requirements for the
system, or a portion of the system. Requirements described in this document are derived
from the Vision Document prepared for the Online Library System.

College of Education Bilaspur Page 10


3.1.2 Scope

The Software Requirements Specification captures all the requirements in a single


document. The Library Management System that is to be developed provides the members
of the Library and employees of the library with books information, online blocking of
books and many other facilities. The Library Management System is supposed to have the
following features.

 The product provides the members with online blocking of books capabilities and
the Library System is up and running all day.
 The system provides logon facility to the users.
 The system provides the members with the option to check their account and/or
change their options like password of the account whenever needed all through the
day during the library hours.
 The system allows the members to block the books 24 hours a day and all the
through the semester.
 The system lets the library staff to check which all members have blocked the books
and whether they can borrow any more books or not.
 The system allows the Librarian to create the books catalog, add/delete books and
maintain the books catalog.
 The system updates the billing system as and when the member borrows or returns a
book.
 The book catalog is automated and the decision of offering the book based on the
category of the book is automatically decided.
 We also have an order department, which manages to add or remove a book from the
Library.

3.2 Specific Requirements


This section describes in detail all the functional requirements.
3.2.1 Functionality
Logon Capabilities
The system shall provide the users with logon capabilities.
Mobile Devices
The Online Library System is also supported on mobile devices such as cell phones.
Alerts
The system can alert the Librarian or the administrator in case of any problems.

College of Education Bilaspur Page 11


3.2.2 Usability
 The system shall allow the users to access the system from the Internet using HTML or
it’s derivative technologies. The system uses a web browser as an interface.
 Since all users are familiar with the general usage of browsers, no specific training is
required.
 The system is user friendly and self-explanatory.

3.2.3 Reliability
The system has to be very reliable due to the importance of data and the damages incorrect or
incomplete data can do.

3.2.4 Availability
The system is available 100% for the user and is used 24 hrs a day and 365 days a year. The
system shall be operational 24 hours a day and 7 days a week.

3.2.5 Accuracy
The accuracy of the system is limited by the accuracy of the speed at which the employees of
the library and users of the library use the system.

3.2.6 Access Reliability


The system shall provide 100% access reliability.

3.3 Performance
3.3.1 Response Time
The Splash Page or Information page should be able to be downloaded within a minute
using a 56K modem. The information is refreshed every two minutes. The access time for a
mobile device should be less than a minute. The system shall respond to the member in not
less than two seconds from the time of the request submittal. The system shall be allowed to
take more time when doing large processing jobs.

3.3.2 Administrator/Librarian Response


The system shall take as less time as possible to provide service to the administrator or the
librarian.
3.3.3 Throughput
The number of transactions is directly dependent on the number of users, the users may be the
Librarian, employees of the Library and also the people who use the Library for checking-out
books, returning books and checking online library account.

College of Education Bilaspur Page 12


3.3.4 Capacity
The system is capable of handling 250 users at a time.

3.3.5 Resource Utilization


The resources are modified according the user requirements and also according to the books
requested by the users.

3.3.6 Drawbacks of Manual System


 Tracing book/student information is difficult.
 Tracing book/student information is time consuming.
 Information about issue/return of books are not properly maintained.
 No central database can be created as information is not available in database.

3.3.7 Technology Used


Frontend – Java
Backend – MySQL Database

College of Education Bilaspur Page 13


4. Design

4.1 Software Language Used

The languages that shall be used for coding the Online Library System are Active Server
Pages (ASP), Java Servlets, Java Server Pages (JSP), HTML, JavaScript, and VBScript. For
working on the coding phase of the Online Library System, the Internet Information
Services (IIS) Server needs to be installed.

4.2 Development Tools

Will make use of the available Java Development Tool kits for working with Java Beans
and Java Server Pages. Also will make use of the online references available for developing
programs in ASP, HTML and the two scripting languages, JavaScript and VBScript.

4.3 Class Libraries

Will make use of the existing Java libraries available for JSP and Servlets. Also we need to
develop some new libraries for the web-based application. Also will develop new programs
using ASP and scripting languages.

College of Education Bilaspur Page 14


4.4 ER Diagram

STUDENTSINFO

Ha
s

ISSUE INFO

Ha
s

STUDENTSINFO

College of Education Bilaspur Page 15


4.5 Data Flow Diagram

 Zero level DFD

BOOKS ISSUES RETURNS

STUDENT / LIBRARY DATA BASE


Informa Data
FACULTY MANAGE-
tion
MENT
SYSTEM

 First level DFD’s

BOOKS

1.1
BOOKS Details Data Save Into Table

Add
BOOK

Id

STUDENT

College of Education Bilaspur Page 16


USERS

ADD 1.2 Data


USERS
SAVE
BOOKS
Detai
ls

User_ID

USERS

4.6 Modules

1. MainScreen.java

College of Education Bilaspur Page 17


2. AddStudents.java

College of Education Bilaspur Page 18


3. AddBooks.java

College of Education Bilaspur Page 19


4. AddIssues.java

College of Education Bilaspur Page 20


5. ViewStudents.java
College of Education Bilaspur Page 21
6. ViewBooks.java

College of Education Bilaspur Page 22


College of Education Bilaspur Page 23
7. ViewIssues.java

College of Education Bilaspur Page 24


8. SearchStudents.java

College of Education Bilaspur Page 25


9. SearchBooks.java

College of Education Bilaspur Page 26


10. SearchIssues.java

College of Education Bilaspur Page 27


4.7 Database

 DATA TABLES
 STUDENTS INFO

Field Name Data Type Range


STROLLNO SMALLINT 0 to 65535
STNAME VARCHAR 30
STBRANCH VARCHAR 10
ISSUEDBOOKSNO SMALLINT 0 to 65535
LATEFEE FLOAT Decimal Values

 BOOKSINFO

Field Name Data Type Range


BOOKNO SMALL INT 0 to 65535
ISBN VARCHAR 20
TITLE VARCHAR 50
AUTHOR VARCHAR 30
SUBJECT VARCHAR 30
PUBLISHER VARCHAR 30
EDITION VARCHAR 15
COPIES TINYINT 0 to 255
PRICE FLOAT Decimal Values

College of Education Bilaspur Page 28


 ISSUESINFO

Field Name Data Type Range


BOOKNO SMALLINT 0 to 65535
TITLE VARCHAR 50
ISSUEDROLLNO SMALLINT 0 to 65535
ISSUEDSTNAME VARCHAR 30
ISSUEDATE VARCHAR 15
DUEDATE VARCHAR 15
RETURNSTATUS VARCHAR 10

College of Education Bilaspur Page 29


5. Coading

1. MainScreen.java

Coding:
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.sql.SQLException;

import javax.imageio.ImageIO;
import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

publicclass MainScreen extends JDialog implements ActionListener{

/**
*
*/
privatestaticfinallongserialVersionUID = 1L;
JPanel rightPanel;
JPanel leftPanel;
JButton exitButton;
JButton aboutButton;
JButton studentsButton;
JButton booksButton;
JButton issuesButton;
JPanel studentsPanel;
JButton addStudents;
JButton viewStudents;
JButton searchStudents;
JPanel booksPanel;
JButton addBooks;
JButton viewBooks;
JButton searchBooks;
JPanel issuesPanel;
JButton addIssues;
JButton viewIssues;

College of Education Bilaspur Page 30


JButton searchIssues;

public MainScreen() {
// TODO Auto-generated constructor stub

Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();


Dimension prefleftSize = new Dimension(screensize.width/3, screensize.height);
Dimension prefrightSize = new Dimension((screensize.width*2)/3,
screensize.height);
Dimension buttonSize = new Dimension(150, 50);

JFrame frame = new JFrame("Main Menu");


frame.setSize(screensize);

ImageIcon buttonimg = new


ImageIcon(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/
buttonbg.jpg")));

//leftPanel
leftPanel = new LPanel();
leftPanel.setPreferredSize(prefleftSize);
leftPanel.setBorder(BorderFactory.createEmptyBorder(150, 50, 200, 50));

//BoxLayout on leftPanel
BoxLayout box = new BoxLayout(leftPanel, BoxLayout.Y_AXIS);
leftPanel.setLayout(box);

studentsButton = new JButton("STUDENTS");


studentsButton.setIcon(buttonimg);
studentsButton.setHorizontalTextPosition(AbstractButton.CENTER);

booksButton = new JButton("BOOKS");


booksButton.setIcon(buttonimg);
booksButton.setHorizontalTextPosition(AbstractButton.CENTER);

issuesButton = new JButton("ISSUES");


issuesButton.setIcon(buttonimg);
issuesButton.setHorizontalTextPosition(AbstractButton.CENTER);

exitButton = new JButton("EXIT");


exitButton.setIcon(buttonimg);
exitButton.setHorizontalTextPosition(AbstractButton.CENTER);

aboutButton = new JButton("ABOUT");


aboutButton.setIcon(buttonimg);
aboutButton.setHorizontalTextPosition(AbstractButton.CENTER);

studentsButton.setPreferredSize(buttonSize);
booksButton.setPreferredSize(buttonSize);
issuesButton.setPreferredSize(buttonSize);
exitButton.setPreferredSize(buttonSize);
aboutButton.setPreferredSize(buttonSize);

//Menu Panels

College of Education Bilaspur Page 31


JPanel j1 = new JPanel();
j1.setOpaque(false);
JPanel j2 = new JPanel();
j2.setOpaque(false);
JPanel j3 = new JPanel();
j3.setOpaque(false);
JPanel j4 = new JPanel();
j4.setOpaque(false);
JPanel j5 = new JPanel();
j5.setOpaque(false);

//Menu Buttons
j1.add(studentsButton);
j2.add(booksButton);
j3.add(issuesButton);
j4.add(aboutButton);
j5.add(exitButton);
leftPanel.add(j1);
leftPanel.add(j2);
leftPanel.add(j3);
leftPanel.add(j4);
leftPanel.add(j5);

//Right Panel
rightPanel = new RPanel();
rightPanel.setPreferredSize(prefrightSize);
rightPanel.setOpaque(false);

//Right Panel Layout


rightPanel.setBorder(BorderFactory.createEmptyBorder(150, 0, 150, 0));
rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.Y_AXIS));

//Button Panels in Right Panel


JPanel bj1 = new JPanel();
bj1.setOpaque(false);
JPanel bj2 = new JPanel();
bj2.setOpaque(false);
JPanel bj3 = new JPanel();
bj3.setOpaque(false);

//Buttons in Book Panel


addBooks = new JButton("ADD BOOKS");
addBooks.setIcon(buttonimg);
addBooks.setHorizontalTextPosition(AbstractButton.CENTER);
viewBooks = new JButton("VIEW BOOKS");
viewBooks.setIcon(buttonimg);
viewBooks.setHorizontalTextPosition(AbstractButton.CENTER);
searchBooks = new JButton("SEARCH BOOKS");
searchBooks.setIcon(buttonimg);
searchBooks.setHorizontalTextPosition(AbstractButton.CENTER);
bj1.add(addBooks);
bj2.add(viewBooks);
bj3.add(searchBooks);

College of Education Bilaspur Page 32


//Button Size
addBooks.setPreferredSize(buttonSize);
viewBooks.setPreferredSize(buttonSize);
searchBooks.setPreferredSize(buttonSize);

//Book Panel in Right Panel


booksPanel = new JPanel();
booksPanel.setOpaque(false);
booksPanel.setLayout(new BoxLayout(booksPanel, BoxLayout.Y_AXIS));
booksPanel.setVisible(false);

//Button Panels in Book panel


booksPanel.add(bj1);
booksPanel.add(bj2);
booksPanel.add(bj3);

//Buttons in Student panel


addStudents = new JButton("ADD STUDENTS");
addStudents.setIcon(buttonimg);
addStudents.setHorizontalTextPosition(AbstractButton.CENTER);
viewStudents = new JButton("VIEW STUDENTS");
viewStudents.setIcon(buttonimg);
viewStudents.setHorizontalTextPosition(AbstractButton.CENTER);
searchStudents = new JButton("SEARCH STUDENTS");
searchStudents.setIcon(buttonimg);
searchStudents.setHorizontalTextPosition(AbstractButton.CENTER);
addStudents.setPreferredSize(buttonSize);
viewStudents.setPreferredSize(buttonSize);
searchStudents.setPreferredSize(buttonSize);

//Student Buttons Panels


JPanel sj1 = new JPanel();
JPanel sj2 = new JPanel();
JPanel sj3 = new JPanel();

sj1.add(addStudents);
sj1.setOpaque(false);
sj2.add(viewStudents);
sj2.setOpaque(false);
sj3.add(searchStudents);
sj3.setOpaque(false);

//Student Panel
studentsPanel = new JPanel();
studentsPanel.setOpaque(false);
studentsPanel.setLayout(new BoxLayout(studentsPanel, BoxLayout.Y_AXIS));
studentsPanel.setVisible(false);

studentsPanel.add(sj1);
studentsPanel.add(sj2);
studentsPanel.add(sj3);

//Buttons in Issue panel


addIssues = new JButton("ADD ISSUES");

College of Education Bilaspur Page 33


addIssues.setIcon(buttonimg);
addIssues.setHorizontalTextPosition(AbstractButton.CENTER);
viewIssues = new JButton("VIEW ISSUES");
viewIssues.setIcon(buttonimg);
viewIssues.setHorizontalTextPosition(AbstractButton.CENTER);
searchIssues = new JButton("SEARCH ISSUES");
searchIssues.setIcon(buttonimg);
searchIssues.setHorizontalTextPosition(AbstractButton.CENTER);
addIssues.setPreferredSize(buttonSize);
viewIssues.setPreferredSize(buttonSize);
searchIssues.setPreferredSize(buttonSize);

//Issue Buttons Panels


JPanel ij1 = new JPanel();
ij1.setOpaque(false);
JPanel ij2 = new JPanel();
ij2.setOpaque(false);
JPanel ij3 = new JPanel();
ij3.setOpaque(false);

ij1.add(addIssues);
ij2.add(viewIssues);
ij3.add(searchIssues);

//Issue Panel
issuesPanel = new JPanel();
issuesPanel.setOpaque(false);
issuesPanel.setLayout(new BoxLayout(issuesPanel, BoxLayout.Y_AXIS));
issuesPanel.setVisible(false);

issuesPanel.add(ij1);
issuesPanel.add(ij2);
issuesPanel.add(ij3);

rightPanel.add(booksPanel);
rightPanel.add(studentsPanel);
rightPanel.add(issuesPanel);

frame.add(leftPanel);
frame.add(rightPanel);

frame.getContentPane().add(BorderLayout.WEST, leftPanel);
frame.getContentPane().add(BorderLayout.EAST, rightPanel);

exitButton.addActionListener(this);
booksButton.addActionListener(this);
studentsButton.addActionListener(this);
issuesButton.addActionListener(this);
aboutButton.addActionListener(this);
addStudents.addActionListener(this);
addBooks.addActionListener(this);
addIssues.addActionListener(this);
viewBooks.addActionListener(this);
viewStudents.addActionListener(this);

College of Education Bilaspur Page 34


viewIssues.addActionListener(this);
searchStudents.addActionListener(this);
searchBooks.addActionListener(this);
searchIssues.addActionListener(this);

frame.pack();
frame.setVisible(true);
}

/**
* @param args
*/
publicstaticvoid main(String[] args) {
// TODO Auto-generated method stub

MainScreen mainscreen = new MainScreen();


mainscreen.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

@Override
publicvoid actionPerformed(ActionEvent ae) {
// TODO Auto-generated method stub

if(ae.getSource()==exitButton)
{
setVisible(false);
dispose();
System.exit(0);
}

if(ae.getSource()==booksButton){

booksPanel.setVisible(true);
studentsPanel.setVisible(false);
issuesPanel.setVisible(false);

if(ae.getSource()==studentsButton){

booksPanel.setVisible(false);
studentsPanel.setVisible(true);
issuesPanel.setVisible(false);

if(ae.getSource()==issuesButton){

booksPanel.setVisible(false);
studentsPanel.setVisible(false);
issuesPanel.setVisible(true);

College of Education Bilaspur Page 35


if(ae.getSource()==aboutButton){

JOptionPane.showMessageDialog(new JFrame("About Us"), "This project


is made by \n Himanshu Chauhan \n Bsc. IT \n Semester 5 \n AMITY University \n" +
" This project cannot be distributed without
permission from the programmer. \n This project cannot be used for commercial purpose
yet some bugs may exists.");

if(ae.getSource()==addStudents){

new AddStudents();

if(ae.getSource()==addBooks){

new AddBooks();

if(ae.getSource()==addIssues){

new AddIssues();

if(ae.getSource()==viewBooks){

try {
new ViewBooks();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

if(ae.getSource()==viewStudents){

try {
new ViewStudents();
} catch (SQLException | ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

College of Education Bilaspur Page 36


if(ae.getSource()==viewIssues){

try {
new ViewIssues();
} catch (ClassNotFoundException | SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

if(ae.getSource()==searchStudents){

new SearchStudents();

if(ae.getSource()==searchBooks){

new SearchBooks();

if(ae.getSource()==searchIssues){

new SearchIssues();

}
}

class LPanel extends JPanel{

/**
*
*/
privatestaticfinallongserialVersionUID = 1L;

publicvoid paintComponent(Graphics g)
{
Image bgimage = null;
try {
bgimage =
ImageIO.read(getClass().getResource("images/leftpanelbg.jpg"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
super.paintComponent(g);
if( bgimage!= null)
{
g.drawImage(bgimage, 0, 0, this.getWidth(), this.getHeight(),
this);

College of Education Bilaspur Page 37


}
}

class RPanel extends JPanel{

/**
*
*/
privatestaticfinallongserialVersionUID = 1L;

publicvoid paintComponent(Graphics g)
{
Image bgimage = null;
try {
bgimage =
ImageIO.read(getClass().getResource("images/rightpanelbg.jpg"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

super.paintComponent(g);
if( bgimage!= null)
{
g.drawImage(bgimage, 0, 0, this.getWidth(), this.getHeight(),
this);
}
}

College of Education Bilaspur Page 38


2. AddStudents.java

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

publicclass AddStudents {

Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();

JPanel rollnoPanel;
JPanel stunamePanel;
JPanel branchPanel;
JPanel booksissuedPanel;
JPanel latefeePanel;
JPanel decisionPanel;

String query;

public AddStudents() {
// TODO Auto-generated constructor stub

super();
final JFrame frame = new JFrame("ADD STUDENTS");
frame.setSize(screensize);

JPanel headPanel = new JPanel();


JLabel mainLabel = new JLabel("ADD STUDENTS RECORD");
mainLabel.setForeground(Color.red);
mainLabel.setFont(new Font(Font.SERIF, Font.ITALIC+Font.BOLD, 30));
headPanel.setLayout(new FlowLayout());

College of Education Bilaspur Page 39


headPanel.add(mainLabel);

rollnoPanel = new JPanel();


rollnoPanel.setLayout(new GridLayout(1, 2));

JLabel rollnoLabel = new JLabel("Enter Roll No. : ");


final JTextField rollnoField = new JTextField(10);
rollnoPanel.add(rollnoLabel);
rollnoPanel.add(rollnoField);

stunamePanel = new JPanel();


stunamePanel.setLayout(new GridLayout(1, 2));

JLabel stunameLabel = new JLabel("Enter Student Name : ");


final JTextField stunameField = new JTextField(20);
stunamePanel.add(stunameLabel);
stunamePanel.add(stunameField);

branchPanel = new JPanel();


branchPanel.setLayout(new GridLayout(1, 2));

JLabel branchLabel = new JLabel("Enter Branch : ");


final JComboBox<String> branchCombo = new JComboBox<String>();
String branches[] = {"AIIT", "ASET", "AIB", "ALS"};
for(int i = 0; i<branches.length; i++){
branchCombo.insertItemAt(branches[i], i);
}
branchPanel.add(branchLabel);
branchPanel.add(branchCombo);

booksissuedPanel = new JPanel();


booksissuedPanel.setLayout(new GridLayout(1, 2));

JLabel booksissuedLabel = new JLabel("No of Books Issued (Max. 5) : ");


final JComboBox<Integer> booksissuedCombo = new JComboBox<Integer>();
int j=0;
for(int i=0; i<=5; i++){
booksissuedCombo.insertItemAt(j++, i);
}
booksissuedPanel.add(booksissuedLabel);
booksissuedPanel.add(booksissuedCombo);

latefeePanel = new JPanel();


latefeePanel.setLayout(new GridLayout(1, 2));

JLabel latefeeLabel = new JLabel("Cummulative Late Fee (Rs.) : ");


final JTextField latefeeField = new JTextField(3);
latefeePanel.add(latefeeLabel);
latefeePanel.add(latefeeField);

decisionPanel = new JPanel();


JButton addButton = new JButton("ADD");
addButton.addActionListener(new ActionListener() {

College of Education Bilaspur Page 40


@Override
publicvoid actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn =
DriverManager.getConnection("jdbc:odbc:LIBMGMT", "root", "pass");
Statement statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

query = "INSERT INTO STUDENTSINFO VALUES("+


Integer.parseInt(rollnoField.getText())+ ", '"+ stunameField.getText()+"', '"
+
branchCombo.getSelectedItem().toString()+ "', "+
Integer.parseInt(booksissuedCombo.getSelectedItem().toString())+
", "+
Float.parseFloat(latefeeField.getText())+ " );";

statement.executeUpdate(query);

statement.close();
conn.close();

JOptionPane.showMessageDialog(new JFrame(),"Database
Updated Successfully!");
}
catch(SQLException e){
System.out.print("SQL Exception : "+ e);
}
catch(ClassNotFoundException e){
System.out.print("ClassNotFoundException : "+ e);
}

}
});
JButton cancelButton = new JButton("CANCEL");
cancelButton.addActionListener(new ActionListener() {

@Override
publicvoid actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
frame.dispose();
}
});
decisionPanel.add(addButton);
decisionPanel.add(cancelButton);

JPanel mainPanel = new JPanel();


mainPanel.setBorder(BorderFactory.createEmptyBorder(250, 150, 600, 400));
BoxLayout bl = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
mainPanel.setLayout(bl);
mainPanel.add(headPanel);

College of Education Bilaspur Page 41


mainPanel.add(new JPanel());
mainPanel.add(rollnoPanel);
mainPanel.add(new JPanel());
mainPanel.add(stunamePanel);
mainPanel.add(new JPanel());
mainPanel.add(branchPanel);
mainPanel.add(new JPanel());
mainPanel.add(booksissuedPanel);
mainPanel.add(new JPanel());
mainPanel.add(latefeePanel);
mainPanel.add(new JPanel());
mainPanel.add(decisionPanel);

frame.add(mainPanel);
frame.setVisible(true);
}

College of Education Bilaspur Page 42


2. AddBooks.java

Coding:
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

publicclass AddBooks {

Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();

JPanel detailsPanel;
JPanel booksnoPanel;
JPanel booksisbnPanel;
JPanel titlePanel;
JPanel authorPanel;
JPanel subjectPanel;
JPanel publisherPanel;
JPanel editionPanel;
JPanel copiesPanel;
JPanel pricePanel;
JPanel decisionPanel;

public AddBooks(){

super();
final JFrame frame = new JFrame("ADD BOOKS");
frame.setSize(screensize);

College of Education Bilaspur Page 43


GridLayout gLayout = new GridLayout(1, 2);

JLabel mainLabel = new JLabel("ADD BOOKS RECORD");


mainLabel.setForeground(Color.red);
mainLabel.setFont(new Font(Font.MONOSPACED, Font.ITALIC+Font.BOLD, 30));

booksnoPanel = new JPanel();

JLabel booksnoLabel = new JLabel("Book No. ");


final JTextField booksnoField = new JTextField(5);
booksnoPanel.add(booksnoLabel);
booksnoPanel.add(booksnoField);

booksisbnPanel = new JPanel();

JLabel booksisbnLabel = new JLabel("ISBN ");


final JTextField booksisbnField = new JTextField(5);
booksisbnPanel.add(booksisbnLabel);
booksisbnPanel.add(booksisbnField);

detailsPanel = new JPanel();


detailsPanel.setLayout(gLayout);

detailsPanel.add(booksnoPanel);
detailsPanel.add(booksisbnPanel);

titlePanel = new JPanel();


titlePanel.setLayout(gLayout);

JLabel titleLabel = new JLabel("Title");


final JTextField titleField = new JTextField(20);
titlePanel.add(titleLabel);
titlePanel.add(titleField);

authorPanel = new JPanel();


authorPanel.setLayout(gLayout);

JLabel authorLabel = new JLabel("Author");


final JTextField authorField = new JTextField(20);
authorPanel.add(authorLabel);
authorPanel.add(authorField);

subjectPanel = new JPanel();


subjectPanel.setLayout(gLayout);

JLabel subjectLabel = new JLabel("Subject");


final JTextField subjectField = new JTextField(20);
subjectPanel.add(subjectLabel);
subjectPanel.add(subjectField);

publisherPanel = new JPanel();


publisherPanel.setLayout(gLayout);

JLabel publisherLabel = new JLabel("Publisher");

College of Education Bilaspur Page 44


final JTextField publisherField = new JTextField(20);
publisherPanel.add(publisherLabel);
publisherPanel.add(publisherField);

editionPanel = new JPanel();


editionPanel.setLayout(gLayout);

JLabel editionLabel = new JLabel("Edition");


final JTextField editionField = new JTextField(20);
editionPanel.add(editionLabel);
editionPanel.add(editionField);

copiesPanel = new JPanel();


copiesPanel.setLayout(gLayout);

JLabel copiesLabel = new JLabel("Copies");


final JTextField copiesField = new JTextField(4);
copiesPanel.add(copiesLabel);
copiesPanel.add(copiesField);

pricePanel = new JPanel();


pricePanel.setLayout(gLayout);

JLabel priceLabel = new JLabel("Price (Rs.)");


final JTextField priceField = new JTextField(6);
pricePanel.add(priceLabel);
pricePanel.add(priceField);

decisionPanel = new JPanel();


JButton addButton = new JButton("ADD");
addButton.addActionListener(new ActionListener() {

@Override
publicvoid actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn =
DriverManager.getConnection("jdbc:odbc:LIBMGMT", "root", "pass");
Statement statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

String query = "INSERT INTO BOOKSINFO VALUES("+


Integer.parseInt(booksnoField.getText())+ ",'"+ booksisbnField.getText()
+"','"+ titleField.getText()+ "','"+
authorField.getText()+ "','"+ subjectField.getText()+ "','"+
publisherField.getText()+ "','"+
editionField.getText()+ "',"+ Integer.parseInt(copiesField.getText())+ ","+
Float.parseFloat(priceField.getText())+
");";

statement.executeUpdate(query);

College of Education Bilaspur Page 45


statement.close();
conn.close();

JOptionPane.showMessageDialog(new JFrame(),"Database
Updated Successfully!");

frame.dispose();
}
catch(SQLException e){

System.out.print("SQLException : "+ e);

}
catch(ClassNotFoundException e){
System.out.print("ClassNotFoundException : "+ e);
}

}
});
JButton cancelButton = new JButton("CANCEL");
cancelButton.addActionListener(new ActionListener() {

@Override
publicvoid actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
frame.dispose();
}
});
decisionPanel.add(addButton);
decisionPanel.add(cancelButton);

JPanel mainPanel = new JPanel();


mainPanel.setBorder(BorderFactory.createEmptyBorder(250, 150, 600, 600));
BoxLayout bl = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
mainPanel.setLayout(bl);

mainPanel.add(mainLabel);
mainPanel.add(new JPanel());
mainPanel.add(detailsPanel);
mainPanel.add(new JPanel());
mainPanel.add(titlePanel);
mainPanel.add(new JPanel());
mainPanel.add(authorPanel);
mainPanel.add(new JPanel());
mainPanel.add(subjectPanel);
mainPanel.add(new JPanel());
mainPanel.add(publisherPanel);
mainPanel.add(new JPanel());
mainPanel.add(editionPanel);
mainPanel.add(new JPanel());
mainPanel.add(copiesPanel);
mainPanel.add(new JPanel());
mainPanel.add(pricePanel);

College of Education Bilaspur Page 46


mainPanel.add(new JPanel());
mainPanel.add(decisionPanel);

frame.add(mainPanel);
frame.setVisible(true);
}

3. AddIssues.java

Coding:
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

publicclass AddIssues {

Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();

JPanel booknoPanel;
JPanel titlePanel;
JPanel recieverPanel;
JPanel issueToPanel;
JPanel rollnoPanel;
JPanel issueDatePanel;
JPanel dueDatePanel;
JPanel returnDatePanel;
JPanel decisionPanel;

JTextField booknoField;
JTextField titleField;

College of Education Bilaspur Page 47


JTextField issueToField;
JTextField rollnoField;
JTextField issueDateField;
JTextField dueDateField;
JComboBox<String>returnStatusCombo;

public AddIssues(){

super();
final JFrame frame = new JFrame("ADD ISSUES");
frame.setSize(screensize);

JLabel mainLabel = new JLabel("ADD ISSUE RECORD");


mainLabel.setForeground(Color.red);
mainLabel.setFont(new Font(Font.MONOSPACED, Font.ITALIC+Font.BOLD, 30));

GridLayout gLayout = new GridLayout(1, 2);

booknoPanel = new JPanel();


booknoPanel.setLayout(gLayout);

JLabel booknoLabel = new JLabel("Book No.");


booknoField = new JTextField();
booknoPanel.add(booknoLabel);
booknoPanel.add(booknoField);

titlePanel = new JPanel();


titlePanel.setLayout(gLayout);

JLabel titleLabel = new JLabel("Book Title");


titleField = new JTextField();
titlePanel.add(titleLabel);
titlePanel.add(titleField);

recieverPanel = new JPanel();


recieverPanel.setLayout(gLayout);

issueToPanel = new JPanel();


issueToPanel.setLayout(gLayout);
//issueToPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

JLabel issueToLabel = new JLabel("Issue To");


issueToField = new JTextField(10);
issueToPanel.add(issueToLabel);
issueToPanel.add(issueToField);

rollnoPanel = new JPanel();


rollnoPanel.setLayout(gLayout);
rollnoPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 30));

JLabel rollnoLabel = new JLabel("Roll No.");


rollnoField = new JTextField(6);
rollnoPanel.add(rollnoLabel);
rollnoPanel.add(rollnoField);

College of Education Bilaspur Page 48


recieverPanel.add(rollnoPanel);
recieverPanel.add(issueToPanel);

issueDatePanel = new JPanel();


issueDatePanel.setLayout(gLayout);

JLabel issueDateLabel = new JLabel("Issue Date");


issueDateField = new JTextField(10);
String issueDate = new String(new SimpleDateFormat("dd MMMM
yyyy").format(new Date()));
issueDateField.setText(issueDate);
issueDatePanel.add(issueDateLabel);
issueDatePanel.add(issueDateField);

dueDatePanel = new JPanel();


dueDatePanel.setLayout(gLayout);

JLabel dueDateLabel = new JLabel("Due Date");


dueDateField = new JTextField(10);
String dueDate = new String(new SimpleDateFormat("dd MMMM
yyyy").format(new Date()));
dueDateField.setText(dueDate);
dueDatePanel.add(dueDateLabel);
dueDatePanel.add(dueDateField);

returnDatePanel = new JPanel();


returnDatePanel.setLayout(gLayout);

JLabel returnStatusLabel = new JLabel("Return Status");


returnStatusCombo = new JComboBox<String>();
String returnStatus[] = {"Pending", "Returned"};
for(int i = 0; i<returnStatus.length; i++){
returnStatusCombo.insertItemAt(returnStatus[i], i);
}
returnDatePanel.add(returnStatusLabel);
returnDatePanel.add(returnStatusCombo);

decisionPanel = new JPanel();


JButton addButton = new JButton("ADD");
addButton.addActionListener(new ActionListener() {

@Override
publicvoid actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn =
DriverManager.getConnection("jdbc:odbc:LIBMGMT", "root", "pass");
Statement statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

College of Education Bilaspur Page 49


String query = "INSERT INTO ISSUESINFO VALUES("+
Integer.parseInt(booknoField.getText())+ ", '"+
titleField.getText()+ "', "+
Integer.parseInt(rollnoField.getText())+ ", '"+
issueToField.getText()+ "', '"+
issueDateField.getText()+ "', '"+ dueDateField.getText()+
"', '"+ returnStatusCombo.getSelectedItem()+ "');";

statement.executeUpdate(query);

statement.close();
conn.close();

JOptionPane.showMessageDialog(new JFrame(),"Database
Updated Successfully!");
}
catch(SQLException e){
System.out.print("SQL Exception : "+ e);
}
catch(ClassNotFoundException e){
System.out.println("ClassNotFoundException : "+ e);
}

}
});
JButton cancelButton = new JButton("CANCEL");
cancelButton.addActionListener(new ActionListener() {

@Override
publicvoid actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
frame.dispose();
}
});
decisionPanel.add(addButton);
decisionPanel.add(cancelButton);

JPanel mainPanel = new JPanel();


mainPanel.setBorder(BorderFactory.createEmptyBorder(250, 150, 600, 400));
BoxLayout bl = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
mainPanel.setLayout(bl);

mainPanel.add(mainLabel);
mainPanel.add(new JPanel());
mainPanel.add(new JPanel());
mainPanel.add(new JPanel());
mainPanel.add(new JPanel());
mainPanel.add(new JPanel());
mainPanel.add(recieverPanel);
mainPanel.add(new JPanel());
mainPanel.add(booknoPanel);
mainPanel.add(new JPanel());
mainPanel.add(titlePanel);
mainPanel.add(new JPanel());

College of Education Bilaspur Page 50


mainPanel.add(issueDatePanel);
mainPanel.add(new JPanel());
mainPanel.add(dueDatePanel);
mainPanel.add(new JPanel());
mainPanel.add(returnDatePanel);
mainPanel.add(new JPanel());
mainPanel.add(decisionPanel);
frame.add(mainPanel);
frame.setVisible(true);
}

4. ViewStudents.java

Coding:
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;

publicclass ViewStudents {

Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();

JPanel rollnoPanel;
JPanel stunamePanel;
JPanel branchPanel;
JPanel booksissuedPanel;
JPanel latefeePanel;
JPanel decisionPanel;
JTable issuesTable;

College of Education Bilaspur Page 51


public ViewStudents() throws SQLException, ClassNotFoundException {
// TODO Auto-generated constructor stub
super();
final JFrame frame = new JFrame("VIEW STUDENTS");
frame.setSize(screensize);

JPanel headPanel = new JPanel();


JLabel mainLabel = new JLabel("VIEW STUDENT RECORDS");
mainLabel.setForeground(Color.red);
mainLabel.setFont(new Font(Font.SERIF, Font.ITALIC+Font.BOLD, 30));
headPanel.setLayout(new FlowLayout());
headPanel.add(mainLabel);

rollnoPanel = new JPanel();


rollnoPanel.setLayout(new GridLayout(1, 2));

JLabel rollnoLabel = new JLabel("Roll No. : ");


final JTextField rollnoField = new JTextField(10);
rollnoField.setEnabled(false);
rollnoPanel.add(rollnoLabel);
rollnoPanel.add(rollnoField);

stunamePanel = new JPanel();


stunamePanel.setLayout(new GridLayout(1, 2));

JLabel stunameLabel = new JLabel("Student Name : ");


final JTextField stunameField = new JTextField(20);
stunameField.setEnabled(false);
stunamePanel.add(stunameLabel);
stunamePanel.add(stunameField);

branchPanel = new JPanel();


branchPanel.setLayout(new GridLayout(1, 2));

JLabel branchLabel = new JLabel("Branch : ");


final JTextField branchField = new JTextField();
branchField.setEnabled(false);
branchPanel.add(branchLabel);
branchPanel.add(branchField);

booksissuedPanel = new JPanel();


booksissuedPanel.setLayout(new GridLayout(1, 2));

JLabel booksissuedLabel = new JLabel("No of Books Issued (Max. 5) : ");


final JTextField booksissuedField = new JTextField();
booksissuedField.setEnabled(false);
booksissuedPanel.add(booksissuedLabel);
booksissuedPanel.add(booksissuedField);

latefeePanel = new JPanel();


latefeePanel.setLayout(new GridLayout(1, 2));

JLabel latefeeLabel = new JLabel("Cummulative Late Fee (Rs.) : ");

College of Education Bilaspur Page 52


final JTextField latefeeField = new JTextField(3);
latefeeField.setEnabled(false);
latefeePanel.add(latefeeLabel);
latefeePanel.add(latefeeField);

decisionPanel = new JPanel();

JButton prevButton = new JButton("<<");


JButton nextButton = new JButton(">>");
JButton closeButton = new JButton("CLOSE");

decisionPanel.add(prevButton);
decisionPanel.add(nextButton);
decisionPanel.add(closeButton);

String columnNames[] = {"Book No.", "Title", "Issue Date", "Due Date",


"Return Status"};
String rowValues[][] =
{
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
};
issuesTable = new JTable(rowValues, columnNames);
JScrollPane jp = new JScrollPane(issuesTable);
issuesTable.setEnabled(false);

JPanel mainPanel = new JPanel();


mainPanel.setBorder(BorderFactory.createEmptyBorder(250, 150, 100, 400));
BoxLayout bl = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
mainPanel.setLayout(bl);
mainPanel.add(headPanel);
mainPanel.add(new JPanel());
mainPanel.add(rollnoPanel);
mainPanel.add(new JPanel());
mainPanel.add(stunamePanel);
mainPanel.add(new JPanel());
mainPanel.add(branchPanel);
mainPanel.add(new JPanel());
mainPanel.add(booksissuedPanel);
mainPanel.add(new JPanel());
mainPanel.add(latefeePanel);
mainPanel.add(new JPanel());
mainPanel.add(jp, BorderLayout.CENTER);
mainPanel.add(new JPanel());
mainPanel.add(decisionPanel);

frame.add(mainPanel);
frame.setVisible(true);

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

College of Education Bilaspur Page 53


final Connection conn = DriverManager.getConnection("jdbc:odbc:LIBMGMT",
"root", "pass");;
final Statement statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);;
final Statement tableStatement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);;
String query = "SELECT * FROM STUDENTSINFO";

final ResultSet rs = statement.executeQuery(query);

nextButton.addActionListener(new ActionListener() {

publicvoid actionPerformed(ActionEvent arg0) {


// TODO Auto-generated method stub

for(int i = 0; i<5; i++){


for(int j=0; j<5; j++){

issuesTable.setValueAt("", i, j);

}
}

try {
if(rs.next()){

rollnoField.setText(Integer.toString(rs.getInt(1)));
stunameField.setText(rs.getString(2));
branchField.setText(rs.getString(3));

booksissuedField.setText(Integer.toString(rs.getInt(4)));

latefeeField.setText(Integer.toString(rs.getInt(5)));
}
else{
JOptionPane.showMessageDialog(new
JFrame(), "No more records to display.");
}

String tablequery = "SELECT * FROM ISSUESINFO


WHERE ISSUEDROLLNO = "+ Integer.parseInt(rollnoField.getText())+ ";";
ResultSet tablers = null;
try {
tablers =
tableStatement.executeQuery(tablequery);
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

while(tablers.next()){

for(int i = 0; i<5; i++){

College of Education Bilaspur Page 54


issuesTable.setValueAt(tablers.getString(1), i, 0);

issuesTable.setValueAt(tablers.getString(2), i, 1);

issuesTable.setValueAt(tablers.getString(5), i, 2);

issuesTable.setValueAt(tablers.getString(6), i, 3);

issuesTable.setValueAt(tablers.getString(7), i, 4);
tablers.next();

}
tablers.close();
tableStatement.close();

}
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});

prevButton.addActionListener(new ActionListener() {

publicvoid actionPerformed(ActionEvent arg0) {


// TODO Auto-generated method stub

try {
if(rs.previous()){

rollnoField.setText(Integer.toString(rs.getInt(1)));
stunameField.setText(rs.getString(2));
branchField.setText(rs.getString(3));

booksissuedField.setText(Integer.toString(rs.getInt(4)));

latefeeField.setText(Integer.toString(rs.getInt(5)));
}
else{
JOptionPane.showMessageDialog(new
JFrame(), "No more records to display.");
}
String tablequery = "SELECT * FROM ISSUESINFO
WHERE ISSUEDROLLNO = "+ Integer.parseInt(rollnoField.getText())+ ";";
ResultSet tablers = null;
try {
tablers =
tableStatement.executeQuery(tablequery);
} catch (SQLException e1) {

College of Education Bilaspur Page 55


// TODO Auto-generated catch block
e1.printStackTrace();
}

while(tablers.previous()){

for(int i = 0; i<5; i++){

issuesTable.setValueAt(tablers.getString(1), i, 0);

issuesTable.setValueAt(tablers.getString(2), i, 1);

issuesTable.setValueAt(tablers.getString(5), i, 2);

issuesTable.setValueAt(tablers.getString(6), i, 3);

issuesTable.setValueAt(tablers.getString(7), i, 4);
tablers.previous();

}
tablers.close();
tableStatement.close();
}
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});

closeButton.addActionListener(new ActionListener() {

@Override
publicvoid actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
try {
statement.close();
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
frame.dispose();
}
});

College of Education Bilaspur Page 56


5. ViewBooks.java

Coding:
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

publicclass ViewBooks {

Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();

JPanel detailsPanel;
JPanel booksnoPanel;
JPanel booksisbnPanel;
College of Education Bilaspur Page 57
JPanel titlePanel;
JPanel authorPanel;
JPanel subjectPanel;
JPanel publisherPanel;
JPanel editionPanel;
JPanel copiesPanel;
JPanel pricePanel;
JPanel decisionPanel;

public ViewBooks() throws ClassNotFoundException, SQLException{

super();
final JFrame frame = new JFrame("VIEW BOOKS");
frame.setSize(screensize);

GridLayout gLayout = new GridLayout(1, 2);

JLabel mainLabel = new JLabel("VIEW BOOK RECORDS");


mainLabel.setForeground(Color.red);
mainLabel.setFont(new Font(Font.MONOSPACED, Font.ITALIC+Font.BOLD, 30));

booksnoPanel = new JPanel();

JLabel booksnoLabel = new JLabel("Book No. ");


booksnoLabel.setToolTipText("Input number");
final JTextField booksnoField = new JTextField(5);
booksnoField.setEnabled(false);
booksnoPanel.add(booksnoLabel);
booksnoPanel.add(booksnoField);

booksisbnPanel = new JPanel();

JLabel booksisbnLabel = new JLabel("ISBN ");


final JTextField booksisbnField = new JTextField(5);
booksisbnField.setEnabled(false);
booksisbnPanel.add(booksisbnLabel);
booksisbnPanel.add(booksisbnField);

detailsPanel = new JPanel();


detailsPanel.setLayout(gLayout);

detailsPanel.add(booksnoPanel);
detailsPanel.add(booksisbnPanel);

titlePanel = new JPanel();


titlePanel.setLayout(gLayout);

JLabel titleLabel = new JLabel("Title");


final JTextField titleField = new JTextField(20);
titleField.setEnabled(false);
titlePanel.add(titleLabel);
titlePanel.add(titleField);

authorPanel = new JPanel();

College of Education Bilaspur Page 58


authorPanel.setLayout(gLayout);

JLabel authorLabel = new JLabel("Author");


final JTextField authorField = new JTextField(20);
authorField.setEnabled(false);
authorPanel.add(authorLabel);
authorPanel.add(authorField);

subjectPanel = new JPanel();


subjectPanel.setLayout(gLayout);

JLabel subjectLabel = new JLabel("Subject");


final JTextField subjectField = new JTextField(20);
subjectField.setEnabled(false);
subjectPanel.add(subjectLabel);
subjectPanel.add(subjectField);

publisherPanel = new JPanel();


publisherPanel.setLayout(gLayout);

JLabel publisherLabel = new JLabel("Publisher");


final JTextField publisherField = new JTextField(20);
publisherField.setEnabled(false);
publisherPanel.add(publisherLabel);
publisherPanel.add(publisherField);

editionPanel = new JPanel();


editionPanel.setLayout(gLayout);

JLabel editionLabel = new JLabel("Edition");


final JTextField editionField = new JTextField(20);
editionField.setEnabled(false);
editionPanel.add(editionLabel);
editionPanel.add(editionField);

copiesPanel = new JPanel();


copiesPanel.setLayout(gLayout);

JLabel copiesLabel = new JLabel("Copies");


copiesLabel.setToolTipText("Input number");
final JTextField copiesField = new JTextField(4);
copiesField.setEnabled(false);
copiesPanel.add(copiesLabel);
copiesPanel.add(copiesField);

pricePanel = new JPanel();


pricePanel.setLayout(gLayout);

JLabel priceLabel = new JLabel("Price (Rs.)");


priceLabel.setToolTipText("Input number");
final JTextField priceField = new JTextField(6);
priceField.setEnabled(false);
pricePanel.add(priceLabel);
pricePanel.add(priceField);

College of Education Bilaspur Page 59


decisionPanel = new JPanel();
JButton prevButton = new JButton("<<");
JButton nextButton = new JButton(">>");
JButton closeButton = new JButton("CLOSE");

decisionPanel.add(prevButton);
decisionPanel.add(nextButton);
decisionPanel.add(closeButton);

JPanel mainPanel = new JPanel();


mainPanel.setBorder(BorderFactory.createEmptyBorder(250, 150, 600, 600));
BoxLayout bl = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
mainPanel.setLayout(bl);

mainPanel.add(mainLabel);
mainPanel.add(new JPanel());
mainPanel.add(detailsPanel);
mainPanel.add(new JPanel());
mainPanel.add(titlePanel);
mainPanel.add(new JPanel());
mainPanel.add(authorPanel);
mainPanel.add(new JPanel());
mainPanel.add(subjectPanel);
mainPanel.add(new JPanel());
mainPanel.add(publisherPanel);
mainPanel.add(new JPanel());
mainPanel.add(editionPanel);
mainPanel.add(new JPanel());
mainPanel.add(copiesPanel);
mainPanel.add(new JPanel());
mainPanel.add(pricePanel);
mainPanel.add(new JPanel());
mainPanel.add(decisionPanel);

frame.add(mainPanel);
frame.setVisible(true);

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
final Connection conn = DriverManager.getConnection("jdbc:odbc:LIBMGMT",
"root", "pass");;
final Statement statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);;
String query = "SELECT * FROM BOOKSINFO";
final ResultSet rs = statement.executeQuery(query);

nextButton.addActionListener(new ActionListener() {

publicvoid actionPerformed(ActionEvent arg0) {


// TODO Auto-generated method stub

try {
if(rs.next()){

College of Education Bilaspur Page 60


booksnoField.setText(Integer.toString(rs.getInt(1)));
booksisbnField.setText(rs.getString(2));
titleField.setText(rs.getString(3));
authorField.setText(rs.getString(4));
subjectField.setText(rs.getString(5));
publisherField.setText(rs.getString(6));
editionField.setText(rs.getString(7));

copiesField.setText(Integer.toString(rs.getInt(8)));

priceField.setText(Float.toString(rs.getFloat(9)));
}
else{
JOptionPane.showMessageDialog(new
JFrame(), "No more records to display.");
}
}
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});

prevButton.addActionListener(new ActionListener() {

publicvoid actionPerformed(ActionEvent arg0) {


// TODO Auto-generated method stub

try {
if(rs.previous()){

booksnoField.setText(Integer.toString(rs.getInt(1)));
booksisbnField.setText(rs.getString(2));
titleField.setText(rs.getString(3));
authorField.setText(rs.getString(4));
subjectField.setText(rs.getString(5));
publisherField.setText(rs.getString(6));
editionField.setText(rs.getString(7));

copiesField.setText(Integer.toString(rs.getInt(8)));

priceField.setText(Float.toString(rs.getFloat(9)));
}
else{
JOptionPane.showMessageDialog(new
JFrame(), "No more records to display.");
}
}
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

College of Education Bilaspur Page 61


}
});

closeButton.addActionListener(new ActionListener() {

@Override
publicvoid actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
try {
statement.close();
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
frame.dispose();
}
});
}

College of Education Bilaspur Page 62


6. ViewIssues.java

Coding:
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

publicclass ViewIssues {

Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();

JPanel booknoPanel;
JPanel titlePanel;
JPanel recieverPanel;
JPanel issueToPanel;
JPanel rollnoPanel;
JPanel issueDatePanel;
JPanel dueDatePanel;
JPanel returnDatePanel;
JPanel decisionPanel;

JButton prevButton;
JButton nextButton;
JButton closeButton;

JTextField booknoField;
JTextField titleField;
JTextField issueToField;
JTextField rollnoField;
JTextField returnStatusField;
JTextField dueDateField;
JTextField issueDateField;

College of Education Bilaspur Page 63


JFrame frame;

public ViewIssues() throws ClassNotFoundException, SQLException{

super();
frame = new JFrame("VIEW ISSUES");
frame.setSize(screensize);

JLabel mainLabel = new JLabel("VIEW ISSUE RECORDS");


mainLabel.setForeground(Color.red);
mainLabel.setFont(new Font(Font.MONOSPACED, Font.ITALIC+Font.BOLD, 30));

GridLayout gLayout = new GridLayout(1, 2);

booknoPanel = new JPanel();


booknoPanel.setLayout(gLayout);

JLabel booknoLabel = new JLabel("Book No.");


booknoField = new JTextField();
booknoField.setEnabled(false);
booknoPanel.add(booknoLabel);
booknoPanel.add(booknoField);

titlePanel = new JPanel();


titlePanel.setLayout(gLayout);

JLabel titleLabel = new JLabel("Book Title");


titleField = new JTextField();
titleField.setEnabled(false);
titlePanel.add(titleLabel);
titlePanel.add(titleField);

recieverPanel = new JPanel();


recieverPanel.setLayout(gLayout);

issueToPanel = new JPanel();


issueToPanel.setLayout(gLayout);
//issueToPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

JLabel issueToLabel = new JLabel("Issue To");


issueToField = new JTextField(10);
issueToField.setEnabled(false);
issueToPanel.add(issueToLabel);
issueToPanel.add(issueToField);

rollnoPanel = new JPanel();


rollnoPanel.setLayout(gLayout);
rollnoPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 30));

JLabel rollnoLabel = new JLabel("Roll No.");


rollnoField = new JTextField(6);
rollnoField.setEnabled(false);
rollnoPanel.add(rollnoLabel);
rollnoPanel.add(rollnoField);

College of Education Bilaspur Page 64


recieverPanel.add(rollnoPanel);
recieverPanel.add(issueToPanel);

issueDatePanel = new JPanel();


issueDatePanel.setLayout(gLayout);

JLabel issueDateLabel = new JLabel("Issue Date");


issueDateField = new JTextField(10);
issueDateField.setEnabled(false);
issueDatePanel.add(issueDateLabel);
issueDatePanel.add(issueDateField);

dueDatePanel = new JPanel();


dueDatePanel.setLayout(gLayout);

JLabel dueDateLabel = new JLabel("Due Date");


dueDateField = new JTextField(10);
dueDateField.setEnabled(false);
dueDatePanel.add(dueDateLabel);
dueDatePanel.add(dueDateField);

returnDatePanel = new JPanel();


returnDatePanel.setLayout(gLayout);

JLabel returnDateLabel = new JLabel("Return Status");


returnStatusField = new JTextField(10);
returnStatusField.setEnabled(false);
returnDatePanel.add(returnDateLabel);
returnDatePanel.add(returnStatusField);

decisionPanel = new JPanel();

JButton prevButton = new JButton("<<");


JButton nextButton = new JButton(">>");
JButton closeButton = new JButton("CLOSE");

decisionPanel.add(prevButton);
decisionPanel.add(nextButton);
decisionPanel.add(closeButton);

JPanel mainPanel = new JPanel();


mainPanel.setBorder(BorderFactory.createEmptyBorder(250, 150, 600, 400));
BoxLayout bl = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
mainPanel.setLayout(bl);

mainPanel.add(mainLabel);
mainPanel.add(new JPanel());
mainPanel.add(new JPanel());
mainPanel.add(new JPanel());
mainPanel.add(new JPanel());
mainPanel.add(new JPanel());

College of Education Bilaspur Page 65


mainPanel.add(recieverPanel);
mainPanel.add(new JPanel());
mainPanel.add(booknoPanel);
mainPanel.add(new JPanel());
mainPanel.add(titlePanel);
mainPanel.add(new JPanel());
mainPanel.add(issueDatePanel);
mainPanel.add(new JPanel());
mainPanel.add(dueDatePanel);
mainPanel.add(new JPanel());
mainPanel.add(returnDatePanel);
mainPanel.add(new JPanel());
mainPanel.add(decisionPanel);

frame.add(mainPanel);
frame.setVisible(true);

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
final Connection conn = DriverManager.getConnection("jdbc:odbc:LIBMGMT",
"root", "pass");;
final Statement statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);;
String query = "SELECT * FROM ISSUESINFO";
final ResultSet rs = statement.executeQuery(query);

prevButton.addActionListener(new ActionListener() {

@Override
publicvoid actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub

try {
if(rs.previous()){

booknoField.setText(Integer.toString(rs.getInt(1)));
titleField.setText(rs.getString(2));

rollnoField.setText(Integer.toString(rs.getInt(3)));
issueToField.setText(rs.getString(4));
issueDateField.setText(rs.getString(5));
dueDateField.setText(rs.getString(6));
returnStatusField.setText(rs.getString(7));

}
else{
JOptionPane.showMessageDialog(new JFrame(), "No
more records to display.");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

College of Education Bilaspur Page 66


}
});

nextButton.addActionListener(new ActionListener() {

@Override
publicvoid actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
try {
if(rs.next()){

booknoField.setText(Integer.toString(rs.getInt(1)));
titleField.setText(rs.getString(2));

rollnoField.setText(Integer.toString(rs.getInt(3)));
issueToField.setText(rs.getString(4));
issueDateField.setText(rs.getString(5));
dueDateField.setText(rs.getString(6));
returnStatusField.setText(rs.getString(7));

}
else{
JOptionPane.showMessageDialog(new JFrame(), "No
more records to display.");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});

closeButton.addActionListener(new ActionListener() {

@Override
publicvoid actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub

try {
statement.close();
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

frame.dispose();

}
});

College of Education Bilaspur Page 67


}

7. SearchStudents.java

Coding:
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.TableColumn;

publicclass SearchStudents implements ActionListener{

Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();

JPanel rollnoPanel;
JPanel stunamePanel;
JPanel branchPanel;
JPanel booksissuedPanel;
JPanel latefeePanel;
JPanel decisionPanel;
JTable issuesTable;
JFrame frame;

JTextField rollnoField ;
JTextField stunameField;

College of Education Bilaspur Page 68


JComboBox<String>branchCombo;
JTextField booksissuedField;
JTextField latefeeField;

JButton searchButton;
JButton deleteButton;
JButton updateButton;
JButton closeButton;
JButton saveButton;

public SearchStudents() {
// TODO Auto-generated constructor stub

super();
frame = new JFrame("SEARCH STUDENTS");
frame.setSize(screensize);

JPanel headPanel = new JPanel();


JLabel mainLabel = new JLabel("SEARCH STUDENT RECORDS");
mainLabel.setForeground(Color.red);
mainLabel.setFont(new Font(Font.SERIF, Font.ITALIC+Font.BOLD, 30));
headPanel.setLayout(new FlowLayout());
headPanel.add(mainLabel);

rollnoPanel = new JPanel();


rollnoPanel.setLayout(new GridLayout(1, 2));

JLabel rollnoLabel = new JLabel("Roll No. : ");


rollnoField = new JTextField(10);
rollnoPanel.add(rollnoLabel);
rollnoPanel.add(rollnoField);

stunamePanel = new JPanel();


stunamePanel.setLayout(new GridLayout(1, 2));

JLabel stunameLabel = new JLabel("Student Name : ");


stunameField = new JTextField(20);
stunameField.setEnabled(false);
stunamePanel.add(stunameLabel);
stunamePanel.add(stunameField);

branchPanel = new JPanel();


branchPanel.setLayout(new GridLayout(1, 2));

JLabel branchLabel = new JLabel("Branch : ");


branchCombo = new JComboBox<String>();
String branches[] = {"AIIT", "ASET", "AIB", "ALS"};
for(int i = 0; i<branches.length; i++){
branchCombo.insertItemAt(branches[i], i);
}
branchCombo.setEnabled(false);
branchPanel.add(branchLabel);
branchPanel.add(branchCombo);

College of Education Bilaspur Page 69


booksissuedPanel = new JPanel();
booksissuedPanel.setLayout(new GridLayout(1, 2));

JLabel booksissuedLabel = new JLabel("No of Books Issued (Max. 5) : ");


booksissuedField = new JTextField();
booksissuedField.setEnabled(false);
booksissuedPanel.add(booksissuedLabel);
booksissuedPanel.add(booksissuedField);

latefeePanel = new JPanel();


latefeePanel.setLayout(new GridLayout(1, 2));

JLabel latefeeLabel = new JLabel("Cummulative Late Fee (Rs.) : ");


latefeeField = new JTextField(3);
latefeeField.setEnabled(false);
latefeePanel.add(latefeeLabel);
latefeePanel.add(latefeeField);

decisionPanel = new JPanel();

searchButton = new JButton("SEARCH");


updateButton = new JButton("UPDATE");
saveButton = new JButton("SAVE");
saveButton.setVisible(false);
deleteButton = new JButton("DELETE");
closeButton = new JButton("CLOSE");

decisionPanel.add(searchButton);
decisionPanel.add(updateButton);
decisionPanel.add(saveButton);
decisionPanel.add(deleteButton);
decisionPanel.add(closeButton);

String columnNames[] = {"Book No.", "Title", "Issue Date", "Due Date",


"Return Status"};
String rowValues[][] =
{
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
{"","","","",""},
};

issuesTable = new JTable(rowValues, columnNames);


issuesTable.setEnabled(false);

TableColumn returnStatus = issuesTable.getColumnModel().getColumn(4);


JComboBox<String> statusCombo = new JComboBox<String>();
statusCombo.addItem("Pending");
statusCombo.addItem("Returned");
returnStatus.setCellEditor(new DefaultCellEditor(statusCombo));
JScrollPane jp = new JScrollPane(issuesTable);

College of Education Bilaspur Page 70


JPanel mainPanel = new JPanel();
mainPanel.setBorder(BorderFactory.createEmptyBorder(250, 150, 100, 400));
BoxLayout bl = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
mainPanel.setLayout(bl);
mainPanel.add(headPanel);
mainPanel.add(new JPanel());
mainPanel.add(rollnoPanel);
mainPanel.add(new JPanel());
mainPanel.add(stunamePanel);
mainPanel.add(new JPanel());
mainPanel.add(branchPanel);
mainPanel.add(new JPanel());
mainPanel.add(booksissuedPanel);
mainPanel.add(new JPanel());
mainPanel.add(latefeePanel);
mainPanel.add(new JPanel());
mainPanel.add(jp);
mainPanel.add(new JPanel());
mainPanel.add(decisionPanel);

frame.add(mainPanel);
frame.setVisible(true);

searchButton.addActionListener(this);
updateButton.addActionListener(this);
saveButton.addActionListener(this);
deleteButton.addActionListener(this);
closeButton.addActionListener(this);
}

@Override
publicvoid actionPerformed(ActionEvent ae) {
// TODO Auto-generated method stub

if(ae.getSource()==searchButton){

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Connection conn = null;
Statement statement = null;
try {
conn =
DriverManager.getConnection("jdbc:odbc:LIBMGMT", "root", "pass");
statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

College of Education Bilaspur Page 71


String query = "SELECT * FROM STUDENTSINFO WHERE STROLLNO =
"+ Integer.parseInt(rollnoField.getText())+ ";";

ResultSet rs = null;
try {
rs = statement.executeQuery(query);
if(rs.next()){
rollnoField.setText(Integer.toString(rs.getInt(1)));
stunameField.setText(rs.getString(2));
branchCombo.setSelectedItem((rs.getString(3)));

booksissuedField.setText(Integer.toString(rs.getInt(4)));
latefeeField.setText(Float.toString(rs.getFloat(5)));
}
else{
JOptionPane.showMessageDialog(new JFrame(),
"Record not found!");
}

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Statement tableStatement = null;
try {
tableStatement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
} catch (SQLException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
};
String tablequery = "SELECT * FROM ISSUESINFO WHERE
ISSUEDROLLNO = "+ Integer.parseInt(rollnoField.getText())+ ";";
ResultSet tablers = null;
try {
tablers = tableStatement.executeQuery(tablequery);
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

try {
while(tablers.next()){

for(int i = 0; i<5; i++){

issuesTable.setValueAt(tablers.getString(1), i, 0);

issuesTable.setValueAt(tablers.getString(2), i, 1);

issuesTable.setValueAt(tablers.getString(5), i, 2);

issuesTable.setValueAt(tablers.getString(6), i, 3);

College of Education Bilaspur Page 72


issuesTable.setValueAt(tablers.getString(7), i, 4);
tablers.next();

}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
tablers.close();
tableStatement.close();
statement.close();
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

if(ae.getSource()==updateButton){

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Connection conn = null;
Statement statement = null;
try {
conn = DriverManager.getConnection("jdbc:odbc:LIBMGMT",
"root", "pass");
statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

String query = "SELECT * FROM STUDENTSINFO WHERE STROLLNO = "+


Integer.parseInt(rollnoField.getText())+ ";";

ResultSet rs = null;
try {
rs = statement.executeQuery(query);
if(rs.next()){
rollnoField.setText(Integer.toString(rs.getInt(1)));
stunameField.setText(rs.getString(2));
branchCombo.setSelectedItem((rs.getString(3)));

College of Education Bilaspur Page 73


booksissuedField.setText(Integer.toString(rs.getInt(4)));
latefeeField.setText(Float.toString(rs.getFloat(5)));

rollnoField.setEnabled(false);
stunameField.setEnabled(true);
branchCombo.setEnabled(true);
booksissuedField.setEnabled(true);
latefeeField.setEnabled(true);

saveButton.setVisible(true);
}
else{
JOptionPane.showMessageDialog(new JFrame(), "Record
not found!");
}

statement.close();
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

if(ae.getSource()==saveButton){

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn =
DriverManager.getConnection("jdbc:odbc:LIBMGMT", "root", "pass");
Statement statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
String query = "UPDATE STUDENTSINFO SET STNAME = '"+
stunameField.getText()+ "', STBRANCH = '"+ branchCombo.getSelectedItem().toString()+
"', ISSUEDBOOKSNO = "+
Integer.parseInt(booksissuedField.getText())+ ", LATEFEE = "+
Float.parseFloat(latefeeField.getText())+
" WHERE STROLLNO = "+
Integer.parseInt(rollnoField.getText())+ ";";

statement.executeUpdate(query);
statement.close();
conn.close();

JOptionPane.showMessageDialog(new JFrame(), "Database


updated!");

}
catch(ClassNotFoundException e){
System.out.print("ClassNotFound : "+ e);
}
catch(SQLException e1){
System.out.print("SQL Exception : "+ e1);

College of Education Bilaspur Page 74


}

rollnoField.setEnabled(true);
stunameField.setEnabled(false);
branchCombo.setEnabled(false);
booksissuedField.setEnabled(false);
latefeeField.setEnabled(false);
saveButton.setVisible(false);

if(ae.getSource()==deleteButton){

int confirm = JOptionPane.showConfirmDialog(new JFrame(), "Are you


sure about deleting this record?");

if(confirm==JOptionPane.YES_OPTION){

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn =
DriverManager.getConnection("jdbc:odbc:LIBMGMT", "root", "pass");
Statement statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
String query = "DELETE FROM STUDENTSINFO WHERE
STROLLNO = "+ Integer.parseInt(rollnoField.getText())+ ";";

statement.executeUpdate(query);
statement.close();
conn.close();

}
catch(ClassNotFoundException e){
System.out.print("ClassNotFoundException : "+ e);
}
catch(SQLException e1){
System.out.print("SQL Exception : "+ e1);
}

JOptionPane.showMessageDialog(new JFrame(), "Record


Deleted!");
}
else{
JOptionPane.showMessageDialog(new JFrame(), "Deletion
Cancelled!");
}

if(ae.getSource()==closeButton){

frame.dispose();

College of Education Bilaspur Page 75


}
}

8. SearchBooks.java

Coding:
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

publicclass SearchBooks implements ActionListener{

Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();

JFrame frame;
JPanel detailsPanel;
JPanel booksnoPanel;
JPanel booksisbnPanel;
JPanel titlePanel;
JPanel authorPanel;
JPanel subjectPanel;
JPanel publisherPanel;
JPanel editionPanel;
JPanel copiesPanel;
College of Education Bilaspur Page 76
JPanel pricePanel;
JPanel decisionPanel;

JButton searchButton;
JButton updateButton;
JButton saveButton;
JButton deleteButton;
JButton closeButton;

JTextField booksnoField;
JTextField booksisbnField;
JTextField titleField;
JTextField authorField;
JTextField subjectField;
JTextField publisherField;
JTextField editionField;
JTextField copiesField;
JTextField priceField;

public SearchBooks(){

super();
frame = new JFrame("SEARCH BOOKS");
frame.setSize(screensize);

GridLayout gLayout = new GridLayout(1, 2);

JLabel mainLabel = new JLabel("SEARCH BOOK RECORDS");


mainLabel.setForeground(Color.red);
mainLabel.setFont(new Font(Font.MONOSPACED, Font.ITALIC+Font.BOLD, 30));

booksnoPanel = new JPanel();

JLabel booksnoLabel = new JLabel("Book No. ");


booksnoField = new JTextField(10);
booksnoPanel.add(booksnoLabel);
booksnoPanel.add(booksnoField);

booksisbnPanel = new JPanel();

JLabel booksisbnLabel = new JLabel("ISBN ");


booksisbnField = new JTextField(10);
booksisbnField.setEnabled(false);
booksisbnPanel.add(booksisbnLabel);
booksisbnPanel.add(booksisbnField);

detailsPanel = new JPanel();


detailsPanel.setLayout(gLayout);

detailsPanel.add(booksnoPanel);
detailsPanel.add(booksisbnPanel);

titlePanel = new JPanel();


titlePanel.setLayout(gLayout);

College of Education Bilaspur Page 77


JLabel titleLabel = new JLabel("Title");
titleField = new JTextField();
titleField.setEnabled(false);
titlePanel.add(titleLabel);
titlePanel.add(titleField);

authorPanel = new JPanel();


authorPanel.setLayout(gLayout);

JLabel authorLabel = new JLabel("Author");


authorField = new JTextField();
authorField.setEnabled(false);
authorPanel.add(authorLabel);
authorPanel.add(authorField);

subjectPanel = new JPanel();


subjectPanel.setLayout(gLayout);

JLabel subjectLabel = new JLabel("Subject");


subjectField = new JTextField();
subjectField.setEnabled(false);
subjectPanel.add(subjectLabel);
subjectPanel.add(subjectField);

publisherPanel = new JPanel();


publisherPanel.setLayout(gLayout);

JLabel publisherLabel = new JLabel("Publisher");


publisherField = new JTextField();
publisherField.setEnabled(false);
publisherPanel.add(publisherLabel);
publisherPanel.add(publisherField);

editionPanel = new JPanel();


editionPanel.setLayout(gLayout);

JLabel editionLabel = new JLabel("Edition");


editionField = new JTextField();
editionField.setEnabled(false);
editionPanel.add(editionLabel);
editionPanel.add(editionField);

copiesPanel = new JPanel();


copiesPanel.setLayout(gLayout);

JLabel copiesLabel = new JLabel("Copies");


copiesField = new JTextField();
copiesField.setEnabled(false);
copiesPanel.add(copiesLabel);
copiesPanel.add(copiesField);

pricePanel = new JPanel();


pricePanel.setLayout(gLayout);

College of Education Bilaspur Page 78


JLabel priceLabel = new JLabel("Price (Rs.)");
priceField = new JTextField();
priceField.setEnabled(false);
pricePanel.add(priceLabel);
pricePanel.add(priceField);

decisionPanel = new JPanel();


searchButton = new JButton("SEARCH");
updateButton = new JButton("UPDATE");
saveButton = new JButton("SAVE");
saveButton.setVisible(false);
deleteButton = new JButton("DELETE");
closeButton = new JButton("CLOSE");
decisionPanel.add(searchButton);
decisionPanel.add(updateButton);
decisionPanel.add(saveButton);
decisionPanel.add(deleteButton);
decisionPanel.add(closeButton);

JPanel mainPanel = new JPanel();


mainPanel.setBorder(BorderFactory.createEmptyBorder(250, 150, 600, 600));
BoxLayout bl = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
mainPanel.setLayout(bl);

mainPanel.add(mainLabel);
mainPanel.add(new JPanel());
mainPanel.add(detailsPanel);
mainPanel.add(new JPanel());
mainPanel.add(titlePanel);
mainPanel.add(new JPanel());
mainPanel.add(authorPanel);
mainPanel.add(new JPanel());
mainPanel.add(subjectPanel);
mainPanel.add(new JPanel());
mainPanel.add(publisherPanel);
mainPanel.add(new JPanel());
mainPanel.add(editionPanel);
mainPanel.add(new JPanel());
mainPanel.add(copiesPanel);
mainPanel.add(new JPanel());
mainPanel.add(pricePanel);
mainPanel.add(new JPanel());
mainPanel.add(decisionPanel);

frame.add(mainPanel);
frame.setVisible(true);

searchButton.addActionListener(this);
updateButton.addActionListener(this);
saveButton.addActionListener(this);
deleteButton.addActionListener(this);
closeButton.addActionListener(this);
}

College of Education Bilaspur Page 79


@Override
publicvoid actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub

if(e.getSource()==searchButton){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn =
DriverManager.getConnection("jdbc:odbc:LIBMGMT", "root", "pass");
Statement statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

String query = null;

query = "SELECT * FROM BOOKSINFO WHERE BOOKNO = "+


Integer.parseInt(booksnoField.getText())+ ";";

ResultSet rs = statement.executeQuery(query);

if(rs.next()){
booksnoField.setText(Integer.toString(rs.getInt(1)));
booksisbnField.setText(rs.getString(2));
titleField.setText(rs.getString(3));
authorField.setText(rs.getString(4));
subjectField.setText(rs.getString(5));
publisherField.setText(rs.getString(6));
editionField.setText(rs.getString(7));
copiesField.setText(rs.getString(8));
priceField.setText(Float.toString(rs.getFloat(9)));
}
else{
JOptionPane.showMessageDialog(new JFrame(), "Record
not found!");
}

statement.close();
conn.close();

}
catch(ClassNotFoundException e1){

}
catch(SQLException e1){

if(e.getSource()==updateButton){

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

College of Education Bilaspur Page 80


Connection conn =
DriverManager.getConnection("jdbc:odbc:LIBMGMT", "root", "pass");
Statement statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

String query = null;

query = "SELECT * FROM BOOKSINFO WHERE BOOKNO = "+


Integer.parseInt(booksnoField.getText())+ ";";

ResultSet rs = statement.executeQuery(query);

if(rs.next()){
booksnoField.setText(Integer.toString(rs.getInt(1)));
booksisbnField.setText(rs.getString(2));
titleField.setText(rs.getString(3));
authorField.setText(rs.getString(4));
subjectField.setText(rs.getString(5));
publisherField.setText(rs.getString(6));
editionField.setText(rs.getString(7));
copiesField.setText(rs.getString(8));
priceField.setText(Float.toString(rs.getFloat(9)));
}
else{
JOptionPane.showMessageDialog(new JFrame(), "Record
not found!");
}

statement.close();
conn.close();

booksnoField.setEnabled(false);
booksisbnField.setEnabled(true);
titleField.setEnabled(true);
authorField.setEnabled(true);
subjectField.setEnabled(true);
publisherField.setEnabled(true);
editionField.setEnabled(true);
copiesField.setEnabled(true);
priceField.setEnabled(true);

saveButton.setVisible(true);
}
catch(ClassNotFoundException e1){

}
catch(SQLException e1){

if(e.getSource()==saveButton){

College of Education Bilaspur Page 81


try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn =
DriverManager.getConnection("jdbc:odbc:LIBMGMT", "root", "pass");
Statement statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

String query = null;

query = "UPDATE BOOKSINFO SET BOOKNO ="+


Integer.parseInt(booksnoField.getText())+ ", ISBN = '"+
booksisbnField.getText()+ "', TITLE = '"+
titleField.getText()+ "', AUTHOR = '"+ authorField.getText()+
"', SUBJECT = '"+ subjectField.getText()+ "', PUBLISHER = '"+
publisherField.getText()+ "', EDITION = '"+
editionField.getText()+ "', COPIES = "+
Integer.parseInt(copiesField.getText())+ ", PRICE = "+
Float.parseFloat(priceField.getText())+ "WHERE BOOKNO = "+
Integer.parseInt(booksnoField.getText())+ ";";

statement.executeUpdate(query);

statement.close();
conn.close();

JOptionPane.showMessageDialog(new JFrame(), "Database


updated!");

booksnoField.setEnabled(true);
booksisbnField.setEnabled(false);
titleField.setEnabled(false);
authorField.setEnabled(false);
subjectField.setEnabled(false);
publisherField.setEnabled(false);
editionField.setEnabled(false);
copiesField.setEnabled(false);
priceField.setEnabled(false);

saveButton.setVisible(false);
}

catch(ClassNotFoundException ce){

}
catch(SQLException se){

if(e.getSource()==deleteButton){

int confirm = JOptionPane.showConfirmDialog(new JFrame(), "Are you


sure about deleting this record?");

College of Education Bilaspur Page 82


if(confirm==JOptionPane.YES_OPTION){

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn =
DriverManager.getConnection("jdbc:odbc:LIBMGMT", "root", "pass");
Statement statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
String query = "DELETE FROM BOOKSINFO WHERE BOOKNO =
"+ Integer.parseInt(booksnoField.getText())+ ";";

statement.executeUpdate(query);
statement.close();
conn.close();

JOptionPane.showMessageDialog(new JFrame(), "Record


Deleted!");

booksnoField.setText("");
booksisbnField.setText("");
titleField.setText("");
authorField.setText("");
subjectField.setText("");
publisherField.setText("");
editionField.setText("");
copiesField.setText("");
priceField.setText("");

}
catch(ClassNotFoundException ce){

}
catch(SQLException se){

}
}
else{
JOptionPane.showMessageDialog(new JFrame(), "Deletion
Cancelled!");
}

if(e.getSource()==closeButton){

frame.dispose();

College of Education Bilaspur Page 83


11. SearchIssues.java

Coding:
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

publicclass SearchIssues implements ActionListener {

Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();

JPanel booknoPanel;
JPanel titlePanel;
College of Education Bilaspur Page 84
JPanel recieverPanel;
JPanel issueToPanel;
JPanel rollnoPanel;
JPanel issueDatePanel;
JPanel dueDatePanel;
JPanel returnDatePanel;
JPanel decisionPanel;

JFrame frame;

JTextField booknoField;
JTextField titleField;
JTextField issueToField;
JTextField rollnoField;
JTextField issueDateField;
JTextField dueDateField;
JComboBox<String>returnStatusCombo;

JButton searchButton;
JButton updateButton;
JButton saveButton;
JButton deleteButton;
JButton closeButton;

public SearchIssues(){

super();
frame = new JFrame("SEARCH ISSUES");
frame.setSize(screensize);

JLabel mainLabel = new JLabel("SEARCH ISSUE RECORDS");


mainLabel.setForeground(Color.red);
mainLabel.setFont(new Font(Font.MONOSPACED, Font.ITALIC+Font.BOLD, 30));

GridLayout gLayout = new GridLayout(1, 2);

booknoPanel = new JPanel();


booknoPanel.setLayout(gLayout);

JLabel booknoLabel = new JLabel("Book No.");


booknoField = new JTextField();
booknoPanel.add(booknoLabel);
booknoPanel.add(booknoField);

titlePanel = new JPanel();


titlePanel.setLayout(gLayout);

JLabel titleLabel = new JLabel("Book Title");


titleField = new JTextField();
titleField.setEnabled(false);
titlePanel.add(titleLabel);
titlePanel.add(titleField);

recieverPanel = new JPanel();

College of Education Bilaspur Page 85


recieverPanel.setLayout(gLayout);

issueToPanel = new JPanel();


issueToPanel.setLayout(gLayout);
//issueToPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

JLabel issueToLabel = new JLabel("Issued To");


issueToField = new JTextField(10);
issueToField.setEnabled(false);
issueToPanel.add(issueToLabel);
issueToPanel.add(issueToField);

rollnoPanel = new JPanel();


rollnoPanel.setLayout(gLayout);
rollnoPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 30));

JLabel rollnoLabel = new JLabel("Roll No.");


rollnoField = new JTextField(6);
rollnoPanel.add(rollnoLabel);
rollnoPanel.add(rollnoField);

recieverPanel.add(rollnoPanel);
recieverPanel.add(issueToPanel);

issueDatePanel = new JPanel();


issueDatePanel.setLayout(gLayout);

JLabel issueDateLabel = new JLabel("Issue Date");


issueDateField = new JTextField(10);
issueDateField.setEnabled(false);
issueDatePanel.add(issueDateLabel);
issueDatePanel.add(issueDateField);

dueDatePanel = new JPanel();


dueDatePanel.setLayout(gLayout);

JLabel dueDateLabel = new JLabel("Due Date");


dueDateField = new JTextField(10);
dueDateField.setEnabled(false);
dueDatePanel.add(dueDateLabel);
dueDatePanel.add(dueDateField);

returnDatePanel = new JPanel();


returnDatePanel.setLayout(gLayout);

JLabel returnDateLabel = new JLabel("Return Status");


returnStatusCombo = new JComboBox<String>();
String returnStatus[] = {"Pending", "Returned"};
for(int i=0; i<returnStatus.length; i++){
returnStatusCombo.insertItemAt(returnStatus[i], i);
}
returnStatusCombo.setEnabled(false);
returnDatePanel.add(returnDateLabel);
returnDatePanel.add(returnStatusCombo);

College of Education Bilaspur Page 86


decisionPanel = new JPanel();

searchButton = new JButton("SEARCH");


updateButton = new JButton("UPDATE");
saveButton = new JButton("SAVE");
saveButton.setVisible(false);
deleteButton = new JButton("DELETE");
closeButton = new JButton("CLOSE");
decisionPanel.add(searchButton);
decisionPanel.add(updateButton);
decisionPanel.add(saveButton);
decisionPanel.add(deleteButton);
decisionPanel.add(closeButton);

JPanel mainPanel = new JPanel();


mainPanel.setBorder(BorderFactory.createEmptyBorder(250, 150, 600, 400));
BoxLayout bl = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
mainPanel.setLayout(bl);

mainPanel.add(mainLabel);
mainPanel.add(new JPanel());
mainPanel.add(new JPanel());
mainPanel.add(new JPanel());
mainPanel.add(new JPanel());
mainPanel.add(new JPanel());
mainPanel.add(recieverPanel);
mainPanel.add(new JPanel());
mainPanel.add(booknoPanel);
mainPanel.add(new JPanel());
mainPanel.add(titlePanel);
mainPanel.add(new JPanel());
mainPanel.add(issueDatePanel);
mainPanel.add(new JPanel());
mainPanel.add(dueDatePanel);
mainPanel.add(new JPanel());
mainPanel.add(returnDatePanel);
mainPanel.add(new JPanel());
mainPanel.add(decisionPanel);

frame.add(mainPanel);
frame.setVisible(true);

searchButton.addActionListener(this);
updateButton.addActionListener(this);
saveButton.addActionListener(this);
deleteButton.addActionListener(this);
closeButton.addActionListener(this);
}

@Override
publicvoid actionPerformed(ActionEvent se) {
// TODO Auto-generated method stub

College of Education Bilaspur Page 87


if(se.getSource()==searchButton){

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:LIBMGMT",
"root", "pass");
Statement statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

String query = null;

if(rollnoField.getText().equals("")
&&booknoField.getText().equals("")){
JOptionPane.showMessageDialog(new JFrame(), "Input Roll No/
Book No to search a record!");
}
if(rollnoField.getText().equals("")){
query = "SELECT * FROM ISSUESINFO WHERE BOOKNO = "+
Integer.parseInt(booknoField.getText())+ ";";
}
if(booknoField.getText().equals("")){
query = "SELECT * FROM ISSUESINFO WHERE ISSUEDROLLNO = "+
Integer.parseInt(rollnoField.getText())+ ";";
}

ResultSet rs = statement.executeQuery(query);

if(rs.next()){
booknoField.setText(Integer.toString(rs.getInt(1)));
titleField.setText(rs.getString(2));
rollnoField.setText(Integer.toString(rs.getInt(3)));
issueToField.setText(rs.getString(4));
issueDateField.setText(rs.getString(5));
dueDateField.setText(rs.getString(6));
returnStatusCombo.setSelectedItem(rs.getString(7));
}
else{
JOptionPane.showMessageDialog(new JFrame(), "Record not
found!");
}

statement.close();
conn.close();
}
catch(ClassNotFoundException e){
System.out.println(e);
}
catch(SQLException ce)
{
System.out.println(ce);
}

College of Education Bilaspur Page 88


int oldBookno = 0;

if(se.getSource()==updateButton){

oldBookno= Integer.parseInt(booknoField.getText());

rollnoField.setEnabled(false);
issueToField.setEditable(false);
booknoField.setEnabled(true);
titleField.setEnabled(true);
issueDateField.setEnabled(true);
dueDateField.setEnabled(true);
returnStatusCombo.setEnabled(true);

saveButton.setVisible(true);

if(se.getSource()==saveButton){

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Connection conn = null;
Statement statement = null;
try {
conn = DriverManager.getConnection("jdbc:odbc:LIBMGMT",
"root", "pass");
statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

String query = null;

if(returnStatusCombo.getSelectedItem().equals("Returned")){
query = "DELETE FROM ISSUESINFO WHERE BOOKNO = "+ oldBookno+
";";
JOptionPane.showMessageDialog(new JFrame(), "Deleting
record.");
}
else{
query = "UPDATE ISSUESINFO SET BOOKNO = "+
Integer.parseInt(booknoField.getText())+ ", TITLE = '"+
titleField.getText()+ "', ISSUEDROLLNO = "+
Integer.parseInt(rollnoField.getText())+ ", ISSUEDSTNAME = '"+
issueToField.getText()+ "', ISSUEDATE = '"+
issueDateField.getText()+ "', DUEDATE = '"+ dueDateField.getText()+

College of Education Bilaspur Page 89


"', RETURNSTATUS = '"+ returnStatusCombo.getSelectedItem()+
"' WHERE ISSUEDROLLNO = "+ Integer.parseInt(rollnoField.getText())+
";";
}

try {
statement.executeUpdate(query);
statement.close();
conn.close();
JOptionPane.showMessageDialog(new JFrame(), "Database
Updated!");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

saveButton.setVisible(false);

rollnoField.setEnabled(true);
issueToField.setEditable(false);
booknoField.setEnabled(true);
titleField.setEnabled(false);
issueDateField.setEnabled(false);
dueDateField.setEnabled(false);
returnStatusCombo.setEnabled(false);
}

if(se.getSource()==deleteButton){
int confirm = JOptionPane.showConfirmDialog(new JFrame(), "Are you sure about deleting
this record?");

if(confirm==JOptionPane.YES_OPTION){

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn =
DriverManager.getConnection("jdbc:odbc:LIBMGMT", "root", "pass");
Statement statement =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
String query = "DELETE FROM ISSUESINFO WHERE BOOKNO =
"+ Integer.parseInt(booknoField.getText())+ ";";

statement.executeUpdate(query);
statement.close();
conn.close();

JOptionPane.showMessageDialog(new JFrame(), "Record


Deleted!");

rollnoField.setText("");
booknoField.setText("");
titleField.setText("");
issueToField.setText("");
issueDateField.setText("");

College of Education Bilaspur Page 90


dueDateField.setText("");

}
catch(ClassNotFoundException ce){

}
catch(SQLException qe){

}
}
else{
JOptionPane.showMessageDialog(new JFrame(), "Deletion
Cancelled!");
}
}

if(se.getSource()==closeButton){

frame.dispose();
}

9. TESTING

 Functionality Testing

Apart from SearchIssues.java module, every module is working as per expected output.
SearchIssues.java does not allow changing in the values of BOOKNO or TITLE since they are
foreign keys and cannot be altered.

 Usability Testing

The project is working well and can be used in the real system. It does not need network interface
so its installation is complete offline and standalone.

 Interface Testing

Interface is completely functional and designed for large resolution screens. Preffered screen
resolution is 1366x768; any change in screensize/window size may hide/cut/overlap the swing
components from visible portion of the screen.
College of Education Bilaspur Page 91
 Compatibility Testing

The project is compatible with all types of operating systems if proper drivers and compatible java
runtime environment is installed. Incase MySQL ODBC Driver is missing/incompatible; the
software may run but would not work along the database which means no
deletion/updation/addition/evaluation of data from the tables of the database.

 Performance Testing

Performance of the software depends upon the hardware functions and amount of memory available
for the software to work. In case of low RAM, shortage of disk space, underclocked processor or
database related problems, the program may work slow or may not work at all and can even fail to
execute.

 Security Testing

System is completely secured and integrated. Any user with invalid credidentials will not be able to
connect to the database. The project itself cannot interfere with the system security or security of
other softwares installed in the system.

College of Education Bilaspur Page 92


10. Enhancement

With the changing time and rapid growth in technological fields, future development of this project
might need to eliminate existing errors/bugs or improve the interface and functioning of the
software.
Current build of the software is not overall complete in itself. It needs added background
images, better searching techniques and more reliable error/exception handling and
acknowledgement of the same to the user.

With the increase in number of students and the library resources, database will also have to be
extended to meet the huge requirement ahead of it. As every year, the university/college using this
system will gather more students and books, the current data types for the database will be felt
limited and therefore it may need change in the whole database.
There can also be added complexity to the database as more information about the students
or books maybe required being stored.

College of Education Bilaspur Page 93


11. Limitations

 Distortion in user interface when the window is resized into smaller size. Usually this results
in overlapping of components or reduced visible portion of the swing components.
 In case there is type mismatch while writing values to the tables in the database, the
errors/exceptions are displayed over the console which is hidden from the user on the time
of execution.
 Dates/Edition of books is taken as String input.
 In case book details are entered incorrect in the issues table, that record cannot be modified
and needs to be deleted and create/added as a new record.

College of Education Bilaspur Page 94


12. Conclusion

From a proper analysis of positive points and constraints onthe component, it can be safely
concluded that the software isa highly efficient GUI based component. This application is
working properly and meeting to all user requirements. The software does not need very high
system configuration and does not hang the system that is using it.

College of Education Bilaspur Page 95


13. References

 McGraw Hill – Java The CompleteReference, 7thEditionDec.2006


 McGraw Hill - SCJP Sun Certified Programmer for Java 6 Exam (2008)
 www.java2s.com
 www.roseindia.net
 www.dreamincode.net
 www.stackoverflow.com

College of Education Bilaspur Page 96

You might also like