0% found this document useful (0 votes)
44 views156 pages

Enhanced Library Management System: Department of Computer Science

This document describes a project report for an Enhanced Library Management System submitted to Srimad Andavan Arts & Science College. The report was submitted by S.Narmatha and T.Mohana under the guidance of Dr. M.Subhashini to fulfill the requirements for a Bachelor of Computer Applications degree. The project aims to develop a computerized system to manage all daily operations of a library more efficiently compared to a manual system.

Uploaded by

Prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views156 pages

Enhanced Library Management System: Department of Computer Science

This document describes a project report for an Enhanced Library Management System submitted to Srimad Andavan Arts & Science College. The report was submitted by S.Narmatha and T.Mohana under the guidance of Dr. M.Subhashini to fulfill the requirements for a Bachelor of Computer Applications degree. The project aims to develop a computerized system to manage all daily operations of a library more efficiently compared to a manual system.

Uploaded by

Prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 156

ENHANCED LIBRARY MANAGEMENT SYSTEM

A Project Report submitted to Srimad Andavan Arts & Science College


(Autonomous),
Affiliated to BHARATHIDASAN UNIVERSITY in
partial fulfillment of the requirement for the award of the
Degree of

BACHELOR OF COMPUTER APPLICATIONS


Submitted By

S.Narmatha
Register No. U20CA0060
T.Mohana
Register No. U20CA0054

Under the Guidance of

Dr. M.Subhashini M.C.A., M.Phil, Ph.D.,

DEPARTMENT OF COMPUTER SCIENCE


Srimad Andavan Arts & Science College (Autonomous)
(Affiliated to Bharathidasan
University) Nationally Re -
accredited by NAAC An ISO
9001:2015 Certified Institution No
7, Nelson Road, Tiruvanaikoil,
Tiruchirappalli - 620 005.
APRIL 2023

Srimad Andavan Arts & Science College (


Autonomous)
(Affiliated to Bharathidasan
University) Nationally Re -accredited
by NAAC
An ISO 9001:2015 Certified
Institution No 7, Nelson Road,
Tiruvanaikoil, Tiruchirapalli - 620
005.

Dr. M.Subhashini
M.C.A., M.Phil., Ph.D.,

CERTIFICATE

This is to certify that the Project Report appellation entitled "Enhanced Library
Management System"submitted to Srimad Andavan Arts & Science College (Autonomous),
Affiliated to Bharathidasan University, Tiruchirappalli in partial fulfillment of the requirement
for the award of the degree of Bachelor of Computer Applications for the academic Year
2022-2023, is a bonafide record of the project work done by S.Narmatha under my guidance
and supervision. The dissertation has not previously formed the basis for the award of any
degree or fellowship to the candidate.

Comments:

SIGNATURE OF THE GUIDE SIGNATURE OF THE


HOD

SIGNATURE OF THE EXAMINER

Date:

DECLARATION

I declare that the project work entitled “Enhanced Library Management System”
submitted to, Srimad Andavan Arts and Science College (Autonomous), affiliated to
Bharathidasan University, Tiruchirappalli in partial fulfillment of the requirement for the
award of the degree of Bachelor of Computer Applications for the academic year 2022-2023,
is the result of the original work carried out by me under the guidance and supervision of Dr.
M.Subhashini, Department of Computer Science, Srimad Andavan Arts and Science College
(Autonomous), Thiruchirappalli.

Date :

Place :

Signature of the Candidate

S.Narmatha

VIVA VOCE

The Viva-Voce Examination of this Project Work is held on _________at Srimad


Andavan Arts and Science College (Autonomous), Tiruchirappalli-5

Internal Examiner External Examiner


ACKNOWLEDGEMENT

First, I am very thankful to the Almighty for showering the Blessings throughout my life.
I would like to express my heartfelt thanks to my beloved parents who have sacrificed a lot for
my future. This support was the foundation stone for my efforts.

I acknowledge my sincere thanks to Shri Ammangi V.BALAJI, Secretary &


Correspondent, Dr.M.PITCHAIMANI., Principal, , Dr.S.R.SATHYANARAYANAN,Vice
Principal,Dr.S.MADHU, Dean of Sciences, Dr.V.UPENDRAN., Head-PG and Research
Department of Computer Science, Dr.N.KARTHIKEYAN, Co-ordinator, PG and Research
Department of Computer Science, for giving me the opportunity to do my Under Graduate
Degree course in this renowned institution and providing facilities to carry out the project work.

I am grateful to Dr. M.Subhashini PG and Research Department of Computer Science, the


internal guide for timely suggestions and constant encouragement and support that led to the
accomplishment of the project.
I extend my thanks to all the teaching, non-teaching staff members and Computer Center
Staffs who helped me either directly or indirectly to complete this project.

I wish to express my heartfelt thanks to my friends for their useful tips that helped me to
complete this project successfully.

CONTENT

S.NO Title Page Number

1 Introduction

Requirement specification

2.1 Hardware Requirement


2.2 Software Requirement
2 2.3 Existing System
2.4 Proposed System
2.5 Software Description
2.6 Project Description

Design

3 3.1 Data Flow Diagram


3.2 Use Case Diagram
3.3 Table Design

Implementation
4
4.1 Source Code
4.2 Screenshots

5 Testing

6 Conclusion

7 Bibliography

ENHANCED LIBRARY MANAGEMENT SYSTEM

ABSTRACT

Enhanced Library management system is a project which aims in developing a computerized


system to maintain all the daily work of library. This software project is a library management
software system with all the basic as well as some innovative features for managing a library. It
consists of a large database of various books available in the library. This project has many
features which are generally not available in normal library management systems like facility of
student login and a facility of staff login like librarian. It also has a facility of admin login
through which the admin can monitor the whole system. It also lists various books issued to
respective readers. The system keeps track of all the books readily available and also the books
that have been issued to various readers the time period for which the books have been issued.
The system also handles separate database for each users. Readers usually tend to forget the date
to resubmit their library books so these books that have been issued to the reader and have
reached their expiry date, SMS notification is sent to the reader automatically by the system to
remind him about the book return date. Thus this innovative library management system
provides enhanced library functionality for this modern day world. The proposed system
implemented in java(JSP) as front end design and MySQL server as back end design.

INTRODUCTION
A system is a set of connected parts/components forming a complex whole. It contains entities,
namely, men, machines and materials. These entities are integrated to serve definite purpose and
objectives. The system components are inter-related, inter-dependent and have effect on each
other as a whole. Thus a library is also a system and its various sections/divisions are its
components. The primary objective of any library system is to collect, store, organize, retrieve
and make available the information sources to the information users. A library, as a system, is a
subsystem of some super-system (an organization in any field, whether education, research or
social service). It has its own subsystems, such as, acquisition system, circulation system,
administration system, etc. In this lesson, you will learn library management and the role of
Library Management is the adaptation of the principles and techniques of management to the
library situation. It includes decision making and getting the work done by others. The five
fundamental management functions are: Planning, Organizing, Staffing, Leading and
Controlling.
Libraries have an important role to play in facilitating access to information for learning,
education and training. It is a known fact that a well-managed library is a successful library. The
library management means efficient and effective management of material (information sources),
machinery, men (human resource), technology and money to meet the objectives of the library.
Thus, librarian as manager performs all the functions of manager/administrator.
REQUIREMENTS SPECIFICATION
2.1 HARDWARE REQUIREMENTS

• Processor : Dual core processor 2.6.0 GHZ


• RAM : 4GB
• Hard disk : 320 GB
• Compact Disk : 650 Mb
• Keyboard : Standard keyboard
2.2 SOFTWARE REQUIREMENTS
• Operating system : Windows OS
• Front End : JAVA (JSP)
• Back End : SQL SERVER
• Tool : Net Beans IDE

2.3 EXISTING SYSTEM


In the existing system all the transaction of books are done manually, So takes more time for a
transaction like borrowing a book or returning a book and also for searching the books. Another
major disadvantage is that to prepare the list of books borrowed and the available books in the
library will take more time, currently it is done in one day for verifying all records.
In this existing system takes lots of time for searching particular book in library.
DISADVANTAGES

• Fast report generation is not possible.


• Tracing a book is difficult.
• Information about issue/return of the books is not properly maintained.
• No central database can be created as information is not available in database.

2.4 PROPOSED SYSTEM

The proposed system provides the features like issue books and barrow book via in
this application. The proposed application’s improvement in control and performance request
column for the librarian for providing new books. The system is developed to cope up with the
current issues and problems of the library. The system can add user, validate the user. A separate
column for the digital library that librarian is able to search the record by using few clicks of the
mouse and few search keywords thus saving his valuable time. Student login page
where student can find books issued by him/her and date of return. 

ADVANTAGES

• It provides "better and efficient" service to members.


• Reduce the workload of an employee.
• Faster retrieval of information about the desired book.
• Provide facility for proper monitoring reduces paper work and provide data security.
• All details will be available on a one click.
2.5 SOFTWARE DESCRIPTION

Front End

Java
Java programming language was originally developed by Sun Microsystems which was initiated
by James Gosling and released in 1995 as core component of Sun Microsystems' Java
platform (Java 1.0 [J2SE]). The latest release of the Java Standard Edition is Java SE 8. With the
advancement of Java and its widespread popularity, multiple configurations were built to suit
various types of platforms. For example: J2EE for Enterprise Applications, J2ME for Mobile
Applications. The new J2 versions were renamed as Java SE, Java EE, and Java ME respectively.
Java is guaranteed to be Write Once, Run Anywhere.

FEATURES

Object Oriented − In Java, everything is an Object. Java can be easily extended since it is based
on the Object model.

Platform Independent − unlike many other programming languages including C and C++, when
Java is compiled, it is not compiled into platform specific machine, rather into platform
independent byte code. This byte code is distributed over the web and=interpreted by the
JavaVirtual Machine (JVM) on whichever platform it is being run on.

Simple − Java is designed to be easy to learn. If you understand the basic concept of OOP Java,
it would be easy to master.

Secure − With Java secure feature it enables to develop virus-free, tamper-free systems.
Authentication techniques are based on public-key encryption.

Architecture-neutral − Java compiler generates an architecture-neutral object file format, which


makes the compiled code executable on many processors, with the presence of Java runtime
system.

Portable − Being architecture-neutral and having no implementation dependent aspects of the


specification makes Java portable. Compiler in Java is written in ANSI C with a clean portability
boundary, which is a POSIX subset.

Robust − Java makes an effort to eliminate error prone situations by emphasizing mainly on
compile time error checking and runtime checking.
Multithreaded − With Java's multithreaded feature it is possible to write programs that can
perform many tasks simultaneously. This design feature allows the developers to construct
interactive applications that can run smoothly.

Interpreted − Java byte code is translated on the fly to native machine instructions and is not
stored anywhere. The development process is more rapid and analytical since the linking is an
incremental and light-weight process.

High Performance − With the use of Just-In-Time compilers, Java enables high
performance.

Distributed − Java is designed for the distributed environment of the internet.

Dynamic − Java is considered to be more dynamic than C or C++ since it is designed to


adapt to an evolving environment. Java programs can carry extensive amount of run-time
information that can be used to verify and resolve accesses to objects on run-time.

JAVA ARCHITECTURE

Compilation and interpretation in Java

Java combines both the approaches of compilation and interpretation. First, java compiler
compiles the source code into bytecode. At the run time, Java Virtual Machine (JVM) interprets
this bytecode and generates machine code which will be directly executed by the machine in
which java program runs. So java is both compiled and interpreted language.

Java Virtual Machine (JVM)

JVM is a component which provides an environment for running Java programs. JVM
interprets the bytecode into machine code which will be executed the machine in which the Java
program runs.

Why Java is Platform Independent?

Platform independence is one of the main advantages of Java. In another words, java is portable
because the same java program can be executed in multiple platforms without making any
changes in the source code. You just need to write the java code for one platform and the same
program will run in any platforms. But how does Java make this possible?
As we discussed early, first the Java code is compiled by the Java compiler and generates the
bytecode.  This bytecode will be stored in class files. Java Virtual Machine (JVM) is unique for
each platform.   Though JVM is unique for each platform, all interpret the same bytecode and
convert it into machine code required for its own platform and this machine code will be directly
executed by the machine in which java program runs.  This makes Java platform independent
and portable.

Let’s make it more clear with the help of the following diagram.  Here the same compiled Java
bytecode is interpreted by two different JVMS to make it run in Windows and Linux platforms.

Java Runtime Environment (JRE) and Java Architecture in Detail

Java Runtime Environment contains JVM, class libraries and other supporting components.

As you know the Java source code is compiled into bytecode by Java compiler. This bytecode
will be stored in class files. During runtime, this bytecode will be loaded, verified and   JVM
interprets the bytecode into machine code which will be executed in the machine in which the
Java program runs.

A Java Runtime Environment performs the following main tasks respectively.

1. Loads the class

This is done by the class loader

2. Verifies the bytecode

This is done by bytecode verifier.

3. Interprets the bytecode

This is done by the JVM

These tasks are described in detail in the subsequent sessions.A detailed Java architecture can be
drawn as given below.
JavaScript

JavaScript is a scripting language widely used for client-side web development. It is a


dynamic, weakly typed, prototype-based language with first-class functions. JavaScript was
influenced by many languages and was designed to look like Java, but be easier for non-
programmers to work with.

Although best known for its use in websites (as client-side JavaScript), JavaScript is also
used to enable scripting access to objects embedded in other applications. The key design
principles within JavaScript are inherited from the Self and Scheme programming languages.

Back End

SQL SERVER EXPRESS

SQL Server Express is a free version of Microsoft’s primary relational database management
system (RDBMS) – the SQL Server. Essentially, the SQL Server is a database management
system that can be used to store and access the information stored in many different databases.
SQL Server comes with an impressive range of features like business intelligence, reporting, and
in-depth advanced analytics.

Microsoft does, however, offer SQL Server in some different editions including:

• SQL Server Enterprise


• SQL Server Business Intelligence
• SQL Server Standard
• SQL Server Web
• SQL Server Express

SQL Server Express is the most basic offering available. It is a full database engine you
can deploy to a server or embed into an application. Express is free and comes with many of the
same features as the enterprise edition. SQL Server Express is probably most suited to supporting
production applications for smaller to midsize businesses.

SQL Server Express Benefits


Some benefits come with an SQL Server Express deployment.

• Free: One huge advantage of SQL Server Express is that it is free. Your only outlay is the
time investment you make downloading and setting up the system. If you only want to learn how
to use SQL Server, then Express is for you. There is nothing to lose by downloading the system
and getting used to how it works.
• Scalability: SQL Server Express is an ideal starting point for smaller independent
software vendors (ISVs) since it can be used with any smaller application. The licensing allows
Express to be included as part of an app or product. While there are limitations on memory and
socket usage, they are not as restrictive as some might think. Express is not limited to a single
user which is a commonly held misconception. There is a 10GB database restriction, but that is a
maximum size per database meaning you can have multiple databases that store up to 10GB of
data. If you are an ISV and your company experiences high growth rate resulting in increased
database demands, then you can only upgrade to a paid version of SQL Server.
• Security: Within SQL Server Express there is the option of free online backup that will
help to protect your valuable business data if anything goes wrong. Administrators should still
follow security best practices like restricting access to backup folders and following Windows
password policies.
• Features: While Express is the “lite” version of SQL Server, there is still an impressive
range of features that you would have to pay for with other systems.

Express supports Full-Text Search, native XML, and the SQL Common Language Other key
features include a reporting component and report designer enabling custom report creation.

SQL Server Express Limitations:

• Before deploying SQL Server Express, you should make yourself aware of
its limitations which include:

• 1GB maximum memory used by the SQL Server Database Engine


• The maximum size of each relational database is 10GB
• SQL Agent is not included in Express. The SQL Agent is a background tool which
enables administrators to automate tasks like backing up data, database replication setup, job
scheduling, user permissions, and database monitoring.
• The limit on the buffer cache for each instance is 1MB of RAM.
• The relational database engine is restricted to the lesser of 1 socket or 4 cores.

Versions of SQL Server Express


The 2016 version of SQL Server Express was released in three different editions:

SQL Server 2016 SP1 Express: This is the core express offering and comes with the features
we have already laid out. In addition, capabilities like dynamic data masking and row-level
security are now available in Express.

SQL Server 2016 Express with Advanced Services: This edition of Express contains the most
features. Included are the relational database engine, Management Studio, reporting, and full-text
search. Ideal for developers working on smaller applications which need to implement reporting
on their applications.

SQL Server 2016 Express Local DB: This edition is mainly used as a development tool. It is a
lighter version of Express that runs as a local app. It does support all the main programmability
features of the other editions. The big advantage of Local DB for developers is that it allows
them to create a local environment that is much easier to install and manage. Users can just start
up an instance of Local DB runtime as they need it and do not need to install a service.

2.6 PROJECT DESCRIPTION

Library is a place where all kind of books are available; The collection of knowledge in an
institution is library. The library usually contains the information physically or digitized method.
Library management system consists of list of records about the management of the student
detail, book details and its transaction performance. The ELMS project is developing a
computerized system in library management. As the modern organizations are computerized,
This ELMS helps become essential for human being, commodity and computers in modern
organization Student login page where student can find books issued by him/her and date of
return. After computerized system is implemented less human force will be required to maintain
the library thus reducing the overall cost. A search column to search availability of books. A
staff login page where teacher can add any events being organized in the college and important
suggestions regarding books. And the system also checks the eligible students. Student has the
limitations for barrow books. Student can check the available book via online. Students have to
register before using in the system. . This application is a proof-of-concept visual system
designed to assist readers with finding shelved books in library. This system helps to remind the
students to return book and also intimate the fine amount. The fine amount will be increased day
by day according to college rules.

MODULES
Admin

• Login
• Add Book Details
• Book Allotment
• Book Maintenance
• Student Registration
• Fine Module
• Location Details
• Student Details

Student

• Login
• Search module
• Location Details
• Notification

MODULE DESCRIPTION

Admin/ Librarian

• Login
In this module, the admin can login the system using his/her username and password.
• Add Book Details
In this module contains various facilities like add new book and search book. In the ‘add
new book’ section if any new book comes in the library then the librarian can add its
specifications. Similarly if the user wants to search for a specific book then he/she can
use search book option to do it. In this module admin enter the available book details in
the library.
• Book Allotment
In this module used allot the book to appropriate department. Department details and
book details are maintain by admin.
• Book Maintenance
Book maintenance module allows the member to view the book currently they have
borrowed and also view the book they have borrowed. Not only that, there got reservation
module which allow member to reserve book. Members are allowing reserving book and
deleting the reservation and also view currently the book they reserve.
• Student Registration
Allow the administrator to register new student and update the student records. Student
record details contain ID card image, id number, student name, department, phone
number
• Student Details
In this module user can view the registered student details. And their barrowed book
details.
• Fine Calculation
In this module used to maintain the fine. The student has returned a book on date
otherwise the fine was calculated and increased day by day.
• Location Details
In this module used to add the details about location of the book in track. The information
posted by admin.

Student

• Login
This module is used by user and also admin user for the website. They need to login to
the website using their id and password. In order to distinguish the user’s level, user can
access to different module when successfully login. Student also precedes their ID card
image for verification.
• Search Module
Search Module allow user or guess who visit website to search the book. Not only that
the user allow viewing the details of the book and also seeing the request of the book.
There are a few of type allow users to search. They can search via ISBN, book title and
author.
• Location Details
In this module used to view the details about location of the book in track. The
information posted by admin.
• Notification
Notification sends to student for remaining the return date of the book. Member Expired
report is to view the student’s is date expired via which date, month or year. So they can
remind their student to return the book. Student can also view their fine amount on their
dash board.
DESIGN
3.1 DATA FLOW DIAGRAM
A two-dimensional diagram explains how data is processed and transferred in a system. The
graphical depiction identifies each source of data and how it interacts with other data sources to
reach a common output. Individuals seeking to draft a data flow diagram must identify external
inputs and outputs, determine how the inputs and outputs relate to each other, and explain with
graphics how these connections relate and what they result in. This type of diagram helps
business development and design teams visualize how data is processed and identify or improve
certain aspects.

Level 0 DFD

The Level 0 DFD shows how the system is divided into 'sub-systems' (processes), each of
which deals with one or more of the data flows to or from an external agent, and which together
provide all of the functionality of the system as a whole. It also identifies internal data stores that
must be present in order for the system to do its job, and shows the flow of data between the
various parts of the system.

Level 1 DFD

The next stage is to create the Level 1 Data Flow Diagram. This highlights the main functions
carried out by the system. As a rule, to describe the system was using between two and seven
functions - two being a simple system and seven being a complicated system. This enables us to
keep the model manageable on screen or paper.

Level 2 DFD

A Data Flow Diagram (DFD) tracks processes and their data paths within the business or
system boundary under investigation. A DFD defines each domain boundary and illustrates the
logical movement and transformation of data within the defined boundary. The diagram shows
'what' input data enters the domain, 'what' logical processes the domain applies to that data, and
'what' output data leaves the domain. Essentially, a DFD is a tool for process modeling and one
of the oldest.

3.2 USE CASE DIAGRAM


Use case diagrams referred as Behaviour model or diagram. It describes and displays the
relation or interaction between the users or customers and provides of application service or the
system. It describes different actions that a system performs in colloboration to acheive
something with one or more users of the system. Use case diagram is used a lot nowadays to
manage the system.

3.3 TABLE DESIGN

Database Design is a collection of processes that facilitate the designing, development,


implementation and maintenance of enterprise data management systems

It helps produce  database systems

• That meet the requirements of the users


• Have high performance.

 The logical model concentrates on the data requirements and the data to be stored independent
of physical considerations. It does not concern itself with how the data will be stored or where it
will be stored physically.

The physical data design model involves translating the logical design of the database onto
physical media using hardware resources and software systems such as database management
systems (DBMS).
Table name: book
Field Type Null Default
id int(5) Yes NULL
book varchar(30) Yes NULL
title varchar(50) Yes NULL
author varchar(30) Yes NULL
date varchar(20) Yes NULL
publishe varchar(30) Yes NULL
r
price varchar(20) Yes NULL
count varchar(10) Yes NULL
location varchar(100) Yes NULL
img varchar(50) Yes NULL

Table name: request


Field Type Nul Default
l
id int(5) Yes NULL
uid varchar(5) Yes NULL
uname varchar(30) Yes NULL
bid varchar(5) Yes NULL
book varchar(50) Yes NULL
title varchar(50) Yes NULL
date varchar(20) Yes NULL
end varchar(20) Yes NULL
image varchar(50) Yes NULL
status varchar(5) Yes NULL
report varchar(5) Yes NULL
sta varchar(5) Yes NULL

Table name: user


Field Type Null Default
id int(30) Yes NULL
name varchar(30 Yes NULL
)
gender varchar(30 Yes NULL
)
contact varchar(30 Yes NULL
)
email varchar(30 Yes NULL
)
address varchar(50 Yes NULL
)
uname varchar(30 Yes NULL
)
pass varchar(30 Yes NULL
)
cpass varchar(30 Yes NULL
)

IMPLEMENTATION
4.1 SOURCE CODE
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Library_Management;

import java.awt.Dimension;
import java.awt.Toolkit;

/**
*
* @author ZI Zohir
*/
public class Home extends javax.swing.JFrame {

/**
* Creates new form Home
*/
public Home() {
initComponents();
Toolkit toolkit = getToolkit();
Dimension size = toolkit.getScreenSize();
setLocation(size.width/2 - getWidth()/2, size.height/2 - getHeight()/2);
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents() {

jLabel1 = new javax.swing.JLabel();


jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jPanel4 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
btnrbook = new javax.swing.JButton();
btnibook = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
btnstatistics = new javax.swing.JButton();
btnnewstudent = new javax.swing.JButton();
btnnewbook = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
miexit = new javax.swing.JMenuItem();
milogout = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
miabout = new javax.swing.JMenuItem();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Main Menu");
setBackground(new java.awt.Color(0, 204, 204));

jLabel1.setBackground(new java.awt.Color(0, 255, 255));


jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Library Management System");

jLabel2.setText("Welcome");

jLabel3.setText("to");

jLabel4.setText(" Library");
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFact
ory.createLineBorder(new java.awt.Color(102, 255, 204)), "Action",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1,
24), new java.awt.Color(255, 102, 102))); // NOI18N

btnrbook.setText("Return Book");
btnrbook.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnrbookActionPerformed(evt);
}
});

btnibook.setText("Issue Book");
btnibook.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnibookActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);


jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnibook, javax.swing.GroupLayout.PREFERRED_SIZE, 175,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(btnrbook, javax.swing.GroupLayout.PREFERRED_SIZE, 175,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(btnibook, javax.swing.GroupLayout.PREFERRED_SIZE, 73,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnrbook, javax.swing.GroupLayout.PREFERRED_SIZE, 73,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(23, Short.MAX_VALUE))
);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFact
ory.createLineBorder(new java.awt.Color(102, 255, 102)), "Operation",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1,
24), new java.awt.Color(0, 102, 204))); // NOI18N

btnstatistics.setText("Statistics");
btnstatistics.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnstatisticsActionPerformed(evt);
}
});

btnnewstudent.setText("New Student");
btnnewstudent.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnnewstudentActionPerformed(evt);
}
});

btnnewbook.setText("New Book");
btnnewbook.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnnewbookActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnnewbook, javax.swing.GroupLayout.PREFERRED_SIZE,
175, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(btnstatistics, javax.swing.GroupLayout.PREFERRED_SIZE,
175, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(btnnewstudent, javax.swing.GroupLayout.PREFERRED_SIZE,
175, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(62, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(btnnewbook, javax.swing.GroupLayout.PREFERRED_SIZE,
65, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnstatistics, javax.swing.GroupLayout.PREFERRED_SIZE,
65, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnnewstudent,
javax.swing.GroupLayout.PREFERRED_SIZE, 62,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(29, Short.MAX_VALUE))
);

javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);


jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(

jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(21, 21, 21))
);
jPanel4Layout.setVerticalGroup(

jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel4Layout.createSequentialGroup()
.addGap(32, 32, 32)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(41, 41, 41)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(106, Short.MAX_VALUE))
);

jMenu1.setText("File");

miexit.setText("Exit");
miexit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
miexitActionPerformed(evt);
}
});
jMenu1.add(miexit);

milogout.setText("Logout");
milogout.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
milogoutActionPerformed(evt);
}
});
jMenu1.add(milogout);

jMenuBar1.add(jMenu1);

jMenu2.setText("Edit");

miabout.setText("About");
jMenu2.add(miabout);

jMenuBar1.add(jMenu2);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment
.CENTER)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addContainerGap())))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D)
.addComponent(jLabel4))
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);

setSize(new java.awt.Dimension(700, 605));


setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents

private void milogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_milogoutActionPerformed
Login log = new Login();
log.setVisible(true);
this.dispose();
}//GEN-LAST:event_milogoutActionPerformed

private void miexitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_miexitActionPerformed
System.exit(0);
}//GEN-LAST:event_miexitActionPerformed

private void btnnewbookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnnewbookActionPerformed
NewBook ob = new NewBook();
ob.setVisible(true);
this.dispose();
}//GEN-LAST:event_btnnewbookActionPerformed

private void btnstatisticsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnstatisticsActionPerformed
Statistics ob = new Statistics();
ob.setVisible(true);
this.dispose();
}//GEN-LAST:event_btnstatisticsActionPerformed

private void btnnewstudentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnnewstudentActionPerformed
Student ob = new Student();
ob.setVisible(true);
this.dispose();
}//GEN-LAST:event_btnnewstudentActionPerformed

private void btnrbookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnrbookActionPerformed
Return ob = new Return();
ob.setVisible(true);
this.dispose();
}//GEN-LAST:event_btnrbookActionPerformed

private void btnibookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnibookActionPerformed
Issue ob = new Issue();
ob.setVisible(true);
this.dispose();
}//GEN-LAST:event_btnibookActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Home().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JButton btnibook;
private javax.swing.JButton btnnewbook;
private javax.swing.JButton btnnewstudent;
private javax.swing.JButton btnrbook;
private javax.swing.JButton btnstatistics;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel4;
private javax.swing.JMenuItem miabout;
private javax.swing.JMenuItem miexit;
private javax.swing.JMenuItem milogout;
// End of variables declaration//GEN-END:variables
}
package Library_Management;

import DAO.DatabaseHelper;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author angel jude suarez
*/
public class Login extends javax.swing.JFrame {
Connection con = null;
ResultSet rs = null;
PreparedStatement ps = null;
/**
* Creates new form Login
*/
public Login() {
initComponents();
con = DatabaseHelper.getConnection();
Toolkit toolkit = getToolkit();
Dimension size = toolkit.getScreenSize();
setLocation(size.width/2 - getWidth()/2, size.height/2 - getHeight()/2);
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


btnsignup = new javax.swing.JButton();
btnforgot = new javax.swing.JButton();
txtuname = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
btnlogin = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtpassword = new javax.swing.JPasswordField();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Login");

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Login",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1,
18), new java.awt.Color(0, 102, 102))); // NOI18N

btnsignup.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


btnsignup.setText("Signup");
btnsignup.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnsignupActionPerformed(evt);
}
});
btnforgot.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
btnforgot.setText("Forgot Password");
btnforgot.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnforgotActionPerformed(evt);
}
});

txtuname.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


txtuname.setText("admin");

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel2.setText("Password");

btnlogin.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


btnlogin.setText("Login");
btnlogin.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnloginActionPerformed(evt);
}
});

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel1.setText("Username");

jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel3.setForeground(new java.awt.Color(255, 0, 51));
jLabel3.setText("Trouble Login..!");

txtpassword.setText("admin");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE,
60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGap(29, 29, 29)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(btnlogin)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNR
ELATED)
.addComponent(btnsignup))
.addComponent(txtpassword)
.addComponent(txtuname)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel3)
.addGap(27, 27, 27)
.addComponent(btnforgot)))
.addContainerGap(12, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel1)
.addComponent(txtuname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtpassword, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(btnlogin)
.addComponent(btnsignup))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(btnforgot)
.addComponent(jLabel3))
.addContainerGap())
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(52, 52, 52)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(58, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(52, Short.MAX_VALUE))
);

pack();
}// </editor-fold>//GEN-END:initComponents
private void btnsignupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_btnsignupActionPerformed
Signup si = new Signup();
si.setVisible(true);
this.dispose();
}//GEN-LAST:event_btnsignupActionPerformed

private void btnforgotActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnforgotActionPerformed
Forgot fo = new Forgot();
fo.setVisible(true);
this.dispose();
}//GEN-LAST:event_btnforgotActionPerformed

private void btnloginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnloginActionPerformed
String sql = "select * from account where username=? and password=?";
try {
ps = con.prepareStatement(sql);
ps.setString(1, txtuname.getText());
ps.setString(2, txtpassword.getText());
rs = ps.executeQuery();
if (rs.next()) {
rs.close();
ps.close();
Loading lod = new Loading();
lod.setUploading();
lod.setVisible(true);
}else{
JOptionPane.showMessageDialog(null, "Incorrect Username and Password");
}
this.dispose();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}//GEN-LAST:event_btnloginActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Login().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JButton btnforgot;
private javax.swing.JButton btnlogin;
private javax.swing.JButton btnsignup;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPasswordField txtpassword;
private javax.swing.JTextField txtuname;
// End of variables declaration//GEN-END:variables
}
package Library_Management;

import DAO.DatabaseHelper;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author ZI Zohir
*/
public class Forgot extends javax.swing.JFrame {
Connection con = null;
ResultSet rs = null;
PreparedStatement ps = null;
/**
* Creates new form Forgot
*/
public Forgot() {
initComponents();
con = DatabaseHelper.getConnection();
Toolkit toolkit = getToolkit();
Dimension size = toolkit.getScreenSize();
setLocation(size.width/2 - getWidth()/2, size.height/2 - getHeight()/2);
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
txtuname = new javax.swing.JTextField();
txtpassword = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
txtname = new javax.swing.JTextField();
txtsques = new javax.swing.JTextField();
btnretrive = new javax.swing.JButton();
txtanswer = new javax.swing.JTextField();
btnsearch = new javax.swing.JButton();
btnback = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Forgot Password");

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Forgot
Password", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1,
18), new java.awt.Color(255, 0, 0))); // NOI18N

jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel3.setText("Your Security Question");

jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel4.setText("Answer");

txtuname.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


txtpassword.setEditable(false);
txtpassword.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel2.setText("Name");

txtname.setEditable(false);
txtname.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

txtsques.setEditable(false);
txtsques.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

btnretrive.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


btnretrive.setText("Retrive");
btnretrive.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnretriveActionPerformed(evt);
}
});

txtanswer.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

btnsearch.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


btnsearch.setText("Search");
btnsearch.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnsearchActionPerformed(evt);
}
});

btnback.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


btnback.setText("Back");
btnback.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnbackActionPerformed(evt);
}
});

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel1.setText("Username");

jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel5.setText("Your Password");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5))
.addGap(9, 9, 9)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addComponent(txtanswer,
javax.swing.GroupLayout.PREFERRED_SIZE, 140,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtpassword,
javax.swing.GroupLayout.PREFERRED_SIZE, 140,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtsques, javax.swing.GroupLayout.PREFERRED_SIZE,
204, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addGap(80, 80, 80)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addComponent(txtuname,
javax.swing.GroupLayout.PREFERRED_SIZE, 140,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtname, javax.swing.GroupLayout.PREFERRED_SIZE,
140, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(btnretrive, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnsearch)
.addComponent(btnback, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel1)
.addComponent(txtuname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnsearch))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtsques, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtanswer, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnretrive))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtpassword, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnback))
.addContainerGap())
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(40, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(29, 29, 29)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(44, Short.MAX_VALUE))
);

pack();
}// </editor-fold>//GEN-END:initComponents

private void btnsearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnsearchActionPerformed
search();
}//GEN-LAST:event_btnsearchActionPerformed

private void btnretriveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnretriveActionPerformed
retrive();
}//GEN-LAST:event_btnretriveActionPerformed

private void btnbackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnbackActionPerformed
Login lo = new Login();
lo.setVisible(true);
this.dispose();
}//GEN-LAST:event_btnbackActionPerformed
public void search(){
String a1= txtuname.getText();
String sql = "select * from account where username='"+a1+"'";
try {
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
if (rs.next()) {
txtname.setText(rs.getString(2));
txtsques.setText(rs.getString(4));
rs.close();
ps.close();
}else{
JOptionPane.showMessageDialog(null, "Incorrect Username");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}

public void retrive(){


String a1 = txtuname.getText();
String a2 = txtanswer.getText();
String sql = "select * from account where answer='"+a2+"'";
try {
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
if (rs.next()) {
txtpassword.setText(rs.getString(3));
// rs.close();
// ps.close();
}else{
JOptionPane.showMessageDialog(null, "Incorrect Username");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Forgot.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Forgot.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Forgot.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Forgot.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Forgot().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JButton btnback;
private javax.swing.JButton btnretrive;
private javax.swing.JButton btnsearch;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField txtanswer;
private javax.swing.JTextField txtname;
private javax.swing.JTextField txtpassword;
private javax.swing.JTextField txtsques;
private javax.swing.JTextField txtuname;
// End of variables declaration//GEN-END:variables
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Library_Management;

import DAO.DatabaseHelper;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Random;
import javax.swing.JOptionPane;

/**
*
* @author ZI Zohir
*/
public class NewBook extends javax.swing.JFrame {

Connection con = null;


ResultSet rs = null;
PreparedStatement ps = null;
/**
* Creates new form NewBook
*/
public NewBook() {
initComponents();
con = DatabaseHelper.getConnection();
Random();
Toolkit toolkit = getToolkit();
Dimension size = toolkit.getScreenSize();
setLocation(size.width/2 - getWidth()/2, size.height/2 - getHeight()/2);
}

public void Random(){


Random rd= new Random();
txtbid.setText(""+rd.nextInt(1000+1));
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
txtprice = new javax.swing.JTextField();
cmbedition = new javax.swing.JComboBox<>();
jLabel2 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtstock = new javax.swing.JTextField();
btnback = new javax.swing.JButton();
btnadd = new javax.swing.JButton();
txtbid = new javax.swing.JTextField();
txtpub = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
txtname = new javax.swing.JTextField();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("New Book");

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFact
ory.createLineBorder(new java.awt.Color(0, 204, 102)), "New Book",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1,
18), new java.awt.Color(0, 153, 153))); // NOI18N

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel1.setText("Book ID");

jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel4.setText("Publisher");

txtprice.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

cmbedition.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


cmbedition.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "1",
"2", "3", "4", "5", "6" }));

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel2.setText("Name");

jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel5.setText("Price");

jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel3.setText("Edition");
txtstock.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

btnback.setText("Back");
btnback.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnbackActionPerformed(evt);
}
});

btnadd.setText("Add");
btnadd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnaddActionPerformed(evt);
}
});

txtbid.setEditable(false);
txtbid.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

txtpub.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel6.setText("Stock");

txtname.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addGap(34, 34, 34)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addComponent(txtpub)
.addComponent(txtprice)
.addComponent(txtstock)
.addComponent(txtbid, javax.swing.GroupLayout.PREFERRED_SIZE,
170, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtname)
.addComponent(cmbedition, 0,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(109, 109, 109)
.addComponent(btnadd)
.addGap(18, 18, 18)
.addComponent(btnback)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel1)
.addComponent(txtbid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel3)
.addComponent(cmbedition, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtpub, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtprice, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel6)
.addComponent(txtstock, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(btnadd, javax.swing.GroupLayout.PREFERRED_SIZE, 31,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnback, javax.swing.GroupLayout.PREFERRED_SIZE, 31,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(47, 47, 47)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(53, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(35, 35, 35)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(38, Short.MAX_VALUE))
);

setSize(new java.awt.Dimension(402, 421));


setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents

private void btnbackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnbackActionPerformed
Home ob = new Home();
ob.setVisible(true);
this.dispose();
}//GEN-LAST:event_btnbackActionPerformed

private void btnaddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnaddActionPerformed
try {
String sql = "insert into book"
+"(book_id, name, edition, publisher, price, stock) "
+ "values (10,C programming,2,pearson,150,2)";
ps = con.prepareStatement(sql);
ps.setString(1, txtbid.getText());
ps.setString(2, txtname.getText());
ps.setString(3, (String) cmbedition.getSelectedItem());
ps.setString(4, txtpub.getText());
ps.setString(5, txtprice.getText());
ps.setString(6, txtstock.getText());
ps.execute();
JOptionPane.showMessageDialog(null, "New book added");
// rs.close();
// ps.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}//GEN-LAST:event_btnaddActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(NewBook.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(NewBook.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(NewBook.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(NewBook.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewBook().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JButton btnadd;
private javax.swing.JButton btnback;
private javax.swing.JComboBox<String> cmbedition;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField txtbid;
private javax.swing.JTextField txtname;
private javax.swing.JTextField txtprice;
private javax.swing.JTextField txtpub;
private javax.swing.JTextField txtstock;
// End of variables declaration//GEN-END:variables
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Library_Management;

import DAO.DatabaseHelper;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;

/**
*
* @author ZI Zohir
*/
public class Return extends javax.swing.JFrame {

Connection con = null;


ResultSet rs = null;
PreparedStatement ps = null;
/**
* Creates new form Return
*/
public Return() {
initComponents();
con = DatabaseHelper.getConnection();
Toolkit toolkit = getToolkit();
Dimension size = toolkit.getScreenSize();
setLocation(size.width/2 - getWidth()/2, size.height/2 - getHeight()/2);
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel12 = new javax.swing.JLabel();
txtcourse = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
txtstock = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
txtsemister = new javax.swing.JTextField();
txtbid = new javax.swing.JTextField();
txtbname = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtedition = new javax.swing.JTextField();
btnsearch = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
txtpub = new javax.swing.JTextField();
txtbranch = new javax.swing.JTextField();
txtfname = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
txtsname = new javax.swing.JTextField();
txtprice = new javax.swing.JTextField();
jLabel14 = new javax.swing.JLabel();
txtdoi = new javax.swing.JTextField();
jLabel13 = new javax.swing.JLabel();
txtyear = new javax.swing.JTextField();
txtsid = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
txtreturn = new javax.swing.JTextField();
btnreturn = new javax.swing.JButton();
btnback = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Return Book");

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFact
ory.createLineBorder(new java.awt.Color(204, 204, 255)), "Return Book",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1,
24), new java.awt.Color(204, 0, 153))); // NOI18N

jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel12.setText("Course");

txtcourse.setEditable(false);

jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel8.setText("Student ID");

txtstock.setEditable(false);
txtstock.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel4.setText("Publisher");

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel1.setText("Book ID");

txtsemister.setEditable(false);

txtbid.setEditable(false);
txtbid.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

txtbname.setEditable(false);
txtbname.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel10.setText("Name");

jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel7.setText("Semister");

jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel3.setText("Edition");

txtedition.setEditable(false);
txtedition.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

btnsearch.setText("Search");
btnsearch.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnsearchActionPerformed(evt);
}
});

jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel6.setText("Stock");
txtpub.setEditable(false);
txtpub.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

txtbranch.setEditable(false);

txtfname.setEditable(false);

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel2.setText("Name");

txtsname.setEditable(false);

txtprice.setEditable(false);
txtprice.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel14.setText("Date of Issue");

txtdoi.setEditable(false);

jLabel13.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel13.setText("Branch");

txtyear.setEditable(false);

jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel9.setText("Year");
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel5.setText("Price");

jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel11.setText("Father's Name");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel8)
.addComponent(jLabel10)
.addComponent(jLabel11)
.addComponent(jLabel12)
.addComponent(jLabel13)
.addComponent(jLabel9)
.addComponent(jLabel7))
.addGap(31, 31, 31)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING, false)
.addComponent(txtyear, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtsid, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtsname, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtfname, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtsemister)
.addComponent(txtbranch)
.addComponent(txtcourse, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.PREFERRED_SIZE, 192,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(btnsearch)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
44, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel14))
.addGap(34, 34, 34)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(txtdoi)
.addComponent(txtprice)
.addComponent(txtpub)
.addComponent(txtedition)
.addComponent(txtbname)
.addComponent(txtbid)
.addComponent(txtstock, javax.swing.GroupLayout.PREFERRED_SIZE, 170,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel8)
.addComponent(txtsid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnsearch))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel10)
.addComponent(txtsname,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel11)
.addComponent(txtfname,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addComponent(jLabel12)
.addComponent(txtcourse,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel13)
.addComponent(txtbranch,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel9)
.addComponent(txtyear, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel7)
.addComponent(txtsemister,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel1)
.addComponent(txtbid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtbname,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtedition,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtpub, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtprice, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel6)
.addComponent(txtstock, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel14)
.addComponent(txtdoi, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap())
);

jLabel15.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel15.setText("Return Date");

btnreturn.setText("Return");
btnreturn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnreturnActionPerformed(evt);
}
});
btnback.setText("Back");
btnback.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnbackActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TR
AILING)
.addGroup(layout.createSequentialGroup()
.addGap(42, 42, 42)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment
.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel15)
.addGap(40, 40, 40)
.addComponent(txtreturn,
javax.swing.GroupLayout.PREFERRED_SIZE, 170,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(14, 14, 14))
.addGroup(layout.createSequentialGroup()
.addComponent(btnreturn)
.addGap(18, 18, 18)
.addComponent(btnback,
javax.swing.GroupLayout.PREFERRED_SIZE, 64,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(23, 23, 23)))))
.addGap(23, 23, 23))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(41, 41, 41)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(jLabel15)
.addComponent(txtreturn, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(btnreturn, javax.swing.GroupLayout.DEFAULT_SIZE, 39,
Short.MAX_VALUE)
.addComponent(btnback, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);

pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents

private void btnbackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnbackActionPerformed
Home ob = new Home();
ob.setVisible(true);
this.dispose();
}//GEN-LAST:event_btnbackActionPerformed

private void btnsearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnsearchActionPerformed
String sql = "select * from issue where stu_id=?";
try {
ps = con.prepareStatement(sql);
ps.setString(1, txtsid.getText());
rs = ps.executeQuery();
if (rs.next()) {
String add6 = rs.getString("s_name");
txtsname.setText(add6);

String add7 = rs.getString("f_name");


txtfname.setText(add7);
String add8 = rs.getString("course");
txtcourse.setText(add8);

String add9 = rs.getString("branch");


txtbranch.setText(add9);

String add10 = rs.getString("year");


txtyear.setText(add10);

String add11 = rs.getString("semister");


txtsemister.setText(add11);

String add13 = rs.getString("book_id");


txtbid.setText(add13);

String add1 = rs.getString("b_name");


txtbname.setText(add1);

String add2 = rs.getString("edition");


txtedition.setText(add2);

String add3 = rs.getString("publisher");


txtpub.setText(add3);

String add4 = rs.getString("price");


txtprice.setText(add4);
String add5 = rs.getString("stock");
txtstock.setText(add5);

String add12 = rs.getString("doi");


txtdoi.setText(add12);

rs.close();
ps.close();
} else {
JOptionPane.showMessageDialog(null, "Student ID not found");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
} finally {
try {
rs.close();
ps.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
}//GEN-LAST:event_btnsearchActionPerformed

private void btnreturnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnreturnActionPerformed
delete();
returnUpdate();
}//GEN-LAST:event_btnreturnActionPerformed
public void delete(){
String sql = "delete from issue where stu_id=?";
try {
ps = con.prepareStatement(sql);
ps.setString(1, txtsid.getText());
ps.execute();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
public void returnUpdate(){
String sql = "insert into returntbl(book_id, b_name, edition, publisher, price,"
+ "stock, stu_id, s_name, f_name, course, branch, year, semister, doi, doreturn)"
+ "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
try {
ps = con.prepareStatement(sql);
ps.setString(1, txtbid.getText());
ps.setString(2, txtbname.getText());
ps.setString(3, txtedition.getText());
ps.setString(4, txtpub.getText());
ps.setString(5, txtprice.getText());
ps.setString(6, txtstock.getText());
ps.setString(7, txtsid.getText());
ps.setString(8, txtsname.getText());
ps.setString(9, txtfname.getText());
ps.setString(10, txtcourse.getText());
ps.setString(11, txtbranch.getText());
ps.setString(12, txtyear.getText());
ps.setString(13, txtsemister.getText());
ps.setString(14, txtdoi.getText());
ps.setString(15, txtreturn.getText());
ps.execute();
JOptionPane.showMessageDialog(null, "Book Returned");
update();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
} finally {
try {
rs.close();
ps.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
}

public void update(){


int st = Integer.parseInt(txtstock.getText());
int q = 1;
int sup = st + q;
String s = String.valueOf(sup);
txtstock.setText(s);
try {
String val1= txtbid.getText();
String val2 = txtstock.getText();
String sql = "update book set book_id='"+val1+"', "
+ "stock='"+val2+"' where book_id='"+val1+"'";
ps = con.prepareStatement(sql);
ps.executeUpdate();
JOptionPane.showMessageDialog(null, "Record Updated");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}finally{
try {
rs.close();
ps.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Return.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Return.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Return.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Return.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Return().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JButton btnback;
private javax.swing.JButton btnreturn;
private javax.swing.JButton btnsearch;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField txtbid;
private javax.swing.JTextField txtbname;
private javax.swing.JTextField txtbranch;
private javax.swing.JTextField txtcourse;
private javax.swing.JTextField txtdoi;
private javax.swing.JTextField txtedition;
private javax.swing.JTextField txtfname;
private javax.swing.JTextField txtprice;
private javax.swing.JTextField txtpub;
private javax.swing.JTextField txtreturn;
private javax.swing.JTextField txtsemister;
private javax.swing.JTextField txtsid;
private javax.swing.JTextField txtsname;
private javax.swing.JTextField txtstock;
private javax.swing.JTextField txtyear;
// End of variables declaration//GEN-END:variables
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Library_Management;

import DAO.DatabaseHelper;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
*
* @author ZI Zohir
*/
public class Issue extends javax.swing.JFrame {

Connection con = null;


ResultSet rs = null;
PreparedStatement ps = null;

/**
* Creates new form Issue
*/
public Issue() {
initComponents();
con = DatabaseHelper.getConnection();
Toolkit toolkit = getToolkit();
Dimension size = toolkit.getScreenSize();
setLocation(size.width/2 - getWidth()/2, size.height/2 - getHeight()/2);
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
txtprice = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtstock = new javax.swing.JTextField();
txtbid = new javax.swing.JTextField();
txtpub = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
txtbname = new javax.swing.JTextField();
txtedition = new javax.swing.JTextField();
btnbsearch = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
txtsid = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
txtsname = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
txtbranch = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
txtfname = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
txtcourse = new javax.swing.JTextField();
txtyear = new javax.swing.JTextField();
txtsemister = new javax.swing.JTextField();
btnssearch = new javax.swing.JButton();
jLabel14 = new javax.swing.JLabel();
txtdoi = new javax.swing.JTextField();
btnissue = new javax.swing.JButton();
btnback = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Issue Book");

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFact
ory.createLineBorder(new java.awt.Color(0, 204, 102)), "Book Details",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1,
18), new java.awt.Color(204, 204, 0))); // NOI18N

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel1.setText("Book ID");

jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel4.setText("Publisher");

txtprice.setEditable(false);
txtprice.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel2.setText("Name");

jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel5.setText("Price");

jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel3.setText("Edition");

txtstock.setEditable(false);
txtstock.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

txtbid.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

txtpub.setEditable(false);
txtpub.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N


jLabel6.setText("Stock");

txtbname.setEditable(false);
txtbname.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
txtedition.setEditable(false);
txtedition.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

btnbsearch.setText("Search");
btnbsearch.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnbsearchActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addGap(34, 34, 34)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING, false)
.addComponent(txtprice, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
.addComponent(txtpub, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtedition, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtbname, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtbid, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtstock))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
17, Short.MAX_VALUE)
.addComponent(btnbsearch)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel1)
.addComponent(txtbid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnbsearch))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtbname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtedition, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtpub, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtprice, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel6)
.addComponent(txtstock, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFact
ory.createLineBorder(new java.awt.Color(255, 255, 102)), "Student Details",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1,
18))); // NOI18N

jLabel7.setText("Semister");

jLabel8.setText("Student ID");

txtsname.setEditable(false);

jLabel9.setText("Year");

txtbranch.setEditable(false);

jLabel10.setText("Name");

txtfname.setEditable(false);

jLabel11.setText("Father's Name");

jLabel12.setText("Course");

jLabel13.setText("Branch");

txtcourse.setEditable(false);
txtyear.setEditable(false);

txtsemister.setEditable(false);

btnssearch.setText("Search");
btnssearch.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnssearchActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);


jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel8)
.addComponent(jLabel10)
.addComponent(jLabel11)
.addComponent(jLabel12)
.addComponent(jLabel13)
.addComponent(jLabel9)
.addComponent(jLabel7))
.addGap(31, 31, 31)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING, false)
.addComponent(txtyear, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
.addComponent(txtsid, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtsname, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtfname, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtsemister)
.addComponent(txtbranch)
.addComponent(txtcourse, javax.swing.GroupLayout.Alignment.LEADING))
.addGap(18, 18, 18)
.addComponent(btnssearch)
.addContainerGap(12, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel8)
.addComponent(txtsid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnssearch))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel10)
.addComponent(txtsname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel11)
.addComponent(txtfname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel12)
.addComponent(txtcourse, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel13)
.addComponent(txtbranch, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel9)
.addComponent(txtyear, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel7)
.addComponent(txtsemister, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);

jLabel14.setText("Date of Issue");

btnissue.setText("Issue");
btnissue.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnissueActionPerformed(evt);
}
});

btnback.setText("Back");
btnback.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnbackActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment
.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(btnissue)
.addGap(18, 18, 18)
.addComponent(btnback))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel14)
.addGap(18, 18, 18)
.addComponent(txtdoi, javax.swing.GroupLayout.PREFERRED_SIZE,
130, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(110, 110, 110))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(jLabel14)
.addComponent(txtdoi, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(btnissue, javax.swing.GroupLayout.DEFAULT_SIZE, 36,
Short.MAX_VALUE)
.addComponent(btnback, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);

pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void btnbackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_btnbackActionPerformed
Home ob = new Home();
ob.setVisible(true);
this.dispose();
}//GEN-LAST:event_btnbackActionPerformed

private void btnbsearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnbsearchActionPerformed
String sql = "select * from book where book_id=?";
try {
ps = con.prepareStatement(sql);
ps.setString(1, txtbid.getText());
rs = ps.executeQuery();
if (rs.next()) {
String add1 = rs.getString("name");
txtbname.setText(add1);

String add2 = rs.getString("edition");


txtedition.setText(add2);

String add3 = rs.getString("publisher");


txtpub.setText(add3);

String add4 = rs.getString("price");


txtprice.setText(add4);

String add5 = rs.getString("stock");


txtstock.setText(add5);
rs.close();
ps.close();
} else {
JOptionPane.showMessageDialog(null, "Book is not found");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
} finally {
try {
rs.close();
ps.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
}//GEN-LAST:event_btnbsearchActionPerformed

private void btnssearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnssearchActionPerformed
String sql = "select * from student where student_id=?";
try {
ps = con.prepareStatement(sql);
ps.setString(1, txtsid.getText());
rs = ps.executeQuery();
if (rs.next()) {
String add6 = rs.getString("name");
txtsname.setText(add6);
String add7 = rs.getString("fathers_name");
txtfname.setText(add7);

String add8 = rs.getString("course");


txtcourse.setText(add8);

String add9 = rs.getString("branch");


txtbranch.setText(add9);

String add10 = rs.getString("year");


txtyear.setText(add10);

String add11 = rs.getString("semister");


txtsemister.setText(add11);
rs.close();
ps.close();
} else {
JOptionPane.showMessageDialog(null, "Student ID not found");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
} finally {
try {
rs.close();
ps.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
}//GEN-LAST:event_btnssearchActionPerformed

private void btnissueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnissueActionPerformed
String sql = "insert into issue(book_id, b_name, edition, publisher, price,"
+ "stock, stu_id, s_name, f_name, course, branch, year, semister, doi)"
+ "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
try {
ps = con.prepareStatement(sql);
ps.setString(1, txtbid.getText());
ps.setString(2, txtbname.getText());
ps.setString(3, txtedition.getText());
ps.setString(4, txtpub.getText());
ps.setString(5, txtprice.getText());
ps.setString(6, txtstock.getText());
ps.setString(7, txtsid.getText());
ps.setString(8, txtsname.getText());
ps.setString(9, txtfname.getText());
ps.setString(10, txtcourse.getText());
ps.setString(11, txtbranch.getText());
ps.setString(12, txtyear.getText());
ps.setString(13, txtsemister.getText());
ps.setString(14, txtdoi.getText());
ps.execute();
JOptionPane.showMessageDialog(null, "Book issued");
update();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
} finally {
try {
rs.close();
ps.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
}//GEN-LAST:event_btnissueActionPerformed

public void update(){


int st = Integer.parseInt(txtstock.getText());
int q = 1;
int sup = st - q;
String s = String.valueOf(sup);
txtstock.setText(s);
try {
int n = Integer.parseInt(s);
if (n>0){
String val1= txtbid.getText();
String val2 = txtstock.getText();
String sql = "update book set book_id='"+val1+"', "
+ "stock='"+val2+"' where book_id='"+val1+"'";
ps = con.prepareStatement(sql);
ps.executeUpdate();
JOptionPane.showMessageDialog(null, "Record Updated");
}else{
JOptionPane.showMessageDialog(null, "Book is not issued");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}finally{
try {
rs.close();
ps.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Issue.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Issue.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Issue.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Issue.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Issue().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JButton btnback;
private javax.swing.JButton btnbsearch;
private javax.swing.JButton btnissue;
private javax.swing.JButton btnssearch;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JTextField txtbid;
private javax.swing.JTextField txtbname;
private javax.swing.JTextField txtbranch;
private javax.swing.JTextField txtcourse;
private javax.swing.JTextField txtdoi;
private javax.swing.JTextField txtedition;
private javax.swing.JTextField txtfname;
private javax.swing.JTextField txtprice;
private javax.swing.JTextField txtpub;
private javax.swing.JTextField txtsemister;
private javax.swing.JTextField txtsid;
private javax.swing.JTextField txtsname;
private javax.swing.JTextField txtstock;
private javax.swing.JTextField txtyear;
// End of variables declaration//GEN-END:variables

}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Library_Management;

import DAO.DatabaseHelper;
import java.sql.Connection;
import javax.swing.JOptionPane;

/**
*
* @author ZI Zohir
*/
public class Loading extends javax.swing.JFrame implements Runnable {

Connection con;
int s=0;
Thread th;
/**
* Creates new form Loading
*/
public Loading() {
initComponents();
con = DatabaseHelper.getConnection();
th = new Thread((Runnable)this);
}

public void setUploading(){


setVisible(false);
th.start();
}

public void run(){


try {
for (int i = 0; i <= 200; i++) {
s = s + 1;
int m = jProgressBar1.getMaximum();
int v = jProgressBar1.getValue();
if (v<m) {
jProgressBar1.setValue(jProgressBar1.getValue()+1);
}else{
i=201;
setVisible(false);
Home ob = new Home();
ob.setVisible(true);
}Thread.sleep(50);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel1 = new javax.swing.JLabel();
jProgressBar1 = new javax.swing.JProgressBar();
jLabel3 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Loding");

jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new
java.awt.Color(153, 153, 255)));

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N


jLabel1.setForeground(new java.awt.Color(102, 102, 255));
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Jakir Library");

jProgressBar1.setForeground(new java.awt.Color(102, 255, 102));


jProgressBar1.setStringPainted(true);

jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/book
loading.png"))); // NOI18N

jLabel2.setText("Please wait...");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE,
254, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(45, 45, 45)
.addComponent(jProgressBar1,
javax.swing.GroupLayout.PREFERRED_SIZE, 160,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(95, 95, 95)
.addComponent(jLabel2))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(80, 80, 80)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE,
110, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(55, 55, 55)
.addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE,
29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED
)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 99,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(27, 27, 27)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(51, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
setSize(new java.awt.Dimension(370, 352));
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Loading.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Loading.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Loading.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Loading.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Loading().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JProgressBar jProgressBar1;
// End of variables declaration//GEN-END:variables
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Library_Management;

import DAO.DatabaseHelper;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;

/**
*
* @author ZI Zohir
*/
public class Statistics extends javax.swing.JFrame {

Connection con = null;


ResultSet rs = null;
PreparedStatement ps = null;
/**
* Creates new form Statistics
*/
public Statistics() {
initComponents();
con = DatabaseHelper.getConnection();
Toolkit toolkit = getToolkit();
Dimension size = toolkit.getScreenSize();
setLocation(size.width/2 - getWidth()/2, size.height/2 - getHeight()/2);
tblissue();
tblreturn();
}

public void tblissue(){


try {
String sql = "select book_id, b_name, edition, publisher, price, stock from issue";
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
tblissue.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}

public void tblreturn(){


try {
String sql = "select stu_id, s_name, f_name, course, branch, year, semister from
returntbl";
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
tblreturn.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jScrollPane1 = new javax.swing.JScrollPane();
tblissue = new javax.swing.JTable();
jPanel2 = new javax.swing.JPanel();
jScrollPane2 = new javax.swing.JScrollPane();
tblreturn = new javax.swing.JTable();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Statistics");

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFact
ory.createLineBorder(new java.awt.Color(0, 0, 0)), "Issue Details",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1,
18), new java.awt.Color(0, 102, 102))); // NOI18N

tblissue.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane1.setViewportView(tblissue);

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
664, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
150, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);

jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFact
ory.createLineBorder(new java.awt.Color(0, 0, 0)), "Return Details",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1,
18), new java.awt.Color(0, 102, 102))); // NOI18N

tblreturn.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane2.setViewportView(tblreturn);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
664, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
150, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);

jButton1.setText("Back");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED
)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);

pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_jButton1ActionPerformed
Home ob = new Home();
ob.setVisible(true);
this.dispose();
}//GEN-LAST:event_jButton1ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Statistics.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Statistics.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Statistics.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Statistics.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Statistics().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JButton jButton1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTable tblissue;
private javax.swing.JTable tblreturn;
// End of variables declaration//GEN-END:variables
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Library_Management;

import DAO.DatabaseHelper;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Random;
import javax.swing.JOptionPane;

/**
*
* @author ZI Zohir
*/
public class Student extends javax.swing.JFrame {

Connection con = null;


ResultSet rs = null;
PreparedStatement ps = null;
/**
* Creates new form Student
*/
public Student() {
initComponents();
con = DatabaseHelper.getConnection();
Random();
Toolkit toolkit = getToolkit();
Dimension size = toolkit.getScreenSize();
setLocation(size.width/2 - getWidth()/2, size.height/2 - getHeight()/2);
}

public void Random(){


Random rd= new Random();
txtsid.setText(""+rd.nextInt(1000+1));
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jLabel7 = new javax.swing.JLabel();
cmbcourse = new javax.swing.JComboBox<>();
cmbsemister = new javax.swing.JComboBox<>();
txtsid = new javax.swing.JTextField();
cmbyear = new javax.swing.JComboBox<>();
jLabel1 = new javax.swing.JLabel();
txtname = new javax.swing.JTextField();
btnregister = new javax.swing.JButton();
btnback = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
txtbranch = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
txtfname = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("New Student");

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFact
ory.createLineBorder(new java.awt.Color(102, 255, 51)), "New Student",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1,
24), new java.awt.Color(204, 51, 0))); // NOI18N

jLabel7.setText("Semister");

cmbcourse.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]


{ "BSc", "BBA", "BSS", "BA" }));
cmbcourse.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmbcourseActionPerformed(evt);
}
});

cmbsemister.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]


{ "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th" }));

txtsid.setEditable(false);
txtsid.setText("2");

cmbyear.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "1st",


"2nd", "3rd", "4th" }));
jLabel1.setText("Student ID");

txtname.setText("nar");

btnregister.setText("Register");
btnregister.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnregisterActionPerformed(evt);
}
});

btnback.setText("Back");
btnback.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnbackActionPerformed(evt);
}
});

jLabel6.setText("Year");

txtbranch.setText("musir");

jLabel2.setText("Name");

txtfname.setText("san");
jLabel3.setText("Father's Name");

jLabel4.setText("Course");

jLabel5.setText("Branch");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel7))
.addGap(31, 31, 31)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alig
nment.LEADING, false)
.addComponent(txtsid)
.addComponent(txtname)
.addComponent(txtfname)
.addComponent(cmbcourse, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(txtbranch)
.addComponent(cmbyear, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(cmbsemister,
javax.swing.GroupLayout.PREFERRED_SIZE, 180,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(btnregister)
.addGap(18, 18, 18)
.addComponent(btnback, javax.swing.GroupLayout.PREFERRED_SIZE,
70, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel1)
.addComponent(txtsid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtfname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel4)
.addComponent(cmbcourse, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtbranch, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel6)
.addComponent(cmbyear, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel7)
.addComponent(cmbsemister, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(btnregister, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnback, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(39, 39, 39)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(41, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(30, 30, 30)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(40, Short.MAX_VALUE))
);

setSize(new java.awt.Dimension(406, 455));


setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents

private void btnbackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnbackActionPerformed
Home ob = new Home();
ob.setVisible(true);
this.dispose();
}//GEN-LAST:event_btnbackActionPerformed

private void btnregisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_btnregisterActionPerformed
try {
String sql = "insert into student"
+"(student_id, name, fathers_name, course, branch, year,"
+ " semister)values (?,?,?,?,?,?,?)";
ps = con.prepareStatement(sql);
ps.setString(1, txtsid.getText());
ps.setString(2, txtname.getText());
ps.setString(3, txtfname.getText());
ps.setString(4, (String) cmbcourse.getSelectedItem());
ps.setString(5, txtbranch.getText());
ps.setString(6, (String) cmbyear.getSelectedItem());
ps.setString(7, (String) cmbsemister.getSelectedItem());
ps.execute();
JOptionPane.showMessageDialog(null, "New student Registered");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}finally{
try {
rs.close();
ps.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}//GEN-LAST:event_btnregisterActionPerformed

private void cmbcourseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_cmbcourseActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cmbcourseActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Student.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Student.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Student.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Student.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Student().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JButton btnback;
private javax.swing.JButton btnregister;
private javax.swing.JComboBox<String> cmbcourse;
private javax.swing.JComboBox<String> cmbsemister;
private javax.swing.JComboBox<String> cmbyear;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField txtbranch;
private javax.swing.JTextField txtfname;
private javax.swing.JTextField txtname;
private javax.swing.JTextField txtsid;
// End of variables declaration//GEN-END:variables
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Library_Management;

import DAO.DatabaseHelper;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;

/**
*
* @author ZI Zohir
*/
public class Statistics extends javax.swing.JFrame {

Connection con = null;


ResultSet rs = null;
PreparedStatement ps = null;
/**
* Creates new form Statistics
*/
public Statistics() {
initComponents();
con = DatabaseHelper.getConnection();
Toolkit toolkit = getToolkit();
Dimension size = toolkit.getScreenSize();
setLocation(size.width/2 - getWidth()/2, size.height/2 - getHeight()/2);
tblissue();
tblreturn();
}

public void tblissue(){


try {
String sql = "select book_id, b_name, edition, publisher, price, stock from issue";
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
tblissue.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}

public void tblreturn(){


try {
String sql = "select stu_id, s_name, f_name, course, branch, year, semister from
returntbl";
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
tblreturn.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents() {

jPanel1 = new javax.swing.JPanel();


jScrollPane1 = new javax.swing.JScrollPane();
tblissue = new javax.swing.JTable();
jPanel2 = new javax.swing.JPanel();
jScrollPane2 = new javax.swing.JScrollPane();
tblreturn = new javax.swing.JTable();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Statistics");
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFact
ory.createLineBorder(new java.awt.Color(0, 0, 0)), "Issue Details",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1,
18), new java.awt.Color(0, 102, 102))); // NOI18N

tblissue.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane1.setViewportView(tblissue);

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
664, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
150, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);

jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFact
ory.createLineBorder(new java.awt.Color(0, 0, 0)), "Return Details",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1,
18), new java.awt.Color(0, 102, 102))); // NOI18N

tblreturn.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane2.setViewportView(tblreturn);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
664, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
150, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);

jButton1.setText("Back");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED
)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);

pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-


FIRST:event_jButton1ActionPerformed
Home ob = new Home();
ob.setVisible(true);
this.dispose();
}//GEN-LAST:event_jButton1ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Statistics.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Statistics.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Statistics.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Statistics.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Statistics().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JButton jButton1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTable tblissue;
private javax.swing.JTable tblreturn;
// End of variables declaration//GEN-END:variables
}
4.2 SCREENSHOTS
TESTING
Testing is a series of different tests that whose primary purpose is to fully exercise the computer
based system. Although each test has a different purpose, all work should verify that all system
element have been properly integrated and performed allocated function. Testing is the process
of checking whether the developed system works according to the actual requirement and
objectives of the system. The philosophy behind testing is to find the errors. A good test is one
that has a high probability of finding an undiscovered error. A successful test is one that uncovers
the undiscovered error. Test cases are devised with this purpose in mind. A test case is a set of
data that the system will process as an input.

UNIT TESTING

The first test in the development process is the unit test. The source code is normally divided into
modules, which in turn are divided into smaller units called units. These units have specific
behavior. The test done on these units of code is called unit test. Unit test depends upon the
language on which the project is developed. Unit tests ensure that each unique path of the project
performs accurately to the documented specifications and contains clearly defined inputs and
expected results. Functional and reliability testing in an Engineering environment. Producing
tests for the behavior of components (nodes and vertices) of a product to ensure their correct
behavior prior to system integration.
INTEGRATION TESTING

Testing in which modules are combined and tested as a group. Modules are typically code
modules, individual applications, source and destination applications on a network, etc.
Integration Testing follows unit testing and precedes system testing. Testing after the product is
code complete. Betas are often widely distributed or even distributed to the public at large in
hopes that they will buy the final product when it is release.

VALIDATION TESTING

Valid and invalid data should be created and the program should be made to process this data to
catch errors. When the user of each module wants to enter into the page by the login page using
the use rid and password .If the user gives the wrong password or use rid then the information is
provided to the user like “you must enter user id and password”. Here the inputs given by the
user are validated. That is password validation, format of date are correct, textbox validation.
Changes that need to be done after result of this testing.

CONCLUSION
The Books and Students are given a particular unique id no.  So that they can be accessed
correctly and without errors. Our main aim of the project is to get the correct information about a
particular student and books available in the library. The problems, which existed in the earlier
system, have been removed to a large extent. And it is expected that this project will go a long
way in satisfying user’s requirements. The computerization of the Library Management will not
only improves the efficiency but will also reduce human stress thereby indirectly improving
human recourses.
BIBLIOGRAPHY
BOOK REFERENCES

• Gerken, Till, and Tobias Ratschiller. Web Application Development with


JSP. New Riders Publishing, 2000.
• Ratschiller, Tobias, and Till Gerken. Web application development with JSP
4.0. New Riders, 2000.
• Ware, Brent. Open source development with LAMP: using Linux, Apache,
MySQL and JSP. Addison-Wesley Longman Publishing Co., Inc., 2002.
• Ware, Brent. Open source development with LAMP: using Linux, Apache,
MySQL and JSP. Addison-Wesley Longman Publishing Co., Inc., 2002.
• Bakken, Stig Saether, Zeev Suraski, and Egon Schmid. JSP Manual: Volume
1. iUniverse, Incorporated, 2000.

WEBSITE REFERENCES

• www.ntu.edu.sg
• www.tutorialspoint.com
• www.javaworld.com
• www.edureka.co
• www.java.net

You might also like