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

Project Report Java

This document provides an index and overview of a project report on a library management system. The report includes sections on acknowledgements, declarations, introduction, hardware/software requirements, feasibility study, screenshots of the user interface, program code, and the end of the report. The introduction describes the two main parts of any application - the user interface and the program. The feasibility study assesses the economic, technical, and behavioral feasibility of the proposed system. Screenshots show interfaces for login, main menu, adding/deleting books and members, and other functions. The code section provides code examples.

Uploaded by

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

Project Report Java

This document provides an index and overview of a project report on a library management system. The report includes sections on acknowledgements, declarations, introduction, hardware/software requirements, feasibility study, screenshots of the user interface, program code, and the end of the report. The introduction describes the two main parts of any application - the user interface and the program. The feasibility study assesses the economic, technical, and behavioral feasibility of the proposed system. Screenshots show interfaces for login, main menu, adding/deleting books and members, and other functions. The code section provides code examples.

Uploaded by

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

PROJECT REPORT

ON

LIBRARY SYSTEM
SUBMITTED TO
CCS. MANDI
In the partial fulfillment of the requirement
for the award of Degree
Msc-IT (Master Of Science In Information
Technology)
Session( 2009 2010 )

( )

Under the suprivision of :


By:-

Mr. Rohit Bhardwaj Sumeet Kumar, Roll


no- 910536011

Faculty Member Dinesh Kumar ,


Roll no-910536016

1
c.c.s Mandi Sunita Kumari , Roll no-
910536017
(Msc-IT) 4th Semester)

INDEX

S.N CONTENTS PAGE


O NO.
1 Acknowledgement 3
2 Candidate declaration 4
3 Certificate 5
4 Introduction to project 6
5 Hardware & Software 8
requirement
6 Feasibility study 9
7 Output screens 10
8 Code 22
9 End of Report 77

2
ACKNOWLEDGEMENT

During the entire project I have encountered many obstacles.

As with any project work,this one wouldt have been possible


without the contribution of many people behind the scenes.It is
not always easy to make and introduce new things but we are
very happy to complete this project.

I am very thankful to my friends for their


support,encouragement,valuable comments,suggestions and
many innovative ideas in carring out this project.

I would like to thank Ms. Susheela Sharma (Principal) to provide


timely help and provide extra time for our project.

3
I am also thankful to my parents for their love,encouragement
and comfort in my career.

Finally I would like to thank Mr. Rohit Bhardwaj . Because his


advice has greatly enhanced the worth of this project.

CANDIDATES DECLARATION

I,hereby declare that wort which is being presented by


me in this project entitled Library System , in prrtial
fulfillment of the requirement for the award of Degree of
Msc-IT.
By C.C.S. is an authentic record of our own carried out
under the suprivision of Mr. Rohit Bhardwaj . I have not
submitted the matter embodied in this project for the
award of any Degree or Diploma.

4
Sumeet Kumar
Dinesh Kumar
Sunita Kumari

INTRODUCTION TO PROJECT
The areas of computer application are literally too numerous to
mention.Computers have become an integral part of mans
everyday life.They dominate every sphere of life be it
entertainment , education , banking insurance , research ,
medicine , design or manufacting.They continue to grow and open
new horizons of discovery and application.

One of the primary reasons for the immense proof computer is


the speed with which they can accomplish specified
tasks.However computer applications are not always easy to

5
use.This project is made for the purpose of entertainment .It
consist two applications:-

Any application has two parts:-

1 User Interface:This is the screen displayed by the


application.We interact with an application via the interface.Every
application has a user interface in one form or other.The
application asks for and provides the necessary instruction using
the interface.

2 Program:-Computers needs clear cut instruction to tell them


what to do , how to do , and when to do.A set of instructions to
carry out a specified task is called a program.This is what goes in
the background.

A good interface will be:-

Easy to learn
Easy to use
Attractive

SYSTEM STUDY

System Planing:- The most important phase of managing


system project is planning.To launch a new project , we need a
plan detailing every step to be taken.Identifing the need for a

6
system and launching an investigation is the first step in
developing and managing system.The basis for planning in
system analysis is that information is a vital resource and must be
managed efficiently.Also a number of financial resources are
committed to system.So proper management is necessary to
enhance the profit.

Initial Investigation:-Initial investigation is carried out in


order to define the need of the user , problem with the existing
system and to determine whether the request for a new system is
feasible or not

Identification of need:-The success of system largely


depends up on how accurately the problem is defined and
investigated. Not until the problem is clearly defined and
evaluated , should we think about solutions?

7
HARDWARE & SOFTWARE
REQUIREMENT

To run Visual Basic , we must have used certain hardware and


software installed on our system.The system requirements
includes:-

HARDWARE REQUIRMENT:-

80486 or higher microprocessor


A hard disk with a minimum of 2.30
megabytes(MB)
Available space for a full installation
A Cd-Rom dick drive
A colored monitor
32 MB of RAM
Mouse and other peripheral devices

SOFTWARE REQUIRMENT:-

SYSTEM SOFTWARE:-

Micro Soft Window 98 or Upper Version

APPLICATION SOFTWARE:-

JDK 1.4 OR above


MS Access

8
FEASIBILITY STUDY
When the management approves the proposed system , a
feasibility study is initiated to describe the candidate system.
Three keys consideration involved in feasibility analysis:-
Economic , Technical and Behavioral.We determine the
performance and cost effectiveness of the proposed system and if
it meets all the constraints , it is recommended in feasibility
report.

Economic Feasibility
Economic analysis is the most frequently used method for
evaluating the effectiveness of a candidate system , commonly
known as cost benefit analysis , the produced is to determine the
benefits and savings that are expected from a candidate system
compare with them costs , if outweigh costs then the dicision is
made to design and implement the system.

Technical Feasibility
Technical feasibility centers around the hareware and software
required and to what extent these will support our system along
with the technical expertise required.The purposed system is
technically feasible because Visual Basic is compatible and
supports the programs and database design quite efficiently.

Behavioral Feasibility
Computers are known to facilitate change and people are usually
resistant to change.In determining the behavioral feasibility , we
make an estimate of how strong a reaction the user staffs towards
the development of computerized system will and try to keep the

9
user response positive.Our proposed system needs an operator
only simplifies the job without bringing about changes in way of
working of existing system.

LOGIN WINDOW

10
MAIN WINDOW

11
12
ADD NEW BOOK WINDOW

13
ADD NEW MEMBER WINDOW

14
ISSUE BOOK WINDOW

15
RETURN BOOK WINDOW

16
DELETE BOOK WINDOW

17
DELETE MEMBER WINDOW

18
CREATE NEW CLERK WINDOW

19
NEW BOOK CATEGORY WINDOW

20
NEW MEMBER CATEGORY
WINDOW

21
CODING

22
LoginWindow

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class LoginWindow extends Frame implements


ActionListener

Label lblUserName,lblPassWord;

TextField txtUserName,txtPassWord;

Button btnOk,btnCancel;

Panel pnlData;

Connection con;

Statement stmt;

ResultSet rs;

String query;

LoginWindow()

lblUserName=new Label("User Name:",Label.CENTER);

lblPassWord=new Label("Pass Word:",Label.CENTER);

txtUserName=new TextField(30);

23
txtPassWord=new TextField(30);

txtPassWord.setEchoChar('*');

btnOk=new Button("Ok");

btnCancel=new Button("Cancel");

lblUserName.setForeground(new Color(128,0,64));

lblPassWord.setForeground(new Color(128,0,64));

txtUserName.setForeground(new Color(128,0,64));

txtPassWord.setForeground(new Color(128,0,64));

btnOk.setForeground(new Color(128,0,64));

btnCancel.setForeground(new Color(128,0,64));

pnlData=new Panel(new GridLayout(3,2));

btnOk.setBounds(20,90,100,25);

pnlData.add(lblUserName); pnlData.add(txtUserName);

pnlData.add(lblPassWord); pnlData.add(txtPassWord);

pnlData.add(btnOk); pnlData.add(btnCancel);

setLayout(new GridLayout(1,1));

add(pnlData);

pack();

setVisible(true);

setTitle("Library Management System");

btnOk.addActionListener(this);

btnCancel.addActionListener(this);

24
try

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

con=DriverManager.getConnection("jdbc:odbc:MyDsn");

stmt=con.createStatement();

catch(Exception e)

System.out.println(e.toString());

public void actionPerformed(ActionEvent ae)

if(ae.getSource()==btnOk)

try

25
{

String name=txtUserName.getText();

int pass=Integer.parseInt(txtPassWord.getText());

query="select * from users";

rs=stmt.executeQuery(query);

while(rs.next())

if(rs.getString("username").equals(name));

if(rs.getInt("password")==pass);

//this.setVisible(false);

MainWindow m = new
MainWindow();

break;

catch(Exception e)

System.out.println(e.toString());
26
}

if(ae.getSource()==btnCancel)

System.exit(0);

public static void main(String args[])

new LoginWindow();

MainWindow
import java.awt.*;

import java.awt.event.*;

27
public class MainWindow extends Frame implements
ActionListener

TextArea ta;

MenuBar MBar;

Menu mnuFile,mnuEdit,mnuAdmin,mnuHelp;

MenuItem
miNewBook,miNewMember,miSep1,miSep2,miEnd;

MenuItem
miIssueBook,miReturnBook,miSep3,miDelBook,miDelMember;

MenuItem miMakeUser,miAddBCat,miAddMCat,miSep5;

MenuItem miKeyHelp,miAbout;

MainWindow()

ta=new TextArea();

MBar=new MenuBar();

mnuFile=new Menu("file");

mnuEdit=new Menu("Edit");

mnuAdmin=new Menu("Admin");

mnuHelp=new Menu("Help");

miNewBook=new MenuItem("New Book");

miNewMember=new MenuItem("New Member");

miSep1=new MenuItem("-");

28
miSep2=new MenuItem("-");

miEnd=new MenuItem("End");

miIssueBook=new MenuItem("Issue Book");

miReturnBook=new MenuItem("Return Book");

miSep3=new MenuItem("-");

miDelBook=new MenuItem("Delete Book");

miDelMember=new MenuItem("Delete Member");

ta.setBackground(new Color(255,204,153));

miMakeUser=new MenuItem("Make User");

miAddBCat=new MenuItem("Add Book Catg");

miAddMCat=new MenuItem("Add Mem Catg");

miSep5=new MenuItem("-");

miAbout=new MenuItem("About Lyb Sys");

mnuFile.add(miNewBook);

mnuFile.add(miNewMember);

mnuFile.add(miSep1);

mnuFile.add(miSep2);

mnuFile.add(miEnd);

mnuEdit.add(miIssueBook);

mnuEdit.add(miReturnBook);

mnuEdit.add(miSep3);

mnuEdit.add(miDelBook);

29
mnuEdit.add(miDelMember);

mnuAdmin.add(miMakeUser);

mnuAdmin.add(miAddBCat);

mnuAdmin.add(miAddMCat);

mnuAdmin.add(miSep5);

mnuHelp.add(miAbout);

MBar.add(mnuFile);

MBar.add(mnuEdit);

MBar.add(mnuAdmin);

MBar.add(mnuHelp);

setMenuBar(MBar);

add(ta);

setSize(500,500);

setTitle("Library Management System");

setVisible(true);miAbout.addActionListener(this);

miNewBook.addActionListener(this);

miNewMember.addActionListener(this);

miEnd.addActionListener(this);

miIssueBook.addActionListener(this);

miReturnBook.addActionListener(this);

miDelBook.addActionListener(this);

miDelMember.addActionListener(this);

30
miMakeUser.addActionListener(this);

miAddBCat.addActionListener(this);

miAddMCat.addActionListener(this);

public void actionPerformed(ActionEvent ae)

if(ae.getSource()==miAbout)

MyInfo obj=new MyInfo(this,"About Library


System",true);

obj.show();

if(ae.getSource()==miNewBook)

ANBWindow anbw=new ANBWindow();

anbw.show();

if(ae.getSource()==miNewMember)

31
ANMWindow anmw=new ANMWindow();

anmw.show();

if(ae.getSource()==miIssueBook)

IBWindow ibw=new IBWindow();

ibw.show();

if(ae.getSource()==miReturnBook)

RBWindow rbw=new RBWindow();

rbw.show();

if(ae.getSource()==miDelBook)

DBWindow dbw=new DBWindow();

dbw.show();

if(ae.getSource()==miDelMember)

DMWindow dmw=new DMWindow();

dmw.show();

32
}

if(ae.getSource()==miMakeUser)

CNCWindow cncw=new CNCWindow();

cncw.show();

if(ae.getSource()==miAddBCat)

NBCWindow nbcw=new NBCWindow();

nbcw.show();

if(ae.getSource()==miAddMCat)

NMCWindow nmcw=new NMCWindow();

nmcw.show();

if(ae.getSource()==miEnd)

System.exit(0);

33
}

public static void main(String args[])

new MainWindow();

Add New Book Window

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class ANBWindow extends Frame implements


ActionListener

Label
lblBookId,lblBookName,lblBookAuthor,lblReference,lblBookCatego
ry;

TextField txtBookId,txtBookName,txtBookAuthor;

CheckboxGroup cbg;

Checkbox cbYes,cbNo;
34
Choice chCategory;

Button btnOk,btnCancel;

Panel pnlReference;

Connection con;

Statement stmt;

ResultSet rs;

String query;

ANBWindow()

lblBookId=new Label("Book Id:",Label.CENTER);

lblBookName=new Label("Book Name:",Label.CENTER);

lblBookAuthor=new Label("Book
Author:",Label.CENTER);

lblReference=new Label("Reference:",Label.CENTER);

lblBookCategory=new Label("Book
Category:",Label.CENTER);

txtBookId=new TextField(30);

txtBookName=new TextField(30);

txtBookAuthor=new TextField(30);

cbg=new CheckboxGroup();

cbYes=new Checkbox("Yes",true,cbg);

cbNo=new Checkbox("No",false,cbg);
35
chCategory=new Choice();

chCategory.add("java");

chCategory.add("CSharp");

chCategory.add("C Language");

chCategory.add("C ++");

chCategory.add("SQL");

chCategory.add("Oracle");

chCategory.add("DBMS");

chCategory.add("Computer Fundamental");

btnOk=new Button("Ok");

btnCancel=new Button("Cancel");

lblBookId.setForeground(new Color(128,0,64));

blBookName.setForeground(new Color(128,0,64));

lblBookAuthor.setForeground(new Color(128,0,64));

lblReference.setForeground(new Color(128,0,64));

lblBookCategory.setForeground(new Color(128,0,64));

cbYes.setForeground(new Color(128,0,64));

cbNo.setForeground(new Color(128,0,64));

btnOk.setForeground(new Color(128,0,64));

btnCancel.setForeground(new Color(128,0,64));

chCategory.setForeground(new Color(128,0,64));

txtBookId.setForeground(new Color(128,0,64));

36
txtBookName.setForeground(new Color(128,0,64));

txtBookAuthor.setForeground(new Color(128,0,64));

pnlReference=new Panel(new GridLayout(1,2));

pnlReference.add(cbYes);

pnlReference.add(cbNo);

setLayout(new GridLayout(6,2));

add(lblBookId); add(txtBookId);

add(lblBookName); add(txtBookName);

add(lblBookAuthor); add(txtBookAuthor);

add(lblBookCategory); add(chCategory);

add(btnOk); add(btnCancel);

btnCancel.addActionListener(this);

btnOk.addActionListener(this);

setSize(500,500);

setTitle("Add New Book");

setVisible(true);

try

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

con=DriverManager.getConnection("jdbc:odbc:MyDsn");

37
stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);

catch(Exception e)

System.out.println(e.toString());

public void actionPerformed(ActionEvent ae)

if(ae.getSource()==btnOk)

try

int bookid=Integer.parseInt(txtBookId.getText());

String bookname=txtBookName.getText();

String bookauthor=txtBookAuthor.getText();

query="INSERT INTO Books


(BookId,BookName,BookAuthor) VALUES ('" + bookid + "','" +
bookname + "','" + bookauthor + "')";

38
System.out.println(query);

int result=stmt.executeUpdate(query);

catch(Exception e)

System.out.println(e.toString());

if(ae.getSource()==btnCancel)

MainWindow mw=new MainWindow();

mw.show();

public static void main(String args[])

new ANBWindow();

39
Add New Member Window

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class ANBWindow extends Frame implements


ActionListener

Label
lblBookId,lblBookName,lblBookAuthor,lblReference,lblBookCatego
ry;

TextField txtBookId,txtBookName,txtBookAuthor;

CheckboxGroup cbg;

Checkbox cbYes,cbNo;

Choice chCategory;

Button btnOk,btnCancel;

Panel pnlReference;

Connection con;

Statement stmt;

ResultSet rs;

String query;

ANBWindow()

40
{

lblBookId=new Label("Book Id:",Label.CENTER);

lblBookName=new Label("Book Name:",Label.CENTER);

lblBookAuthor=new Label("Book
Author:",Label.CENTER);

lblReference=new Label("Reference:",Label.CENTER);

lblBookCategory=new Label("Book
Category:",Label.CENTER);

txtBookId=new TextField(30);

txtBookName=new TextField(30);

txtBookAuthor=new TextField(30);

cbg=new CheckboxGroup();

cbYes=new Checkbox("Yes",true,cbg);

cbNo=new Checkbox("No",false,cbg);

chCategory=new Choice();

chCategory.add("java");

chCategory.add("CSharp");

chCategory.add("C Language");

chCategory.add("C ++");

chCategory.add("SQL");

chCategory.add("Oracle");

chCategory.add("DBMS");
41
chCategory.add("Computer Fundamental");

btnOk=new Button("Ok");

btnCancel=new Button("Cancel");

lblBookId.setForeground(new Color(128,0,64));

blBookName.setForeground(new Color(128,0,64));

lblBookAuthor.setForeground(new Color(128,0,64));

lblReference.setForeground(new Color(128,0,64));

lblBookCategory.setForeground(new Color(128,0,64));

cbYes.setForeground(new Color(128,0,64));

cbNo.setForeground(new Color(128,0,64));

btnOk.setForeground(new Color(128,0,64));

btnCancel.setForeground(new Color(128,0,64));

chCategory.setForeground(new Color(128,0,64));

txtBookId.setForeground(new Color(128,0,64));

txtBookName.setForeground(new Color(128,0,64));

txtBookAuthor.setForeground(new Color(128,0,64));

pnlReference=new Panel(new GridLayout(1,2));

pnlReference.add(cbYes);

pnlReference.add(cbNo);

setLayout(new GridLayout(6,2));

add(lblBookId); add(txtBookId);

add(lblBookName); add(txtBookName);

42
add(lblBookAuthor); add(txtBookAuthor);

add(lblBookCategory); add(chCategory);

add(btnOk); add(btnCancel);

btnCancel.addActionListener(this);

btnOk.addActionListener(this);

setSize(500,500);

setTitle("Add New Book");

setVisible(true);

try

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

con=DriverManager.getConnection("jdbc:odbc:MyDsn");

stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);

catch(Exception e)

System.out.println(e.toString());

43
}

public void actionPerformed(ActionEvent ae)

if(ae.getSource()==btnOk)

try

int bookid=Integer.parseInt(txtBookId.getText());

String bookname=txtBookName.getText();

String bookauthor=txtBookAuthor.getText();

query="INSERT INTO Books


(BookId,BookName,BookAuthor) VALUES ('" + bookid + "','" +
bookname + "','" + bookauthor + "')";

System.out.println(query);

int result=stmt.executeUpdate(query);

catch(Exception e)

System.out.println(e.toString());

44
if(ae.getSource()==btnCancel)

MainWindow mw=new MainWindow();

mw.show();

public static void main(String args[])

new ANBWindow();

Issue Book Window

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class IBWindow extends Frame implements


ActionListener,FocusListener

Label lblBookId,lblBookName,lblBookAuthor,lblBookCategory,
lblMemberId,lblMemberName,lblIssueDate,lblReturnDate;

45
TextField
txtBookId,txtBookName,txtBookAuthor,txtBookCategory,
txtMemberId,txtMemberName,txtIssueDate,txtReturnDate;

Button btnOk,btnCancel;

Connection con;

Statement stmt;

ResultSet rs;

String query;

IBWindow()

lblBookId=new Label("Book Id:",Label.CENTER);

lblBookName=new Label("Book Name:",Label.CENTER);

lblBookAuthor=new Label("Book
Author:",Label.CENTER);

lblBookCategory=new Label("Book
Category:",Label.CENTER);

lblMemberId=new Label("Member Id:",Label.CENTER);

lblMemberName=new Label("Member
Name:",Label.CENTER);

lblIssueDate=new Label("IssueDate:",Label.CENTER);

lblReturnDate=new Label("Return
Date:",Label.CENTER);

txtBookId=new TextField(30);

46
txtBookName=new TextField(30);

txtBookAuthor=new TextField(30);

txtBookCategory=new TextField(30);

txtMemberId=new TextField(30);

txtMemberName=new TextField(30);

txtIssueDate=new TextField(30);

txtReturnDate=new TextField(30);

btnOk=new Button("Ok");

btnCancel=new Button("Cancel");

lblBookId.setForeground(new Color(128,0,64));

lblBookName.setForeground(new Color(128,0,64));

lblBookAuthor.setForeground(new Color(128,0,64));

lblBookCategory.setForeground(new Color(128,0,64));

lblMemberId.setForeground(new Color(128,0,64));

lblMemberName.setForeground(new Color(128,0,64));

lblIssueDate.setForeground(new Color(128,0,64));

lblReturnDate.setForeground(new Color(128,0,64));

txtBookId.setForeground(new Color(128,0,64));

txtBookName.setForeground(new Color(128,0,64));

txtBookAuthor.setForeground(new Color(128,0,64));

txtBookCategory.setForeground(new Color(128,0,64));

txtMemberId.setForeground(new Color(128,0,64));

47
txtMemberName.setForeground(new Color(128,0,64));

txtIssueDate.setForeground(new Color(128,0,64));

txtReturnDate.setForeground(new Color(128,0,64));

btnOk.setForeground(new Color(128,0,64));

btnCancel.setForeground(new Color(128,0,64));

setLayout(new GridLayout(9,2));

add(lblBookId); add(txtBookId);

add(lblBookName); add(txtBookName);

add(lblBookAuthor); add(txtBookAuthor);

add(lblBookCategory); add(txtBookCategory);

add(lblMemberId); add(txtMemberId);

add(lblMemberName); add(txtMemberName);

add(lblIssueDate); add(txtIssueDate);

add(lblReturnDate); add(txtReturnDate);

add(btnOk); add(btnCancel);

btnCancel.addActionListener(this);

btnOk.addActionListener(this);

txtBookId.addFocusListener(this);

txtMemberId.addFocusListener(this);

setSize(500,500);

setTitle("Issue Book");

setVisible(true);

48
try

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

con=DriverManager.getConnection("jdbc:odbc:MyDsn");

stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);

catch(Exception e)

System.out.println(e.toString());

public void actionPerformed(ActionEvent ae)

if(ae.getSource()==btnCancel)

MainWindow mw=new MainWindow();

49
mw.show();

if(ae.getSource()==btnOk)

try

String id =txtMemberId.getText();

String bid= txtBookId.getText();

query="UPDATE Books set MId="+id+" where


BookId='"+bid+"'";

System.out.println(query);

int result=stmt.executeUpdate(query);

catch(Exception e)

System.out.println(e.toString());

50
}

public void focusLost(FocusEvent fe)

try

if(fe.getSource()==txtBookId)

String id = txtBookId.getText();

query = "Select * from Books where BookId='"+id+"'";

rs = stmt.executeQuery(query);

while(rs.next())

txtBookName.setText(rs.getString("BookName"));

txtBookAuthor.setText(rs.getString("BookAuthor"));

txtBookCategory.setText(rs.getString("BookCat"));

if(fe.getSource()==txtMemberId)

51
String id = txtMemberId.getText();

query = "Select * from Members where id="+id;

rs = stmt.executeQuery(query);

while(rs.next())

txtMemberName.setText(rs.getString("Mname"));

catch(Exception e)

System.out.println(e.toString());

public void focusGained(FocusEvent fe)

52
public static void main(String args[])

new IBWindow();

Return Book Window


import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class RBWindow extends Frame implements


ActionListener,FocusListener

Label lblBookId,lblBookName,lblBookIssueTo;

TextField txtBookId,txtBookName,txtBookIssueTo;

Button btnReturnBook,btnCancel;

Connection con;

Statement stmt;

ResultSet rs;

53
String query;

RBWindow()

lblBookId=new Label("Book Id:",Label.CENTER);

lblBookName=new Label("Book Name:",Label.CENTER);

lblBookIssueTo=new Label("Book Issued


To:",Label.CENTER);

txtBookId=new TextField(30);

txtBookName=new TextField(30);

txtBookIssueTo=new TextField(30);

btnReturnBook=new Button("Return Book");

btnCancel=new Button("Cancel");

lblBookId.setForeground(new Color(128,0,64));

lblBookName.setForeground(new Color(128,0,64));

lblBookIssueTo.setForeground(new Color(128,0,64));

txtBookId.setForeground(new Color(128,0,64));

txtBookName.setForeground(new Color(128,0,64));

txtBookIssueTo.setForeground(new Color(128,0,64));

btnReturnBook.setForeground(new Color(128,0,64));

btnCancel.setForeground(new Color(128,0,64));

setLayout(new GridLayout(4,2));

54
add(lblBookId); add(txtBookId);

add(lblBookName); add(txtBookName);

add(lblBookIssueTo); add(txtBookIssueTo);

add(btnReturnBook); add(btnCancel);

btnCancel.addActionListener(this);

btnReturnBook.addActionListener(this);

txtBookId.addFocusListener(this);

setSize(500,500);

setTitle("Return Book");

setVisible(true);

try

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

con=DriverManager.getConnection("jdbc:odbc:MyDsn");

stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);

catch(Exception e)

55
System.out.println(e.toString());

public void actionPerformed(ActionEvent ae)

if(ae.getSource()==btnCancel)

MainWindow mw=new MainWindow();

mw.show();

if(ae.getSource()==btnReturnBook)

try

int id=Integer.parseInt(txtBookId.getText());

query="Update Books SET MId=0 WHERE


BookId='"+id+"'";

System.out.println(query);

int result=stmt.executeUpdate(query);

56
System.out.println(result+" record(s) updated");

catch(Exception e)

System.out.println(e.toString());

public void focusLost(FocusEvent fe)

try

if(fe.getSource()==txtBookId)

String id = txtBookId.getText();

query = "Select BookName from Books where


BookId='"+id+"'";

rs = stmt.executeQuery(query);

while(rs.next())

57
{

txtBookName.setText(rs.getString("BookName"));

catch(Exception e)

System.out.println(e.toString());

public void focusGained(FocusEvent fe)

public static void main(String args[])

new RBWindow();

58
}

Delete Book Window


import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class DBWindow extends Frame implements ActionListener

Label lblBookId,lblBookName,lblBookAuthor;

TextField txtBookId,txtBookName,txtBookAuthor;

Button btnDeleteBook,btnCancel;

Connection con;

Statement stmt;

ResultSet rs;

String query;

DBWindow()

lblBookId=new Label("Book Id:",Label.CENTER);

lblBookName=new Label("Book Name:",Label.CENTER);

lblBookAuthor=new Label("Book
Author:",Label.CENTER);

txtBookId=new TextField(30);

59
txtBookName=new TextField(30);

txtBookAuthor=new TextField(30);

btnDeleteBook=new Button("Delete Book");

btnCancel=new Button("Cancel");

lblBookId.setForeground(new Color(128,0,64));

lblBookName.setForeground(new Color(128,0,64));

lblBookAuthor.setForeground(new Color(128,0,64));

txtBookId.setForeground(new Color(128,0,64));

txtBookName.setForeground(new Color(128,0,64));

txtBookAuthor.setForeground(new Color(128,0,64));

btnDeleteBook.setForeground(new Color(128,0,64));

btnCancel.setForeground(new Color(128,0,64));

setLayout(new GridLayout(4,2));

add(lblBookId); add(txtBookId);

add(lblBookName); add(txtBookName);

add(lblBookAuthor); add(txtBookAuthor);

add(btnDeleteBook); add(btnCancel);

btnCancel.addActionListener(this);

btnDeleteBook.addActionListener(this);

setSize(500,500);

setTitle("Delete Book");

setVisible(true);

60
try

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

con=DriverManager.getConnection("jdbc:odbc:MyDsn");

stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);

catch(Exception e)

System.out.println(e.toString());

public void actionPerformed(ActionEvent ae)

if(ae.getSource()==btnDeleteBook)

try

int id=Integer.parseInt(txtBookId.getText());

61
query="DELETE * FROM Books WHERE
bookid='"+id+"'";

System.out.println(query);

int result=stmt.executeUpdate(query);

catch(Exception e)

System.out.println(e.toString());

if(ae.getSource()==btnCancel)

MainWindow mw=new MainWindow();

mw.show();

public static void main(String args[])

new DBWindow();

62
Delete Member Window
import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class DMWindow extends Frame implements ActionListener

Label lblMemberId,lblMemberName,lblCategory;

TextField txtMemberId,txtMemberName,txtCategory;

Button btnDeleteMember,btnCancel;

Connection con;

Statement stmt;

ResultSet rs;

String query;

DMWindow()

lblMemberId=new Label("Member Id:",Label.CENTER);

lblMemberName=new Label("Member
Name:",Label.CENTER);

lblCategory=new Label("Category:",Label.CENTER);

txtMemberId=new TextField(30);

txtMemberName=new TextField(30);

63
txtCategory=new TextField(30);

btnDeleteMember=new Button("Delete Member");

btnCancel=new Button("Cancel");

lblMemberId.setForeground(new Color(128,0,64));

lblMemberName.setForeground(new Color(128,0,64));

lblCategory.setForeground(new Color(128,0,64));

txtMemberId.setForeground(new Color(128,0,64));

txtMemberName.setForeground(new Color(128,0,64));

txtCategory.setForeground(new Color(128,0,64));

btnDeleteMember.setForeground(new Color(128,0,64));

btnCancel.setForeground(new Color(128,0,64));

setLayout(new GridLayout(4,2));

add(lblMemberId); add(txtMemberId);

add(lblMemberName); add(txtMemberName);

add(lblCategory); add(txtCategory);

add(btnDeleteMember); add(btnCancel);

btnCancel.addActionListener(this);

btnDeleteMember.addActionListener(this);

setSize(500,500);

setTitle("Delete Member");

setVisible(true);

try

64
{

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

con=DriverManager.getConnection("jdbc:odbc:MyDsn");

stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);

catch(Exception e)

System.out.println(e.toString());

public void actionPerformed(ActionEvent ae)

if(ae.getSource()==btnDeleteMember)

try

int id=Integer.parseInt(txtMemberId.getText());

query="DELETE * FROM Members WHERE id="+id;

System.out.println(query);

int result=stmt.executeUpdate(query);

65
}

catch(Exception e)

System.out.println(e.toString());

if(ae.getSource()==btnCancel)

MainWindow mw=new MainWindow();

mw.show();

public static void main(String args[])

new DMWindow();

Create New Clerk Window


66
import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class CNCWindow extends Frame implements


ActionListener

Label lblClerkId,lblPassWord;

TextField txtClerkId,txtPassWord;

Button btnOk,btnCancel;

Connection con;

Statement stmt;

ResultSet rs;

String query;

CNCWindow()

lblClerkId=new Label("Clerk ID:",Label.LEFT);

lblPassWord=new Label("PassWord:",Label.LEFT);

txtClerkId=new TextField(30);

txtPassWord=new TextField(30);

txtPassWord.setEchoChar('*');

btnOk=new Button("Ok");

btnCancel=new Button("Cancel");

67
lblClerkId.setForeground(new Color(128,0,64));

lblPassWord.setForeground(new Color(128,0,64));

txtClerkId.setForeground(new Color(128,0,64));

txtPassWord.setForeground(new Color(128,0,64));

btnOk.setForeground(new Color(128,0,64));

btnCancel.setForeground(new Color(128,0,64));

setLayout(new GridLayout(3,2));

add(lblClerkId); add(txtClerkId);

add(lblPassWord); add(txtPassWord);

add(btnOk); add(btnCancel);

btnCancel.addActionListener(this);

btnOk.addActionListener(this);

setSize(500,500);

setTitle("Create New Clerk");

setVisible(true);

try

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

con=DriverManager.getConnection("jdbc:odbc:MyDsn");

stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);

68
}

catch(Exception e)

System.out.println(e.toString());

public void actionPerformed(ActionEvent ae)

if(ae.getSource()==btnOk)

try

String id=txtClerkId.getText();

String password=txtPassWord.getText();

query="INSERT INTO Clerks VALUES ('" + id + "','" +


password + "')";

System.out.println(query);

int result=stmt.executeUpdate(query);

catch(Exception e)

System.out.println(e.toString());

69
}

if(ae.getSource()==btnCancel)

MainWindow mw=new MainWindow();

mw.show();

public static void main(String args[])

new CNCWindow();

New Book Category Window


import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class NBCWindow extends Frame implements


ActionListener

70
Label lblCategory;

TextField txtCategory;

Button btnOk,btnCancel;

Connection con;

Statement stmt;

ResultSet rs;

String query;

NBCWindow()

lblCategory=new Label("Category:",Label.LEFT);

txtCategory=new TextField(30);

btnOk=new Button("Ok");

btnCancel=new Button("Cancel");

lblCategory.setForeground(new Color(128,0,64));

txtCategory.setForeground(new Color(128,0,64));

btnOk.setForeground(new Color(128,0,64));

btnCancel.setForeground(new Color(128,0,64));

setLayout(new GridLayout(2,2));

add(lblCategory); add(txtCategory);

add(btnOk); add(btnCancel);

btnCancel.addActionListener(this);

btnOk.addActionListener(this);

71
setSize(500,500);

setTitle("New Book Category");

setVisible(true);

try

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

con=DriverManager.getConnection("jdbc:odbc:MyDsn");

stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);

catch(Exception e)

System.out.println(e.toString());

public void actionPerformed(ActionEvent ae)

if(ae.getSource()==btnOk)

try

72
String name=txtCategory.getText();

query="INSERT INTO Bcat VALUES ('" + name + "')";

System.out.println(query);

int result=stmt.executeUpdate(query);

catch(Exception e)

System.out.println(e.toString());

if(ae.getSource()==btnCancel)

MainWindow mw=new MainWindow();

mw.show();

public static void main(String args[])

new NBCWindow();

73
New Member Category Window
import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class NMCWindow extends Frame implements


ActionListener

Label lblCategory,lblDaysIssued,lblNoOfBooks;

TextField txtNoOfBooks,txtDaysIssued,txtCategory;

Button btnOk,btnCancel;

Connection con;

Statement stmt;

ResultSet rs;

String query;

NMCWindow()

lblDaysIssued=new Label("Days
Issued:",Label.CENTER);

lblNoOfBooks=new Label("No. Of
Books:",Label.CENTER);

lblCategory=new Label("Category:",Label.CENTER);

txtDaysIssued=new TextField(30);

txtNoOfBooks=new TextField(30);

74
txtCategory=new TextField(30);

btnOk=new Button("Ok");

btnCancel=new Button("Cancel");

lblCategory.setForeground(new Color(128,0,64));

txtCategory.setForeground(new Color(128,0,64));

lblDaysIssued.setForeground(new Color(128,0,64));

txtDaysIssued.setForeground(new Color(128,0,64));

lblNoOfBooks.setForeground(new Color(128,0,64));

txtNoOfBooks.setForeground(new Color(128,0,64));

btnOk.setForeground(new Color(128,0,64));

btnCancel.setForeground(new Color(128,0,64));

setLayout(new GridLayout(4,2));

add(lblCategory); add(txtCategory);

add(lblDaysIssued); add(txtDaysIssued);

add(lblNoOfBooks); add(txtNoOfBooks);

add(btnOk); add(btnCancel);

btnCancel.addActionListener(this);

btnOk.addActionListener(this);

setSize(500,500);

setTitle("New Member Category");

setVisible(true);

75
try

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

con=DriverManager.getConnection("jdbc:odbc:MyDsn");

stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);

catch(Exception e)

System.out.println(e.toString());

public void actionPerformed(ActionEvent ae)

if(ae.getSource()==btnOk)

try

String category=txtCategory.getText();

int di=Integer.parseInt(txtDaysIssued.getText());

int nob=Integer.parseInt(txtNoOfBooks.getText());

76
query="INSERT INTO Mecat (CName,BImt,DImt) VALUES ('" +
category + "','" + di + "','" + nob + "')";

System.out.println(query);

int result=stmt.executeUpdate(query);

catch(Exception e)

System.out.println(e.toString());

if(ae.getSource()==btnCancel)

MainWindow mw=new MainWindow();

mw.show();

public static void main(String args[])

new NMCWindow();

77
Dialog Window
import java.awt.*;

import java.awt.event.*;

public class MyInfo extends Dialog implements ActionListener

Label
lblText4,lblText5,lblText6,lblText7,lblText8,lblText9,lblText10,lblText
11,lblText12,lblText13;

Button btnOk;

MyInfo(Frame f,String t,boolean m)

super(f,t,m);

lblText4=new Label(" Created a design by:


");

lblText5=new Label(" ");

lblText6=new Label(" Sumeet Kumar ( Roll No -


910536011 )");

lblText7=new Label("
");

lblText8=new Label(" Dinesh Kumar (Roll No -


910536016)");

lblText9=new Label(" &


");

78
lblText12=new Label(" Sunita Kumari ( Roll No -
910536017 )");

lblText13=new Label(" ");

lblText10=new Label(" ");

lblText11=new Label(" Msc-IT 4th


Semester") ;

btnOk=new Button("Ok");

lblText4.setForeground(new Color(128,0,64));

lblText5.setForeground(new Color(128,0,64));

lblText6.setForeground(new Color(128,0,64));

lblText7.setForeground(new Color(128,0,64));

lblText8.setForeground(new Color(128,0,64));

lblText9.setForeground(new Color(128,0,64));

lblText10.setForeground(new Color(128,0,64));

lblText11.setForeground(new Color(128,0,64));

lblText12.setForeground(new Color(128,0,64));

lblText13.setForeground(new Color(128,0,64));

btnOk.setForeground(new Color(128,0,64));

setLayout(new GridLayout(11,1));

add(lblText4);

add(lblText5);

add(lblText6);

add(lblText7);
79
add(lblText8);

add(lblText9);

add(lblText12);

add(lblText13);

add(lblText10);

add(lblText11);

add(btnOk);

pack();

btnOk.addActionListener(this);

public void actionPerformed(ActionEvent ae)

this.dispose();

About Window

import java.awt.*;

import java.awt.event.*;

public class AboutWindow extends Frame implements


ActionListener

80
{

TextArea ta;

MenuBar MBar;

Menu mnuFile,mnuEdit,mnuOptions,mnuAdmin,mnuHelp;

MenuItem MnuItemAbout;

AboutWindow()

ta=new TextArea();

MBar=new MenuBar();

mnuFile=new Menu("file");

mnuEdit=new Menu("Edit");

mnuOptions=new Menu("Options");

mnuAdmin=new Menu("Admin");

mnuHelp=new Menu("Help");

MnuItemAbout=new MenuItem("About Library


System");

MBar.add(mnuFile);

MBar.add(mnuEdit);

MBar.add(mnuOptions);

MBar.add(mnuAdmin);

MBar.add(mnuHelp);

mnuHelp.add(MnuItemAbout);

81
setMenuBar(MBar);

add(ta);

MnuItemAbout.addActionListener(this);

setSize(500,500);

setTitle("Library Management System");

setVisible(true);

public void actionPerformed(ActionEvent ae)

MyInfo obj=new MyInfo(this,"About Library System",true);

obj.show();

public static void main(String args[])

new AboutWindow();

82

You might also like