SlideShare uma empresa Scribd logo
1 de 33
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

APIIT SD INDIA
CE00396-1-OOEDP
Object Oriented & Event Driven Programming

Lecturer
Gaurav Gambhir
Submitted by:
Prince Kumar
Intake no: PT1082219
E-mail id: Pt1082219@apiit.edu.in

1

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

ACKNOWLEDGEMENT

The satisfaction that accompanies that the successful
Completion of any task would be incomplete without the
Mention of people whose ceaseless cooperation made it
Possible, whose constant guidance and encouragement
Crown all efforts with success.
We are grateful to our project guide Mr. Gaurav Gambhir
For the Guidance, inspiration and constructive suggestions
that Helpful us in the preparation of this project. We also
thank our colleagues who have helped in successful
Completion of the project.

Prince Kumar

2

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
ABSTRACT

“Secure prisons are essential to making our justice system an effective
weapon against crime. When Prisoners – convicted or awaiting trial – are
entrusted to your care, they must know and the public must know that they will
remain there until they are legally discharged …”

Prisoner Management system has never been easier .The prisoner
module provides management tools and reporting specifically design
for modern law enforcement. The security of a prison should go
further than preventing the effective control of communication of
prisoners with the outside world to prevent the continuation of
organized crime, or intimidation of witnesses or victims by
incarcerated prisoners.

This report describes implementation of a Prisoner Management
system. We used the UML Diagrams model to design a database that
will store and organize the Prisoner data. We have created the
database using SQL and populated it with some sample Data. The
system can keep track of Add Prisoner, Delete Prisoner, Find
Prisoner, Release Prisoner, Add Warden, Delete Prisoner, and Find
Prisoner And the relationships between them. Using Awt Java, java
sql and JDBC, we have created an Internet-based graphical user
interface that allows Warden to access the system remotely. This
management system includes two different action first is Prisoner and
second is Warden. They both perform different operation. In which
warden and prisoner are handled. Like user can handle warden by
adding, deleting, updating the status and many more .And in prisoner
user can add, delete, update, find, release, edit. Which we discuss in
further i.e., assignment.

3

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

Table of Contents
S.no
1.

Topic
UML Diagram

1.1.
1.2.
1.3.
1.4.

Page no:
5-9

Use case
Class Diagram
Activity Diagram
Sequence Diagram

5
6-7
8
9

2.

Story Boarding

10

3.

Source Code

11-28

4.

Sample Output

29-30

5.

Assumptions

31

6.

Conclusion

32

7.

References

33

4

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

1. UML Diagram
1.1 Use Case Diagram...

System
Add
*

Delete
*

Search

*
*

Prisoner

*
*

**
*

*

Update
*

Find
*

Display

*

*
Add
*

*

*
**

Warden

Delete

*

*
*

*

*
Update

Users
*

*

Find

*
Display
*

Exit

5

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

1.2 Class Diagram …..

ShowWarden

6

PMS

Asia Pacific Institute of Information Technology

Prisondbase
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

Prisoner

7

showpRecord

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

1.3 Activity Diagram …..

Execute Stand Alone
Application

Welcome Frame

Decision
by user

Prisoner

Warden

Add
Add
Delete

Find

Release

Display

8

Asia Pacific Institute of Information Technology

Delete

Display

Warden
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

1.4 Sequence Diagram..
A sequence diagram in a Unified Modeling Language (UML) is a kind of interaction diagram that
shows how processes operate with one another and in what order. It is a construct of a Message
Sequence Chart. A sequence diagram shows object interactions arranged in time sequence. It
depicts the objects and classes involved in the scenario and the sequence of messages exchanged
between the objects needed to carry out the functionality of the scenario. Sequence diagrams
typically are associated with use case realizations in the Logical View of the system under
development.

Sequence diagrams are sometimes called event diagrams, event scenarios, and timing diagrams

Prisoner : Add

Prisoner : Delete

Prisoner : Release

Prisoner : Find

Add

Find

Display Result

Request Display All

Display Records

Find Prisoner

Return Prisoner

Delete and Update
Actor
Return Records

9

Asia Pacific Institute of Information Technology

Prisoner : Display All
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

2.

Story Boarding
For Warden Window

For Closing the
window

For Prisoner
Window

Delete

Search

Add
Prisoner

10

Asia Pacific Institute of Information Technology

Update

Display
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

3.

Source code
Save as : PMS.java

import java.awt.Color;
import java.awt.Container;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Calendar;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class PMS extends JFrame implements ActionListener
{
Container c;
JPanel pnlWarden;
JLabel name , ptype;
JTextField txtname , txtwardenid;
JButton btndisplay, btnupdate, btnsearch, btndelete, btnadd ;
JComboBox cborank;
prisondbase db=new prisondbase();

public PMS()
{
c=getContentPane();
c.setLayout(null);
pnlWarden=new JPanel();
pnlWarden.setLayout(null);
pnlWarden.setBounds(new Rectangle(100,10,700,600));
pnlWarden.setBackground(Color.lightGray);
c.add(pnlWarden);
name=new JLabel("Warden ID: ");
name.setBounds(new Rectangle(90,200,100,30));
11

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
pnlWarden.add(name);
c.add(pnlWarden);
name = new JLabel("Warden Name: ");
name.setBounds(new Rectangle(90,250,100,30));
pnlWarden.add(name);
//name = new JLabel("Date Of Birth: ");
//name.setBounds(new Rectangle(90,150,100,30));
//pnlWarden.add(name);
name = new JLabel("Rank :");
name.setBounds(new Rectangle(90,300,100,30));
pnlWarden.add(name);
txtname = new JTextField();
txtname.setBounds(new Rectangle(200,250,120,30));
pnlWarden.add(txtname);
txtwardenid = new JTextField();
txtwardenid.setBounds(new Rectangle(200,200,120,30));
pnlWarden.add(txtwardenid);

btnadd = new JButton("Add");
btnadd.setBounds(new Rectangle(220, 400 , 100 ,30 ));
pnlWarden.add(btnadd);

btndelete = new JButton("Delete");
btndelete.setBounds(new Rectangle(150, 100 , 90 ,30 ));
pnlWarden.add(btndelete);
btnsearch = new JButton("Search");
btnsearch.setBounds(new Rectangle(270, 100 , 90 ,30 ));
pnlWarden.add(btnsearch);
btnupdate = new JButton("Update");
btnupdate.setBounds(new Rectangle(390, 100 , 90 ,30 ));
pnlWarden.add(btnupdate);
btndisplay = new JButton("Display");
btndisplay.setBounds(new Rectangle(510, 100 , 90 ,30 ));
pnlWarden.add(btndisplay);
//ptype = new JLabel("Rank");
//JLabel.setBounds ((new Rectangle(90,200,100,30));
cborank = new JComboBox();
cborank.setBounds(new Rectangle(200 , 300 , 100 , 30 ));
cborank.addItem("1");
cborank.addItem("2");
cborank.addItem("3");
cborank.addItem("4");
12

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
cborank.addItem("5");
pnlWarden.add(cborank);

btndisplay.addActionListener(this);
btnupdate.addActionListener(this);
btnsearch.addActionListener(this);
btndelete.addActionListener(this);
btnadd.addActionListener(this);
pnlWarden.setVisible(true);

}
public static void main(String[] args) {
PMS pm=new PMS();
pm.setSize(1000, 700);
pm.setVisible(true);
}
public void actionPerformed(ActionEvent ev)
{
if(ev.getSource()==btnadd)
{
Connection con=null;
PreparedStatement ptmt;
int i=0;
try {
con=db.getDBConnection();
String sql="INSERT INTO WARDEN VALUES (?,?,?)";
ptmt=con.prepareStatement(sql);
ptmt.setString(1, txtwardenid.getText());
ptmt.setString(2, txtname.getText());
ptmt.setString(3,(String) cborank.getSelectedItem());

i=ptmt.executeUpdate();
if(i>0)
{
JOptionPane.showMessageDialog(null, "Warden Inserted Successfully");
}
else {
JOptionPane.showMessageDialog(null, "Warden Not Inserted Successfully");
}
13

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
} catch (Exception e1) {
e1.printStackTrace();
}
}
if(ev.getSource()==btnsearch)
{
System.out.println("Clicked");
Connection con=null;
PreparedStatement ptmt;
try {
con=db.getDBConnection();
String sql="SELECT * FROM WARDEN WHERE Warden_Id LIKE ?";
ptmt=con.prepareStatement(sql);
ptmt.setString(1, txtwardenid.getText());
ResultSet rs=ptmt.executeQuery();
while(rs.next())
{
txtwardenid.setText(rs.getString(1));
txtname.setText(rs.getString(2));
cborank.setSelectedItem(rs.getString(3));
}

} catch (Exception e1) {
e1.printStackTrace();
}
}
if(ev.getSource()==btndelete)
{
int i=0;
try {
Connection con=db.getDBConnection();
String sql="DELETE * FROM WARDEN WHERE Warden_Id LIKE ?";
PreparedStatement ptmt=con.prepareStatement(sql);
ptmt.setString(1, txtwardenid.getText());
i=ptmt.executeUpdate();
} catch (Exception e2) {
e2.printStackTrace();
}
if(i>0)
{
JOptionPane.showMessageDialog(null, "Warden DELETED Successfully");
}
else {
14

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
JOptionPane.showMessageDialog(null, "Warden NOT DELETED
Successfully");
}
}
if(ev.getSource()==btndisplay)
{
showWardens ws=new showWardens();
ws.setVisible(true);
ws.setSize(700, 500);
}
}
}

Save as : prisonedbase.java
import java.sql.Connection;
import java.sql.*;
public class prisondbase
{
private static final String driverclass="sun.jdbc.odbc.JdbcOdbcDriver";
static String url = "jdbc:odbc:PRINCE";

public Connection getDBConnection()
{
Connection con=null;
try
{
Class.forName(driverclass);
con=DriverManager.getConnection(url);
}
catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return con;
}
}

15

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

Save as : Prisoner.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Calendar;

public class Prisoner extends JFrame implements ActionListener
{
/**
*
*/
private static final long serialVersionUID = 1L;
Container c;
JPanel pnlPrisoner;
JLabel lblpid , lblname , lblsecuritylevel , lbldateofprison , lblrelease ;
JTextField txtid , txtname ;
JComboBox cboseclevel , cboddp , cbommp , cboyyp , cboddr , cbommr , cboyyr ;
JButton btndisplay, btnupdate, btnsearch, btndelete, btnadd ;
prisondbase mydb=new prisondbase();
public Prisoner()
{
c=getContentPane();
c.setLayout(null);
pnlPrisoner=new JPanel();
pnlPrisoner.setBounds(new Rectangle(10,10,780,600));
pnlPrisoner.setLayout(null);
pnlPrisoner.setBackground(Color.LIGHT_GRAY);
lblpid=new JLabel("Prisoner ID");
lblname=new JLabel("Prisoner Name");
lblsecuritylevel=new JLabel("Security Type");
lbldateofprison=new JLabel( "Date Of prison");
lblrelease=new JLabel("Date of release");
txtid=new JTextField();
txtname=new JTextField();
cboseclevel=new JComboBox();
cboseclevel.addItem("High");
cboseclevel.addItem("Low");
16

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
cboddp=new JComboBox();
cboddp.addItem("Day");
cboddp.addItem("1");
cboddp.addItem("2");
cboddp.addItem("3");
cboddp.addItem("4");
cboddp.addItem("5");
cboddp.addItem("6");
cboddp.addItem("7");
cboddp.addItem("8");
cboddp.addItem("9");
cboddp.addItem("10");
cboddp.addItem("11");
cboddp.addItem("12");
cboddp.addItem("13");
cboddp.addItem("14");
cboddp.addItem("15");
cboddp.addItem("16");
cboddp.addItem("17");
cboddp.addItem("18");
cboddp.addItem("19");
cboddp.addItem("20");
cboddp.addItem("21");
cboddp.addItem("23");
cboddp.addItem("24");
cboddp.addItem("25");
cboddp.addItem("26");
cboddp.addItem("27");
cboddp.addItem("28");
cboddp.addItem("29");
cboddp.addItem("30");
cboddp.addItem("31");
cbommp=new JComboBox();
cbommp.addItem("Month");
cbommp.addItem("1");
cbommp.addItem("2");
cbommp.addItem("3");
cbommp.addItem("4");
cbommp.addItem("5");
cbommp.addItem("6");
cbommp.addItem("7");
cbommp.addItem("8");
cbommp.addItem("9");
cbommp.addItem("10");
cbommp.addItem("11");
cbommp.addItem("12");
cboyyp=new JComboBox();
cboyyp.addItem("Year");
17

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
cboyyp.addItem("1980");
cboyyp.addItem("1981");
cboyyp.addItem("1982");
cboyyp.addItem("1983");
cboyyp.addItem("1984");
cboyyp.addItem("1985");
cboyyp.addItem("1986");
cboyyp.addItem("1987");
cboyyp.addItem("1988");
cboyyp.addItem("1989");
cboyyp.addItem("1990");
cboyyp.addItem("1991");
cboyyp.addItem("1992");
cboyyp.addItem("1993");
cboyyp.addItem("1994");
cboyyp.addItem("1995");
cboyyp.addItem("1996");
cboyyp.addItem("1997");
cboyyp.addItem("1998");
cboyyp.addItem("1999");
cboyyp.addItem("2000");
cboyyp.addItem("2001");
cboyyp.addItem("2002");
cboyyp.addItem("2003");
cboyyp.addItem("2004");
cboyyp.addItem("2005");
cboyyp.addItem("2006");
cboyyp.addItem("2007");
cboyyp.addItem("2008");
cboyyp.addItem("2009");
cboyyp.addItem("2010");
cboyyp.addItem("2011");
cboyyp.addItem("2012");
cboddr=new JComboBox();
cboddr.addItem("Day");
cboddr.addItem("1");
cboddr.addItem("2");
cboddr.addItem("3");
cboddr.addItem("4");
cboddr.addItem("5");
cboddr.addItem("6");
cboddr.addItem("7");
cboddr.addItem("8");
cboddr.addItem("9");
cboddr.addItem("10");
cboddr.addItem("11");
cboddr.addItem("12");
cboddr.addItem("13");
cboddr.addItem("14");
18

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
cboddr.addItem("15");
cboddr.addItem("16");
cboddr.addItem("17");
cboddr.addItem("18");
cboddr.addItem("19");
cboddr.addItem("20");
cboddr.addItem("21");
cboddr.addItem("23");
cboddr.addItem("24");
cboddr.addItem("25");
cboddr.addItem("26");
cboddr.addItem("27");
cboddr.addItem("28");
cboddr.addItem("29");
cboddr.addItem("30");
cboddr.addItem("31");
cbommr=new JComboBox();
cbommr.addItem("Month");
cbommr.addItem("1");
cbommr.addItem("2");
cbommr.addItem("3");
cbommr.addItem("4");
cbommr.addItem("5");
cbommr.addItem("6");
cbommr.addItem("7");
cbommr.addItem("8");
cbommr.addItem("9");
cbommr.addItem("10");
cbommr.addItem("11");
cbommr.addItem("12");
cboyyr =new JComboBox();
cboyyr.addItem("Year");
cboyyr.addItem("1980");
cboyyr.addItem("1981");
cboyyr.addItem("1982");
cboyyr.addItem("1983");
cboyyr.addItem("1984");
cboyyr.addItem("1985");
cboyyr.addItem("1986");
cboyyr.addItem("1987");
cboyyr.addItem("1988");
cboyyr.addItem("1989");
cboyyr.addItem("1990");
cboyyr.addItem("1991");
cboyyr.addItem("1992");
cboyyr.addItem("1993");
cboyyr.addItem("1994");
cboyyr.addItem("1995");
cboyyr.addItem("1996");
19

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
cboyyr.addItem("1997");
cboyyr.addItem("1998");
cboyyr.addItem("1999");
cboyyr.addItem("2000");
cboyyr.addItem("2001");
cboyyr.addItem("2002");
cboyyr.addItem("2003");
cboyyr.addItem("2004");
cboyyr.addItem("2005");
cboyyr.addItem("2006");
cboyyr.addItem("2007");
cboyyr.addItem("2008");
cboyyr.addItem("2009");
cboyyr.addItem("2010");
cboyyr.addItem("2011");
cboyyr.addItem("2012");

lblpid.setBounds(new Rectangle(50,80,100,30));
txtid.setBounds(new Rectangle(200,80,100,30));
lblname.setBounds(new Rectangle(50,130,100,30));
txtname.setBounds(new Rectangle(200,130,100,30));
lblsecuritylevel.setBounds(new Rectangle(50,180,100,30));
cboseclevel.setBounds(new Rectangle(200,180,100,30));
lbldateofprison.setBounds(new Rectangle(50,230,100,30));
cboddp.setBounds(new Rectangle(200,230,50,30));
cbommp.setBounds(new Rectangle(260,230,50,30));
cboyyp.setBounds(new Rectangle(320,230,100,30));
lblrelease.setBounds(new Rectangle(50,280,100,30));
cboddr.setBounds(new Rectangle(200,280,50,30));
cbommr.setBounds(new Rectangle(260,280,50,30));
cboyyr.setBounds(new Rectangle(320,280,100,30));
//buttons
btnadd = new JButton("Add");
btnadd.setBounds(new Rectangle(20, 30 , 100 ,30 ));
btndelete = new JButton("Delete");
btndelete.setBounds(new Rectangle(150, 30 , 90 ,30 ));
btnsearch = new JButton("Search");
btnsearch.setBounds(new Rectangle(270, 30 , 90 ,30 ));
btnupdate = new JButton("Update");
btnupdate.setBounds(new Rectangle(390, 30 , 90 ,30 ));
btndisplay = new JButton("Display");
btndisplay.setBounds(new Rectangle(510, 30 , 90 ,30 ));
pnlPrisoner.add(lblpid);
20

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
pnlPrisoner.add(txtid);
pnlPrisoner.add(lblname);
pnlPrisoner.add(txtname);
pnlPrisoner.add(lblsecuritylevel);
pnlPrisoner.add(cboseclevel);
pnlPrisoner.add(lbldateofprison);
pnlPrisoner.add(cboddp);
pnlPrisoner.add(cbommp);
pnlPrisoner.add(cboyyp);
pnlPrisoner.add(lblrelease);
pnlPrisoner.add(cboddr);
pnlPrisoner.add(cbommr);
pnlPrisoner.add(cboyyr);

pnlPrisoner.add(btndisplay);
pnlPrisoner.add(btnupdate);
pnlPrisoner.add(btnsearch);
pnlPrisoner.add(btndelete);
pnlPrisoner.add(btnadd);
c.add(pnlPrisoner);

btndisplay.addActionListener(this);
btnupdate.addActionListener(this);
btnsearch.addActionListener(this);
btndelete.addActionListener(this);
btnadd.addActionListener(this);
pnlPrisoner.setVisible(true);
}
public static void main(String[] args) {
Prisoner prison = new Prisoner ();
prison.setSize(815,700);
prison.setVisible(true);
}
@SuppressWarnings("deprecation")
@Override
public void actionPerformed(ActionEvent ev)
{
if(ev.getSource()==btnadd)
{
int i=0;
21

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
Calendar entrydate = Calendar.getInstance();
entrydate.set(Calendar.DATE, Integer.parseInt((String) cboddp
.getSelectedItem()));
entrydate.set(Calendar.MONTH, Integer.parseInt((String) cbommp
.getSelectedItem()));
entrydate.set(Calendar.YEAR, Integer.parseInt((String) cboyyp
.getSelectedItem()));
Date dop = new Date(entrydate.getTimeInMillis());
Calendar dateofrelease = Calendar.getInstance();
dateofrelease.set(Calendar.DATE, Integer.parseInt((String) cboddr
.getSelectedItem()));
dateofrelease.set(Calendar.MONTH, Integer.parseInt((String) cbommr
.getSelectedItem()));
dateofrelease.set(Calendar.YEAR, Integer.parseInt((String) cboyyr
.getSelectedItem()));
Date dor = new Date(dateofrelease.getTimeInMillis());
try {
Connection con=mydb.getDBConnection();
String sql="INSERT INTO PRISON VALUES (?,?,?,?,?,?)";
PreparedStatement ptmt=con.prepareStatement(sql);
ptmt.setString(1, txtid.getText());
ptmt.setString(2,txtname.getText() );
ptmt.setString(3,(String)cboseclevel.getSelectedItem() );
ptmt.setDate(4, dop);
ptmt.setDate(5,dor );
ptmt.setString(6,"Not released" );

i=ptmt.executeUpdate();
if(i>0)
{
JOptionPane.showMessageDialog(null, "Prisoner Inserted Successfully");
}
else {
JOptionPane.showMessageDialog(null, "Prisoner Not Inserted Successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
}
if(ev.getSource()==btnsearch)
{
Connection con=null;
PreparedStatement ptmt;
try {
con=mydb.getDBConnection();
22

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
String sql="SELECT * FROM PRISON WHERE PID LIKE ?";
ptmt=con.prepareStatement(sql);
ptmt.setString(1, txtid.getText());
ResultSet rs=ptmt.executeQuery();
while(rs.next())
{
txtid.setText(rs.getString(1));
txtname.setText(rs.getString(2));
cboseclevel.setSelectedItem(rs.getString(3));

cboddp.setSelectedItem(rs.getDate(6).getDate());
cbommp.setSelectedItem(rs.getDate(6).getMonth());
cboyyp.setSelectedItem(rs.getDate(6).getYear());
cboddr.setSelectedItem(rs.getDate(7).getDate());
cbommr.setSelectedItem(rs.getDate(7).getMonth());
cboyyr.setSelectedItem(rs.getDate(7).getYear());
}

} catch (Exception e) {
e.printStackTrace();
}
}
if(ev.getSource()==btndelete)
{
int i=0;
try {
Connection con3=mydb.getDBConnection();
String sql3 = "UPDATE PRISON SET Status=? WHERE PID=?";
PreparedStatement ptmt3 = con3.prepareStatement(sql3);
ptmt3.setString(1, "Dead");
ptmt3.setString(2, txtid.getText());
i = ptmt3.executeUpdate();
if(i>0)
{
JOptionPane.showMessageDialog(null,"Prisoner Successfully
deletd");
}
else
{
JOptionPane.showMessageDialog(null,"Prisoner Successfully Not
deletd");
}
23

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}
}
if(ev.getSource()==btnupdate)
{
ResultSet rs = null;
int dd, mm, yy;
int totaldaysLeft = 0;
Calendar cd = Calendar.getInstance();
Date dateOfRelese = null, dateDifference = null;
try {
Connection con = mydb.getDBConnection();
String sql = "SELECT * FROM PRISON WHERE PID LIKE ?";
PreparedStatement ptmt = con.prepareStatement(sql);
ptmt.setString(1, txtid.getText());
rs = ptmt.executeQuery();
while (rs.next()) {
dateOfRelese = rs.getDate(6);
}
dd = dateOfRelese.getDate();
mm = dateOfRelese.getMonth();
yy = dateOfRelese.getYear();
con.close();
ptmt.close();
cd.set(yy, mm, dd);
System.out.println(cd);
dateDifference = new Date(cd.getTimeInMillis()
- Calendar.getInstance().getTimeInMillis());
System.out.println(dateDifference);
totaldaysLeft = dateDifference.getDay();
System.out.println("Total days left+"+totaldaysLeft);
if (totaldaysLeft > 7) {
JOptionPane.showMessageDialog(null,
"The Prisoner Could not be released");
} else {
int i = 0;
try {

24

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
Connection con1 = mydb.getDBConnection();
String sql3 = "UPDATE PRISON SET Status=? WHERE PID=?";
PreparedStatement ptmt3 = con1.prepareStatement(sql3);
ptmt3.setString(1, "Released");
ptmt3.setString(2, txtid.getText());
i = ptmt3.executeUpdate();
if(i>0)
{
JOptionPane.showMessageDialog(null,
"Prisoner Released Successfully");

}
else {
JOptionPane.showMessageDialog(null,
"Prisoner Couldnot Be Released");
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
} catch (Exception e2) {
e2.printStackTrace();
}
if (rs == null) {
JOptionPane.showMessageDialog(null,
"Prisoner Couldnot Be Found");
}
}
if(ev.getSource()==btndisplay)
{
showpRecord ps=new showpRecord();
ps.setVisible(true);
ps.setVisible(true);
}
}
}

25

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
Save as : showpRecord
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.sql.*;
import java.util.Vector;
public class showpRecord extends JFrame
{

Container c;
DefaultTableModel prisonerTablemodel;
prisondbase db=new prisondbase();

Vector<String> prisonVector;
JTable prisonTable;

showpRecord()
{
c=getContentPane();
setSize(1300,700);
setTitle("Records For Prisoner ");
c.setBackground(Color.white);
c.setLayout(null);
setResizable(false);
String pRecord[]={"Prisoner ID","Name"," Security Level ","Date Of Prison","Date Of
Release","Status"};
prisonerTablemodel=new DefaultTableModel(pRecord,0);
prisonTable=new JTable(prisonerTablemodel);
JScrollPane jspPrisoner=new JScrollPane(prisonTable);
jspPrisoner.setSize(1150, 700);
c.add(jspPrisoner);

try{
Connection con=db.getDBConnection();
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from PRISON");
while(rs.next())
{
prisonVector=new Vector<String>();
26

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
prisonVector.add(rs.getString(1));
prisonVector.add(rs.getString(2));
prisonVector.add(rs.getString(3));
prisonVector.add(rs.getString(4));
prisonVector.add(rs.getString(5));
prisonVector.add(rs.getString(6));

prisonerTablemodel.addRow(prisonVector);
}
st.close();
con.close();
}
catch(Exception e){
System.out.println(e);
}
setVisible(true);
setDefaultCloseOperation(3);
}
}

Save as : showWardens.java
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.sql.*;
import java.util.Vector;
public class showWardens extends JFrame
{

Container c;
DefaultTableModel WardenTablemodel;
prisondbase db=new prisondbase();

Vector<String> WVector;
JTable WardenTable;

showWardens()
{
c=getContentPane();
27

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
setSize(1000,700);
setTitle("Records For Warden ");
c.setBackground(Color.white);
c.setLayout(null);
setResizable(false);
String pRecord[]={"Warden ID"," Name "," Rank "};
WardenTablemodel=new DefaultTableModel(pRecord,0);
WardenTable=new JTable(WardenTablemodel);
JScrollPane jspWarden=new JScrollPane(WardenTable);
jspWarden.setSize(900, 700);
c.add(jspWarden);
ResultSet rs=null;
try{
Connection con=db.getDBConnection();
Statement st=con.createStatement();
rs=st.executeQuery("Select * from WARDEN");
while(rs.next())
{
WVector=new Vector<String>();
WVector.add(rs.getString(1));
WVector.add(rs.getString(2));
WVector.add(rs.getString(3));
WardenTablemodel.addRow(WVector);
}
st.close();
con.close();
}
catch(Exception e){
System.out.println(e);
}
setDefaultCloseOperation(3);
}

}

28

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

4. Sample Output

Welcome Form: Prisoner Management System

Prisoner Form
29

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

Warden Form

30

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

5. Assumptions

Due to limited knowledge the following assumptions were made in the assignment:

validations on the textboxes have not been given, so it has been assumed that the user
enters correct data
lesser class files could have been made
all the functionalities like add, delete, find etc are given on the same page
combo box has not been used to select warden id while adding a prisoner .

31

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

6. Conclusion

Finally completing this assignment I came to know more about Object oriented.
I have to implement some of the features of java to design Prisoner management
system. This assignment based on Prisoner management through database.
During the completion of the assignment, I have learned a many new things like
working with swing, action listeners. Now i can create Stand Alone
Application easily. I have become well aware of the following concepts of java:
Arrays
Classes
Objects
Constructors
Inheritance
Exception Handling
Abstract classes
Interface
Polymorphism
Looping

32

Asia Pacific Institute of Information Technology
[OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012

7.References
[1] http://www.java-examples.com/ [Accessed on : 1st April,12 ]
[2] http://en.wikipedia.org/wiki/Sequence_diagram [for sequence - definition :
Accessed on : 26th April , 12 ]
[3] Dietel, H.M. & Dietel, P.J. (2001) Java: How to Program, Prentice Hall. (ISBN:
0130341517)

[4] http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/ [For Layout - Accessed on :
2nd April , 12 ]

33

Asia Pacific Institute of Information Technology

Mais conteúdo relacionado

Mais procurados

Hotel management system
Hotel management systemHotel management system
Hotel management systemRoni Roy
 
Hotel Management System final report
Hotel Management System final report  Hotel Management System final report
Hotel Management System final report jaysavani5
 
Online Hotel Room Booking System
Online Hotel Room Booking SystemOnline Hotel Room Booking System
Online Hotel Room Booking SystemAbhishek Kumar
 
E leave management-system
E leave management-systemE leave management-system
E leave management-systemArti Sehgal
 
Online crime reporting system ppt
Online crime reporting system  pptOnline crime reporting system  ppt
Online crime reporting system pptYOGESH SHARMA
 
GPS based Bus management system
GPS based Bus management systemGPS based Bus management system
GPS based Bus management systemNeeraj Kansal
 
Student attendance management system
Student attendance management systemStudent attendance management system
Student attendance management systemVikrant Kumar
 
student database management system
student database management systemstudent database management system
student database management systemMd. Riadul Islam
 
Mobile based attandance system
Mobile based attandance systemMobile based attandance system
Mobile based attandance systemAbhishek Jha
 
Crime investigation system
Crime investigation systemCrime investigation system
Crime investigation systemDeepa Rani
 
SRS example
SRS exampleSRS example
SRS examplegentzone
 
Leave Management System Documentation
Leave Management System DocumentationLeave Management System Documentation
Leave Management System Documentationmuzammil siddiq
 
College Management System project srs 2015
College Management System project srs 2015College Management System project srs 2015
College Management System project srs 2015Surendra Mahala
 
373512722-Employee-Leave-Management-System.docx
373512722-Employee-Leave-Management-System.docx373512722-Employee-Leave-Management-System.docx
373512722-Employee-Leave-Management-System.docxsanthoshyadav23
 
Online Hotel Management
Online Hotel ManagementOnline Hotel Management
Online Hotel ManagementSouvik Banik
 
Software requirement specification
Software requirement specificationSoftware requirement specification
Software requirement specificationRavi Yasas
 

Mais procurados (20)

Hotel management system
Hotel management systemHotel management system
Hotel management system
 
Software requirement specification(SRS)
Software requirement specification(SRS)Software requirement specification(SRS)
Software requirement specification(SRS)
 
Hotel Management System final report
Hotel Management System final report  Hotel Management System final report
Hotel Management System final report
 
Online Hotel Room Booking System
Online Hotel Room Booking SystemOnline Hotel Room Booking System
Online Hotel Room Booking System
 
E leave management-system
E leave management-systemE leave management-system
E leave management-system
 
Software Requirement Specification
Software Requirement SpecificationSoftware Requirement Specification
Software Requirement Specification
 
Online crime reporting system ppt
Online crime reporting system  pptOnline crime reporting system  ppt
Online crime reporting system ppt
 
GPS based Bus management system
GPS based Bus management systemGPS based Bus management system
GPS based Bus management system
 
Student attendance management system
Student attendance management systemStudent attendance management system
Student attendance management system
 
student database management system
student database management systemstudent database management system
student database management system
 
Mobile based attandance system
Mobile based attandance systemMobile based attandance system
Mobile based attandance system
 
Crime investigation system
Crime investigation systemCrime investigation system
Crime investigation system
 
Hms project report
Hms project reportHms project report
Hms project report
 
SRS example
SRS exampleSRS example
SRS example
 
Leave Management System Documentation
Leave Management System DocumentationLeave Management System Documentation
Leave Management System Documentation
 
College Management System project srs 2015
College Management System project srs 2015College Management System project srs 2015
College Management System project srs 2015
 
373512722-Employee-Leave-Management-System.docx
373512722-Employee-Leave-Management-System.docx373512722-Employee-Leave-Management-System.docx
373512722-Employee-Leave-Management-System.docx
 
Online Hotel Management
Online Hotel ManagementOnline Hotel Management
Online Hotel Management
 
Sample SRS format
Sample SRS formatSample SRS format
Sample SRS format
 
Software requirement specification
Software requirement specificationSoftware requirement specification
Software requirement specification
 

Destaque

Prison management system
Prison management system Prison management system
Prison management system SNOW WHITE
 
The Prison System
The Prison SystemThe Prison System
The Prison Systemmrkaeagles
 
Crime Record Management System (CRMS)
Crime Record Management System (CRMS)Crime Record Management System (CRMS)
Crime Record Management System (CRMS)Zara Tariq
 
Online Crime Management system
Online Crime Management system Online Crime Management system
Online Crime Management system shinyvaibhav
 
Web based Prison management system
Web based Prison management systemWeb based Prison management system
Web based Prison management systemFAKHRUN NISHA
 
Project Report On Online Crime Management Application
Project Report On Online Crime Management ApplicationProject Report On Online Crime Management Application
Project Report On Online Crime Management Applicationsatvirsandhu9
 
Crime Record Management System (CRMS)
Crime Record Management System (CRMS)Crime Record Management System (CRMS)
Crime Record Management System (CRMS)Zara Tariq
 
ppt on e crime management system
ppt on e crime management systemppt on e crime management system
ppt on e crime management systemKrishna Kinkar Jha
 
Event Management System Document
Event Management System Document Event Management System Document
Event Management System Document LJ PROJECTS
 
Acknowledgement For Assignment
Acknowledgement For AssignmentAcknowledgement For Assignment
Acknowledgement For AssignmentThomas Mon
 
Criminal Record Management
Criminal Record ManagementCriminal Record Management
Criminal Record ManagementKhokan Sardar
 
Social psychology video assignment report
Social psychology video assignment reportSocial psychology video assignment report
Social psychology video assignment reportChin Tze Wei
 
Mid term assignment of audit and assurance
Mid term assignment of audit and assuranceMid term assignment of audit and assurance
Mid term assignment of audit and assuranceArslan Akram
 
Prisoners Rights - Legal Aid & Prison Reforms
Prisoners Rights - Legal Aid & Prison ReformsPrisoners Rights - Legal Aid & Prison Reforms
Prisoners Rights - Legal Aid & Prison ReformsNaveen Bhartiya
 
Collaboration Diagram
Collaboration DiagramCollaboration Diagram
Collaboration Diagramfahad_uaar
 
Acknowledgement
AcknowledgementAcknowledgement
Acknowledgementferdzzz
 

Destaque (20)

Prison management system
Prison management system Prison management system
Prison management system
 
The Prison System
The Prison SystemThe Prison System
The Prison System
 
Crime Record Management System (CRMS)
Crime Record Management System (CRMS)Crime Record Management System (CRMS)
Crime Record Management System (CRMS)
 
Online Crime Management system
Online Crime Management system Online Crime Management system
Online Crime Management system
 
Web based Prison management system
Web based Prison management systemWeb based Prison management system
Web based Prison management system
 
Srs
SrsSrs
Srs
 
Project Report On Online Crime Management Application
Project Report On Online Crime Management ApplicationProject Report On Online Crime Management Application
Project Report On Online Crime Management Application
 
Crime Record Management System (CRMS)
Crime Record Management System (CRMS)Crime Record Management System (CRMS)
Crime Record Management System (CRMS)
 
ppt on e crime management system
ppt on e crime management systemppt on e crime management system
ppt on e crime management system
 
Event Management System Document
Event Management System Document Event Management System Document
Event Management System Document
 
Example of acknowledgment
Example of acknowledgmentExample of acknowledgment
Example of acknowledgment
 
Acknowledgement For Assignment
Acknowledgement For AssignmentAcknowledgement For Assignment
Acknowledgement For Assignment
 
Criminal Record Management
Criminal Record ManagementCriminal Record Management
Criminal Record Management
 
Social psychology video assignment report
Social psychology video assignment reportSocial psychology video assignment report
Social psychology video assignment report
 
Prisons
PrisonsPrisons
Prisons
 
Mid term assignment of audit and assurance
Mid term assignment of audit and assuranceMid term assignment of audit and assurance
Mid term assignment of audit and assurance
 
Prisoners Rights - Legal Aid & Prison Reforms
Prisoners Rights - Legal Aid & Prison ReformsPrisoners Rights - Legal Aid & Prison Reforms
Prisoners Rights - Legal Aid & Prison Reforms
 
Collaboration Diagram
Collaboration DiagramCollaboration Diagram
Collaboration Diagram
 
Acknowledgement
AcknowledgementAcknowledgement
Acknowledgement
 
Acknowledgement
AcknowledgementAcknowledgement
Acknowledgement
 

Semelhante a Prisoner Management System

Project for Student Result System
Project for Student Result SystemProject for Student Result System
Project for Student Result SystemKuMaR AnAnD
 
Ujjwalreverseengineeringppptfinal
UjjwalreverseengineeringppptfinalUjjwalreverseengineeringppptfinal
Ujjwalreverseengineeringppptfinalujjwalchauhan87
 
Deep Reinforcement Learning for Visual Navigation
Deep Reinforcement Learning for Visual NavigationDeep Reinforcement Learning for Visual Navigation
Deep Reinforcement Learning for Visual NavigationManish Pandey
 
Image Classification and Annotation Using Deep Learning
Image Classification and Annotation Using Deep LearningImage Classification and Annotation Using Deep Learning
Image Classification and Annotation Using Deep LearningIRJET Journal
 
Latest Resume
Latest ResumeLatest Resume
Latest ResumeK Goutham
 
OOP_chapter _1.pptx
OOP_chapter _1.pptxOOP_chapter _1.pptx
OOP_chapter _1.pptxAbdexAliyi
 
Software_Engineering_Presentation (1).pptx
Software_Engineering_Presentation (1).pptxSoftware_Engineering_Presentation (1).pptx
Software_Engineering_Presentation (1).pptxArifaMehreen1
 
Manjunatha Resume 7+ years Experience
Manjunatha Resume 7+ years ExperienceManjunatha Resume 7+ years Experience
Manjunatha Resume 7+ years Experiencemanjunathasb
 
Car Showroom management System in c++
Car Showroom management System in c++Car Showroom management System in c++
Car Showroom management System in c++PUBLIVE
 
CSc investigatory project
CSc investigatory projectCSc investigatory project
CSc investigatory projectDIVYANSHU KUMAR
 
Towards a Unified Data Analytics Optimizer with Yanlei Diao
Towards a Unified Data Analytics Optimizer with Yanlei DiaoTowards a Unified Data Analytics Optimizer with Yanlei Diao
Towards a Unified Data Analytics Optimizer with Yanlei DiaoDatabricks
 
Hostel management system (5)
Hostel management system (5)Hostel management system (5)
Hostel management system (5)PRIYANKMZN
 
Minor Project Synopsis on Data Structure Visualizer
Minor Project Synopsis on Data Structure VisualizerMinor Project Synopsis on Data Structure Visualizer
Minor Project Synopsis on Data Structure VisualizerRonitShrivastava057
 
Android Application For Decentralized Family Locator
Android Application For Decentralized Family LocatorAndroid Application For Decentralized Family Locator
Android Application For Decentralized Family LocatorIRJET Journal
 
Gym Management System User Manual
Gym Management System User ManualGym Management System User Manual
Gym Management System User ManualDavid O' Connor
 

Semelhante a Prisoner Management System (20)

Project for Student Result System
Project for Student Result SystemProject for Student Result System
Project for Student Result System
 
Ujjwalreverseengineeringppptfinal
UjjwalreverseengineeringppptfinalUjjwalreverseengineeringppptfinal
Ujjwalreverseengineeringppptfinal
 
SATHISH KUMAR
SATHISH KUMARSATHISH KUMAR
SATHISH KUMAR
 
Deep Reinforcement Learning for Visual Navigation
Deep Reinforcement Learning for Visual NavigationDeep Reinforcement Learning for Visual Navigation
Deep Reinforcement Learning for Visual Navigation
 
Image Classification and Annotation Using Deep Learning
Image Classification and Annotation Using Deep LearningImage Classification and Annotation Using Deep Learning
Image Classification and Annotation Using Deep Learning
 
Latest Resume
Latest ResumeLatest Resume
Latest Resume
 
OOP_chapter _1.pptx
OOP_chapter _1.pptxOOP_chapter _1.pptx
OOP_chapter _1.pptx
 
Software_Engineering_Presentation (1).pptx
Software_Engineering_Presentation (1).pptxSoftware_Engineering_Presentation (1).pptx
Software_Engineering_Presentation (1).pptx
 
Presentation5
Presentation5Presentation5
Presentation5
 
Manjunatha Resume 7+ years Experience
Manjunatha Resume 7+ years ExperienceManjunatha Resume 7+ years Experience
Manjunatha Resume 7+ years Experience
 
Car Showroom management System in c++
Car Showroom management System in c++Car Showroom management System in c++
Car Showroom management System in c++
 
Rachita Gupta
Rachita GuptaRachita Gupta
Rachita Gupta
 
CSc investigatory project
CSc investigatory projectCSc investigatory project
CSc investigatory project
 
Towards a Unified Data Analytics Optimizer with Yanlei Diao
Towards a Unified Data Analytics Optimizer with Yanlei DiaoTowards a Unified Data Analytics Optimizer with Yanlei Diao
Towards a Unified Data Analytics Optimizer with Yanlei Diao
 
Hostel management system (5)
Hostel management system (5)Hostel management system (5)
Hostel management system (5)
 
2 Object Oriented Programming
2 Object Oriented Programming2 Object Oriented Programming
2 Object Oriented Programming
 
Minor Project Synopsis on Data Structure Visualizer
Minor Project Synopsis on Data Structure VisualizerMinor Project Synopsis on Data Structure Visualizer
Minor Project Synopsis on Data Structure Visualizer
 
Android Application For Decentralized Family Locator
Android Application For Decentralized Family LocatorAndroid Application For Decentralized Family Locator
Android Application For Decentralized Family Locator
 
I_CLASS_ROOM.pptx
I_CLASS_ROOM.pptxI_CLASS_ROOM.pptx
I_CLASS_ROOM.pptx
 
Gym Management System User Manual
Gym Management System User ManualGym Management System User Manual
Gym Management System User Manual
 

Mais de Prince Kumar

A letter from mom and dad
A letter from mom and dadA letter from mom and dad
A letter from mom and dadPrince Kumar
 
Factors influencing creativity
Factors influencing creativityFactors influencing creativity
Factors influencing creativityPrince Kumar
 
Online Railway Reservation System
Online Railway Reservation SystemOnline Railway Reservation System
Online Railway Reservation SystemPrince Kumar
 
Car portal- Ewa final assignment
Car portal- Ewa final assignmentCar portal- Ewa final assignment
Car portal- Ewa final assignmentPrince Kumar
 
Hotel Management system in C++
Hotel Management system in C++ Hotel Management system in C++
Hotel Management system in C++ Prince Kumar
 
SAD - Waiter on Wheels
SAD - Waiter on WheelsSAD - Waiter on Wheels
SAD - Waiter on WheelsPrince Kumar
 
Professional enterprise and development - IBM
Professional enterprise and development - IBMProfessional enterprise and development - IBM
Professional enterprise and development - IBMPrince Kumar
 
Feedback System in PHP
Feedback System in PHPFeedback System in PHP
Feedback System in PHPPrince Kumar
 

Mais de Prince Kumar (12)

A letter from mom and dad
A letter from mom and dadA letter from mom and dad
A letter from mom and dad
 
Factors influencing creativity
Factors influencing creativityFactors influencing creativity
Factors influencing creativity
 
Personality test
Personality testPersonality test
Personality test
 
Online Railway Reservation System
Online Railway Reservation SystemOnline Railway Reservation System
Online Railway Reservation System
 
Car portal- Ewa final assignment
Car portal- Ewa final assignmentCar portal- Ewa final assignment
Car portal- Ewa final assignment
 
College Network
College NetworkCollege Network
College Network
 
C Programming
C ProgrammingC Programming
C Programming
 
Positive attitude
Positive attitudePositive attitude
Positive attitude
 
Hotel Management system in C++
Hotel Management system in C++ Hotel Management system in C++
Hotel Management system in C++
 
SAD - Waiter on Wheels
SAD - Waiter on WheelsSAD - Waiter on Wheels
SAD - Waiter on Wheels
 
Professional enterprise and development - IBM
Professional enterprise and development - IBMProfessional enterprise and development - IBM
Professional enterprise and development - IBM
 
Feedback System in PHP
Feedback System in PHPFeedback System in PHP
Feedback System in PHP
 

Último

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Último (20)

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

Prisoner Management System

  • 1. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 APIIT SD INDIA CE00396-1-OOEDP Object Oriented & Event Driven Programming Lecturer Gaurav Gambhir Submitted by: Prince Kumar Intake no: PT1082219 E-mail id: Pt1082219@apiit.edu.in 1 Asia Pacific Institute of Information Technology
  • 2. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 ACKNOWLEDGEMENT The satisfaction that accompanies that the successful Completion of any task would be incomplete without the Mention of people whose ceaseless cooperation made it Possible, whose constant guidance and encouragement Crown all efforts with success. We are grateful to our project guide Mr. Gaurav Gambhir For the Guidance, inspiration and constructive suggestions that Helpful us in the preparation of this project. We also thank our colleagues who have helped in successful Completion of the project. Prince Kumar 2 Asia Pacific Institute of Information Technology
  • 3. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 ABSTRACT “Secure prisons are essential to making our justice system an effective weapon against crime. When Prisoners – convicted or awaiting trial – are entrusted to your care, they must know and the public must know that they will remain there until they are legally discharged …” Prisoner Management system has never been easier .The prisoner module provides management tools and reporting specifically design for modern law enforcement. The security of a prison should go further than preventing the effective control of communication of prisoners with the outside world to prevent the continuation of organized crime, or intimidation of witnesses or victims by incarcerated prisoners. This report describes implementation of a Prisoner Management system. We used the UML Diagrams model to design a database that will store and organize the Prisoner data. We have created the database using SQL and populated it with some sample Data. The system can keep track of Add Prisoner, Delete Prisoner, Find Prisoner, Release Prisoner, Add Warden, Delete Prisoner, and Find Prisoner And the relationships between them. Using Awt Java, java sql and JDBC, we have created an Internet-based graphical user interface that allows Warden to access the system remotely. This management system includes two different action first is Prisoner and second is Warden. They both perform different operation. In which warden and prisoner are handled. Like user can handle warden by adding, deleting, updating the status and many more .And in prisoner user can add, delete, update, find, release, edit. Which we discuss in further i.e., assignment. 3 Asia Pacific Institute of Information Technology
  • 4. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 Table of Contents S.no 1. Topic UML Diagram 1.1. 1.2. 1.3. 1.4. Page no: 5-9 Use case Class Diagram Activity Diagram Sequence Diagram 5 6-7 8 9 2. Story Boarding 10 3. Source Code 11-28 4. Sample Output 29-30 5. Assumptions 31 6. Conclusion 32 7. References 33 4 Asia Pacific Institute of Information Technology
  • 5. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 1. UML Diagram 1.1 Use Case Diagram... System Add * Delete * Search * * Prisoner * * ** * * Update * Find * Display * * Add * * * ** Warden Delete * * * * * Update Users * * Find * Display * Exit 5 Asia Pacific Institute of Information Technology
  • 6. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 1.2 Class Diagram ….. ShowWarden 6 PMS Asia Pacific Institute of Information Technology Prisondbase
  • 7. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 Prisoner 7 showpRecord Asia Pacific Institute of Information Technology
  • 8. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 1.3 Activity Diagram ….. Execute Stand Alone Application Welcome Frame Decision by user Prisoner Warden Add Add Delete Find Release Display 8 Asia Pacific Institute of Information Technology Delete Display Warden
  • 9. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 1.4 Sequence Diagram.. A sequence diagram in a Unified Modeling Language (UML) is a kind of interaction diagram that shows how processes operate with one another and in what order. It is a construct of a Message Sequence Chart. A sequence diagram shows object interactions arranged in time sequence. It depicts the objects and classes involved in the scenario and the sequence of messages exchanged between the objects needed to carry out the functionality of the scenario. Sequence diagrams typically are associated with use case realizations in the Logical View of the system under development. Sequence diagrams are sometimes called event diagrams, event scenarios, and timing diagrams Prisoner : Add Prisoner : Delete Prisoner : Release Prisoner : Find Add Find Display Result Request Display All Display Records Find Prisoner Return Prisoner Delete and Update Actor Return Records 9 Asia Pacific Institute of Information Technology Prisoner : Display All
  • 10. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 2. Story Boarding For Warden Window For Closing the window For Prisoner Window Delete Search Add Prisoner 10 Asia Pacific Institute of Information Technology Update Display
  • 11. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 3. Source code Save as : PMS.java import java.awt.Color; import java.awt.Container; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.Connection; import java.sql.Date; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.Calendar; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; public class PMS extends JFrame implements ActionListener { Container c; JPanel pnlWarden; JLabel name , ptype; JTextField txtname , txtwardenid; JButton btndisplay, btnupdate, btnsearch, btndelete, btnadd ; JComboBox cborank; prisondbase db=new prisondbase(); public PMS() { c=getContentPane(); c.setLayout(null); pnlWarden=new JPanel(); pnlWarden.setLayout(null); pnlWarden.setBounds(new Rectangle(100,10,700,600)); pnlWarden.setBackground(Color.lightGray); c.add(pnlWarden); name=new JLabel("Warden ID: "); name.setBounds(new Rectangle(90,200,100,30)); 11 Asia Pacific Institute of Information Technology
  • 12. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 pnlWarden.add(name); c.add(pnlWarden); name = new JLabel("Warden Name: "); name.setBounds(new Rectangle(90,250,100,30)); pnlWarden.add(name); //name = new JLabel("Date Of Birth: "); //name.setBounds(new Rectangle(90,150,100,30)); //pnlWarden.add(name); name = new JLabel("Rank :"); name.setBounds(new Rectangle(90,300,100,30)); pnlWarden.add(name); txtname = new JTextField(); txtname.setBounds(new Rectangle(200,250,120,30)); pnlWarden.add(txtname); txtwardenid = new JTextField(); txtwardenid.setBounds(new Rectangle(200,200,120,30)); pnlWarden.add(txtwardenid); btnadd = new JButton("Add"); btnadd.setBounds(new Rectangle(220, 400 , 100 ,30 )); pnlWarden.add(btnadd); btndelete = new JButton("Delete"); btndelete.setBounds(new Rectangle(150, 100 , 90 ,30 )); pnlWarden.add(btndelete); btnsearch = new JButton("Search"); btnsearch.setBounds(new Rectangle(270, 100 , 90 ,30 )); pnlWarden.add(btnsearch); btnupdate = new JButton("Update"); btnupdate.setBounds(new Rectangle(390, 100 , 90 ,30 )); pnlWarden.add(btnupdate); btndisplay = new JButton("Display"); btndisplay.setBounds(new Rectangle(510, 100 , 90 ,30 )); pnlWarden.add(btndisplay); //ptype = new JLabel("Rank"); //JLabel.setBounds ((new Rectangle(90,200,100,30)); cborank = new JComboBox(); cborank.setBounds(new Rectangle(200 , 300 , 100 , 30 )); cborank.addItem("1"); cborank.addItem("2"); cborank.addItem("3"); cborank.addItem("4"); 12 Asia Pacific Institute of Information Technology
  • 13. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 cborank.addItem("5"); pnlWarden.add(cborank); btndisplay.addActionListener(this); btnupdate.addActionListener(this); btnsearch.addActionListener(this); btndelete.addActionListener(this); btnadd.addActionListener(this); pnlWarden.setVisible(true); } public static void main(String[] args) { PMS pm=new PMS(); pm.setSize(1000, 700); pm.setVisible(true); } public void actionPerformed(ActionEvent ev) { if(ev.getSource()==btnadd) { Connection con=null; PreparedStatement ptmt; int i=0; try { con=db.getDBConnection(); String sql="INSERT INTO WARDEN VALUES (?,?,?)"; ptmt=con.prepareStatement(sql); ptmt.setString(1, txtwardenid.getText()); ptmt.setString(2, txtname.getText()); ptmt.setString(3,(String) cborank.getSelectedItem()); i=ptmt.executeUpdate(); if(i>0) { JOptionPane.showMessageDialog(null, "Warden Inserted Successfully"); } else { JOptionPane.showMessageDialog(null, "Warden Not Inserted Successfully"); } 13 Asia Pacific Institute of Information Technology
  • 14. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 } catch (Exception e1) { e1.printStackTrace(); } } if(ev.getSource()==btnsearch) { System.out.println("Clicked"); Connection con=null; PreparedStatement ptmt; try { con=db.getDBConnection(); String sql="SELECT * FROM WARDEN WHERE Warden_Id LIKE ?"; ptmt=con.prepareStatement(sql); ptmt.setString(1, txtwardenid.getText()); ResultSet rs=ptmt.executeQuery(); while(rs.next()) { txtwardenid.setText(rs.getString(1)); txtname.setText(rs.getString(2)); cborank.setSelectedItem(rs.getString(3)); } } catch (Exception e1) { e1.printStackTrace(); } } if(ev.getSource()==btndelete) { int i=0; try { Connection con=db.getDBConnection(); String sql="DELETE * FROM WARDEN WHERE Warden_Id LIKE ?"; PreparedStatement ptmt=con.prepareStatement(sql); ptmt.setString(1, txtwardenid.getText()); i=ptmt.executeUpdate(); } catch (Exception e2) { e2.printStackTrace(); } if(i>0) { JOptionPane.showMessageDialog(null, "Warden DELETED Successfully"); } else { 14 Asia Pacific Institute of Information Technology
  • 15. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 JOptionPane.showMessageDialog(null, "Warden NOT DELETED Successfully"); } } if(ev.getSource()==btndisplay) { showWardens ws=new showWardens(); ws.setVisible(true); ws.setSize(700, 500); } } } Save as : prisonedbase.java import java.sql.Connection; import java.sql.*; public class prisondbase { private static final String driverclass="sun.jdbc.odbc.JdbcOdbcDriver"; static String url = "jdbc:odbc:PRINCE"; public Connection getDBConnection() { Connection con=null; try { Class.forName(driverclass); con=DriverManager.getConnection(url); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } return con; } } 15 Asia Pacific Institute of Information Technology
  • 16. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 Save as : Prisoner.java import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.Connection; import java.sql.Date; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.Calendar; public class Prisoner extends JFrame implements ActionListener { /** * */ private static final long serialVersionUID = 1L; Container c; JPanel pnlPrisoner; JLabel lblpid , lblname , lblsecuritylevel , lbldateofprison , lblrelease ; JTextField txtid , txtname ; JComboBox cboseclevel , cboddp , cbommp , cboyyp , cboddr , cbommr , cboyyr ; JButton btndisplay, btnupdate, btnsearch, btndelete, btnadd ; prisondbase mydb=new prisondbase(); public Prisoner() { c=getContentPane(); c.setLayout(null); pnlPrisoner=new JPanel(); pnlPrisoner.setBounds(new Rectangle(10,10,780,600)); pnlPrisoner.setLayout(null); pnlPrisoner.setBackground(Color.LIGHT_GRAY); lblpid=new JLabel("Prisoner ID"); lblname=new JLabel("Prisoner Name"); lblsecuritylevel=new JLabel("Security Type"); lbldateofprison=new JLabel( "Date Of prison"); lblrelease=new JLabel("Date of release"); txtid=new JTextField(); txtname=new JTextField(); cboseclevel=new JComboBox(); cboseclevel.addItem("High"); cboseclevel.addItem("Low"); 16 Asia Pacific Institute of Information Technology
  • 17. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 cboddp=new JComboBox(); cboddp.addItem("Day"); cboddp.addItem("1"); cboddp.addItem("2"); cboddp.addItem("3"); cboddp.addItem("4"); cboddp.addItem("5"); cboddp.addItem("6"); cboddp.addItem("7"); cboddp.addItem("8"); cboddp.addItem("9"); cboddp.addItem("10"); cboddp.addItem("11"); cboddp.addItem("12"); cboddp.addItem("13"); cboddp.addItem("14"); cboddp.addItem("15"); cboddp.addItem("16"); cboddp.addItem("17"); cboddp.addItem("18"); cboddp.addItem("19"); cboddp.addItem("20"); cboddp.addItem("21"); cboddp.addItem("23"); cboddp.addItem("24"); cboddp.addItem("25"); cboddp.addItem("26"); cboddp.addItem("27"); cboddp.addItem("28"); cboddp.addItem("29"); cboddp.addItem("30"); cboddp.addItem("31"); cbommp=new JComboBox(); cbommp.addItem("Month"); cbommp.addItem("1"); cbommp.addItem("2"); cbommp.addItem("3"); cbommp.addItem("4"); cbommp.addItem("5"); cbommp.addItem("6"); cbommp.addItem("7"); cbommp.addItem("8"); cbommp.addItem("9"); cbommp.addItem("10"); cbommp.addItem("11"); cbommp.addItem("12"); cboyyp=new JComboBox(); cboyyp.addItem("Year"); 17 Asia Pacific Institute of Information Technology
  • 18. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 cboyyp.addItem("1980"); cboyyp.addItem("1981"); cboyyp.addItem("1982"); cboyyp.addItem("1983"); cboyyp.addItem("1984"); cboyyp.addItem("1985"); cboyyp.addItem("1986"); cboyyp.addItem("1987"); cboyyp.addItem("1988"); cboyyp.addItem("1989"); cboyyp.addItem("1990"); cboyyp.addItem("1991"); cboyyp.addItem("1992"); cboyyp.addItem("1993"); cboyyp.addItem("1994"); cboyyp.addItem("1995"); cboyyp.addItem("1996"); cboyyp.addItem("1997"); cboyyp.addItem("1998"); cboyyp.addItem("1999"); cboyyp.addItem("2000"); cboyyp.addItem("2001"); cboyyp.addItem("2002"); cboyyp.addItem("2003"); cboyyp.addItem("2004"); cboyyp.addItem("2005"); cboyyp.addItem("2006"); cboyyp.addItem("2007"); cboyyp.addItem("2008"); cboyyp.addItem("2009"); cboyyp.addItem("2010"); cboyyp.addItem("2011"); cboyyp.addItem("2012"); cboddr=new JComboBox(); cboddr.addItem("Day"); cboddr.addItem("1"); cboddr.addItem("2"); cboddr.addItem("3"); cboddr.addItem("4"); cboddr.addItem("5"); cboddr.addItem("6"); cboddr.addItem("7"); cboddr.addItem("8"); cboddr.addItem("9"); cboddr.addItem("10"); cboddr.addItem("11"); cboddr.addItem("12"); cboddr.addItem("13"); cboddr.addItem("14"); 18 Asia Pacific Institute of Information Technology
  • 19. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 cboddr.addItem("15"); cboddr.addItem("16"); cboddr.addItem("17"); cboddr.addItem("18"); cboddr.addItem("19"); cboddr.addItem("20"); cboddr.addItem("21"); cboddr.addItem("23"); cboddr.addItem("24"); cboddr.addItem("25"); cboddr.addItem("26"); cboddr.addItem("27"); cboddr.addItem("28"); cboddr.addItem("29"); cboddr.addItem("30"); cboddr.addItem("31"); cbommr=new JComboBox(); cbommr.addItem("Month"); cbommr.addItem("1"); cbommr.addItem("2"); cbommr.addItem("3"); cbommr.addItem("4"); cbommr.addItem("5"); cbommr.addItem("6"); cbommr.addItem("7"); cbommr.addItem("8"); cbommr.addItem("9"); cbommr.addItem("10"); cbommr.addItem("11"); cbommr.addItem("12"); cboyyr =new JComboBox(); cboyyr.addItem("Year"); cboyyr.addItem("1980"); cboyyr.addItem("1981"); cboyyr.addItem("1982"); cboyyr.addItem("1983"); cboyyr.addItem("1984"); cboyyr.addItem("1985"); cboyyr.addItem("1986"); cboyyr.addItem("1987"); cboyyr.addItem("1988"); cboyyr.addItem("1989"); cboyyr.addItem("1990"); cboyyr.addItem("1991"); cboyyr.addItem("1992"); cboyyr.addItem("1993"); cboyyr.addItem("1994"); cboyyr.addItem("1995"); cboyyr.addItem("1996"); 19 Asia Pacific Institute of Information Technology
  • 20. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 cboyyr.addItem("1997"); cboyyr.addItem("1998"); cboyyr.addItem("1999"); cboyyr.addItem("2000"); cboyyr.addItem("2001"); cboyyr.addItem("2002"); cboyyr.addItem("2003"); cboyyr.addItem("2004"); cboyyr.addItem("2005"); cboyyr.addItem("2006"); cboyyr.addItem("2007"); cboyyr.addItem("2008"); cboyyr.addItem("2009"); cboyyr.addItem("2010"); cboyyr.addItem("2011"); cboyyr.addItem("2012"); lblpid.setBounds(new Rectangle(50,80,100,30)); txtid.setBounds(new Rectangle(200,80,100,30)); lblname.setBounds(new Rectangle(50,130,100,30)); txtname.setBounds(new Rectangle(200,130,100,30)); lblsecuritylevel.setBounds(new Rectangle(50,180,100,30)); cboseclevel.setBounds(new Rectangle(200,180,100,30)); lbldateofprison.setBounds(new Rectangle(50,230,100,30)); cboddp.setBounds(new Rectangle(200,230,50,30)); cbommp.setBounds(new Rectangle(260,230,50,30)); cboyyp.setBounds(new Rectangle(320,230,100,30)); lblrelease.setBounds(new Rectangle(50,280,100,30)); cboddr.setBounds(new Rectangle(200,280,50,30)); cbommr.setBounds(new Rectangle(260,280,50,30)); cboyyr.setBounds(new Rectangle(320,280,100,30)); //buttons btnadd = new JButton("Add"); btnadd.setBounds(new Rectangle(20, 30 , 100 ,30 )); btndelete = new JButton("Delete"); btndelete.setBounds(new Rectangle(150, 30 , 90 ,30 )); btnsearch = new JButton("Search"); btnsearch.setBounds(new Rectangle(270, 30 , 90 ,30 )); btnupdate = new JButton("Update"); btnupdate.setBounds(new Rectangle(390, 30 , 90 ,30 )); btndisplay = new JButton("Display"); btndisplay.setBounds(new Rectangle(510, 30 , 90 ,30 )); pnlPrisoner.add(lblpid); 20 Asia Pacific Institute of Information Technology
  • 21. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 pnlPrisoner.add(txtid); pnlPrisoner.add(lblname); pnlPrisoner.add(txtname); pnlPrisoner.add(lblsecuritylevel); pnlPrisoner.add(cboseclevel); pnlPrisoner.add(lbldateofprison); pnlPrisoner.add(cboddp); pnlPrisoner.add(cbommp); pnlPrisoner.add(cboyyp); pnlPrisoner.add(lblrelease); pnlPrisoner.add(cboddr); pnlPrisoner.add(cbommr); pnlPrisoner.add(cboyyr); pnlPrisoner.add(btndisplay); pnlPrisoner.add(btnupdate); pnlPrisoner.add(btnsearch); pnlPrisoner.add(btndelete); pnlPrisoner.add(btnadd); c.add(pnlPrisoner); btndisplay.addActionListener(this); btnupdate.addActionListener(this); btnsearch.addActionListener(this); btndelete.addActionListener(this); btnadd.addActionListener(this); pnlPrisoner.setVisible(true); } public static void main(String[] args) { Prisoner prison = new Prisoner (); prison.setSize(815,700); prison.setVisible(true); } @SuppressWarnings("deprecation") @Override public void actionPerformed(ActionEvent ev) { if(ev.getSource()==btnadd) { int i=0; 21 Asia Pacific Institute of Information Technology
  • 22. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 Calendar entrydate = Calendar.getInstance(); entrydate.set(Calendar.DATE, Integer.parseInt((String) cboddp .getSelectedItem())); entrydate.set(Calendar.MONTH, Integer.parseInt((String) cbommp .getSelectedItem())); entrydate.set(Calendar.YEAR, Integer.parseInt((String) cboyyp .getSelectedItem())); Date dop = new Date(entrydate.getTimeInMillis()); Calendar dateofrelease = Calendar.getInstance(); dateofrelease.set(Calendar.DATE, Integer.parseInt((String) cboddr .getSelectedItem())); dateofrelease.set(Calendar.MONTH, Integer.parseInt((String) cbommr .getSelectedItem())); dateofrelease.set(Calendar.YEAR, Integer.parseInt((String) cboyyr .getSelectedItem())); Date dor = new Date(dateofrelease.getTimeInMillis()); try { Connection con=mydb.getDBConnection(); String sql="INSERT INTO PRISON VALUES (?,?,?,?,?,?)"; PreparedStatement ptmt=con.prepareStatement(sql); ptmt.setString(1, txtid.getText()); ptmt.setString(2,txtname.getText() ); ptmt.setString(3,(String)cboseclevel.getSelectedItem() ); ptmt.setDate(4, dop); ptmt.setDate(5,dor ); ptmt.setString(6,"Not released" ); i=ptmt.executeUpdate(); if(i>0) { JOptionPane.showMessageDialog(null, "Prisoner Inserted Successfully"); } else { JOptionPane.showMessageDialog(null, "Prisoner Not Inserted Successfully"); } } catch (Exception e) { e.printStackTrace(); } } if(ev.getSource()==btnsearch) { Connection con=null; PreparedStatement ptmt; try { con=mydb.getDBConnection(); 22 Asia Pacific Institute of Information Technology
  • 23. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 String sql="SELECT * FROM PRISON WHERE PID LIKE ?"; ptmt=con.prepareStatement(sql); ptmt.setString(1, txtid.getText()); ResultSet rs=ptmt.executeQuery(); while(rs.next()) { txtid.setText(rs.getString(1)); txtname.setText(rs.getString(2)); cboseclevel.setSelectedItem(rs.getString(3)); cboddp.setSelectedItem(rs.getDate(6).getDate()); cbommp.setSelectedItem(rs.getDate(6).getMonth()); cboyyp.setSelectedItem(rs.getDate(6).getYear()); cboddr.setSelectedItem(rs.getDate(7).getDate()); cbommr.setSelectedItem(rs.getDate(7).getMonth()); cboyyr.setSelectedItem(rs.getDate(7).getYear()); } } catch (Exception e) { e.printStackTrace(); } } if(ev.getSource()==btndelete) { int i=0; try { Connection con3=mydb.getDBConnection(); String sql3 = "UPDATE PRISON SET Status=? WHERE PID=?"; PreparedStatement ptmt3 = con3.prepareStatement(sql3); ptmt3.setString(1, "Dead"); ptmt3.setString(2, txtid.getText()); i = ptmt3.executeUpdate(); if(i>0) { JOptionPane.showMessageDialog(null,"Prisoner Successfully deletd"); } else { JOptionPane.showMessageDialog(null,"Prisoner Successfully Not deletd"); } 23 Asia Pacific Institute of Information Technology
  • 24. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 } catch (Exception e2) { // TODO: handle exception e2.printStackTrace(); } } if(ev.getSource()==btnupdate) { ResultSet rs = null; int dd, mm, yy; int totaldaysLeft = 0; Calendar cd = Calendar.getInstance(); Date dateOfRelese = null, dateDifference = null; try { Connection con = mydb.getDBConnection(); String sql = "SELECT * FROM PRISON WHERE PID LIKE ?"; PreparedStatement ptmt = con.prepareStatement(sql); ptmt.setString(1, txtid.getText()); rs = ptmt.executeQuery(); while (rs.next()) { dateOfRelese = rs.getDate(6); } dd = dateOfRelese.getDate(); mm = dateOfRelese.getMonth(); yy = dateOfRelese.getYear(); con.close(); ptmt.close(); cd.set(yy, mm, dd); System.out.println(cd); dateDifference = new Date(cd.getTimeInMillis() - Calendar.getInstance().getTimeInMillis()); System.out.println(dateDifference); totaldaysLeft = dateDifference.getDay(); System.out.println("Total days left+"+totaldaysLeft); if (totaldaysLeft > 7) { JOptionPane.showMessageDialog(null, "The Prisoner Could not be released"); } else { int i = 0; try { 24 Asia Pacific Institute of Information Technology
  • 25. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 Connection con1 = mydb.getDBConnection(); String sql3 = "UPDATE PRISON SET Status=? WHERE PID=?"; PreparedStatement ptmt3 = con1.prepareStatement(sql3); ptmt3.setString(1, "Released"); ptmt3.setString(2, txtid.getText()); i = ptmt3.executeUpdate(); if(i>0) { JOptionPane.showMessageDialog(null, "Prisoner Released Successfully"); } else { JOptionPane.showMessageDialog(null, "Prisoner Couldnot Be Released"); } } catch (Exception e2) { e2.printStackTrace(); } } } catch (Exception e2) { e2.printStackTrace(); } if (rs == null) { JOptionPane.showMessageDialog(null, "Prisoner Couldnot Be Found"); } } if(ev.getSource()==btndisplay) { showpRecord ps=new showpRecord(); ps.setVisible(true); ps.setVisible(true); } } } 25 Asia Pacific Institute of Information Technology
  • 26. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 Save as : showpRecord import java.awt.*; import javax.swing.*; import javax.swing.table.*; import javax.swing.event.*; import java.awt.event.*; import java.sql.*; import java.util.Vector; public class showpRecord extends JFrame { Container c; DefaultTableModel prisonerTablemodel; prisondbase db=new prisondbase(); Vector<String> prisonVector; JTable prisonTable; showpRecord() { c=getContentPane(); setSize(1300,700); setTitle("Records For Prisoner "); c.setBackground(Color.white); c.setLayout(null); setResizable(false); String pRecord[]={"Prisoner ID","Name"," Security Level ","Date Of Prison","Date Of Release","Status"}; prisonerTablemodel=new DefaultTableModel(pRecord,0); prisonTable=new JTable(prisonerTablemodel); JScrollPane jspPrisoner=new JScrollPane(prisonTable); jspPrisoner.setSize(1150, 700); c.add(jspPrisoner); try{ Connection con=db.getDBConnection(); Statement st=con.createStatement(); ResultSet rs=st.executeQuery("Select * from PRISON"); while(rs.next()) { prisonVector=new Vector<String>(); 26 Asia Pacific Institute of Information Technology
  • 27. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 prisonVector.add(rs.getString(1)); prisonVector.add(rs.getString(2)); prisonVector.add(rs.getString(3)); prisonVector.add(rs.getString(4)); prisonVector.add(rs.getString(5)); prisonVector.add(rs.getString(6)); prisonerTablemodel.addRow(prisonVector); } st.close(); con.close(); } catch(Exception e){ System.out.println(e); } setVisible(true); setDefaultCloseOperation(3); } } Save as : showWardens.java import java.awt.*; import javax.swing.*; import javax.swing.table.*; import javax.swing.event.*; import java.awt.event.*; import java.sql.*; import java.util.Vector; public class showWardens extends JFrame { Container c; DefaultTableModel WardenTablemodel; prisondbase db=new prisondbase(); Vector<String> WVector; JTable WardenTable; showWardens() { c=getContentPane(); 27 Asia Pacific Institute of Information Technology
  • 28. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 setSize(1000,700); setTitle("Records For Warden "); c.setBackground(Color.white); c.setLayout(null); setResizable(false); String pRecord[]={"Warden ID"," Name "," Rank "}; WardenTablemodel=new DefaultTableModel(pRecord,0); WardenTable=new JTable(WardenTablemodel); JScrollPane jspWarden=new JScrollPane(WardenTable); jspWarden.setSize(900, 700); c.add(jspWarden); ResultSet rs=null; try{ Connection con=db.getDBConnection(); Statement st=con.createStatement(); rs=st.executeQuery("Select * from WARDEN"); while(rs.next()) { WVector=new Vector<String>(); WVector.add(rs.getString(1)); WVector.add(rs.getString(2)); WVector.add(rs.getString(3)); WardenTablemodel.addRow(WVector); } st.close(); con.close(); } catch(Exception e){ System.out.println(e); } setDefaultCloseOperation(3); } } 28 Asia Pacific Institute of Information Technology
  • 29. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 4. Sample Output Welcome Form: Prisoner Management System Prisoner Form 29 Asia Pacific Institute of Information Technology
  • 30. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 Warden Form 30 Asia Pacific Institute of Information Technology
  • 31. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 5. Assumptions Due to limited knowledge the following assumptions were made in the assignment: validations on the textboxes have not been given, so it has been assumed that the user enters correct data lesser class files could have been made all the functionalities like add, delete, find etc are given on the same page combo box has not been used to select warden id while adding a prisoner . 31 Asia Pacific Institute of Information Technology
  • 32. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 6. Conclusion Finally completing this assignment I came to know more about Object oriented. I have to implement some of the features of java to design Prisoner management system. This assignment based on Prisoner management through database. During the completion of the assignment, I have learned a many new things like working with swing, action listeners. Now i can create Stand Alone Application easily. I have become well aware of the following concepts of java: Arrays Classes Objects Constructors Inheritance Exception Handling Abstract classes Interface Polymorphism Looping 32 Asia Pacific Institute of Information Technology
  • 33. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING , INDIVIDUAL ASSIGNMENT ] May 2, 2012 7.References [1] http://www.java-examples.com/ [Accessed on : 1st April,12 ] [2] http://en.wikipedia.org/wiki/Sequence_diagram [for sequence - definition : Accessed on : 26th April , 12 ] [3] Dietel, H.M. & Dietel, P.J. (2001) Java: How to Program, Prentice Hall. (ISBN: 0130341517) [4] http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/ [For Layout - Accessed on : 2nd April , 12 ] 33 Asia Pacific Institute of Information Technology