0% found this document useful (0 votes)
20 views

Project Library

Uploaded by

rocky2463.singh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Project Library

Uploaded by

rocky2463.singh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 76

INFORMATION PRACTICES

A PROJECT ON

“LIBRARY MANAGEMENT SYSTEM”

Submitted in partial rollback in fulfillment of the requirement for the

SENIOR SECONDARY EXAMINATION (AISSCE)

Submitted By : Submitted To :

Student Name Name of Faculty


(Roll No : 1234567) (Computer Sci. Teacher)
CERTIFICATE .

This is to certify that the project titled “LIBRARY


MANAGEMENT SYSTEM” submitted by Miss/Master
STUDENT NAME having roll no ________ of CLASS XII
has completed this project for partial rollback in full -
fillment of the requirement for the senior secondary
examination (AISSCE) embodies the bonafide work
done by him/her under my supervision.

Internal Supervisor External Supervisor


Signature Signature

Name : Name :

Date : Date :

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


ID – SHEET

Roll No : ………………………….

Name of Student : ………………………….

Address : ………………………….
………………………….

Phone No : ………………………….

Email Address : ………………………….

Supervisor : ………………………….

Project Title : ………………………….

Front End Tool : ………………………….

Back End Tool : ………………………….

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


ACKNOWLEDGEMENT

It would be our outmost pleasure to express


our sincere thanks to our Computer Science
Teacher “Faculty Name” in providing a
helping hand in this project.

His unflagging patience, creativity


and immense knowledge that he shared with
us have proved highly beneficial to us and
have made our Project possible and
successful.

Student Name

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


TABLE OF CONTENTS

 Introduction

 Java Details

 Priliminary Design

 Form Layouts

 Database Design

 Implementation

 Bibliography

 Teacher Remarks

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


INTRODUCTION

This program is designed for the use

of Library Management System and

its functioning Main Objective of this

project to facilitate the transactions

through use of electronic medium.

We use java netbeans 6.5 software

and Mysql to programming our

project.

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


What is java?
Java is a general purpose object oriented programming language . It is the first programming
language that is not tied to any particular hardware or operating system .The language is
based on the concept of an object. Java is highly derived from C++ . Most striking feature of
the language is that it is platform neutral language.

There were five primary goals in the creation of the Java language:

• It should use the object-oriented programming methodology.


• It should allow the same program to be executed on multiple operating systems.
• It should contain built-in support for using computer networks.
• It should be designed to execute code from remote sources securely.
• It should be easy to use and borrow the good parts of older object-oriented languages like
C++.

Java tools
In order to write java application or applets ,one need more than a language . The tools that
lets one to write , test , debug programs.

Java features
● Compiler and Interpreted
● Platform independent
● Simple
● Secure
● Familiar
● Portable
● Object-Oriented
● Robust
● Multithreaded
● High performance
● Distributed
● Dynamic

Compiler and Interpreted - There is a java compiler , named javac . The java compiler
takes input source code files (these files typically have the ext.java) and converts them into
compiled bytecode files.The java Interpreter known as javac can be used to execute java
application .The interpreter translates bytecode directly into program actions.

Platform independent - Java programs can be easily moved from one computer to
another, anywhere and anytime.Changes and upgrades made in operating systems,
processors and system resources will not force any changes in java programs.

Simple - Java is designed to be easy for programmer to learn and use efficiently.

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


Secure- When we use a java compatible web browser, we can safely download java applets
without fear of virus infection. Java achieves this protection by confining a java program to
java execution environment and not allowing it access to other parts of the computer.

Familiar- It is modeled on C, C++ languages. Java code looks like C++.

Portable- Java compiler generates bytecode instructions that can be implemented on any
machine and also the size of the primitive data types are machine independent.

Object-Oriented - Java is a true object-oriented language. All program code and data
reside within objects and classes.

Robust -It provides many safeguards to ensure reliable code. It has strict compile time and
run time checking for data types. Designed as a garbage-collected language relieving the
programmers and also incorpates the concept of exception handling which captures series
errors.

Multithreaded - Java supports handling multiple tasks simultaneously which greatly


improves the interactive performance of graphical applications.

High performance - Java performance is impressive for an interpreted language , mainly


due to use of immediate bytecode . Use of multithreaded and further its architecture is also
designed to reduce overheads during runtime.

Distributed - It has ability to share both data and programs. Java applications can open
and access remote objects on internet which enables multiple programmers at multiple
remote locations to collaborate and work together on single project.

Dynamic - Java is capable of dynamically in new class libraries , methods and objects .It
supports functions written in other languages like C,C++ called as native methods.

Automatic garbage collection - One idea behind Java's automatic memory


management model is that programmers should be spared the burden of having to perform
manual memory management. In some languages the programmer allocates memory to
create any object stored on the heap and is responsible for later manually deallocating that
memory to delete any such objects. If a programmer forgets to de-allocate memory or
writes code that fails to do so in a timely fashion, a memory leak can occur: the program will
consume a potentially arbitrarily large amount of memory. In addition, if a region of
memory is de-allocated twice, the program can become unstable and may crash.

In Java, this potential problem is avoided by automatic garbage collection. The programmer
determines when objects are created and the Java runtime is responsible for managing the
objects' lifecycle. The program or other objects can reference an object by holding a
reference to it (which, from a low-level point of view, is its address on the heap). When no
references to an object remain, the Java garbage collector automatically deletes the
LIBRARY MANAGEMENT SYSTEM | Created by : Student Name
unreachable object, freeing memory and preventing a memory leak. Memory leaks may still
occur if a programmer's code holds a reference to an object that is no longer needed—in
other words, they can still occur but at higher conceptual levels.

Comparing Java and C++, it is possible in C++ to implement similar functionality (for
example, a memory management model for specific classes can be designed in C++ to
improve speed and lower memory fragmentation considerably), with the possibly cost of
extra development time and some application complexity. In Java, garbage collection is built
in and virtually invisible to the developer. That is, developers may have no notion of when
garbage collection will take place as it may not necessarily correlate with any actions being
explicitly performed by the code they write. Depending on intended application, this can be
beneficial or disadvantageous: the programmer is freed from performing low-level tasks but
at the same time lose the option of writing lower level code.

Java Magic: The Bytecode

Bytecode is a highly optimized set of instruction designed to be executed by the java


runtime system, which is called Java Virtual Machine and it exists only inside the computer
memory.

Java Program Java Compiler Virtual Machine

Source code Bytecode


Process of Compilation

Bytecode Java Interpreter Machine code


Virtual Machine Real Machine

Process of converting Bytecode into Machine code

Object Oriented Programming

Object Oriented Programming is an approach that provides a way of modularizing programs


by creating partitioned memory area for both data and functions that can be used as
templates for creating copies of such modules on demand.

Objects and Classes - An object is a software bundle of variables and related methods.
Objects are key to understanding object-oriented technology. Real-world objects share two
characteristics: They all have state and behavior.
Software objects are modeled after real-world objects in that they too have state and
behavior Classes can also define class variables. A class variable contains information that is
LIBRARY MANAGEMENT SYSTEM | Created by : Student Name
shared by all instances of the class .A class can also declare class methods. You can invoke a
class method directly from the class, whereas you must invoke instance methods on a
particular instance.

Encapsulation - Wrapping of data and methods into a single unit is known as


encapsulation. It is the most striking feature of class. The data is not accessible to outside
world and only those methods which are wrapped in the class can access it. The insulation
of the data from direct access by the program is called data hiding.

Inheritance - Inheritance is the process by which objects of one class acquire the property
of objects of another class. Each subclass inherits state .However, subclasses are not limited
to the states and behaviors provided to them by their superclass. Subclasses can add
variables and methods to the ones they inherit from the superclass. It supports the concept
of hierarchical classification it also provides the use of reusability. .

Polymorphism - This means the ability to take more than one form. An operation may
exhibit different behaviour in different instances. The behaviour depends upon the types of
data used in the operation. It plays an important role in allowing objects having different
internal structures to share external interface.

Java SE - Java Database Connectivity (JDBC)

The Java Database Connectivity (JDBC) API is the industry standard for database-
independent connectivity between the Java programming language and a wide range of
databases – SQL databases and other tabular data sources, such as spreadsheets or flat files.
The JDBC API provides a call-level API for SQL-based database access.

JDBC technology allows you to use the Java programming language to exploit "Write Once,
Run Anywhere" capabilities for applications that require access to enterprise data. With a
JDBC technology-enabled driver, you can connect all corporate data even in a
heterogeneous environment.

Advantages of JDBC Technology :

Leverage Existing Enterprise Data

Simplified Enterprise Development

Zero Configuration for Network Computers

Driver Loads database drivers and manages the

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


manager connections between the application and the
driver
Driver Translates API calls into operations for a
specific data source
Connection A session between an application and a
database
Statement A SQL statement to perform a query or update
operation
Metadata Information about returned data , database
and driver
Resultset Logical set of columns and rows of data
returned by executing a statement

Driver Manager Connection Statement ResultSet

Driver

Database
Database

The JDBC architecture is based on a collection of java interfaces and classes that together enable you
to connect to data sources , to create and execute SQL statements and to retrieve and modify data in
a database.
The JDBC-ODBC Bridge –“sun.jdbc.odbc.jdbcodbcDriver”-is included with JDK and it enables
Java applications to access data through drivers written to the ODBC standard. The driver bridge is
useful for accessing data in data sources for which no pure JDBC drivers exist. The bridge works by
translating the JDBC methods into ODBC function calls.

SQL-STRUCTURED QUERY LANGUAGE

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


SQL is not a procedural language. It is not used to define complex processes; we can use
SQL to use commands that define and manipulate data. SQL is different from other
languages.

• SQL is very readable.

• In SQL we always issue commands.

SQL statements fall into two groups:-

● Data Defination Language (DDL) – DDL statements are used to describe the tables
and the data they contain. The subset of SQL statements used for modeling the structure
(rather than the contents) of a database or cube. The DDL gives you the ability to create,
modify, and remove databases and database objects.

● Data Manipulation Language (DML) – DML statements that are used to operate on
data in the database. These are statements that allow you to create or alter objects (such as
tables, indexes, views, and so on) in the database. The subset of SQL statements used to
retrieve and manipulate data. DML can be further divided into 2 groups:-

● Select Statements – Statements that return a set of results.

● Everything else – Statements that don’t return a set of results.

Here are some of the quries defined:-

SELECT - SQL statement used to request a selection, projection, join, query, and so on,
from a SQL Server database.

Primary key – Primary key constraints identify the column or set of columns whose values
uniquely identify a row in a table. No two rows in a table can have the same primary key
value. You cannot enter a NULL value for any column in a primary key.

Insert - The Insert logical operator inserts each row from its input into the object specified
in the Argument column. To insert the data into a relation we either specify a tuple to be
inserted or write a query.

Delete - The Delete logical operator deletes from an object rows that satisfy the optional
predicate in the Argument column. We can delete only whole tuples; we cannot delete
values on only particular attributes.

Update - The Update logical operator updates each row from its input in the object
specified in the Argument column. It provides a way of modifying existing data in a table.

SWING

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


SWING is a set of classes that provides powerful and flexible functionality. In addition with
several components provided by AWT, swing supplies several exciting additions, including
tabbed panes, scroll panes, trees and tables. It also changes the images as the state of any
component changes. Swing is built upon the foundation of the AWT. Swing components are
written entirely in Java and therefore are Platform-independent .Swing is also termed also
light-weight and provide pluggable look and feel.
There are 2 Swing classes that are quite important:

Jframe and Component – Jframe extends the AWT class Frame. It contains additional
features that enable it to support Swing components. JComponent extends the AWT
component and Container classes. It is the top level class for all Swing components and
provides Swing pluggable look and feel.
Here are some of the Swing component classes:

CLASS DESCRIPTION
Abstract Button Abstract super class for Swing buttons.
Button Group Encapsulates a mutually exclusive set of
buttons.
Image Icon Encapsulates an icon.
JApplet The SWING version of APPLET.
JButton The SWING push button class.
JCheckBox The SWING check box class.
JComboBox Encapsulates a combo box .
JLabels The SWING version of a label.
JRadioButton The SWING version of a radio button.
JScrollPane Encapsulates a scrollable window.
JTabbedPane Encapsulates a tabbed window.
JTextField The SWING version of Text field.
JTree Encapsulates a tree based-control.

Here are the some of the components used:

● JApplet – Applet that use SWING must be subclass of JApplet.


JApplet is rich with functionality that is not found in Applet.

● Icons – Icons are encapsulated by the Image Icon class, which paints an icon from an
image.

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


● JLabel – Labels are the instances of the JLabel class which extends JComponent. It can
display text or icon. These are passive controls that do not support any interaction with the
user.

● JTextFields – Text field is encapsulated by the JTextComponent class which extends


JComponent. JTextField allows you to edit one line of text.

● JButton – JButton class provides the functionality of a push button. JButton allows an
icon of string to be associated with the push button.

● JCheckBox – It is supported by the JCheckBox class. It is a control that is used to turn an


option on or off.

● JTextArea - Text area is encapsulated by the JTextComponent class which extends


JComponent. JTextArea allows you to edit multiline of text.

● JRadioButton – it is supported by the JRadioButton class. It can be configured into a


group of check boxes in which only one check box can be checked at any one time.

● JComboBox – It is provided through the JComboBox class. It normally displays one entry
and can also display a drop down list that allows a user to select a different entry.

● JScrollPane – It is a component that presents a rectangular area in which a component


may be viewed. These are implemented in Swing by JScrollPane class.

● JTree - It is a component that presents a hierarchical view of data. A user has ability to
expand individual subtrees. These are implemented in Swing by JTree class.

ADVANTAGES OF (JAVAX) SWING:

1. It provides more powerful and more flexible components possible in AWT package.
For e.g. JButton can have both image as well as text field associated with it which is
not possible in awt package.

2. Unlike AWT components SWING components are not implemented by platform-


specific code. Instead they are written entirely in java and therefore are platform
independent. Thus term lightweight is used to describe such elements.

3. Further the Swing components can provide pluggable look and feel, which means
that it is easy to substitute another appearance and behavior for an element.

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


PRELIMINARY
DESIGN
(User Interface)

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


FORM
LAYOUTS

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


LIBRARY MANAGEMENT SYSTEM | Created by : Student Name
LIBRARY MANAGEMENT SYSTEM | Created by : Student Name
LIBRARY MANAGEMENT SYSTEM | Created by : Student Name
LIBRARY MANAGEMENT SYSTEM | Created by : Student Name
LIBRARY MANAGEMENT SYSTEM | Created by : Student Name
DATABASE
DESIGN

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


LIBRARY MANAGEMENT SYSTEM | Created by : Student Name
LIBRARY MANAGEMENT SYSTEM | Created by : Student Name
IMPLEMENTATION

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


***************************************** javax.swing.GroupLayout(jDialog1.getContentPane
());
LOG IN
jDialog1.getContentPane().setLayout(jDialog1Layo
***************************************** ut);
jDialog1Layout.setHorizontalGroup(
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
jDialog1Layout.createParallelGroup(javax.swing.Gr
import java.sql.DriverManager;
oupLayout.Alignment.LEADING)
import java.sql.ResultSet;
.addGap(0, 400, Short.MAX_VALUE)
);
public class login extends javax.swing.JFrame {
jDialog1Layout.setVerticalGroup(

/** Creates new form login */


jDialog1Layout.createParallelGroup(javax.swing.Gr
public login() {
oupLayout.Alignment.LEADING)
initComponents();
.addGap(0, 300, Short.MAX_VALUE)
}
);

/** This method is called from within the


constructor to
setDefaultCloseOperation(javax.swing.WindowCon
* initialize the form.
stants.EXIT_ON_CLOSE);
* WARNING: Do NOT modify this code. The
setTitle("Login - Library Management System
content of this method is
|| www.ezindagi.in ||");
* always regenerated by the Form Editor.
setBounds(new java.awt.Rectangle(200, 70, 0,
*/
0));
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed"
jLabel3.setFont(new java.awt.Font("Tahoma",
desc="Generated Code">
1, 12));
private void initComponents() {
jLabel3.setForeground(new java.awt.Color(0,
153, 255));
jPopupMenu1 = new
jLabel3.setText("Password");
javax.swing.JPopupMenu();
jPopupMenu2 = new
jLabel2.setFont(new java.awt.Font("Tahoma",
javax.swing.JPopupMenu();
1, 12));
jDialog1 = new javax.swing.JDialog();
jLabel2.setForeground(new java.awt.Color(0,
jLabel3 = new javax.swing.JLabel();
153, 255));
jLabel2 = new javax.swing.JLabel();
jLabel2.setText("LOG IN ID");
idtf = new javax.swing.JTextField();
PassWordTF = new
idtf.setBackground(new java.awt.Color(204,
javax.swing.JPasswordField();
255, 204));
jLabel4 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
PassWordTF.setBackground(new
jLabel6 = new javax.swing.JLabel();
java.awt.Color(204, 255, 204));
LogInB = new javax.swing.JButton();
invalidl = new javax.swing.JLabel();
jLabel4.setBackground(new
invalid = new javax.swing.JLabel();
java.awt.Color(204, 204, 255));
jLabel4.setFont(new java.awt.Font("Colonna
javax.swing.GroupLayout jDialog1Layout =
MT", 3, 24));
new

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


jLabel4.setForeground(new java.awt.Color(51, .addComponent(jLabel6,
153, 255)); javax.swing.GroupLayout.PREFERRED_SIZE, 210,
jLabel4.setText("LIBRARY MANAGEMENT javax.swing.GroupLayout.PREFERRED_SIZE))
SYSTEM"); .addGroup(javax.swing.GroupLayout.Ali
gnment.TRAILING, layout.createSequentialGroup()
jLabel1.setIcon(new .addGroup(layout.createParallelGrou
javax.swing.ImageIcon(getClass().getResource("/e- p(javax.swing.GroupLayout.Alignment.TRAILING)
library2.jpg"))); // NOI18N .addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE, 428,
jLabel6.setFont(new java.awt.Font("Poor javax.swing.GroupLayout.PREFERRED_SIZE)
Richard", 0, 18)); .addGroup(layout.createParallelGr
jLabel6.setForeground(new java.awt.Color(0, oup(javax.swing.GroupLayout.Alignment.TRAILING
153, 255)); )
jLabel6.setText("LOG IN TO CONTINUE"); .addGroup(layout.createSequen
tialGroup()
LogInB.setFont(new java.awt.Font("Tahoma", .addPreferredGap(javax.swing.
1, 18)); LayoutStyle.ComponentPlacement.RELATED)
LogInB.setForeground(new java.awt.Color(51, .addComponent(jLabel4,
153, 255)); javax.swing.GroupLayout.PREFERRED_SIZE, 399,
LogInB.setText("Log In"); javax.swing.GroupLayout.PREFERRED_SIZE))
LogInB.addActionListener(new .addGroup(layout.createSequen
java.awt.event.ActionListener() { tialGroup()
public void .addGap(90, 90, 90)
actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(layout.createParall
LogInBActionPerformed(evt); elGroup(javax.swing.GroupLayout.Alignment.LEAD
} ING)
}); .addComponent(jLabel3)
.addComponent(jLabel2,
invalidl.setFont(new java.awt.Font("Tahoma", javax.swing.GroupLayout.PREFERRED_SIZE, 68,
1, 12)); javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(49, 49, 49)
invalid.setFont(new java.awt.Font("Tahoma", .addGroup(layout.createParall
1, 12)); elGroup(javax.swing.GroupLayout.Alignment.LEAD
invalid.setText(" "); ING)
.addComponent(idtf,
javax.swing.GroupLayout layout = new javax.swing.GroupLayout.DEFAULT_SIZE, 221,
javax.swing.GroupLayout(getContentPane()); Short.MAX_VALUE)
getContentPane().setLayout(layout); .addComponent(PassWordT
layout.setHorizontalGroup( F, javax.swing.GroupLayout.DEFAULT_SIZE, 221,
Short.MAX_VALUE)
layout.createParallelGroup(javax.swing.GroupLayo .addGroup(layout.createSeq
ut.Alignment.LEADING) uentialGroup()
.addGroup(layout.createSequentialGroup() .addGap(116, 116, 116)
.addGap(51, 51, 51) .addComponent(invalidl)))
.addGroup(layout.createParallelGroup(jav )))
ax.swing.GroupLayout.Alignment.LEADING) .addGap(19, 19, 19)))
.addGroup(layout.createSequentialGro .addGap(58, 58, 58))
up() .addGroup(layout.createSequentialGroup()
.addGap(237, 237, 237) .addGap(166, 166, 166)

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


.addComponent(LogInB, .addComponent(LogInB,
javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE, 33,
javax.swing.GroupLayout.PREFERRED_SIZE) javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18) .addComponent(invalid)))
.addComponent(invalid) .addContainerGap())
.addContainerGap(270, );
Short.MAX_VALUE))
); java.awt.Dimension screenSize =
layout.setVerticalGroup( java.awt.Toolkit.getDefaultToolkit().getScreenSize(
);
layout.createParallelGroup(javax.swing.GroupLayo setBounds((screenSize.width-572)/2,
ut.Alignment.LEADING) (screenSize.height-469)/2, 572, 469);
.addGroup(javax.swing.GroupLayout.Alignm }// </editor-fold>
ent.TRAILING, layout.createSequentialGroup()
.addGap(19, 19, 19) private void
.addComponent(jLabel4, LogInBActionPerformed(java.awt.event.ActionEve
javax.swing.GroupLayout.PREFERRED_SIZE, 31, nt evt) {
javax.swing.GroupLayout.PREFERRED_SIZE) // TODO add your handling code here:
.addPreferredGap(javax.swing.LayoutStyl invalid.setText("");
e.ComponentPlacement.UNRELATED) String PWord = PassWordTF.getText();
.addComponent(jLabel1, String ID = idtf.getText();
javax.swing.GroupLayout.PREFERRED_SIZE, 208, String str = null;
Short.MAX_VALUE) Statement stmt=null;
.addPreferredGap(javax.swing.LayoutStyl ResultSet rs = null;
e.ComponentPlacement.UNRELATED) try {
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyl Class.forName("java.sql.Driver");
e.ComponentPlacement.UNRELATED) String database =
.addGroup(layout.createParallelGroup(jav "jdbc:mysql://localhost:3306/Library";
ax.swing.GroupLayout.Alignment.BASELINE) Connection conn = (Connection)
.addComponent(jLabel2) DriverManager.getConnection(database, "root",
.addComponent(idtf, "root");
javax.swing.GroupLayout.PREFERRED_SIZE, stmt = (Statement) conn.createStatement();
javax.swing.GroupLayout.DEFAULT_SIZE, String sql = "select * from login where ID = '"
javax.swing.GroupLayout.PREFERRED_SIZE)) + ID + "'";
.addGap(18, 18, 18) rs = stmt.executeQuery(sql);
.addGroup(layout.createParallelGroup(jav rs.next();
ax.swing.GroupLayout.Alignment.BASELINE) str = rs.getString("Password");
.addComponent(PassWordTF, rs.close();
javax.swing.GroupLayout.PREFERRED_SIZE, stmt.close();
javax.swing.GroupLayout.DEFAULT_SIZE, conn.close();
javax.swing.GroupLayout.PREFERRED_SIZE) if(str.equals(PWord)) {
.addComponent(jLabel3)) MainUI m = new MainUI();
.addGap(17, 17, 17) m.setVisible(true);
.addGroup(layout.createParallelGroup(jav this.setVisible(false);
ax.swing.GroupLayout.Alignment.LEADING) } else {
.addComponent(invalidl) invalid.setText("Incorrect ID or
.addGroup(layout.createParallelGroup(j Password");
avax.swing.GroupLayout.Alignment.BASELINE) }

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


} catch (Exception e) * WARNING: Do NOT modify this code. The
{ invalid.setText("Incorrect ID or Password");} content of this method is
} * always regenerated by the Form Editor.
*/
/** @SuppressWarnings("unchecked")
* @param args the command line arguments
*/ // <editor-fold defaultstate="collapsed"
public static void main(String args[]) { desc="Generated Code">
private void initComponents() {
java.awt.EventQueue.invokeLater(new
Runnable() { jLabel1 = new javax.swing.JLabel();
public void run() { jLabel2 = new javax.swing.JLabel();
new login().setVisible(true); jSeparator1 = new javax.swing.JSeparator();
} jLabel3 = new javax.swing.JLabel();
}); jLabel4 = new javax.swing.JLabel();
} jMenuBar1 = new javax.swing.JMenuBar();
jMenu2 = new javax.swing.JMenu();
// Variables declaration - do not modify mnuLib = new javax.swing.JMenuItem();
private javax.swing.JButton LogInB; mnuLibEdit = new javax.swing.JMenuItem();
private javax.swing.JPasswordField PassWordTF; mnuIssue = new javax.swing.JMenuItem();
private javax.swing.JTextField idtf; mnuReturn = new javax.swing.JMenuItem();
private javax.swing.JLabel invalid; jMenu1 = new javax.swing.JMenu();
private javax.swing.JLabel invalidl; mnuPub = new javax.swing.JMenuItem();
private javax.swing.JDialog jDialog1; mnuPMod = new javax.swing.JMenuItem();
private javax.swing.JLabel jLabel1; mnuPDel = new javax.swing.JMenuItem();
private javax.swing.JLabel jLabel2; mnuPNav = new javax.swing.JMenuItem();
private javax.swing.JLabel jLabel3; jMenu3 = new javax.swing.JMenu();
private javax.swing.JLabel jLabel4; mnuMemb = new javax.swing.JMenuItem();
private javax.swing.JLabel jLabel6; mnuMMod = new javax.swing.JMenuItem();
private javax.swing.JPopupMenu jPopupMenu1; mnuMDel = new javax.swing.JMenuItem();
private javax.swing.JPopupMenu jPopupMenu2; mnuMNav = new javax.swing.JMenuItem();
// End of variables declaration jMenu4 = new javax.swing.JMenu();
} mnuABList = new javax.swing.JMenuItem();
***************************************** mnuIBList = new javax.swing.JMenuItem();
mnuMList = new javax.swing.JMenuItem();
MAIN UI jMenu5 = new javax.swing.JMenu();
mnuQuit = new javax.swing.JMenuItem();
*****************************************

public class MainUI extends javax.swing.JFrame {


setDefaultCloseOperation(javax.swing.WindowCon
stants.EXIT_ON_CLOSE);
/** Creates new form MainUI */
setTitle("Library Management System ||
public MainUI() {
www.ezindagi.in ||");
initComponents();
setBounds(new java.awt.Rectangle(200, 70, 0,
}
0));

/** This method is called from within the


jLabel1.setFont(new java.awt.Font("Monotype
constructor to
Corsiva", 0, 36));
* initialize the form.

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


jLabel1.setForeground(new mnuIssue.addActionListener(new
java.awt.Color(153, 0, 153)); java.awt.event.ActionListener() {
public void
jLabel1.setHorizontalAlignment(javax.swing.Swing actionPerformed(java.awt.event.ActionEvent evt) {
Constants.CENTER); mnuIssueActionPerformed(evt);
jLabel1.setText("Library Application"); }
});
jLabel2.setFont(new jMenu2.add(mnuIssue);
java.awt.Font("Helvetica", 1, 30)); // NOI18N
jLabel2.setForeground(new mnuReturn.setText("Book Return");
java.awt.Color(255, 153, 153)); mnuReturn.addActionListener(new
java.awt.event.ActionListener() {
jLabel2.setHorizontalAlignment(javax.swing.Swing public void
Constants.CENTER); actionPerformed(java.awt.event.ActionEvent evt) {
jLabel2.setText("Library Management mnuReturnActionPerformed(evt);
System"); }
});
jLabel4.setIcon(new jMenu2.add(mnuReturn);
javax.swing.ImageIcon(getClass().getResource("/e-
library2.jpg"))); // NOI18N jMenuBar1.add(jMenu2);

jMenu1.setText("Publisher");
jMenuBar1.setBorder(javax.swing.BorderFactory.c
reateBevelBorder(javax.swing.border.BevelBorder. mnuPub.setText("Publisher Console");
RAISED)); mnuPub.addActionListener(new
java.awt.event.ActionListener() {
jMenu2.setText("Book"); public void
actionPerformed(java.awt.event.ActionEvent evt) {
mnuLib.setText("Book Console"); mnuPubActionPerformed(evt);
mnuLib.addActionListener(new }
java.awt.event.ActionListener() { });
public void jMenu1.add(mnuPub);
actionPerformed(java.awt.event.ActionEvent evt) {
mnuLibActionPerformed(evt); mnuPMod.setText("Modification");
} mnuPMod.addActionListener(new
}); java.awt.event.ActionListener() {
jMenu2.add(mnuLib); public void
actionPerformed(java.awt.event.ActionEvent evt) {
mnuLibEdit.setText("Modification"); mnuPModActionPerformed(evt);
mnuLibEdit.addActionListener(new }
java.awt.event.ActionListener() { });
public void jMenu1.add(mnuPMod);
actionPerformed(java.awt.event.ActionEvent evt) {
mnuLibEditActionPerformed(evt); mnuPDel.setText("Deletion");
} mnuPDel.addActionListener(new
}); java.awt.event.ActionListener() {
jMenu2.add(mnuLibEdit); public void
actionPerformed(java.awt.event.ActionEvent evt) {
mnuIssue.setText("Book Issue"); mnuPDelActionPerformed(evt);

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


} mnuMNav.addActionListener(new
}); java.awt.event.ActionListener() {
jMenu1.add(mnuPDel); public void
actionPerformed(java.awt.event.ActionEvent evt) {
mnuPNav.setText("Record Navigation"); mnuMNavActionPerformed(evt);
mnuPNav.addActionListener(new }
java.awt.event.ActionListener() { });
public void jMenu3.add(mnuMNav);
actionPerformed(java.awt.event.ActionEvent evt) {
mnuPNavActionPerformed(evt); jMenuBar1.add(jMenu3);
}
}); jMenu4.setText("Report");
jMenu1.add(mnuPNav);
mnuABList.setText("Available Book List");
jMenuBar1.add(jMenu1); mnuABList.addActionListener(new
java.awt.event.ActionListener() {
jMenu3.setText("Member"); public void
actionPerformed(java.awt.event.ActionEvent evt) {
mnuMemb.setText("Member Console"); mnuABListActionPerformed(evt);
mnuMemb.addActionListener(new }
java.awt.event.ActionListener() { });
public void jMenu4.add(mnuABList);
actionPerformed(java.awt.event.ActionEvent evt) {
mnuMembActionPerformed(evt); mnuIBList.setText("Issued Book List");
} mnuIBList.addActionListener(new
}); java.awt.event.ActionListener() {
jMenu3.add(mnuMemb); public void
actionPerformed(java.awt.event.ActionEvent evt) {
mnuMMod.setText("Modification"); mnuIBListActionPerformed(evt);
mnuMMod.addActionListener(new }
java.awt.event.ActionListener() { });
public void jMenu4.add(mnuIBList);
actionPerformed(java.awt.event.ActionEvent evt) {
mnuMModActionPerformed(evt); mnuMList.setText("Member List");
} mnuMList.addActionListener(new
}); java.awt.event.ActionListener() {
jMenu3.add(mnuMMod); public void
actionPerformed(java.awt.event.ActionEvent evt) {
mnuMDel.setText("Deletion"); mnuMListActionPerformed(evt);
mnuMDel.addActionListener(new }
java.awt.event.ActionListener() { });
public void jMenu4.add(mnuMList);
actionPerformed(java.awt.event.ActionEvent evt) {
mnuMDelActionPerformed(evt); jMenuBar1.add(jMenu4);
}
}); jMenu5.setText("Quit");
jMenu3.add(mnuMDel);
mnuQuit.setText("Application");
mnuMNav.setText("Navigation");

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


mnuQuit.addActionListener(new javax.swing.GroupLayout.PREFERRED_SIZE, 706,
java.awt.event.ActionListener() { javax.swing.GroupLayout.PREFERRED_SIZE))
public void .addContainerGap(53,
actionPerformed(java.awt.event.ActionEvent evt) { Short.MAX_VALUE))
mnuQuitActionPerformed(evt); );
} layout.setVerticalGroup(
});
jMenu5.add(mnuQuit); layout.createParallelGroup(javax.swing.GroupLayo
ut.Alignment.LEADING)
jMenuBar1.add(jMenu5); .addGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING, layout.createSequentialGroup()
setJMenuBar(jMenuBar1); .addContainerGap()
.addComponent(jLabel1,
javax.swing.GroupLayout layout = new javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout.DEFAULT_SIZE,
getContentPane().setLayout(layout); Short.MAX_VALUE)
layout.setHorizontalGroup( .addPreferredGap(javax.swing.LayoutStyl
e.ComponentPlacement.RELATED)
layout.createParallelGroup(javax.swing.GroupLayo .addComponent(jLabel2,
ut.Alignment.LEADING) javax.swing.GroupLayout.PREFERRED_SIZE, 50,
.addGroup(javax.swing.GroupLayout.Alignm javax.swing.GroupLayout.PREFERRED_SIZE)
ent.TRAILING, layout.createSequentialGroup() .addGap(18, 18, 18)
.addContainerGap(147, .addComponent(jSeparator1,
Short.MAX_VALUE) javax.swing.GroupLayout.PREFERRED_SIZE, 13,
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE)
javax.swing.GroupLayout.PREFERRED_SIZE, 462, .addGroup(layout.createParallelGroup(jav
javax.swing.GroupLayout.PREFERRED_SIZE) ax.swing.GroupLayout.Alignment.LEADING)
.addPreferredGap(javax.swing.LayoutStyl .addGroup(layout.createSequentialGro
e.ComponentPlacement.RELATED) up()
.addComponent(jLabel3) .addPreferredGap(javax.swing.Layout
.addGap(189, 189, 189)) Style.ComponentPlacement.RELATED)
.addGroup(layout.createSequentialGroup() .addComponent(jLabel3,
.addGap(34, 34, 34) javax.swing.GroupLayout.PREFERRED_SIZE, 274,
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE))
javax.swing.GroupLayout.PREFERRED_SIZE, 736, .addGroup(layout.createSequentialGro
javax.swing.GroupLayout.PREFERRED_SIZE) up()
.addContainerGap(34, .addGap(28, 28, 28)
Short.MAX_VALUE)) .addComponent(jLabel4,
.addGroup(layout.createSequentialGroup() javax.swing.GroupLayout.PREFERRED_SIZE, 291,
.addGap(45, 45, 45) javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createParallelGroup(jav .addGap(49, 49, 49))
ax.swing.GroupLayout.Alignment.TRAILING, false) );
.addComponent(jLabel1,
javax.swing.GroupLayout.Alignment.LEADING, java.awt.Dimension screenSize =
javax.swing.GroupLayout.DEFAULT_SIZE, java.awt.Toolkit.getDefaultToolkit().getScreenSize(
javax.swing.GroupLayout.DEFAULT_SIZE, );
Short.MAX_VALUE) setBounds((screenSize.width-820)/2,
.addComponent(jLabel2, (screenSize.height-568)/2, 820, 568);
javax.swing.GroupLayout.Alignment.LEADING, }// </editor-fold>

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


private void }
mnuPubActionPerformed(java.awt.event.ActionEv
ent evt) { private void
//this.setVisible(false); mnuMDelActionPerformed(java.awt.event.ActionE
new pubUI().setVisible(true); dispose(); vent evt) {
new pubUI().getAlignmentX(); new MembDelUI().setVisible(true); dispose();
}
}
private void
private void mnuMNavActionPerformed(java.awt.event.Action
mnuQuitActionPerformed(java.awt.event.ActionEv Event evt) {
ent evt) { new MembNavUI().setVisible(true); dispose();
System.exit(0); }
}
private void
private void mnuIssueActionPerformed(java.awt.event.ActionE
mnuPModActionPerformed(java.awt.event.Action vent evt) {
Event evt) { new IssueUI().setVisible(true); dispose();
new PubEditUI().setVisible(true); dispose(); }
}
private void
private void mnuReturnActionPerformed(java.awt.event.Action
mnuPDelActionPerformed(java.awt.event.ActionEv Event evt) {
ent evt) { new ReturnUI().setVisible(true); dispose();
new PubDelUI().setVisible(true); dispose(); }
}
private void
private void mnuABListActionPerformed(java.awt.event.Action
mnuPNavActionPerformed(java.awt.event.ActionE Event evt) {
vent evt) { new ABListUI().setVisible(true); dispose();
new PubNavUI().setVisible(true); dispose(); }
}
private void
private void mnuIBListActionPerformed(java.awt.event.ActionE
mnuLibActionPerformed(java.awt.event.ActionEve vent evt) {
nt evt) { new IBListUI().setVisible(true); dispose();
new LibUI().setVisible(true); dispose(); }
}
private void
private void mnuMListActionPerformed(java.awt.event.ActionE
mnuMembActionPerformed(java.awt.event.Action vent evt) {
Event evt) { new MListUI().setVisible(true); dispose();
new MembUI().setVisible(true); dispose(); }
}
private void
private void mnuLibEditActionPerformed(java.awt.event.Action
mnuMModActionPerformed(java.awt.event.Action Event evt) {
Event evt) { new LibEditUI().setVisible(true); dispose(); //
new MembEditUI().setVisible(true); dispose(); TODO add your handling code here:

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


} *****************************************

/** import java.sql.*;


* @param args the command line arguments import javax.swing.JOptionPane;
*/ import javax.swing.DefaultComboBoxModel;
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new public class LibUI extends javax.swing.JFrame {
Runnable() {
public void run() { /** Creates new form LibUI */
new MainUI().setVisible(true); public LibUI() {
initComponents();
}
}
}); /** This method is called from within the
} constructor to
// Variables declaration - do not modify * initialize the form.
private javax.swing.JLabel jLabel1; * WARNING: Do NOT modify this code. The
private javax.swing.JLabel jLabel2; content of this method is
private javax.swing.JLabel jLabel3; * always regenerated by the Form Editor.
private javax.swing.JLabel jLabel4; */
private javax.swing.JMenu jMenu1; @SuppressWarnings("unchecked")
private javax.swing.JMenu jMenu2; // for table Lib
private javax.swing.JMenu jMenu3; Statement stmt = null;
private javax.swing.JMenu jMenu4; ResultSet rs = null;
private javax.swing.JMenu jMenu5; String SQL = "SELECT * FROM Lib";
private javax.swing.JMenuBar jMenuBar1; // for table Publisher
private javax.swing.JSeparator jSeparator1; Statement stmt1 = null;
private javax.swing.JMenuItem mnuABList; ResultSet rs1 = null;
private javax.swing.JMenuItem mnuIBList; String SQL1 = "SELECT * FROM publisher";
private javax.swing.JMenuItem mnuIssue;
private javax.swing.JMenuItem mnuLib; // <editor-fold defaultstate="collapsed"
private javax.swing.JMenuItem mnuLibEdit; desc="Generated Code">
private javax.swing.JMenuItem mnuMDel; private void initComponents() {
private javax.swing.JMenuItem mnuMList;
private javax.swing.JMenuItem mnuMMod; cmdExit = new javax.swing.JButton();
private javax.swing.JMenuItem mnuMNav; cmdEdit = new javax.swing.JButton();
private javax.swing.JMenuItem mnuMemb; cmdSave = new javax.swing.JButton();
private javax.swing.JMenuItem mnuPDel; cmdNew = new javax.swing.JButton();
private javax.swing.JMenuItem mnuPMod; cmdClear = new javax.swing.JButton();
private javax.swing.JMenuItem mnuPNav; jLabel1 = new javax.swing.JLabel();
private javax.swing.JMenuItem mnuPub; jLabel2 = new javax.swing.JLabel();
private javax.swing.JMenuItem mnuQuit; jLabel3 = new javax.swing.JLabel();
private javax.swing.JMenuItem mnuReturn; jLabel4 = new javax.swing.JLabel();
// End of variables declaration jLabel5 = new javax.swing.JLabel();
} jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
***************************************** jLabel9 = new javax.swing.JLabel();
txtAcno = new javax.swing.JTextField();
BOOK CONSOLE txtBTitle = new javax.swing.JTextField();

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


txtAuth1 = new javax.swing.JTextField(); cmdSave.setText("Save");
txtAuth2 = new javax.swing.JTextField(); cmdSave.addActionListener(new
jComboBox1 = new javax.swing.JComboBox(); java.awt.event.ActionListener() {
txtPrice = new javax.swing.JTextField(); public void
txtPages = new javax.swing.JTextField(); actionPerformed(java.awt.event.ActionEvent evt) {
txtEdition = new javax.swing.JTextField(); cmdSaveActionPerformed(evt);
txtPDate = new javax.swing.JTextField(); }
txtStatus = new javax.swing.JTextField(); });
cmdDelete = new javax.swing.JButton();
jLabel10 = new javax.swing.JLabel(); cmdNew.setText("New");
cmdNew.addActionListener(new
java.awt.event.ActionListener() {
setDefaultCloseOperation(javax.swing.WindowCon public void
stants.EXIT_ON_CLOSE); actionPerformed(java.awt.event.ActionEvent evt) {
setTitle("Console - Library Management cmdNewActionPerformed(evt);
System || www.ezindagi.in ||"); }
setBounds(new java.awt.Rectangle(200, 70, 0, });
0));
addWindowFocusListener(new cmdClear.setText("Clear");
java.awt.event.WindowFocusListener() { cmdClear.addActionListener(new
public void java.awt.event.ActionListener() {
windowGainedFocus(java.awt.event.WindowEvent public void
evt) { actionPerformed(java.awt.event.ActionEvent evt) {
formWindowGainedFocus(evt); cmdClearActionPerformed(evt);
} }
public void });
windowLostFocus(java.awt.event.WindowEvent
evt) { jLabel1.setText("Accession No.");
}
}); jLabel2.setText("Book Title");

cmdExit.setText("Exit"); jLabel3.setText("Authors");
cmdExit.addActionListener(new
java.awt.event.ActionListener() { jLabel4.setText("Publisher");
public void
actionPerformed(java.awt.event.ActionEvent evt) { jLabel5.setText("Price");
cmdExitActionPerformed(evt);
} jLabel6.setText("Purchase Date");
});
jLabel7.setText("Pages");
cmdEdit.setText("Edit");
cmdEdit.addActionListener(new jLabel8.setText("Edition");
java.awt.event.ActionListener() {
public void jLabel9.setText("Status");
actionPerformed(java.awt.event.ActionEvent evt) {
cmdEditActionPerformed(evt); jComboBox1.setModel(new
} DefaultComboBoxModel() );
});
cmdDelete.setText("Delete");

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


cmdDelete.addActionListener(new javax.swing.GroupLayout.DEFAULT_SIZE, 245,
java.awt.event.ActionListener() { Short.MAX_VALUE))
public void .addComponent(txtAcno,
actionPerformed(java.awt.event.ActionEvent evt) { javax.swing.GroupLayout.PREFERRED_SIZE, 39,
cmdDeleteActionPerformed(evt); javax.swing.GroupLayout.PREFERRED_SIZE)))
} .addGroup(layout.createSequentialGro
}); up()
.addGroup(layout.createParallelGrou
jLabel10.setFont(new p(javax.swing.GroupLayout.Alignment.TRAILING)
java.awt.Font("Tahoma", 1, 10)); .addComponent(jLabel5)
.addComponent(jLabel6)
jLabel10.setHorizontalAlignment(javax.swing.Swin .addComponent(jLabel4))
gConstants.CENTER); .addPreferredGap(javax.swing.Layout
jLabel10.setText("(YYYY-MM-DD)"); Style.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGrou
javax.swing.GroupLayout layout = new p(javax.swing.GroupLayout.Alignment.LEADING)
javax.swing.GroupLayout(getContentPane()); .addComponent(jComboBox1,
getContentPane().setLayout(layout); javax.swing.GroupLayout.PREFERRED_SIZE, 231,
layout.setHorizontalGroup( javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequential
layout.createParallelGroup(javax.swing.GroupLayo Group()
ut.Alignment.LEADING) .addComponent(txtPrice,
.addGroup(layout.createSequentialGroup() javax.swing.GroupLayout.PREFERRED_SIZE, 61,
.addContainerGap() javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(jav .addGap(18, 18, 18)
ax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel7)
.addGroup(layout.createSequentialGro .addPreferredGap(javax.swing.La
up() youtStyle.ComponentPlacement.RELATED)
.addGap(3, 3, 3) .addComponent(txtPages,
.addGroup(layout.createParallelGrou javax.swing.GroupLayout.PREFERRED_SIZE, 47,
p(javax.swing.GroupLayout.Alignment.TRAILING) javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3) .addGap(32, 32, 32)
.addComponent(jLabel1) .addComponent(jLabel8)
.addComponent(jLabel2)) .addPreferredGap(javax.swing.La
.addPreferredGap(javax.swing.Layout youtStyle.ComponentPlacement.UNRELATED)
Style.ComponentPlacement.UNRELATED) .addComponent(txtEdition,
.addGroup(layout.createParallelGrou javax.swing.GroupLayout.PREFERRED_SIZE, 57,
p(javax.swing.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtBTitle, .addGroup(layout.createSequential
javax.swing.GroupLayout.PREFERRED_SIZE, 231, Group()
javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallel
.addGroup(layout.createParallelGr Group(javax.swing.GroupLayout.Alignment.TRAILI
oup(javax.swing.GroupLayout.Alignment.TRAILING NG, false)
, false) .addComponent(jLabel10,
.addComponent(txtAuth2, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.DEFAULT_SIZE,
.addComponent(txtAuth1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.Alignment.LEADING, Short.MAX_VALUE)

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


.addComponent(txtPDate, .addGroup(layout.createParallelGroup(jav
javax.swing.GroupLayout.Alignment.LEADING, ax.swing.GroupLayout.Alignment.BASELINE)
javax.swing.GroupLayout.DEFAULT_SIZE, 78, .addComponent(jLabel2)
Short.MAX_VALUE)) .addComponent(txtBTitle,
.addGap(18, 18, 18) javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(jLabel9) javax.swing.GroupLayout.DEFAULT_SIZE,
.addPreferredGap(javax.swing.La javax.swing.GroupLayout.PREFERRED_SIZE))
youtStyle.ComponentPlacement.RELATED) .addGap(18, 18, 18)
.addComponent(txtStatus, .addGroup(layout.createParallelGroup(jav
javax.swing.GroupLayout.PREFERRED_SIZE, 24, ax.swing.GroupLayout.Alignment.BASELINE)
javax.swing.GroupLayout.PREFERRED_SIZE))))) .addComponent(jLabel3)
.addContainerGap(95, .addComponent(txtAuth1,
Short.MAX_VALUE)) javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(javax.swing.GroupLayout.Alignm javax.swing.GroupLayout.DEFAULT_SIZE,
ent.TRAILING, layout.createSequentialGroup() javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(27, 27, 27) .addPreferredGap(javax.swing.LayoutStyl
.addComponent(cmdNew) e.ComponentPlacement.UNRELATED)
.addPreferredGap(javax.swing.LayoutStyl .addComponent(txtAuth2,
e.ComponentPlacement.UNRELATED) javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(cmdSave) javax.swing.GroupLayout.DEFAULT_SIZE,
.addGap(18, 18, 18) javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdEdit) .addPreferredGap(javax.swing.LayoutStyl
.addGap(18, 18, 18) e.ComponentPlacement.RELATED, 8,
.addComponent(cmdDelete) Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyl .addGroup(layout.createParallelGroup(jav
e.ComponentPlacement.UNRELATED) ax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cmdClear, .addComponent(jLabel4)
javax.swing.GroupLayout.DEFAULT_SIZE, 63, .addComponent(jComboBox1,
Short.MAX_VALUE) javax.swing.GroupLayout.PREFERRED_SIZE,
.addGap(18, 18, 18) javax.swing.GroupLayout.DEFAULT_SIZE,
.addComponent(cmdExit) javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(36, 36, 36)) .addGap(18, 18, 18)
); .addGroup(layout.createParallelGroup(jav
layout.setVerticalGroup( ax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
layout.createParallelGroup(javax.swing.GroupLayo .addComponent(txtPrice,
ut.Alignment.LEADING) javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(javax.swing.GroupLayout.Alignm javax.swing.GroupLayout.DEFAULT_SIZE,
ent.TRAILING, layout.createSequentialGroup() javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap() .addComponent(jLabel7)
.addGroup(layout.createParallelGroup(jav .addComponent(jLabel8)
ax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtEdition,
.addComponent(jLabel1) javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(txtAcno, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
javax.swing.GroupLayout.DEFAULT_SIZE, .addComponent(txtPages,
javax.swing.GroupLayout.PREFERRED_SIZE)) javax.swing.GroupLayout.PREFERRED_SIZE,
.addGap(11, 11, 11) javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


.addPreferredGap(javax.swing.LayoutStyl private void
e.ComponentPlacement.UNRELATED) cmdSaveActionPerformed(java.awt.event.ActionEv
.addGroup(layout.createParallelGroup(jav ent evt) {
ax.swing.GroupLayout.Alignment.BASELINE) try {
.addComponent(jLabel6) Class.forName("com.mysql.jdbc.Driver");
.addComponent(txtPDate, Connection con = (Connection)
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, DriverManager.getConnection("jdbc:mysql://local
javax.swing.GroupLayout.PREFERRED_SIZE) host:3306/Library","root","root");
.addComponent(jLabel9) stmt = con.createStatement();
.addComponent(txtStatus, rs = stmt.executeQuery(SQL);
javax.swing.GroupLayout.PREFERRED_SIZE, int Acno =
javax.swing.GroupLayout.DEFAULT_SIZE, Integer.parseInt(txtAcno.getText().trim());
javax.swing.GroupLayout.PREFERRED_SIZE)) String bTitle = txtBTitle.getText();
.addGap(2, 2, 2) String Auth1 = txtAuth1.getText();
.addComponent(jLabel10) String Auth2 = txtAuth2.getText();
.addGap(27, 27, 27) // Creating a String object pName
.addGroup(layout.createParallelGroup(jav String pName = (String)
ax.swing.GroupLayout.Alignment.BASELINE) jComboBox1.getSelectedItem();
.addComponent(cmdNew) // Extract the first 4 characters as publisher
.addComponent(cmdSave) number into a variable
.addComponent(cmdEdit) String PubNo =
.addComponent(cmdDelete) String.valueOf(pName.substring(0, 3).trim());
.addComponent(cmdClear) int pno = Integer.parseInt(PubNo);
.addComponent(cmdExit)) jLabel10.setText(""+pno);
.addGap(24, 24, 24)) float Price =
); Float.parseFloat(txtPrice.getText());
int pages =
java.awt.Dimension screenSize = Integer.parseInt(txtPages.getText());
java.awt.Toolkit.getDefaultToolkit().getScreenSize( int edition =
); Integer.parseInt(txtEdition.getText());
setBounds((screenSize.width-491)/2, String Pdate = txtPDate.getText();
(screenSize.height-355)/2, 491, 355); char BStatus = 'Y';
}// </editor-fold> int code =
private void JOptionPane.showConfirmDialog(this, "Are you
cmdExitActionPerformed(java.awt.event.ActionEv sure to add?", "Confirmation Dialog Box",
ent evt) { JOptionPane.YES_NO_CANCEL_OPTION,
new MainUI ().setVisible(true); JOptionPane.INFORMATION_MESSAGE);
dispose(); if (code == JOptionPane.YES_OPTION) {
} String strSQL = "INSERT INTO Lib(acc_no,
btitle, author1, author2, pub_id, price, pdate,
private void pages, edition, status) VALUES ("+(Acno)+", '"+
cmdEditActionPerformed(java.awt.event.ActionEv (bTitle)+"', '"+(Auth1)+"', '"+(Auth2)+"', "+(pno)+",
ent evt) { "+(Price)+", '"+(Pdate)+"', "+(pages)+", "+(edition)
this.setVisible(false); +", '"+(BStatus)+"')";
new LibEditUI().setVisible(true); int rowsEffected =
} stmt.executeUpdate(strSQL);
JOptionPane.showMessageDialog(this,
"Record added successfully into Lib table");

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


} txtStatus.setText("Y"); // Because it is a
cmdSave.setEnabled(false); new book, when it will be issue,
} catch (Exception e) { // it's status will be N.
JOptionPane.showMessageDialog(this, if (pubno.length() < 4)
e.getMessage()); {
} int x = pubno.length();
} int nl = 4 - x;
while (nl > 0){
private void pubno = pubno + " ";
cmdNewActionPerformed(java.awt.event.ActionEv nl--;
ent evt) { }
// Activate the Save button when New button }
pressed cModel.addElement(pubno + "- " +
cmdSave.setEnabled(true); pubName);
DefaultComboBoxModel cModel = }
(DefaultComboBoxModel) } catch (Exception e) {
jComboBox1.getModel();
cModel.removeAllElements(); JOptionPane.showMessageDialog(this,e.getMessa
txtStatus.setEditable(false); ge());
// Activate the Save button when New button e.printStackTrace();
clicked }
cmdSave.setEnabled(true); }
try {
Class.forName("com.mysql.jdbc.Driver"); private void
Connection con = (Connection) cmdClearActionPerformed(java.awt.event.ActionE
vent evt) {
DriverManager.getConnection("jdbc:mysql://local DefaultComboBoxModel cModel =
host:3306/Library","root","root"); (DefaultComboBoxModel)
jComboBox1.getModel();
stmt = con.createStatement(); // txtAcno.setText("");
Connection string for ResultSet - rs. txtBTitle.setText("");
rs = stmt.executeQuery(SQL); txtAuth1.setText("");
int acno=0, ACNO = 0; txtAuth2.setText("");
while (rs.next()) { cModel.removeAllElements();
ACNO = rs.getInt("acc_no"); txtPrice.setText("");
} txtPages.setText("");
ACNO++; txtEdition.setText("");
acno = ACNO; txtPDate.setText("");
txtAcno.setText(Integer.toString(acno)); txtStatus.setText("");
stmt1 = con.createStatement(); // To list cmdSave.setEnabled(false);
publishers in JComboBox1 component }
rs1 = stmt1.executeQuery(SQL1);
while (rs1.next()) { private void
String pubno = rs1.getString("pub_id"); formWindowGainedFocus(java.awt.event.Window
String pubName = Event evt) {
rs1.getString("pub_name"); txtAcno.setEditable(false);
// To make the publisher no. as 4 digit // Deactivate the Save button when form
because we will extract 4 digit from list value loads
// in mouse click event cmdSave.setEnabled(false);

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


} // End of variables declaration
}
private void
cmdDeleteActionPerformed(java.awt.event.Action
Event evt) { *****************************************
this.setVisible(false); ISSUE BOOK
new LibDelUI().setVisible(true); *****************************************

} import java.sql.*;
import javax.swing.JOptionPane;
/** import javax.swing.DefaultListModel;
* @param args the command line arguments
*/ public class IssueUI extends javax.swing.JFrame {
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new /** Creates new form IssueUI */
Runnable() { public IssueUI() {
public void run() { initComponents();
new LibUI().setVisible(true); }
}
}); /** This method is called from within the
} constructor to
* initialize the form.
// Variables declaration - do not modify * WARNING: Do NOT modify this code. The
private javax.swing.JButton cmdClear; content of this method is
private javax.swing.JButton cmdDelete; * always regenerated by the Form Editor.
private javax.swing.JButton cmdEdit; */
private javax.swing.JButton cmdExit; @SuppressWarnings("unchecked")
private javax.swing.JButton cmdNew; // <editor-fold defaultstate="collapsed"
private javax.swing.JButton cmdSave; desc="Generated Code">
private javax.swing.JComboBox jComboBox1; private void initComponents() {
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10; jLabel6 = new javax.swing.JLabel();
private javax.swing.JLabel jLabel2; jScrollPane1 = new javax.swing.JScrollPane();
private javax.swing.JLabel jLabel3; jList1 = new javax.swing.JList();
private javax.swing.JLabel jLabel4; jLabel11 = new javax.swing.JLabel();
private javax.swing.JLabel jLabel5; jLabel1 = new javax.swing.JLabel();
private javax.swing.JLabel jLabel6; txtMNo = new javax.swing.JTextField();
private javax.swing.JLabel jLabel7; txtMName = new javax.swing.JTextField();
private javax.swing.JLabel jLabel8; jLabel2 = new javax.swing.JLabel();
private javax.swing.JLabel jLabel9; txtMStatus = new javax.swing.JTextField();
private javax.swing.JTextField txtAcno; jLabel5 = new javax.swing.JLabel();
private javax.swing.JTextField txtAuth1; jLabel7 = new javax.swing.JLabel();
private javax.swing.JTextField txtAuth2; txtMDate = new javax.swing.JTextField();
private javax.swing.JTextField txtBTitle; jSeparator1 = new javax.swing.JSeparator();
private javax.swing.JTextField txtEdition; jLabel3 = new javax.swing.JLabel();
private javax.swing.JTextField txtPDate; txtAcno = new javax.swing.JTextField();
private javax.swing.JTextField txtPages; jLabel4 = new javax.swing.JLabel();
private javax.swing.JTextField txtPrice; txtBTitle = new javax.swing.JTextField();
private javax.swing.JTextField txtStatus; jLabel12 = new javax.swing.JLabel();
txtPID = new javax.swing.JTextField();

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


jLabel8 = new javax.swing.JLabel(); jLabel11.setFont(new
txtAuth1 = new javax.swing.JTextField(); java.awt.Font("Helvetica", 1, 12));
jLabel9 = new javax.swing.JLabel(); jLabel11.setText("Select a Book");
txtStatus = new javax.swing.JTextField();
cmdExit = new javax.swing.JButton(); jLabel1.setFont(new java.awt.Font("Arial", 1,
jScrollPane2 = new javax.swing.JScrollPane(); 12));
jList2 = new javax.swing.JList(); jLabel1.setText("Member No.");
cmdIssue = new javax.swing.JButton();
jLabel13 = new javax.swing.JLabel(); txtMName.addActionListener(new
txtIDate = new javax.swing.JTextField(); java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
setDefaultCloseOperation(javax.swing.WindowCon txtMNameActionPerformed(evt);
stants.EXIT_ON_CLOSE); }
setTitle("Book issue form - Library });
Management System || www.ezindagi.in ||"); txtMName.addPropertyChangeListener(new
setBounds(new java.awt.Rectangle(200, 70, 0, java.beans.PropertyChangeListener() {
0)); public void
addWindowFocusListener(new propertyChange(java.beans.PropertyChangeEvent
java.awt.event.WindowFocusListener() { evt) {
public void txtMNamePropertyChange(evt);
windowGainedFocus(java.awt.event.WindowEvent }
evt) { });
formWindowGainedFocus(evt); txtMName.addKeyListener(new
} java.awt.event.KeyAdapter() {
public void public void
windowLostFocus(java.awt.event.WindowEvent keyPressed(java.awt.event.KeyEvent evt) {
evt) { txtMNameKeyPressed(evt);
} }
}); });

jLabel6.setFont(new jLabel2.setFont(new java.awt.Font("Arial", 1,


java.awt.Font("Helvetica", 1, 12)); 12));
jLabel2.setText("Name");
jLabel6.setHorizontalAlignment(javax.swing.Swing
Constants.CENTER); txtMStatus.setFont(new java.awt.Font("Arial",
jLabel6.setText("Select a Member"); 1, 10));

jList1.setModel(new DefaultListModel()); jLabel5.setFont(new java.awt.Font("Arial", 1,


jList1.addMouseListener(new 12));
java.awt.event.MouseAdapter() { jLabel5.setText("Status");
public void
mouseClicked(java.awt.event.MouseEvent evt) { jLabel7.setFont(new java.awt.Font("Arial", 1,
jList1MouseClicked(evt); 12));
} jLabel7.setText("Membership Date");
});
jScrollPane1.setViewportView(jList1); txtMDate.setFont(new java.awt.Font("Arial",
1, 10));

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


jLabel3.setText("Accession No."); .addGroup(layout.createParallelGroup(jav
ax.swing.GroupLayout.Alignment.LEADING)
jLabel4.setText("Book Title"); .addComponent(jSeparator1,
javax.swing.GroupLayout.PREFERRED_SIZE, 605,
jLabel12.setText("Pub ID."); javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGro
jLabel8.setText("Authors"); up()
.addGap(10, 10, 10)
jLabel9.setText("Status"); .addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 138,
cmdExit.setText("Exit"); javax.swing.GroupLayout.PREFERRED_SIZE)
cmdExit.addActionListener(new .addGroup(layout.createParallelGrou
java.awt.event.ActionListener() { p(javax.swing.GroupLayout.Alignment.LEADING)
public void .addGroup(layout.createSequential
actionPerformed(java.awt.event.ActionEvent evt) { Group()
cmdExitActionPerformed(evt); .addGap(36, 36, 36)
} .addGroup(layout.createParallel
}); Group(javax.swing.GroupLayout.Alignment.TRAILI
NG)
jList2.setModel(new DefaultListModel()); .addComponent(jLabel1)
jList2.addMouseListener(new .addComponent(jLabel2)
java.awt.event.MouseAdapter() { .addComponent(jLabel5)))
public void .addGroup(layout.createSequential
mouseClicked(java.awt.event.MouseEvent evt) { Group()
jList2MouseClicked(evt); .addPreferredGap(javax.swing.La
} youtStyle.ComponentPlacement.RELATED)
}); .addComponent(jLabel7)))
jScrollPane2.setViewportView(jList2); .addPreferredGap(javax.swing.Layout
Style.ComponentPlacement.UNRELATED)
cmdIssue.setText("Issue"); .addGroup(layout.createParallelGrou
cmdIssue.addActionListener(new p(javax.swing.GroupLayout.Alignment.LEADING)
java.awt.event.ActionListener() { .addComponent(txtMDate,
public void javax.swing.GroupLayout.PREFERRED_SIZE, 100,
actionPerformed(java.awt.event.ActionEvent evt) { javax.swing.GroupLayout.PREFERRED_SIZE)
cmdIssueActionPerformed(evt); .addComponent(txtMNo,
} javax.swing.GroupLayout.PREFERRED_SIZE, 47,
}); javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtMStatus,
jLabel13.setText("Enter Issue Date :"); javax.swing.GroupLayout.PREFERRED_SIZE, 31,
javax.swing.GroupLayout.PREFERRED_SIZE)
javax.swing.GroupLayout layout = new .addComponent(txtMName,
javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout.PREFERRED_SIZE, 178,
getContentPane().setLayout(layout); javax.swing.GroupLayout.PREFERRED_SIZE)))
layout.setHorizontalGroup( .addGroup(layout.createSequentialGro
up()
layout.createParallelGroup(javax.swing.GroupLayo .addGap(23, 23, 23)
ut.Alignment.LEADING) .addComponent(jLabel6,
.addGroup(layout.createSequentialGroup() javax.swing.GroupLayout.PREFERRED_SIZE, 104,
.addContainerGap() javax.swing.GroupLayout.PREFERRED_SIZE))

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


.addGroup(layout.createSequentialGro .addComponent(txtPID,
up() javax.swing.GroupLayout.PREFERRED_SIZE, 73,
.addGap(32, 32, 32) javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11)) .addPreferredGap(javax.swing.
.addGroup(layout.createSequentialGro LayoutStyle.ComponentPlacement.RELATED,
up() javax.swing.GroupLayout.DEFAULT_SIZE,
.addGroup(layout.createParallelGrou Short.MAX_VALUE)
p(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel9)
.addGroup(javax.swing.GroupLayo .addPreferredGap(javax.swing.
ut.Alignment.LEADING, LayoutStyle.ComponentPlacement.UNRELATED)
layout.createSequentialGroup() .addComponent(txtStatus,
.addGap(8, 8, 8) javax.swing.GroupLayout.PREFERRED_SIZE, 24,
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE)))
javax.swing.GroupLayout.PREFERRED_SIZE, 138, .addComponent(txtIDate,
javax.swing.GroupLayout.PREFERRED_SIZE) javax.swing.GroupLayout.PREFERRED_SIZE, 112,
.addGap(28, 28, 28) javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createParallel .addContainerGap())
Group(javax.swing.GroupLayout.Alignment.TRAILI );
NG) layout.setVerticalGroup(
.addComponent(jLabel8)
.addComponent(jLabel4) layout.createParallelGroup(javax.swing.GroupLayo
.addComponent(jLabel3) ut.Alignment.LEADING)
.addComponent(jLabel12))) .addGroup(layout.createSequentialGroup()
.addComponent(jLabel13)) .addContainerGap()
.addPreferredGap(javax.swing.Layout .addGroup(layout.createParallelGroup(jav
Style.ComponentPlacement.RELATED) ax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGrou .addGroup(layout.createSequentialGro
p(javax.swing.GroupLayout.Alignment.LEADING) up()
.addComponent(txtBTitle, .addComponent(jLabel6)
javax.swing.GroupLayout.PREFERRED_SIZE, 177, .addPreferredGap(javax.swing.Layout
javax.swing.GroupLayout.PREFERRED_SIZE) Style.ComponentPlacement.RELATED)
.addComponent(txtAcno, .addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE, 151,
javax.swing.GroupLayout.PREFERRED_SIZE) javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtAuth1, .addGroup(layout.createSequentialGro
javax.swing.GroupLayout.PREFERRED_SIZE, 240, up()
javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(32, 32, 32)
.addGroup(layout.createParallelGr .addGroup(layout.createParallelGrou
oup(javax.swing.GroupLayout.Alignment.TRAILING p(javax.swing.GroupLayout.Alignment.BASELINE)
, false) .addComponent(txtMNo,
.addGroup(layout.createSequen javax.swing.GroupLayout.PREFERRED_SIZE,
tialGroup() javax.swing.GroupLayout.DEFAULT_SIZE,
.addComponent(cmdIssue) javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(91, 91, 91) .addComponent(jLabel1))
.addComponent(cmdExit)) .addPreferredGap(javax.swing.Layout
.addGroup(layout.createSequen Style.ComponentPlacement.UNRELATED)
tialGroup() .addGroup(layout.createParallelGrou
p(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


.addComponent(txtMName, .addGroup(layout.createParallelGrou
javax.swing.GroupLayout.PREFERRED_SIZE, p(javax.swing.GroupLayout.Alignment.BASELINE)
javax.swing.GroupLayout.DEFAULT_SIZE, .addComponent(jLabel4)
javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtBTitle,
.addGap(10, 10, 10) javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(layout.createParallelGrou javax.swing.GroupLayout.DEFAULT_SIZE,
p(javax.swing.GroupLayout.Alignment.BASELINE) javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtMDate, .addPreferredGap(javax.swing.Layout
javax.swing.GroupLayout.PREFERRED_SIZE, Style.ComponentPlacement.UNRELATED)
javax.swing.GroupLayout.DEFAULT_SIZE, .addGroup(layout.createParallelGrou
javax.swing.GroupLayout.PREFERRED_SIZE) p(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)) .addComponent(jLabel8)
.addGap(18, 18, 18) .addComponent(txtAuth1,
.addGroup(layout.createParallelGrou javax.swing.GroupLayout.PREFERRED_SIZE,
p(javax.swing.GroupLayout.Alignment.BASELINE) javax.swing.GroupLayout.DEFAULT_SIZE,
.addComponent(jLabel5) javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtMStatus, .addPreferredGap(javax.swing.Layout
javax.swing.GroupLayout.PREFERRED_SIZE, Style.ComponentPlacement.UNRELATED)
javax.swing.GroupLayout.DEFAULT_SIZE, .addGroup(layout.createParallelGrou
javax.swing.GroupLayout.PREFERRED_SIZE)))) p(javax.swing.GroupLayout.Alignment.BASELINE)
.addPreferredGap(javax.swing.LayoutStyl .addComponent(jLabel12)
e.ComponentPlacement.RELATED) .addComponent(jLabel9)
.addComponent(jSeparator1, .addComponent(txtStatus,
javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE) javax.swing.GroupLayout.DEFAULT_SIZE,
.addGroup(layout.createParallelGroup(jav javax.swing.GroupLayout.PREFERRED_SIZE)
ax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtPID,
.addGroup(layout.createSequentialGro javax.swing.GroupLayout.PREFERRED_SIZE,
up() javax.swing.GroupLayout.DEFAULT_SIZE,
.addGap(2, 2, 2) javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(jLabel11) .addGap(12, 12, 12)
.addPreferredGap(javax.swing.Layout .addGroup(layout.createParallelGroup(jav
Style.ComponentPlacement.RELATED) ax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jScrollPane2, .addComponent(jLabel13)
javax.swing.GroupLayout.PREFERRED_SIZE, .addComponent(txtIDate,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) javax.swing.GroupLayout.DEFAULT_SIZE,
.addGroup(layout.createSequentialGro javax.swing.GroupLayout.PREFERRED_SIZE))
up() .addGap(18, 18, 18)
.addPreferredGap(javax.swing.Layout .addGroup(layout.createParallelGroup(jav
Style.ComponentPlacement.RELATED) ax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGrou .addComponent(cmdExit)
p(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cmdIssue))
.addComponent(jLabel3) .addGap(23, 23, 23))
.addComponent(txtAcno, );
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, java.awt.Dimension screenSize =
javax.swing.GroupLayout.PREFERRED_SIZE)) java.awt.Toolkit.getDefaultToolkit().getScreenSize(
.addGap(11, 11, 11) );

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


setBounds((screenSize.width-641)/2,
(screenSize.height-488)/2, 641, 488); if (rs.next()) {
}// </editor-fold> String MName =
Statement stmt = null; rs.getString("memb_name");
ResultSet rs = null; String MDate = rs.getString("mdate");
char st1 = 'N'; String MStatus =
char ms = 'Y'; rs.getString("mem_status");
String SQL = "SELECT * FROM Member WHERE // Displaying the contents in respective
mem_issue = '" + st1 + "' and mem_status ='" + ms text boxes.
+ "'"; txtMNo.setText(Mno);
txtMName.setText(MName);
Statement stmt1 = null; txtMDate.setText(MDate);
ResultSet rs1 = null; txtMStatus.setText(MStatus);
char st = 'Y'; // Lib table } else {
String SQL1 = "SELECT * FROM lib WHERE status JOptionPane.showMessageDialog(null,
= '" + st + "';"; "Record does not found in Member table");
}
} catch (Exception e) {
Statement stmt2 = null; JOptionPane.showMessageDialog(this,
ResultSet rs2 = null; e.getMessage());
String SQL2 = "SELECT * FROM missue"; }
}
Statement stmt3 = null;
ResultSet rs3 = null; private void
String SQL3 = "SELECT * FROM tissue"; formWindowGainedFocus(java.awt.event.Window
Event evt) {
txtMNo.setEditable(false);
private void txtMName.setEditable(false);
jList1MouseClicked(java.awt.event.MouseEvent txtMDate.setEditable(false);
evt) { txtMStatus.setEditable(false);
// getSelectedValue() method extracts the txtAcno.setEditable(false);
current cursor location value into a variable txtBTitle.setEditable(false);
String MembNo = (String) txtAuth1.setEditable(false);
jList1.getSelectedValue(); txtPID.setEditable(false);
// Extract the first 4 characters as Member No txtStatus.setEditable(false);
into a variable
String Mno =MembNo.trim().substring(0, 3); // dModel to perform DefaultListModel for
String query = "SELECT * FROM member Member
WHERE memb_no = " + (Mno) + ";"; // method operations
try { DefaultListModel dModel = (DefaultListModel)
jList1.getModel();
Class.forName("com.mysql.jdbc.Driver").newInsta // Method to add elements into jList1 control
nce(); for member
Connection con = (Connection) dModel.clear();
DriverManager.getConnection("jdbc:mysql://local
host:3306/Library","root","root"); try {
// Create SQL statement and execute query. Class.forName("com.mysql.jdbc.Driver");
stmt = con.createStatement(); Connection con = (Connection)
rs = stmt.executeQuery(query);

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


{
DriverManager.getConnection("jdbc:mysql://local int x = Ano.length();
host:3306/Library","root","root"); int nl = 4 - x;
while (nl > 0){
// Listing Members Ano = Ano + " ";
stmt = con.createStatement(); nl--;
rs = stmt.executeQuery(SQL); }
while (rs.next()) { }
String Mno = rs.getString("memb_no"); cModel.addElement(Ano + "- " + BTitle);
String MName = }
rs.getString("memb_name"); jList2.setModel(cModel);
// To make the Member no. as 4 digit
because we will extract 4 digit from list value } catch (Exception e) {
// in mouse click event.
JOptionPane.showMessageDialog(this,e.getMessa
if (Mno.length() < 4) ge());
{ e.printStackTrace();
int x = Mno.length(); }
int nl = 4 - x; }
while (nl > 0){
Mno = Mno + " "; private void
nl--; txtMNameActionPerformed(java.awt.event.Action
} Event evt) {
}
dModel.addElement(Mno + "- " + }
MName);
} private void
jList1.setModel(dModel); txtMNamePropertyChange(java.beans.PropertyCh
angeEvent evt) {

// cModel to perform DefaultListModel for }


Library
// method operations private void
DefaultListModel cModel = txtMNameKeyPressed(java.awt.event.KeyEvent
(DefaultListModel) jList2.getModel(); evt) {
// Method to add elements into jList1
control for Library }
cModel.clear();
private void
// Listing books cmdExitActionPerformed(java.awt.event.ActionEv
stmt1 = con.createStatement(); ent evt) {
rs1 = stmt1.executeQuery(SQL1); new MainUI ().setVisible(true);
while (rs1.next()) { dispose();
String Ano = rs1.getString("acc_no"); }
String BTitle = rs1.getString("btitle");
// To make the Accession no. as 4 digit private void
because we will extract 4 digit from list value jList2MouseClicked(java.awt.event.MouseEvent
// in mouse click event. evt) {
if (Ano.length() < 4)

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


// getSelectedValue() method extracts the
current cursor location value into a variable DriverManager.getConnection("jdbc:mysql://local
String MBook = (String) host:3306/Library","root","root");
jList2.getSelectedValue(); // Missue table
// Extract the first 4 characters as Accession stmt2 = con.createStatement();
number into a variable rs2 = stmt.executeQuery(SQL);
String Acno =MBook.trim().substring(0, 3);
String query = "SELECT * FROM Lib WHERE // Tissue table
acc_no = " + Acno + ";"; stmt3 = con.createStatement();
try { rs3 = stmt.executeQuery(SQL);
int Acno =
Class.forName("com.mysql.jdbc.Driver").newInsta Integer.parseInt(txtAcno.getText().trim());
nce(); int Mno =
Connection con = (Connection) Integer.parseInt(txtMNo.getText().trim());
DriverManager.getConnection("jdbc:mysql://local String idt = txtIDate.getText();
host:3306/Library","root","root"); String rdt = idt; // Temporarily assigned for
// Create SQL statement and execute query. testing purpose
stmt1 = con.createStatement(); int code =
rs1 = stmt1.executeQuery(query); JOptionPane.showConfirmDialog(this, "Are you
if (rs1.next()) { sure to add?", "Confirmation Dialog Box",
String bTitle = rs1.getString("btitle"); JOptionPane.YES_NO_CANCEL_OPTION,
String Auth1 = rs1.getString("author1"); JOptionPane.INFORMATION_MESSAGE);
String PID = rs1.getString("pub_id"); if (code == JOptionPane.YES_OPTION) {
String PStatus = rs1.getString("status"); // Record updated into Missue and Tissue
// Displaying the contents in respective tables
text boxes. String strSQL = "INSERT INTO
txtAcno.setText(Acno); missue(acc_no, memb_no, idate, rdate) VALUES
txtBTitle.setText(bTitle); ("+(Acno)+", "+(Mno)+", '"+(idt)+"', '"+(rdt)+"')";
txtAuth1.setText(Auth1); String strSQL1 = "INSERT INTO
txtPID.setText(PID); tissue(acc_no, memb_no, idate, rdate) VALUES ("+
txtStatus.setText(PStatus); (Acno)+", "+(Mno)+", '"+(idt)+"', '"+(rdt)+"')";
} else { stmt2.executeUpdate(strSQL);
JOptionPane.showMessageDialog(null, stmt3.executeUpdate(strSQL1);
"Record does not found in Lib dent table");
} // Change the status as library book
} catch (Exception e) { issued
JOptionPane.showMessageDialog(this, char sta = 'N'; // Lib table
e.getMessage()); String strSQLa = "Update Lib set status
} ='"+(sta)+"' where acc_no = " + (Acno);
} stmt1.executeUpdate(strSQLa);

private void // Change the status as Member has a


cmdIssueActionPerformed(java.awt.event.ActionE book
vent evt) { char stb = 'Y'; // Member table
try { String strSQLb = "Update Member set
Class.forName("com.mysql.jdbc.Driver"); mem_issue ='"+(stb)+"' where memb_no = " +
Connection con = (Connection) (Mno);
stmt.executeUpdate(strSQLb);

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


JOptionPane.showMessageDialog(this, private javax.swing.JTextField txtPID;
"Record update successfully"); private javax.swing.JTextField txtStatus;
} // End of variables declaration
} catch (Exception e) { }
JOptionPane.showMessageDialog(this, *****************************************
e.getMessage()); RETURN BOOK
}
*****************************************
}
import java.sql.*;
/** import javax.swing.JOptionPane;
* @param args the command line arguments import javax.swing.DefaultListModel;
*/
public static void main(String args[]) { public class ReturnUI extends javax.swing.JFrame {
java.awt.EventQueue.invokeLater(new
Runnable() { /** Creates new form ReturnUI */
public void run() { public ReturnUI() {
new IssueUI().setVisible(true); initComponents();
} }
});
} /** This method is called from within the
constructor to
// Variables declaration - do not modify * initialize the form.
private javax.swing.JButton cmdExit; * WARNING: Do NOT modify this code. The
private javax.swing.JButton cmdIssue; content of this method is
private javax.swing.JLabel jLabel1; * always regenerated by the Form Editor.
private javax.swing.JLabel jLabel11; */
private javax.swing.JLabel jLabel12; @SuppressWarnings("unchecked")
private javax.swing.JLabel jLabel13; // <editor-fold defaultstate="collapsed"
private javax.swing.JLabel jLabel2; desc="Generated Code">
private javax.swing.JLabel jLabel3; private void initComponents() {
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5; jLabel1 = new javax.swing.JLabel();
private javax.swing.JLabel jLabel6; txtMName = new javax.swing.JTextField();
private javax.swing.JLabel jLabel7; txtMNo = new javax.swing.JTextField();
private javax.swing.JLabel jLabel8; jLabel2 = new javax.swing.JLabel();
private javax.swing.JLabel jLabel9; txtMStatus = new javax.swing.JTextField();
private javax.swing.JList jList1; jLabel5 = new javax.swing.JLabel();
private javax.swing.JList jList2; jLabel7 = new javax.swing.JLabel();
private javax.swing.JScrollPane jScrollPane1; txtMDate = new javax.swing.JTextField();
private javax.swing.JScrollPane jScrollPane2; jScrollPane1 = new javax.swing.JScrollPane();
private javax.swing.JSeparator jSeparator1; jList1 = new javax.swing.JList();
private javax.swing.JTextField txtAcno; jLabel6 = new javax.swing.JLabel();
private javax.swing.JTextField txtAuth1; cmdExit = new javax.swing.JButton();
private javax.swing.JTextField txtBTitle; jLabel3 = new javax.swing.JLabel();
private javax.swing.JTextField txtIDate; jSeparator1 = new javax.swing.JSeparator();
private javax.swing.JTextField txtMDate; txtAcno = new javax.swing.JTextField();
private javax.swing.JTextField txtMName; jLabel4 = new javax.swing.JLabel();
private javax.swing.JTextField txtMNo; txtBTitle = new javax.swing.JTextField();
private javax.swing.JTextField txtMStatus; jLabel8 = new javax.swing.JLabel();

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


txtAuth = new javax.swing.JTextField(); });
cmdReturn = new javax.swing.JButton();
jLabel9 = new javax.swing.JLabel(); jLabel2.setFont(new java.awt.Font("Arial", 1,
12));
jLabel2.setText("Name");
setDefaultCloseOperation(javax.swing.WindowCon
stants.EXIT_ON_CLOSE); txtMStatus.setFont(new java.awt.Font("Arial",
setTitle("book return - Library Management 1, 10));
System || www.ezindagi.in ||");
setBounds(new java.awt.Rectangle(200, 70, 0, jLabel5.setFont(new java.awt.Font("Arial", 1,
0)); 12));
addWindowFocusListener(new jLabel5.setText("Status");
java.awt.event.WindowFocusListener() {
public void jLabel7.setFont(new java.awt.Font("Arial", 1,
windowGainedFocus(java.awt.event.WindowEvent 12));
evt) { jLabel7.setText("Membership Date");
formWindowGainedFocus(evt);
} txtMDate.setFont(new java.awt.Font("Arial",
public void 1, 10));
windowLostFocus(java.awt.event.WindowEvent
evt) { jList1.setModel(new DefaultListModel());
} jList1.addMouseListener(new
}); java.awt.event.MouseAdapter() {
public void
jLabel1.setFont(new java.awt.Font("Arial", 1, mouseClicked(java.awt.event.MouseEvent evt) {
12)); jList1MouseClicked(evt);
jLabel1.setText("Member No."); }
});
txtMName.addActionListener(new jScrollPane1.setViewportView(jList1);
java.awt.event.ActionListener() {
public void jLabel6.setFont(new
actionPerformed(java.awt.event.ActionEvent evt) { java.awt.Font("Helvetica", 1, 12));
txtMNameActionPerformed(evt);
} jLabel6.setHorizontalAlignment(javax.swing.Swing
}); Constants.CENTER);
txtMName.addPropertyChangeListener(new jLabel6.setText("Select a Member");
java.beans.PropertyChangeListener() {
public void cmdExit.setText("Exit");
propertyChange(java.beans.PropertyChangeEvent cmdExit.addActionListener(new
evt) { java.awt.event.ActionListener() {
txtMNamePropertyChange(evt); public void
} actionPerformed(java.awt.event.ActionEvent evt) {
}); cmdExitActionPerformed(evt);
txtMName.addKeyListener(new }
java.awt.event.KeyAdapter() { });
public void
keyPressed(java.awt.event.KeyEvent evt) { jLabel3.setText("Accession No. ");
txtMNameKeyPressed(evt);
} jLabel4.setText("Title");

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


.addGroup(layout.createParallelGrou
jLabel8.setText("Author"); p(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtMDate,
cmdReturn.setText("Return"); javax.swing.GroupLayout.PREFERRED_SIZE, 100,
cmdReturn.addActionListener(new javax.swing.GroupLayout.PREFERRED_SIZE)
java.awt.event.ActionListener() { .addComponent(txtMNo,
public void javax.swing.GroupLayout.PREFERRED_SIZE, 47,
actionPerformed(java.awt.event.ActionEvent evt) { javax.swing.GroupLayout.PREFERRED_SIZE)
cmdReturnActionPerformed(evt); .addComponent(txtMStatus,
} javax.swing.GroupLayout.PREFERRED_SIZE, 31,
}); javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtMName,
jLabel9.setFont(new java.awt.Font("Arial", 1, javax.swing.GroupLayout.PREFERRED_SIZE, 178,
12)); javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGro
javax.swing.GroupLayout layout = new up()
javax.swing.GroupLayout(getContentPane()); .addGap(13, 13, 13)
getContentPane().setLayout(layout); .addComponent(jLabel6,
layout.setHorizontalGroup( javax.swing.GroupLayout.PREFERRED_SIZE, 104,
javax.swing.GroupLayout.PREFERRED_SIZE)))
layout.createParallelGroup(javax.swing.GroupLayo .addContainerGap(23,
ut.Alignment.LEADING) Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(26, 26, 26) .addContainerGap()
.addGroup(layout.createParallelGroup(jav .addComponent(jSeparator1,
ax.swing.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.DEFAULT_SIZE, 459,
.addGroup(layout.createSequentialGro Short.MAX_VALUE)
up() .addContainerGap())
.addComponent(jScrollPane1, .addGroup(javax.swing.GroupLayout.Alignm
javax.swing.GroupLayout.PREFERRED_SIZE, 138, ent.TRAILING, layout.createSequentialGroup()
javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()
.addGroup(layout.createParallelGrou .addGroup(layout.createParallelGroup(jav
p(javax.swing.GroupLayout.Alignment.LEADING) ax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequential .addGroup(javax.swing.GroupLayout.Ali
Group() gnment.LEADING, layout.createSequentialGroup()
.addGap(36, 36, 36) .addGroup(layout.createParallelGrou
.addGroup(layout.createParallel p(javax.swing.GroupLayout.Alignment.LEADING)
Group(javax.swing.GroupLayout.Alignment.TRAILI .addComponent(jLabel8,
NG) javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1) .addComponent(jLabel3,
.addComponent(jLabel2) javax.swing.GroupLayout.Alignment.TRAILING))
.addComponent(jLabel5))) .addPreferredGap(javax.swing.Layout
.addGroup(layout.createSequential Style.ComponentPlacement.RELATED)
Group() .addGroup(layout.createParallelGrou
.addPreferredGap(javax.swing.La p(javax.swing.GroupLayout.Alignment.LEADING)
youtStyle.ComponentPlacement.RELATED) .addGroup(layout.createSequential
.addComponent(jLabel7))) Group()
.addPreferredGap(javax.swing.Layout
Style.ComponentPlacement.UNRELATED)

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


.addComponent(txtAuth, .addGroup(layout.createParallelGrou
javax.swing.GroupLayout.PREFERRED_SIZE, 220, p(javax.swing.GroupLayout.Alignment.BASELINE)
javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtMNo,
.addGap(18, 18, 18) javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel1))
.addGroup(layout.createSequential .addPreferredGap(javax.swing.Layout
Group() Style.ComponentPlacement.UNRELATED)
.addComponent(txtAcno, .addGroup(layout.createParallelGrou
javax.swing.GroupLayout.PREFERRED_SIZE, 89, p(javax.swing.GroupLayout.Alignment.BASELINE)
javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2)
.addPreferredGap(javax.swing.La .addComponent(txtMName,
youtStyle.ComponentPlacement.UNRELATED) javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(jLabel4) javax.swing.GroupLayout.DEFAULT_SIZE,
.addGap(18, 18, 18) javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtBTitle, .addGap(10, 10, 10)
javax.swing.GroupLayout.PREFERRED_SIZE, 204, .addGroup(layout.createParallelGrou
javax.swing.GroupLayout.PREFERRED_SIZE))) p(javax.swing.GroupLayout.Alignment.BASELINE)
.addPreferredGap(javax.swing.Layout .addComponent(txtMDate,
Style.ComponentPlacement.RELATED, 20, javax.swing.GroupLayout.PREFERRED_SIZE,
Short.MAX_VALUE)) javax.swing.GroupLayout.DEFAULT_SIZE,
.addGroup(layout.createSequentialGro javax.swing.GroupLayout.PREFERRED_SIZE)
up() .addComponent(jLabel7))
.addComponent(cmdReturn) .addGap(18, 18, 18)
.addGap(81, 81, 81) .addGroup(layout.createParallelGrou
.addComponent(cmdExit))) p(javax.swing.GroupLayout.Alignment.BASELINE)
.addGap(34, 34, 34)) .addComponent(jLabel5)
); .addComponent(txtMStatus,
layout.setVerticalGroup( javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
layout.createParallelGroup(javax.swing.GroupLayo javax.swing.GroupLayout.PREFERRED_SIZE))))
ut.Alignment.LEADING) .addPreferredGap(javax.swing.LayoutStyl
.addGroup(layout.createSequentialGroup() e.ComponentPlacement.RELATED)
.addContainerGap() .addComponent(jSeparator1,
.addGroup(layout.createParallelGroup(jav javax.swing.GroupLayout.PREFERRED_SIZE,
ax.swing.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.DEFAULT_SIZE,
.addGroup(layout.createSequentialGro javax.swing.GroupLayout.PREFERRED_SIZE)
up() .addPreferredGap(javax.swing.LayoutStyl
.addComponent(jLabel6) e.ComponentPlacement.UNRELATED)
.addPreferredGap(javax.swing.Layout .addGroup(layout.createParallelGroup(jav
Style.ComponentPlacement.RELATED) ax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jScrollPane1, .addComponent(jLabel3)
javax.swing.GroupLayout.PREFERRED_SIZE, 151, .addComponent(txtAcno,
javax.swing.GroupLayout.PREFERRED_SIZE)) javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(layout.createSequentialGro javax.swing.GroupLayout.DEFAULT_SIZE,
up() javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32) .addComponent(jLabel4)

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


.addComponent(txtBTitle, String SQL3 = "SELECT * FROM Tissue";
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, private void
javax.swing.GroupLayout.PREFERRED_SIZE)) txtMNameActionPerformed(java.awt.event.Action
.addPreferredGap(javax.swing.LayoutStyl Event evt) {
e.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(jav }
ax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8) private void
.addComponent(txtAuth, txtMNamePropertyChange(java.beans.PropertyCh
javax.swing.GroupLayout.PREFERRED_SIZE, angeEvent evt) {
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE) }
.addComponent(jLabel9))
.addPreferredGap(javax.swing.LayoutStyl private void
e.ComponentPlacement.RELATED, 14, txtMNameKeyPressed(java.awt.event.KeyEvent
Short.MAX_VALUE) evt) {
.addGroup(layout.createParallelGroup(jav
ax.swing.GroupLayout.Alignment.BASELINE) }
.addComponent(cmdReturn)
.addComponent(cmdExit)) private void
.addContainerGap()) jList1MouseClicked(java.awt.event.MouseEvent
); evt) {
// getSelectedValue() method extracts the
java.awt.Dimension screenSize = current cursor location value into a variable
java.awt.Toolkit.getDefaultToolkit().getScreenSize( String MembNo = (String)
); jList1.getSelectedValue();
setBounds((screenSize.width-495)/2, // Extract the first 4 characters as Member No
(screenSize.height-340)/2, 495, 340); into a variable
}// </editor-fold> String Mno =MembNo.trim().substring(0, 3);
Statement stmt = null; String query = "SELECT * FROM Member
ResultSet rs = null; WHERE memb_no = " + (Mno) + ";";
char st1 = 'Y'; try {
String SQL = "SELECT * FROM Member WHERE
mem_issue = '" + st1 + "';"; Class.forName("com.mysql.jdbc.Driver").newInsta
nce();
Statement stmt1 = null; Connection con = (Connection)
ResultSet rs1 = null; DriverManager.getConnection("jdbc:mysql://local
char st = 'Y'; // Lib table host:3306/Library","root","root");
String SQL1 = "SELECT * FROM Lib WHERE status // Create SQL statement and execute query.
= '" + st + "';"; stmt = con.createStatement();
rs = stmt.executeQuery(query);
if (rs.next()) {
Statement stmt2 = null; String MName =
ResultSet rs2 = null; rs.getString("memb_name");
String SQL2 = "SELECT * FROM Missue"; String MDate = rs.getString("mdate");
String MStatus =
Statement stmt3 = null; rs.getString("mem_status");
ResultSet rs3 = null;

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


// Displaying the contents in respective txtMName.setEditable(false);
text boxes. txtMDate.setEditable(false);
txtMNo.setText(Mno); txtMStatus.setEditable(false);
txtMName.setText(MName); txtAcno.setEditable(false);
txtMDate.setText(MDate); txtBTitle.setEditable(false);
txtMStatus.setText(MStatus); txtAuth.setEditable(false);
} else { // dModel to perform DefaultListModel for
JOptionPane.showMessageDialog(null, Member
"Record does not found in Member table"); // method operations
} DefaultListModel dModel = (DefaultListModel)
jList1.getModel();
// Method to add elements into jList1 control
// Extrating the Acc_no from Tissue table to for member
find book details in Lib table dModel.clear();
String query1 = "SELECT * FROM Tissue
WHERE memb_no = " + (Mno) + ";"; try {
// Create SQL statement and execute query. Class.forName("com.mysql.jdbc.Driver");
stmt3 = con.createStatement(); Connection con = (Connection)
rs3 = stmt3.executeQuery(query1);
int ACno = 0; DriverManager.getConnection("jdbc:mysql://local
if (rs3.next()) { host:3306/Library","root","root");
ACno = rs3.getInt("acc_no");
txtAcno.setText(String.valueOf(ACno)); // Listing Members
} stmt = con.createStatement();
// Extrating the Library details for Acc_no rs = stmt.executeQuery(SQL);
from Lib table while (rs.next()) {
String query2 = "SELECT * FROM Lib WHERE String Mno = rs.getString("memb_no");
acc_no = " + (ACno) + ";"; String MName =
// Create SQL statement and execute query. rs.getString("memb_name");
stmt1 = con.createStatement(); // To make the Member no. as 4 digit
rs1 = stmt1.executeQuery(query2); because we will extract 4 digit from list value
String BTitle, Auth; // in mouse click event.
if (rs1.next()) {
BTitle = rs1.getString("btitle"); if (Mno.length() < 4)
Auth = rs1.getString("author1"); {
txtBTitle.setText(BTitle); int x = Mno.length();
txtAuth.setText(Auth); int nl = 4 - x;
jLabel9.setText("Issued"); while (nl > 0){
} Mno = Mno + " ";
} catch (Exception e) { nl--;
JOptionPane.showMessageDialog(this, }
e.getMessage()); }
} dModel.addElement(Mno + "- " +
} MName);
}
private void jList1.setModel(dModel);
formWindowGainedFocus(java.awt.event.Window } catch (Exception e) {
Event evt) {
txtMNo.setEditable(false);

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


String strSQLb = "Update Member set
JOptionPane.showMessageDialog(this,e.getMessa mem_issue ='"+(stb)+"' where memb_no = " +
ge()); (Mno);
e.printStackTrace(); stmt.executeUpdate(strSQLb);
} JOptionPane.showMessageDialog(this,
} "Thanks for returning book");
}
private void } catch (Exception e) {
cmdExitActionPerformed(java.awt.event.ActionEv JOptionPane.showMessageDialog(this,
ent evt) { e.getMessage());
new MainUI ().setVisible(true); }
dispose(); }
}
/**
private void * @param args the command line arguments
cmdReturnActionPerformed(java.awt.event.Action */
Event evt) { public static void main(String args[]) {
try { java.awt.EventQueue.invokeLater(new
Class.forName("com.mysql.jdbc.Driver"); Runnable() {
Connection con = (Connection) public void run() {
new ReturnUI().setVisible(true);
DriverManager.getConnection("jdbc:mysql://local }
host:3306/Library","root","root"); });
// Missue table }
int Mno = 0, Acno = 0;
Mno = // Variables declaration - do not modify
Integer.parseInt(txtMNo.getText().trim()); private javax.swing.JButton cmdExit;
Acno = private javax.swing.JButton cmdReturn;
Integer.parseInt(txtAcno.getText().trim()); private javax.swing.JLabel jLabel1;
// Steps to confirm return private javax.swing.JLabel jLabel2;
int opt = private javax.swing.JLabel jLabel3;
JOptionPane.showConfirmDialog(null, "Are you private javax.swing.JLabel jLabel4;
sure to return this book ?"); private javax.swing.JLabel jLabel5;
if (opt == JOptionPane.YES_OPTION) private javax.swing.JLabel jLabel6;
{ private javax.swing.JLabel jLabel7;
String strSQLr = "Delete from Tissue private javax.swing.JLabel jLabel8;
where memb_no = " + (Mno); private javax.swing.JLabel jLabel9;
stmt3.executeUpdate(strSQLr); private javax.swing.JList jList1;
// Change the status as library book private javax.swing.JScrollPane jScrollPane1;
issued private javax.swing.JSeparator jSeparator1;
char sta = 'Y'; // Lib table private javax.swing.JTextField txtAcno;
String strSQLa = "Update Lib set status private javax.swing.JTextField txtAuth;
='"+(sta)+"' where acc_no = " + (Acno); private javax.swing.JTextField txtBTitle;
stmt1.executeUpdate(strSQLa); private javax.swing.JTextField txtMDate;
// Change the status as Member has a private javax.swing.JTextField txtMName;
book private javax.swing.JTextField txtMNo;
char stb = 'N'; // Member table private javax.swing.JTextField txtMStatus;
// End of variables declaration
}

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


*****************************************
PUBLISHER NAVIGATION setDefaultCloseOperation(javax.swing.WindowCon
stants.EXIT_ON_CLOSE);
*****************************************
setTitle("Publisher Record Navigation - Library
Management System || www.ezindagi.in ||");
import java.sql.*;
setBounds(new java.awt.Rectangle(200, 70, 0,
import javax.swing.JOptionPane;
0));
addWindowFocusListener(new
public class PubNavUI extends javax.swing.JFrame
java.awt.event.WindowFocusListener() {
{
public void
windowGainedFocus(java.awt.event.WindowEvent
/** Creates new form PubNavUI */
evt) {
public PubNavUI() {
formWindowGainedFocus(evt);
initComponents();
}
}
public void
windowLostFocus(java.awt.event.WindowEvent
/** This method is called from within the
evt) {
constructor to
}
* initialize the form.
});
* WARNING: Do NOT modify this code. The
content of this method is
jLabel5.setFont(new java.awt.Font("Arial", 1,
* always regenerated by the Form Editor.
12));
*/
jLabel5.setText("Pbone/Mobile");
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed"
jLabel4.setFont(new java.awt.Font("Arial", 1,
desc="Generated Code">
12));
private void initComponents() {
jLabel4.setText("Phone/Mobile");
jLabel5 = new javax.swing.JLabel();
txtPName.addActionListener(new
jLabel4 = new javax.swing.JLabel();
java.awt.event.ActionListener() {
txtPAdd = new javax.swing.JTextField();
public void
txtPName = new javax.swing.JTextField();
actionPerformed(java.awt.event.ActionEvent evt) {
jLabel2 = new javax.swing.JLabel();
txtPNameActionPerformed(evt);
txtPh1 = new javax.swing.JTextField();
}
jLabel3 = new javax.swing.JLabel();
});
txtPh2 = new javax.swing.JTextField();
txtPName.addPropertyChangeListener(new
txtPno = new javax.swing.JTextField();
java.beans.PropertyChangeListener() {
jLabel6 = new javax.swing.JLabel();
public void
jSeparator1 = new javax.swing.JSeparator();
propertyChange(java.beans.PropertyChangeEvent
jLabel1 = new javax.swing.JLabel();
evt) {
jSeparator2 = new javax.swing.JSeparator();
txtPNamePropertyChange(evt);
cmdFirst = new javax.swing.JButton();
}
cmdNext = new javax.swing.JButton();
});
cmdExit = new javax.swing.JButton();
txtPName.addKeyListener(new
cmdPrev = new javax.swing.JButton();
java.awt.event.KeyAdapter() {
cmdLast = new javax.swing.JButton();
public void
jLabel7 = new javax.swing.JLabel();
keyPressed(java.awt.event.KeyEvent evt) {
txtStatus = new javax.swing.JTextField();
txtPNameKeyPressed(evt);
}

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


});
cmdPrev.setText("Previous");
jLabel2.setFont(new java.awt.Font("Arial", 1, cmdPrev.addActionListener(new
12)); java.awt.event.ActionListener() {
jLabel2.setText("Name"); public void
actionPerformed(java.awt.event.ActionEvent evt) {
jLabel3.setFont(new java.awt.Font("Arial", 1, cmdPrevActionPerformed(evt);
12)); }
jLabel3.setText("Address"); });

jLabel6.setFont(new cmdLast.setText("Last");
java.awt.Font("VAGRounded BT", 1, 14)); cmdLast.addActionListener(new
jLabel6.setForeground(new java.awt.Color(0, java.awt.event.ActionListener() {
153, 153)); public void
actionPerformed(java.awt.event.ActionEvent evt) {
jLabel6.setHorizontalAlignment(javax.swing.Swing cmdLastActionPerformed(evt);
Constants.CENTER); }
jLabel6.setText("PUBLISHER INFORMATION"); });

jLabel1.setFont(new java.awt.Font("Arial", 1, jLabel7.setFont(new java.awt.Font("Arial", 1,


12)); 12));
jLabel1.setText("Publisher No./ID"); jLabel7.setText("Status");

cmdFirst.setText("First"); txtStatus.setFont(new java.awt.Font("Arial", 1,


cmdFirst.addActionListener(new 12));
java.awt.event.ActionListener() {
public void javax.swing.GroupLayout layout = new
actionPerformed(java.awt.event.ActionEvent evt) { javax.swing.GroupLayout(getContentPane());
cmdFirstActionPerformed(evt); getContentPane().setLayout(layout);
} layout.setHorizontalGroup(
});
layout.createParallelGroup(javax.swing.GroupLayo
cmdNext.setText("Next"); ut.Alignment.LEADING)
cmdNext.addActionListener(new .addGroup(javax.swing.GroupLayout.Alignm
java.awt.event.ActionListener() { ent.TRAILING, layout.createSequentialGroup()
public void .addComponent(jLabel6,
actionPerformed(java.awt.event.ActionEvent evt) { javax.swing.GroupLayout.DEFAULT_SIZE, 390,
cmdNextActionPerformed(evt); Short.MAX_VALUE)
} .addContainerGap())
}); .addComponent(jSeparator1,
javax.swing.GroupLayout.DEFAULT_SIZE, 400,
cmdExit.setText("Exit"); Short.MAX_VALUE)
cmdExit.addActionListener(new .addComponent(jSeparator2,
java.awt.event.ActionListener() { javax.swing.GroupLayout.DEFAULT_SIZE, 400,
public void Short.MAX_VALUE)
actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(layout.createSequentialGroup()
cmdExitActionPerformed(evt); .addGap(19, 19, 19)
} .addComponent(cmdFirst)
}); .addGap(18, 18, 18)

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


.addComponent(cmdNext)
.addGap(20, 20, 20) layout.createParallelGroup(javax.swing.GroupLayo
.addComponent(cmdPrev) ut.Alignment.LEADING)
.addGap(18, 18, 18) .addGroup(javax.swing.GroupLayout.Alignm
.addComponent(cmdLast) ent.TRAILING, layout.createSequentialGroup()
.addGap(18, 18, 18) .addComponent(jLabel6)
.addComponent(cmdExit) .addPreferredGap(javax.swing.LayoutStyl
.addContainerGap(22, e.ComponentPlacement.RELATED,
Short.MAX_VALUE)) javax.swing.GroupLayout.DEFAULT_SIZE,
.addGroup(layout.createSequentialGroup() Short.MAX_VALUE)
.addGap(22, 22, 22) .addComponent(jSeparator1,
.addGroup(layout.createParallelGroup(jav javax.swing.GroupLayout.PREFERRED_SIZE,
ax.swing.GroupLayout.Alignment.TRAILING) javax.swing.GroupLayout.DEFAULT_SIZE,
.addComponent(jLabel7) javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5) .addGap(21, 21, 21)
.addComponent(jLabel4) .addGroup(layout.createParallelGroup(jav
.addComponent(jLabel1) ax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2) .addComponent(jLabel1)
.addComponent(jLabel3)) .addComponent(txtPno,
.addPreferredGap(javax.swing.LayoutStyl javax.swing.GroupLayout.PREFERRED_SIZE,
e.ComponentPlacement.UNRELATED) javax.swing.GroupLayout.DEFAULT_SIZE,
.addGroup(layout.createParallelGroup(jav javax.swing.GroupLayout.PREFERRED_SIZE))
ax.swing.GroupLayout.Alignment.LEADING) .addGap(18, 18, 18)
.addComponent(txtPno, .addGroup(layout.createParallelGroup(jav
javax.swing.GroupLayout.PREFERRED_SIZE, 47, ax.swing.GroupLayout.Alignment.BASELINE)
javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2)
.addComponent(txtPAdd, .addComponent(txtPName,
javax.swing.GroupLayout.DEFAULT_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE,
Short.MAX_VALUE) javax.swing.GroupLayout.DEFAULT_SIZE,
.addGroup(layout.createParallelGroup(j javax.swing.GroupLayout.PREFERRED_SIZE))
avax.swing.GroupLayout.Alignment.TRAILING, .addGap(18, 18, 18)
false) .addGroup(layout.createParallelGroup(jav
.addComponent(txtPh2, ax.swing.GroupLayout.Alignment.BASELINE)
javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtPAdd,
.addComponent(txtPh1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
Short.MAX_VALUE)) .addComponent(jLabel3))
.addComponent(txtPName, .addPreferredGap(javax.swing.LayoutStyl
javax.swing.GroupLayout.PREFERRED_SIZE, 164, e.ComponentPlacement.UNRELATED)
javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(jav
.addComponent(txtStatus, ax.swing.GroupLayout.Alignment.BASELINE)
javax.swing.GroupLayout.PREFERRED_SIZE, 27, .addComponent(jLabel4)
javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtPh1,
.addContainerGap()) javax.swing.GroupLayout.PREFERRED_SIZE,
); javax.swing.GroupLayout.DEFAULT_SIZE,
layout.setVerticalGroup( javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyl
e.ComponentPlacement.UNRELATED)

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


.addGroup(layout.createParallelGroup(jav }
ax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5) private void
.addComponent(txtPh2, txtPNameActionPerformed(java.awt.event.ActionE
javax.swing.GroupLayout.PREFERRED_SIZE, vent evt) {
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) }
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(jav private void
ax.swing.GroupLayout.Alignment.BASELINE) txtPNamePropertyChange(java.beans.PropertyCha
.addComponent(jLabel7) ngeEvent evt) {
.addComponent(txtStatus,
javax.swing.GroupLayout.PREFERRED_SIZE, }
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) private void
.addGap(20, 20, 20) txtPNameKeyPressed(java.awt.event.KeyEvent
.addComponent(jSeparator2, evt) {
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, }
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyl private void
e.ComponentPlacement.UNRELATED) cmdFirstActionPerformed(java.awt.event.ActionEv
.addGroup(layout.createParallelGroup(jav ent evt) {
ax.swing.GroupLayout.Alignment.BASELINE) try {
.addComponent(cmdFirst) Class.forName("com.mysql.jdbc.Driver");
.addComponent(cmdLast) Connection con = (Connection)
.addComponent(cmdNext)
.addComponent(cmdPrev) DriverManager.getConnection("jdbc:mysql://local
.addComponent(cmdExit)) host:3306/Library","root","root");
.addGap(35, 35, 35)) if (rs.first()) {
); String PubN = rs.getString("pub_id");
String PubName =
java.awt.Dimension screenSize = rs.getString("pub_name");
java.awt.Toolkit.getDefaultToolkit().getScreenSize( String PubAdd =
); rs.getString("pub_address");
setBounds((screenSize.width-416)/2, String PubPh1 =
(screenSize.height-374)/2, 416, 374); rs.getString("pub_phone1");
}// </editor-fold> String PubPh2 =
// Global variables rs.getString("pub_phone2");
Statement stmt = null; String PStatus = rs.getString("status");
ResultSet rs = null; // Displaying the contents in respective
String SQL = "SELECT * FROM publisher"; text boxes.
public void disable_textfields() { txtPno.setText(PubN);
txtPno.setEditable(false); txtPName.setText(PubName);
txtPName.setEditable(false); txtPAdd.setText(PubAdd);
txtPAdd.setEditable(false); txtPh1.setText(PubPh1);
txtPh1.setEditable(false); txtPh2.setText(PubPh2);
txtPh2.setEditable(false); txtStatus.setText(PStatus);
txtStatus.setEditable(false); cmdFirst.setEnabled(false);

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


cmdNext.setEnabled(true); } else {
cmdPrev.setEnabled(false); cmdNext.setEnabled(false);
cmdLast.setEnabled(true); JOptionPane.showMessageDialog(this,
} else { "You are at last record position", "Student",0);
cmdFirst.setEnabled(false); }
cmdNext.setEnabled(false); } catch (Exception e) {
cmdPrev.setEnabled(false); JOptionPane.showMessageDialog(this,
cmdLast.setEnabled(false); e.getMessage());
JOptionPane.showMessageDialog(this, }
"Rhere is no record in table", "Student",0); }
}
} catch (Exception e) { private void
JOptionPane.showMessageDialog(this, cmdExitActionPerformed(java.awt.event.ActionEv
e.getMessage()); ent evt) {
} new MainUI ().setVisible(true);
} dispose();
}
private void
cmdNextActionPerformed(java.awt.event.ActionEv private void
ent evt) { cmdPrevActionPerformed(java.awt.event.ActionEv
try { ent evt) {
Class.forName("com.mysql.jdbc.Driver"); try {
Connection con = (Connection) Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://local
host:3306/Library","root","root"); DriverManager.getConnection("jdbc:mysql://local
if (rs.next()) { host:3306/Library","root","root");
String PubN = rs.getString("pub_id"); if (rs.previous()) {
String PubName = String PubN = rs.getString("pub_id");
rs.getString("pub_name"); String PubName =
String PubAdd = rs.getString("pub_name");
rs.getString("pub_address"); String PubAdd =
String PubPh1 = rs.getString("pub_address");
rs.getString("pub_phone1"); String PubPh1 =
String PubPh2 = rs.getString("pub_phone1");
rs.getString("pub_phone2"); String PubPh2 =
String PStatus = rs.getString("status"); rs.getString("pub_phone2");
// Displaying the contents in respective String PStatus = rs.getString("status");
text boxes. // Displaying the contents in respective
txtPno.setText(PubN); text boxes.
txtPName.setText(PubName); txtPno.setText(PubN);
txtPAdd.setText(PubAdd); txtPName.setText(PubName);
txtPh1.setText(PubPh1); txtPAdd.setText(PubAdd);
txtPh2.setText(PubPh2); txtPh1.setText(PubPh1);
txtStatus.setText(PStatus); txtPh2.setText(PubPh2);
cmdFirst.setEnabled(true); txtStatus.setText(PStatus);
cmdNext.setEnabled(true); cmdFirst.setEnabled(true);
cmdPrev.setEnabled(true); cmdNext.setEnabled(true);
cmdLast.setEnabled(true); cmdPrev.setEnabled(true);

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


cmdLast.setEnabled(true); JOptionPane.showMessageDialog(this,
} else { e.getMessage());
cmdPrev.setEnabled(false); }
JOptionPane.showMessageDialog(this, }
"You are at first position", "Student",0);
} private void
} catch (Exception e) { formWindowGainedFocus(java.awt.event.Window
JOptionPane.showMessageDialog(this, Event evt) {
e.getMessage()); disable_textfields();
} try {
} // Connect to MySQL database
// Don't forget to import the two packages
private void // import java.sql.*;
cmdLastActionPerformed(java.awt.event.ActionEv // import javax.swing.JOptionPane;
ent evt) { Class.forName("com.mysql.jdbc.Driver");
try { Connection con = (Connection)
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://local
host:3306/Library","root","root");
DriverManager.getConnection("jdbc:mysql://local stmt = con.createStatement();
host:3306/Library","root","root"); rs = stmt.executeQuery(SQL);
if (rs.last()) { if (rs.first())
String PubN = rs.getString("pub_id"); {
String PubName = String PubN = rs.getString("pub_id");
rs.getString("pub_name"); String PubName =
String PubAdd = rs.getString("pub_name");
rs.getString("pub_address"); String PubAdd =
String PubPh1 = rs.getString("pub_address");
rs.getString("pub_phone1"); String PubPh1 =
String PubPh2 = rs.getString("pub_phone1");
rs.getString("pub_phone2"); String PubPh2 =
String PStatus = rs.getString("status"); rs.getString("pub_phone2");
// Displaying the contents in respective String PStatus = rs.getString("status");
text boxes. // Displaying the contents in respective
txtPno.setText(PubN); text boxes.
txtPName.setText(PubName); txtPno.setText(PubN);
txtPAdd.setText(PubAdd); txtPName.setText(PubName);
txtPh1.setText(PubPh1); txtPAdd.setText(PubAdd);
txtPh2.setText(PubPh2); txtPh1.setText(PubPh1);
txtStatus.setText(PStatus); txtPh2.setText(PubPh2);
cmdFirst.setEnabled(true); txtStatus.setText(PStatus);
cmdNext.setEnabled(false); cmdFirst.setEnabled(false);
cmdPrev.setEnabled(true); cmdNext.setEnabled(true);
cmdLast.setEnabled(false); cmdPrev.setEnabled(false);
} else { cmdLast.setEnabled(true);
JOptionPane.showMessageDialog(this, }
"You are already at last record", "Student",0); else
} {
} catch (Exception e) { cmdFirst.setEnabled(false);

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


cmdNext.setEnabled(false); *****************************************
cmdPrev.setEnabled(false); PUBLISHER CONSOLE
cmdLast.setEnabled(false);
*****************************************
JOptionPane.showMessageDialog(this,
"Rhere is no record in table", "Student",0);
import java.sql.*;
}
import javax.swing.JOptionPane;
} catch (Exception e) {
JOptionPane.showMessageDialog(this,
public class pubUI extends javax.swing.JFrame {
e.getMessage());
}
/** Creates new form pubUI */
}
public pubUI() {
initComponents();
/**
}
* @param args the command line arguments
*/
/** This method is called from within the
public static void main(String args[]) {
constructor to
java.awt.EventQueue.invokeLater(new
* initialize the form.
Runnable() {
* WARNING: Do NOT modify this code. The
public void run() {
content of this method is
new PubNavUI().setVisible(true);
* always regenerated by the Form Editor.
}
*/
});
@SuppressWarnings("unchecked")
}
// <editor-fold defaultstate="collapsed"
desc="Generated Code">
// Variables declaration - do not modify
private void initComponents() {
private javax.swing.JButton cmdExit;
private javax.swing.JButton cmdFirst;
cmdExit = new javax.swing.JButton();
private javax.swing.JButton cmdLast;
jLabel1 = new javax.swing.JLabel();
private javax.swing.JButton cmdNext;
txtPno = new javax.swing.JTextField();
private javax.swing.JButton cmdPrev;
cmdNew = new javax.swing.JButton();
private javax.swing.JLabel jLabel1;
jLabel2 = new javax.swing.JLabel();
private javax.swing.JLabel jLabel2;
jLabel3 = new javax.swing.JLabel();
private javax.swing.JLabel jLabel3;
jLabel4 = new javax.swing.JLabel();
private javax.swing.JLabel jLabel4;
jLabel5 = new javax.swing.JLabel();
private javax.swing.JLabel jLabel5;
txtPName = new javax.swing.JTextField();
private javax.swing.JLabel jLabel6;
txtPAdd = new javax.swing.JTextField();
private javax.swing.JLabel jLabel7;
txtPh1 = new javax.swing.JTextField();
private javax.swing.JSeparator jSeparator1;
txtPh2 = new javax.swing.JTextField();
private javax.swing.JSeparator jSeparator2;
cmdSave = new javax.swing.JButton();
private javax.swing.JTextField txtPAdd;
jLabel6 = new javax.swing.JLabel();
private javax.swing.JTextField txtPName;
jSeparator1 = new javax.swing.JSeparator();
private javax.swing.JTextField txtPh1;
jSeparator2 = new javax.swing.JSeparator();
private javax.swing.JTextField txtPh2;
cmdClear = new javax.swing.JButton();
private javax.swing.JTextField txtPno;
cmdEdit = new javax.swing.JButton();
private javax.swing.JTextField txtStatus;
// End of variables declaration
}
setDefaultCloseOperation(javax.swing.WindowCon
stants.EXIT_ON_CLOSE);

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


setTitle("Publisher Console - Library jLabel4.setText("Phone/Mobile");
Management System || www.ezindagi.in ||");
setBounds(new java.awt.Rectangle(200, 70, 0, jLabel5.setFont(new java.awt.Font("Arial", 1,
0)); 12));
addWindowFocusListener(new jLabel5.setText("Pbone/Mobile");
java.awt.event.WindowFocusListener() {
public void txtPName.addActionListener(new
windowGainedFocus(java.awt.event.WindowEvent java.awt.event.ActionListener() {
evt) { public void
formWindowGainedFocus(evt); actionPerformed(java.awt.event.ActionEvent evt) {
} txtPNameActionPerformed(evt);
public void }
windowLostFocus(java.awt.event.WindowEvent });
evt) { txtPName.addPropertyChangeListener(new
} java.beans.PropertyChangeListener() {
}); public void
propertyChange(java.beans.PropertyChangeEvent
cmdExit.setText("Exit"); evt) {
cmdExit.addActionListener(new txtPNamePropertyChange(evt);
java.awt.event.ActionListener() { }
public void });
actionPerformed(java.awt.event.ActionEvent evt) { txtPName.addKeyListener(new
cmdExitActionPerformed(evt); java.awt.event.KeyAdapter() {
} public void
}); keyPressed(java.awt.event.KeyEvent evt) {
txtPNameKeyPressed(evt);
jLabel1.setFont(new java.awt.Font("Arial", 1, }
12)); });
jLabel1.setText("Publisher No./ID");
cmdSave.setText("Save");
cmdNew.setText("New"); cmdSave.addActionListener(new
cmdNew.addActionListener(new java.awt.event.ActionListener() {
java.awt.event.ActionListener() { public void
public void actionPerformed(java.awt.event.ActionEvent evt) {
actionPerformed(java.awt.event.ActionEvent evt) { cmdSaveActionPerformed(evt);
cmdNewActionPerformed(evt); }
} });
});
jLabel6.setFont(new
jLabel2.setFont(new java.awt.Font("Arial", 1, java.awt.Font("VAGRounded BT", 1, 14));
12)); jLabel6.setForeground(new java.awt.Color(0,
jLabel2.setText("Name"); 153, 153));

jLabel3.setFont(new java.awt.Font("Arial", 1, jLabel6.setHorizontalAlignment(javax.swing.Swing


12)); Constants.CENTER);
jLabel3.setText("Address"); jLabel6.setText("PUBLISHER INFORMATION");

jLabel4.setFont(new java.awt.Font("Arial", 1, cmdClear.setText("Clear");


12));

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


cmdClear.addActionListener(new .addGroup(layout.createParallelGroup(jav
java.awt.event.ActionListener() { ax.swing.GroupLayout.Alignment.LEADING)
public void .addGroup(layout.createSequentialGro
actionPerformed(java.awt.event.ActionEvent evt) { up()
cmdClearActionPerformed(evt); .addComponent(txtPName,
} javax.swing.GroupLayout.DEFAULT_SIZE, 256,
}); Short.MAX_VALUE)
.addGap(13, 13, 13))
cmdEdit.setText("Edit"); .addComponent(txtPno,
cmdEdit.addActionListener(new javax.swing.GroupLayout.PREFERRED_SIZE, 47,
java.awt.event.ActionListener() { javax.swing.GroupLayout.PREFERRED_SIZE)
public void .addComponent(txtPAdd,
actionPerformed(java.awt.event.ActionEvent evt) { javax.swing.GroupLayout.DEFAULT_SIZE, 269,
cmdEditActionPerformed(evt); Short.MAX_VALUE)
} .addGroup(layout.createParallelGroup(j
}); avax.swing.GroupLayout.Alignment.TRAILING,
false)
javax.swing.GroupLayout layout = new .addComponent(txtPh2,
javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout.Alignment.LEADING)
getContentPane().setLayout(layout); .addComponent(txtPh1,
layout.setHorizontalGroup( javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 98,
layout.createParallelGroup(javax.swing.GroupLayo Short.MAX_VALUE)))
ut.Alignment.LEADING) .addContainerGap())
.addGroup(layout.createSequentialGroup() .addComponent(jSeparator1,
.addGap(33, 33, 33) javax.swing.GroupLayout.DEFAULT_SIZE, 400,
.addComponent(cmdNew) Short.MAX_VALUE)
.addGap(18, 18, 18) .addComponent(jSeparator2,
.addComponent(cmdSave) javax.swing.GroupLayout.DEFAULT_SIZE, 400,
.addGap(18, 18, 18) Short.MAX_VALUE)
.addComponent(cmdEdit) .addGroup(javax.swing.GroupLayout.Alignm
.addGap(18, 18, 18) ent.TRAILING, layout.createSequentialGroup()
.addComponent(cmdClear) .addContainerGap()
.addGap(18, 18, 18) .addComponent(jLabel6,
.addComponent(cmdExit) javax.swing.GroupLayout.DEFAULT_SIZE, 380,
.addContainerGap(26, Short.MAX_VALUE)
Short.MAX_VALUE)) .addContainerGap())
.addGroup(layout.createSequentialGroup() );
.addGap(22, 22, 22) layout.setVerticalGroup(
.addGroup(layout.createParallelGroup(jav
ax.swing.GroupLayout.Alignment.TRAILING) layout.createParallelGroup(javax.swing.GroupLayo
.addComponent(jLabel1) ut.Alignment.LEADING)
.addComponent(jLabel2) .addGroup(javax.swing.GroupLayout.Alignm
.addComponent(jLabel3) ent.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel4) .addComponent(jLabel6)
.addComponent(jLabel5)) .addPreferredGap(javax.swing.LayoutStyl
.addPreferredGap(javax.swing.LayoutStyl e.ComponentPlacement.RELATED,
e.ComponentPlacement.UNRELATED) javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


.addComponent(jSeparator1, .addPreferredGap(javax.swing.LayoutStyl
javax.swing.GroupLayout.PREFERRED_SIZE, e.ComponentPlacement.RELATED)
javax.swing.GroupLayout.DEFAULT_SIZE, .addGroup(layout.createParallelGroup(jav
javax.swing.GroupLayout.PREFERRED_SIZE) ax.swing.GroupLayout.Alignment.BASELINE)
.addGap(21, 21, 21) .addComponent(cmdNew)
.addGroup(layout.createParallelGroup(jav .addComponent(cmdSave)
ax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cmdEdit)
.addComponent(jLabel1) .addComponent(cmdClear)
.addComponent(txtPno, .addComponent(cmdExit))
javax.swing.GroupLayout.PREFERRED_SIZE, .addGap(40, 40, 40))
javax.swing.GroupLayout.DEFAULT_SIZE, );
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18) java.awt.Dimension screenSize =
.addGroup(layout.createParallelGroup(jav java.awt.Toolkit.getDefaultToolkit().getScreenSize(
ax.swing.GroupLayout.Alignment.BASELINE) );
.addComponent(jLabel2) setBounds((screenSize.width-416)/2,
.addComponent(txtPName, (screenSize.height-365)/2, 416, 365);
javax.swing.GroupLayout.PREFERRED_SIZE, }// </editor-fold>
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) private void
.addGap(29, 29, 29) cmdExitActionPerformed(java.awt.event.ActionEv
.addGroup(layout.createParallelGroup(jav ent evt) {
ax.swing.GroupLayout.Alignment.BASELINE) new MainUI ().setVisible(true);
.addComponent(jLabel3) dispose();
.addComponent(txtPAdd, }
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, private void
javax.swing.GroupLayout.PREFERRED_SIZE)) formWindowGainedFocus(java.awt.event.Window
.addGap(27, 27, 27) Event evt) {
.addGroup(layout.createParallelGroup(jav txtPno.setEditable(false);
ax.swing.GroupLayout.Alignment.BASELINE) // Deactivate the Save button when form
.addComponent(jLabel4) loads
.addComponent(txtPh1, cmdSave.setEnabled(false);
javax.swing.GroupLayout.PREFERRED_SIZE, }
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) private void
.addGap(18, 18, 18) cmdNewActionPerformed(java.awt.event.ActionEv
.addGroup(layout.createParallelGroup(jav ent evt) {
ax.swing.GroupLayout.Alignment.LEADING) // Activate the Save button when New button
.addComponent(jLabel5) clicked
.addComponent(txtPh2, cmdSave.setEnabled(true);
javax.swing.GroupLayout.PREFERRED_SIZE, try {
javax.swing.GroupLayout.DEFAULT_SIZE, Class.forName("com.mysql.jdbc.Driver");
javax.swing.GroupLayout.PREFERRED_SIZE)) Connection con = (Connection)
.addGap(16, 16, 16)
.addComponent(jSeparator2, DriverManager.getConnection("jdbc:mysql://local
javax.swing.GroupLayout.PREFERRED_SIZE, host:3306/Library","root","root");
javax.swing.GroupLayout.DEFAULT_SIZE, Statement stmt = null;
javax.swing.GroupLayout.PREFERRED_SIZE)

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


ResultSet rs = null; // ResultSet for Class.forName("com.mysql.jdbc.Driver");
publisher table. Connection con = (Connection)
String SQL = "SELECT * FROM publisher";
stmt = con.createStatement(); // DriverManager.getConnection("jdbc:mysql://local
Connection string for ResultSet - rs. host:3306/Library","root","root");
rs = stmt.executeQuery(SQL); Statement stmt = null;
int pno = 1; ResultSet rs = null;
int PID=0; String SQL = "SELECT * FROM publisher";
while (rs.next()) { stmt = con.createStatement();
PID = rs.getInt("pub_id"); rs = stmt.executeQuery(SQL);
pno++;
} int Pno = Integer.parseInt(txtPno.getText());
PID++; String PName = txtPName.getText();
pno = PID; String PAdd = txtPAdd.getText();
txtPno.setText(Integer.toString(pno)); String Pph1 = txtPh1.getText();
txtPName.setFocusable(true); String Pph2 = txtPh2.getText();
con.close(); char PStatus = 'Y';
rs.close(); int code =
stmt.close(); JOptionPane.showConfirmDialog(this, "Are you
} catch (Exception e) { sure to add?", "Confirmation Dialog Box",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.showMessageDialog(this,e.getMessa JOptionPane.INFORMATION_MESSAGE);
ge()); if (code == JOptionPane.YES_OPTION) {
e.printStackTrace(); String strSQL = "INSERT INTO
} Publisher(pub_id, pub_name, pub_address,
} pub_phone1, pub_phone2, status) VALUES ("+
(Pno)+", '"+(PName)+"', '"+(PAdd)+"', '"+(Pph1)+"',
private void '"+(Pph2)+"', '"+(PStatus)+"')";
txtPNamePropertyChange(java.beans.PropertyCha int rowsEffected =
ngeEvent evt) { stmt.executeUpdate(strSQL);
JOptionPane.showMessageDialog(this,
} "Record added successfully into Publisher table");
}
private void con.close();
txtPNameActionPerformed(java.awt.event.ActionE stmt.close();
vent evt) { rs.close();
cmdSave.setEnabled(false);
} } catch (Exception e) {
JOptionPane.showMessageDialog(this,
private void e.getMessage());
txtPNameKeyPressed(java.awt.event.KeyEvent }
evt) {
}
}
private void
private void cmdClearActionPerformed(java.awt.event.ActionE
cmdSaveActionPerformed(java.awt.event.ActionEv vent evt) {
ent evt) { txtPno.setText("");
try { txtPName.setText("");

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


txtPAdd.setText(""); *****************************************
txtPh1.setText(""); MEMBER CONSOLE
txtPh2.setText("");
****************************************
cmdSave.setEnabled(false);
} import java.sql.*;
import javax.swing.JOptionPane;
private void
cmdEditActionPerformed(java.awt.event.ActionEv public class MembUI extends javax.swing.JFrame {
ent evt) {
this.setVisible(false); /** Creates new form MembUI */
new PubEditUI().setVisible(true); public MembUI() {
} initComponents();
}
/**
* @param args the command line arguments /** This method is called from within the
*/ constructor to
/*public static void main(String args[]) { * initialize the form.
java.awt.EventQueue.invokeLater(new * WARNING: Do NOT modify this code. The
Runnable() { content of this method is
public void run() { * always regenerated by the Form Editor.
new pubUI().setVisible(true); */
new pubUI().setSize(500, 500); @SuppressWarnings("unchecked")
} // <editor-fold defaultstate="collapsed"
}); desc="Generated Code">
}*/ private void initComponents() {

// Variables declaration - do not modify cmdClear = new javax.swing.JButton();


private javax.swing.JButton cmdClear; jSeparator2 = new javax.swing.JSeparator();
private javax.swing.JButton cmdEdit; cmdEdit = new javax.swing.JButton();
private javax.swing.JButton cmdExit; jLabel4 = new javax.swing.JLabel();
private javax.swing.JButton cmdNew; jLabel2 = new javax.swing.JLabel();
private javax.swing.JButton cmdSave; jLabel3 = new javax.swing.JLabel();
private javax.swing.JLabel jLabel1; txtMPh = new javax.swing.JTextField();
private javax.swing.JLabel jLabel2; txtMName = new javax.swing.JTextField();
private javax.swing.JLabel jLabel3; txtMAdd = new javax.swing.JTextField();
private javax.swing.JLabel jLabel4; cmdExit = new javax.swing.JButton();
private javax.swing.JLabel jLabel5; jSeparator1 = new javax.swing.JSeparator();
private javax.swing.JLabel jLabel6; jLabel1 = new javax.swing.JLabel();
private javax.swing.JSeparator jSeparator1; jLabel6 = new javax.swing.JLabel();
private javax.swing.JSeparator jSeparator2; cmdSave = new javax.swing.JButton();
private javax.swing.JTextField txtPAdd; cmdNew = new javax.swing.JButton();
private javax.swing.JTextField txtPName; txtMNo = new javax.swing.JTextField();
private javax.swing.JTextField txtPh1; jLabel7 = new javax.swing.JLabel();
private javax.swing.JTextField txtPh2; txtMDate = new javax.swing.JTextField();
private javax.swing.JTextField txtPno; jLabel8 = new javax.swing.JLabel();
// End of variables declaration jLabel5 = new javax.swing.JLabel();
} txtMFee = new javax.swing.JTextField();
txtMStatus = new javax.swing.JTextField();
cmdDel = new javax.swing.JButton();

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


jLabel9 = new javax.swing.JLabel(); jLabel3.setFont(new java.awt.Font("Arial", 1,
12));
jLabel3.setText("Address");
setDefaultCloseOperation(javax.swing.WindowCon
stants.EXIT_ON_CLOSE); txtMName.addActionListener(new
setTitle("Membership Data Console - Library java.awt.event.ActionListener() {
Management System || www.ezindagi.in ||"); public void
setBounds(new java.awt.Rectangle(200, 70, 0, actionPerformed(java.awt.event.ActionEvent evt) {
0)); txtMNameActionPerformed(evt);
addWindowFocusListener(new }
java.awt.event.WindowFocusListener() { });
public void txtMName.addPropertyChangeListener(new
windowGainedFocus(java.awt.event.WindowEvent java.beans.PropertyChangeListener() {
evt) { public void
formWindowGainedFocus(evt); propertyChange(java.beans.PropertyChangeEvent
} evt) {
public void txtMNamePropertyChange(evt);
windowLostFocus(java.awt.event.WindowEvent }
evt) { });
} txtMName.addKeyListener(new
}); java.awt.event.KeyAdapter() {
public void
cmdClear.setText("Clear"); keyPressed(java.awt.event.KeyEvent evt) {
cmdClear.addActionListener(new txtMNameKeyPressed(evt);
java.awt.event.ActionListener() { }
public void });
actionPerformed(java.awt.event.ActionEvent evt) {
cmdClearActionPerformed(evt); cmdExit.setText("Exit");
} cmdExit.addActionListener(new
}); java.awt.event.ActionListener() {
public void
cmdEdit.setText("Edit"); actionPerformed(java.awt.event.ActionEvent evt) {
cmdEdit.addActionListener(new cmdExitActionPerformed(evt);
java.awt.event.ActionListener() { }
public void });
actionPerformed(java.awt.event.ActionEvent evt) {
cmdEditActionPerformed(evt); jLabel1.setFont(new java.awt.Font("Arial", 1,
} 12));
}); jLabel1.setText("Member No.");

jLabel4.setFont(new java.awt.Font("Arial", 1, jLabel6.setFont(new


12)); java.awt.Font("VAGRounded BT", 1, 14));
jLabel4.setText("Phone/Mobile"); jLabel6.setForeground(new
java.awt.Color(153, 0, 51));
jLabel2.setFont(new java.awt.Font("Arial", 1,
12)); jLabel6.setHorizontalAlignment(javax.swing.Swing
jLabel2.setText("Name"); Constants.CENTER);
jLabel6.setText("MEMBER INFORMATION");

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


cmdSave.setText("Save");
cmdSave.addActionListener(new javax.swing.GroupLayout layout = new
java.awt.event.ActionListener() { javax.swing.GroupLayout(getContentPane());
public void getContentPane().setLayout(layout);
actionPerformed(java.awt.event.ActionEvent evt) { layout.setHorizontalGroup(
cmdSaveActionPerformed(evt);
} layout.createParallelGroup(javax.swing.GroupLayo
}); ut.Alignment.LEADING)
.addComponent(jSeparator1,
cmdNew.setText("New"); javax.swing.GroupLayout.DEFAULT_SIZE, 480,
cmdNew.addActionListener(new Short.MAX_VALUE)
java.awt.event.ActionListener() { .addGroup(layout.createSequentialGroup()
public void .addComponent(jSeparator2,
actionPerformed(java.awt.event.ActionEvent evt) { javax.swing.GroupLayout.DEFAULT_SIZE, 470,
cmdNewActionPerformed(evt); Short.MAX_VALUE)
} .addContainerGap())
}); .addGroup(layout.createSequentialGroup()
.addGap(33, 33, 33)
jLabel7.setFont(new java.awt.Font("Arial", 1, .addComponent(cmdNew)
12)); .addGap(18, 18, 18)
jLabel7.setText("Membership Date"); .addComponent(cmdSave)
.addGap(18, 18, 18)
txtMDate.setFont(new java.awt.Font("Arial", .addComponent(cmdEdit)
1, 10)); .addGap(18, 18, 18)
.addComponent(cmdDel)
jLabel8.setFont(new java.awt.Font("Arial", 1, .addGap(18, 18, 18)
12)); .addComponent(cmdClear)
jLabel8.setText("Membership Fee"); .addGap(18, 18, 18)
.addComponent(cmdExit)
jLabel5.setFont(new java.awt.Font("Arial", 1, .addContainerGap(25,
12)); Short.MAX_VALUE))
jLabel5.setText("Status"); .addGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING, layout.createSequentialGroup()
txtMFee.setFont(new java.awt.Font("Arial", 1, .addGap(33, 33, 33)
10)); .addGroup(layout.createParallelGroup(jav
ax.swing.GroupLayout.Alignment.LEADING)
txtMStatus.setFont(new java.awt.Font("Arial", .addGroup(layout.createSequentialGro
1, 10)); up()
.addGap(19, 19, 19)
cmdDel.setText("Delete"); .addGroup(layout.createParallelGrou
cmdDel.addActionListener(new p(javax.swing.GroupLayout.Alignment.LEADING)
java.awt.event.ActionListener() { .addComponent(jLabel2,
public void javax.swing.GroupLayout.Alignment.TRAILING)
actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(jLabel1,
cmdDelActionPerformed(evt); javax.swing.GroupLayout.Alignment.TRAILING)
} .addComponent(jLabel4,
}); javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3,
jLabel9.setText("YYYY-MM-DD"); javax.swing.GroupLayout.Alignment.TRAILING))

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


.addPreferredGap(javax.swing.Layout .addContainerGap(javax.swing.GroupLayo
Style.ComponentPlacement.RELATED) ut.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(txtMPh, .addGroup(javax.swing.GroupLayout.Alignm
javax.swing.GroupLayout.PREFERRED_SIZE, 118, ent.TRAILING, layout.createSequentialGroup()
javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()
.addPreferredGap(javax.swing.Layout .addComponent(jLabel6,
Style.ComponentPlacement.UNRELATED) javax.swing.GroupLayout.DEFAULT_SIZE, 460,
.addComponent(jLabel7) Short.MAX_VALUE)
.addPreferredGap(javax.swing.Layout .addContainerGap())
Style.ComponentPlacement.UNRELATED) );
.addGroup(layout.createParallelGrou layout.setVerticalGroup(
p(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel9) layout.createParallelGroup(javax.swing.GroupLayo
.addComponent(txtMDate, ut.Alignment.LEADING)
javax.swing.GroupLayout.PREFERRED_SIZE, 100, .addGroup(layout.createSequentialGroup()
javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(javax.swing.GroupLayo
.addGroup(layout.createSequentialGro ut.DEFAULT_SIZE, Short.MAX_VALUE)
up() .addComponent(jLabel6)
.addComponent(jLabel8) .addPreferredGap(javax.swing.LayoutStyl
.addPreferredGap(javax.swing.Layout e.ComponentPlacement.RELATED)
Style.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(jav
.addComponent(txtMFee, ax.swing.GroupLayout.Alignment.LEADING)
javax.swing.GroupLayout.PREFERRED_SIZE, 74, .addGroup(layout.createSequentialGro
javax.swing.GroupLayout.PREFERRED_SIZE) up()
.addGap(18, 18, 18) .addComponent(jSeparator1,
.addComponent(jLabel5) javax.swing.GroupLayout.PREFERRED_SIZE,
.addPreferredGap(javax.swing.Layout javax.swing.GroupLayout.DEFAULT_SIZE,
Style.ComponentPlacement.RELATED) javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtMStatus, .addPreferredGap(javax.swing.Layout
javax.swing.GroupLayout.PREFERRED_SIZE, 31, Style.ComponentPlacement.UNRELATED)
javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGrou
.addGroup(layout.createSequentialGro p(javax.swing.GroupLayout.Alignment.BASELINE)
up() .addComponent(jLabel1)
.addGap(99, 99, 99) .addComponent(txtMNo,
.addComponent(txtMAdd, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE, 272, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGro .addGap(18, 18, 18)
up() .addGroup(layout.createParallelGrou
.addGap(99, 99, 99) p(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtMName, .addComponent(jLabel2)
javax.swing.GroupLayout.PREFERRED_SIZE, 178, .addComponent(txtMName,
javax.swing.GroupLayout.PREFERRED_SIZE)) javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(layout.createSequentialGro javax.swing.GroupLayout.DEFAULT_SIZE,
up() javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(99, 99, 99) .addPreferredGap(javax.swing.Layout
.addComponent(txtMNo, Style.ComponentPlacement.UNRELATED)
javax.swing.GroupLayout.PREFERRED_SIZE, 47, .addGroup(layout.createParallelGrou
javax.swing.GroupLayout.PREFERRED_SIZE))) p(javax.swing.GroupLayout.Alignment.BASELINE)

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


.addComponent(txtMAdd, .addGroup(javax.swing.GroupLayout.Ali
javax.swing.GroupLayout.PREFERRED_SIZE, gnment.TRAILING, layout.createSequentialGroup()
javax.swing.GroupLayout.DEFAULT_SIZE, .addGap(141, 141, 141)
javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel9)
.addComponent(jLabel3)) .addGap(85, 85, 85))))
.addGap(15, 15, 15) );
.addGroup(layout.createParallelGrou
p(javax.swing.GroupLayout.Alignment.BASELINE) java.awt.Dimension screenSize =
.addComponent(txtMPh, java.awt.Toolkit.getDefaultToolkit().getScreenSize(
javax.swing.GroupLayout.PREFERRED_SIZE, );
javax.swing.GroupLayout.DEFAULT_SIZE, setBounds((screenSize.width-496)/2,
javax.swing.GroupLayout.PREFERRED_SIZE) (screenSize.height-314)/2, 496, 314);
.addComponent(jLabel4) }// </editor-fold>
.addComponent(jLabel7) Statement stmt = null;
.addComponent(txtMDate, ResultSet rs = null; // ResultSet for publisher
javax.swing.GroupLayout.PREFERRED_SIZE, table.
javax.swing.GroupLayout.DEFAULT_SIZE, String SQL = "SELECT * FROM Member";
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.Layout private void
Style.ComponentPlacement.RELATED) cmdClearActionPerformed(java.awt.event.ActionE
.addGroup(layout.createParallelGrou vent evt) {
p(javax.swing.GroupLayout.Alignment.BASELINE) txtMNo.setText("");
.addComponent(jLabel8) txtMName.setText("");
.addComponent(txtMFee, txtMAdd.setText("");
javax.swing.GroupLayout.PREFERRED_SIZE, txtMPh.setText("");
javax.swing.GroupLayout.DEFAULT_SIZE, txtMDate.setText("");
javax.swing.GroupLayout.PREFERRED_SIZE) txtMFee.setText("");
.addComponent(jLabel5) txtMStatus.setText("");
.addComponent(txtMStatus, cmdSave.setEnabled(false);
javax.swing.GroupLayout.PREFERRED_SIZE, }
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) private void
.addGap(18, 18, 18) cmdEditActionPerformed(java.awt.event.ActionEv
.addComponent(jSeparator2, ent evt) {
javax.swing.GroupLayout.PREFERRED_SIZE, this.setVisible(false);
javax.swing.GroupLayout.DEFAULT_SIZE, new MembEditUI().setVisible(true);
javax.swing.GroupLayout.PREFERRED_SIZE) }
.addPreferredGap(javax.swing.Layout
Style.ComponentPlacement.RELATED) private void
.addGroup(layout.createParallelGrou txtMNameActionPerformed(java.awt.event.Action
p(javax.swing.GroupLayout.Alignment.BASELINE) Event evt) {
.addComponent(cmdNew)
.addComponent(cmdSave) }
.addComponent(cmdEdit)
.addComponent(cmdDel) private void
.addComponent(cmdClear) txtMNamePropertyChange(java.beans.PropertyCh
.addComponent(cmdExit)) angeEvent evt) {
.addContainerGap(29,
Short.MAX_VALUE)) }

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


mem_issue) VALUES ("+(Mno)+", '"+(MName)+"',
private void '"+(MAdd)+"', '"+(MPh1)+"', '"+(MDate)+"', '"+
txtMNameKeyPressed(java.awt.event.KeyEvent (MEDate)+"', "+(MFee)+", '"+(MStatus)+"', '"+
evt) { (MIssue)+"')";
int rowsEffected =
} stmt.executeUpdate(strSQL);
JOptionPane.showMessageDialog(this,
private void "Record added successfully into Member table");
cmdExitActionPerformed(java.awt.event.ActionEv }
ent evt) { cmdSave.setEnabled(false);
new MainUI ().setVisible(true); } catch (Exception e) {
dispose(); JOptionPane.showMessageDialog(this,
} e.getMessage());
}
private void }
cmdSaveActionPerformed(java.awt.event.ActionEv
ent evt) { private void
try { cmdNewActionPerformed(java.awt.event.ActionEv
Class.forName("com.mysql.jdbc.Driver"); ent evt) {
Connection con = (Connection) txtMStatus.setText("Y");
// Activate the Save button when New button
DriverManager.getConnection("jdbc:mysql://local clicked
host:3306/Library","root","root"); cmdSave.setEnabled(true);
stmt = con.createStatement(); try {
rs = stmt.executeQuery(SQL); Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
int Mno =
Integer.parseInt(txtMNo.getText()); DriverManager.getConnection("jdbc:mysql://local
String MName = txtMName.getText(); host:3306/Library","root","root");
String MAdd = txtMAdd.getText(); stmt = con.createStatement(); //
String MPh1 = txtMPh.getText(); Connection string for ResultSet - rs.
String MDate = txtMDate.getText(); rs = stmt.executeQuery(SQL);
String MEDate = txtMDate.getText(); // int MNO=0, Mno = 0;
This is temporarily assigned same as membership while (rs.next()) {
date MNO = rs.getInt("memb_no");
double MFee = }
Double.parseDouble(txtMFee.getText()); MNO++;
char MStatus = 'Y'; // Member status is Y Mno = MNO;
char MIssue = 'N'; // Book issue status is N txtMNo.setText(Integer.toString(Mno));
txtMName.setFocusable(true);
int code = } catch (Exception e) {
JOptionPane.showConfirmDialog(this, "Are you
sure to add?", "Confirmation Dialog Box", JOptionPane.showMessageDialog(this,e.getMessa
JOptionPane.YES_NO_CANCEL_OPTION, ge());
JOptionPane.INFORMATION_MESSAGE); e.printStackTrace();
if (code == JOptionPane.YES_OPTION) { }
String strSQL = "INSERT INTO }
Member(memb_no, memb_name, memb_add,
memb_phone, mdate, medate, mfee, mem_status,

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


private void private javax.swing.JTextField txtMFee;
formWindowGainedFocus(java.awt.event.Window private javax.swing.JTextField txtMName;
Event evt) { private javax.swing.JTextField txtMNo;
txtMNo.setEditable(false); private javax.swing.JTextField txtMPh;
txtMStatus.setEditable(false); private javax.swing.JTextField txtMStatus;
// Deactivate the Save button when form // End of variables declaration
loads }
cmdSave.setEnabled(false);
} *****************************************
MEMBER LIST UI
private void
*****************************************
cmdDelActionPerformed(java.awt.event.ActionEve
import javax.swing.table.*;
nt evt) {
import java.sql.*;
this.setVisible(false);
import javax.swing.JOptionPane;
new MembDelUI().setVisible(true);
}
public class MListUI extends javax.swing.JFrame {

/**
/** Creates new form MListUI */
* @param args the command line arguments
public MListUI() {
*/
initComponents();
public static void main(String args[]) {
}
java.awt.EventQueue.invokeLater(new
Runnable() {
/** This method is called from within the
public void run() {
constructor to
new MembUI().setVisible(true);
* initialize the form.
}
* WARNING: Do NOT modify this code. The
});
content of this method is
}
* always regenerated by the Form Editor.
*/
// Variables declaration - do not modify
@SuppressWarnings("unchecked")
private javax.swing.JButton cmdClear;
// <editor-fold defaultstate="collapsed"
private javax.swing.JButton cmdDel;
desc="Generated Code">
private javax.swing.JButton cmdEdit;
private void initComponents() {
private javax.swing.JButton cmdExit;
private javax.swing.JButton cmdNew;
jLabel1 = new javax.swing.JLabel();
private javax.swing.JButton cmdSave;
jScrollPane1 = new javax.swing.JScrollPane();
private javax.swing.JLabel jLabel1;
jTable1 = new javax.swing.JTable();
private javax.swing.JLabel jLabel2;
cmdExit = new javax.swing.JButton();
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
setDefaultCloseOperation(javax.swing.WindowCon
private javax.swing.JLabel jLabel6;
stants.EXIT_ON_CLOSE);
private javax.swing.JLabel jLabel7;
setTitle("Member List - Library Management
private javax.swing.JLabel jLabel8;
System || www.ezindagi.in ||");
private javax.swing.JLabel jLabel9;
setBounds(new java.awt.Rectangle(200, 70, 0,
private javax.swing.JSeparator jSeparator1;
0));
private javax.swing.JSeparator jSeparator2;
addWindowFocusListener(new
private javax.swing.JTextField txtMAdd;
java.awt.event.WindowFocusListener() {
private javax.swing.JTextField txtMDate;

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


public void .addGroup(layout.createSequentialGroup()
windowGainedFocus(java.awt.event.WindowEvent .addGroup(layout.createParallelGroup(jav
evt) { ax.swing.GroupLayout.Alignment.LEADING)
formWindowGainedFocus(evt); .addGroup(javax.swing.GroupLayout.Ali
} gnment.TRAILING, layout.createSequentialGroup()
public void .addContainerGap()
windowLostFocus(java.awt.event.WindowEvent .addGroup(layout.createParallelGrou
evt) { p(javax.swing.GroupLayout.Alignment.LEADING)
} .addComponent(jScrollPane1,
}); javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, 499,
jLabel1.setFont(new java.awt.Font("EnviroD", Short.MAX_VALUE)
1, 14)); .addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE, 499,
jLabel1.setHorizontalAlignment(javax.swing.Swing javax.swing.GroupLayout.PREFERRED_SIZE)))
Constants.CENTER); .addGroup(layout.createSequentialGro
jLabel1.setText("Member List"); up()
.addGap(219, 219, 219)
jTable1.setModel(new .addComponent(cmdExit)))
javax.swing.table.DefaultTableModel( .addContainerGap())
new Object [][] { );
{null, null, null, null, null}, layout.setVerticalGroup(
{null, null, null, null, null},
{null, null, null, null, null}, layout.createParallelGroup(javax.swing.GroupLayo
{null, null, null, null, null} ut.Alignment.LEADING)
}, .addGroup(layout.createSequentialGroup()
new String [] { .addGap(20, 20, 20)
"Member No.", "Name", "Address", .addComponent(jLabel1)
"Phone", "Date" .addGap(18, 18, 18)
} .addComponent(jScrollPane1,
)); javax.swing.GroupLayout.PREFERRED_SIZE, 150,
jScrollPane1.setViewportView(jTable1); javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyl
cmdExit.setText("Exit"); e.ComponentPlacement.RELATED)
cmdExit.addActionListener(new .addComponent(cmdExit)
java.awt.event.ActionListener() { .addContainerGap(javax.swing.GroupLayo
public void ut.DEFAULT_SIZE, Short.MAX_VALUE))
actionPerformed(java.awt.event.ActionEvent evt) { );
cmdExitActionPerformed(evt);
} java.awt.Dimension screenSize =
}); java.awt.Toolkit.getDefaultToolkit().getScreenSize(
);
javax.swing.GroupLayout layout = new setBounds((screenSize.width-535)/2,
javax.swing.GroupLayout(getContentPane()); (screenSize.height-285)/2, 535, 285);
getContentPane().setLayout(layout); }// </editor-fold>
layout.setHorizontalGroup(
private void
layout.createParallelGroup(javax.swing.GroupLayo cmdExitActionPerformed(java.awt.event.ActionEv
ut.Alignment.LEADING) ent evt) {

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


new MainUI ().setVisible(true); String MAdd = rs.getString("memb_add");
dispose(); String MPh1 =
} rs.getString("memb_phone");
String MDate = rs.getString("mdate");
private void //System.out.println(Mno + "|" + MName
formWindowGainedFocus(java.awt.event.Window + "|" + MAdd + "|" + MPh1 + "|" + MDate);
Event evt) { model.addRow(new Object[] {Mno,
// Before writting the followng line, you MName, MAdd, MPh1, MDate});
should import the line: }
// import javax.swing.table.*; at the top }
of your application catch (Exception e) {
DefaultTableModel model = JOptionPane.showMessageDialog(this,
(DefaultTableModel) jTable1.getModel(); e.getMessage());
// Clear the existing table }
int rows = model.getRowCount();
if (rows > 0) { }
for (int i = 0; i < rows; i++) {
model.removeRow(0); /**
} * @param args the command line arguments
} */
// SQL Query public static void main(String args[]) {
String query = "SELECT * FROM Member"; java.awt.EventQueue.invokeLater(new
try { Runnable() {
// Connect to MySQL database public void run() {
new MListUI().setVisible(true);
Class.forName("com.mysql.jdbc.Driver").newInsta }
nce(); });
Connection con = (Connection) }
DriverManager.getConnection("jdbc:mysql://local
host:3306/Library","root","root"); // Variables declaration - do not modify
// Create SQL statement and execute query. private javax.swing.JButton cmdExit;
Statement stmt = con.createStatement(); private javax.swing.JLabel jLabel1;
ResultSet rs = stmt.executeQuery(query); private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
// Iterate through the result and display on // End of variables declaration
screen }
while (rs.next()) {
String Mno = rs.getString("memb_no");
String MName =
rs.getString("memb_name");

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


BIBILOGRAPHY

Book : INFORMATICS PRACTICES


Writtten by:

1. Sumita Arora 12th IP

2. Oxford 12th IP

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name


TEACHER REMARKS

LIBRARY MANAGEMENT SYSTEM | Created by : Student Name

You might also like