You are on page 1of 43

Preparing and Developing Computerized System for Summarized Monthly

Running Report(R/51) in Sri Lanka Transport Board

By

W.A.B.Janith

Group Member
N.M.S.B.Hettigedara

as partial fulfillment for the


Undergraduate Research Project (FSC32P2)

Supervisor:
Professor L.A.L.W.Jayasekara

Faculty of Science
University of Ruhuna
Sri Lanka
2010
ABSTRACT
Preparing and Developing Computerized System for Summarized
Monthly Running Report(R/51) in Sri Lanka Transport Board
W.A.B. Janith
Faculty of Science
University of Ruhuna
Sri Lanka

Summarized monthly running report is a report which is prepared


the end of the month using all records of running details, cost and
income of buses. Usually they filter to enter into there record book
from daily way bill book ticket sheets. After that they summarize data
to fill reports fields in running report at end of the month. We are
trying to create software solution for above situation

Tools & Technologies used :

Java Version 1.6


Mysql Version 5.0.16

Java Persistence (Object relational mapping)

Jasper Report Version 2.0.4

Net beans Version 6.8


Photoshop Cs2, Adobe Flash CS3 Professional

1|Page
ACKNOWLEDGMENTS

I take this opportunity to express my profound sense of gratitude and respect to all
those who helped me throughout the duration of this project. I express my sincere
gratitude and thankfulness towards Professor L.A.L.W.Jayasekara, Department of
mathematics, Ruhuna University, Matara, for his valuable times and guidance
throughout to Our Project.

I am grateful for valuable suggestions rendered by all the staff members of the
running section, Balangoda depot of CTB, Balangoda, Sri lanka.

I am grateful for the co-operation to my project member and all our friends for
providing critical feedback & support whenever required. I regret any inadvertent
omissions.

W.A.B. janith
University of Ruhuna
Matara.

2|Page
CONTENTS

Introduction

Specification of the problem

Method of Solution

Database structure

Conclusions

Discussion

Bibliography

3|Page
Introduction

Sri lanka Transport Board is government organization but it is not efficiency


because main reason is there is used technology as very poor and human must
improve their technical knowledge. As we are University student we must support
to society to develop and easy to done their work.
Mr. H.N.S.B.hettigedara is my friends who invited to me to joined with him
to do ITRC project. Because Mr.H.N.S.B.Hettrigedaras uncle who is Forman of
engine section tell to hettigedara about problems of his work place (Balangoda
depot of CTB) . So he invited to me to carry out ITRC project in this depot
problem. Then I and my partner visited there and searched problems which we can
give a software solution. So after that we decided In this project basically we
consider about time management and get necessary information quickly. There
were many problems, but we selected few major problems. Because network was
very large we had not much time to handle all problems. Nothing any electronic
instruments were used it is another reason. So we selected following problems.
There are two major problems that we show.
1. Preparing document of R/51 (will be Changing Routes )
2. Develop the system (Add some information such as engine oil )
Then I accept to solved Preparing document of R/51 report to any deport as my role
of project.

Document of R/51
There are many documents such as R/22,R/41 and etc. R/51 also a document. It
is the most important document in depot. R means which belongs to running
section. This document is prepared at the end of month and also update per
month. It is full summary of route. Necessary information are got from R/51 by
top management. There are nine copies. One of them send to Sri Lanka transport
commission in Narahenpita. At that place they analyze about route and take
actions for loss routes.
There are 21 columns to fill. Some of them have to fill and others have to calculate data.

4|Page
1. Route number
Any bus travel anywhere definitely it has route number. Each route
has regular number. As a example From Balangoda to Kandy route
number is 69

2. Description of route
This field describe about route. As a example route number 69
description is from Balangoda to Kandy across Kegalle

3. Distance
Total distance at the end of route. It is not change

4. Value of a ticket
Value of a ticket for full route

5. Size of bus
It is mentioned numbers of passengers without stand passengers

6. Type of bus
I. type of A (double decor)
II. type of B (double door)
III. type of C (double door but not large than type of B)
IV. type of D (single door)
V. type of E (single door but not large than type of D, Specially use
this bus for estate or rural areas)

7. Documentary

8. Numbers of buses
Numbers of buses are traveled regular route

9. Registered kilometers
Decided kilometers for travel

10. Kilometers with income


11. Kilometers without income
Sometime bus has been break down. At that time they do not take
passengers, but travel to depot .That kilometers have not included income

12. Numbers of passengers


Numbers of tickets
13. Income

5|Page
14. Income per Kilometer
income
Income per kilometer=
kilometer_ with_incom e
15. Value per kilometer
Value_of_t icket
Value per kilometer=
distance

16. Passenger kilometers


income 100
Passenger kilometers=
income_per _km

17. Site kilometers


Site kilometer= kilometers with income type of bus

18. Load factor


passenger_ km 100
Load factor=
site_km

Load factor>35% =profit

35%>Load factor>30% =normal

Load factor<30% =loss

Clark must give lowest ten load factor out of all. Government pays for that
routes as a encouragement.

19. Kilometers per passenger


passenger_ km
Kilometers per passenger =
number_of_ tickets
20. Income per passenger
income
Income per passenger =
no_of_tick ets

21. Service district


As a example Balangoda-Kandy service district are Rathnapura ,
Colombo and Kandy.

6|Page
Specification of the problem

Problem 1

Completing R/51 at the end of month is major problem which must be filled
end of month by regular Clark, but he cannot do it regular time who was
always late nearly two weeks. So there are lot of complains from top
management. Top management must submit R\51 to transport commission.
Regularly Clark spends 3 days for calculate data.

Problem 2

Completing R/51 at end of the month the report must send to Sri Lanka
transport commission in Narahenpita and other copies must be post in regular
mail post so we can post by E-mail all copies in short time.

Methods of Solution

We have try to give software solution above problem. First we share our
project. I have decided to develop repairing section such as, developing and
preparing R\51 (different than partner). I and partner used below documents to get
data.

1. R\22
2. Log sheet

What is R\22
This document is used by conductor which is also a basic document. Every
day depot provides this document to conductor. Generally this can be used for
financial checking by officers. R\22 has duty no. There is lot of data in here but we
get only necessary data. Below data are used by us.

1. Route
2. No of trip
3. Tickets sold
4. Value of tickets (for a route)
5. Registered kilometers
6. Running kilometers
7. date

7|Page
What is Log sheet

Log sheet also a basic document. It is used by driver. Everyday depot provides
this document. Below data are used by us. Sometime it is used by engine section
for trial.

1. Registered kilometers
2. Running kilometers
3. Lost kilometers
4. Bus number
5. Engine oil
6. Fuel
7. Instrument

To overcome from this entire problem in Sri Lanka Transport Board Balangoda Office wanted to
move to a new system which is desktop application, and which leads to prepare final sheet by the
Desktop and to collect, retrieve and maintain data

Main requirements:
 The Desktop application system should be able to collect data from R/22 and log sheet
to temporary data tables. After the computer operator in running section verified the
submitted data the data is saved into main data tables.
 The data in the database can be viewed by computer operator
 In the running record of maintaining system, operator can be able to log in to the system
to view running information, check defects running information record through the
running system.
 In end of the month operator can be generate R\51 Summery report by one click.
 If operator want to post a this R\51 report by e-mail ,the operate should be tick sending
to head office.

I planed as first to build User interface to enter and retrieved data of Route detail
and Running recodes after then this data must persist in ctbsourse databases.

Finally I generate monthly report using Jasper report .

I Show my first user interfaces that will be in link button can be open route table
,running table and bus type table.

8|Page
There is code in following about above interface
/*
* CtbpROJECTView.java
*/

package ctbproject;

import java.awt.EventQueue;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;

/**
* The application's main frame.
*/
public class CtbpROJECTView extends FrameView {

public CtbpROJECTView(SingleFrameApplication app) {


super(app);

initComponents();

// status bar initialization - message timeout, idle icon and busy animation, etc
ResourceMap resourceMap = getResourceMap();
int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
messageTimer = new Timer(messageTimeout, new ActionListener() {

9|Page
public void actionPerformed(ActionEvent e) {
statusMessageLabel.setText("");
}
});
messageTimer.setRepeats(false);
int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
for (int i = 0; i < busyIcons.length; i++) {
busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
}
busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
public void actionPerformed(ActionEvent e) {
busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
}
});
idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
statusAnimationLabel.setIcon(idleIcon);
progressBar.setVisible(false);

// connecting action tasks to status bar via TaskMonitor


TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
String propertyName = evt.getPropertyName();
if ("started".equals(propertyName)) {
if (!busyIconTimer.isRunning()) {
statusAnimationLabel.setIcon(busyIcons[0]);
busyIconIndex = 0;
busyIconTimer.start();
}
progressBar.setVisible(true);
progressBar.setIndeterminate(true);
} else if ("done".equals(propertyName)) {
busyIconTimer.stop();
statusAnimationLabel.setIcon(idleIcon);
progressBar.setVisible(false);
progressBar.setValue(0);
} else if ("message".equals(propertyName)) {
String text = (String)(evt.getNewValue());
statusMessageLabel.setText((text == null) ? "" : text);
messageTimer.restart();
} else if ("progress".equals(propertyName)) {
int value = (Integer)(evt.getNewValue());
progressBar.setVisible(true);
progressBar.setIndeterminate(false);
progressBar.setValue(value);
}
}
});
}

@Action
public void showAboutBox() {
if (aboutBox == null) {
JFrame mainFrame = CtbpROJECTApp.getApplication().getMainFrame();
aboutBox = new CtbpROJECTAboutBox(mainFrame);
aboutBox.setLocationRelativeTo(mainFrame);
}
CtbpROJECTApp.getApplication().show(aboutBox);
}

/** This method is called from within the constructor to


* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/

10 | P a g e
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

mainPanel = new javax.swing.JPanel();


jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
Report = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
menuBar = new javax.swing.JMenuBar();
javax.swing.JMenu fileMenu = new javax.swing.JMenu();
javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
javax.swing.JMenu helpMenu = new javax.swing.JMenu();
javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
statusPanel = new javax.swing.JPanel();
javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
statusMessageLabel = new javax.swing.JLabel();
statusAnimationLabel = new javax.swing.JLabel();
progressBar = new javax.swing.JProgressBar();

mainPanel.setName("mainPanel"); // NOI18N

org.jdesktop.application.ResourceMap resourceMap =
org.jdesktop.application.Application.getInstance(ctbproject.CtbpROJECTApp.class).getContext
().getResourceMap(CtbpROJECTView.class);
jPanel1.setBackground(resourceMap.getColor("jPanel1.background")); // NOI18N
jPanel1.setName("jPanel1"); // NOI18N

jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setIcon(resourceMap.getIcon("jLabel1.icon")); // NOI18N
jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
jLabel1.setName("jLabel1"); // NOI18N

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


jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 745,
Short.MAX_VALUE)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 181,
Short.MAX_VALUE)
.addContainerGap())
);

jPanel2.setBackground(resourceMap.getColor("jPanel2.background")); // NOI18N
jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel2.setName("jPanel2"); // NOI18N

Report.setBackground(resourceMap.getColor("Report.background")); // NOI18N
Report.setText(resourceMap.getString("Report.text")); // NOI18N
Report.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
Report.setName("Report"); // NOI18N
Report.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
ReportMouseClicked(evt);
}

11 | P a g e
});

jButton2.setBackground(resourceMap.getColor("Route Viwe.background")); // NOI18N


jButton2.setText(resourceMap.getString("Route Viwe.text")); // NOI18N
jButton2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton2.setName("Route Viwe"); // NOI18N
jButton2.setPreferredSize(new java.awt.Dimension(97, 23));
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton2MouseClicked(evt);
}
});

jButton1.setBackground(resourceMap.getColor("jButton1.background")); // NOI18N
jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
jButton1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton1.setName("jButton1"); // NOI18N
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
});

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


jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addGap(217, 217, 217)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 97,
Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 98,
Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Report, javax.swing.GroupLayout.PREFERRED_SIZE, 105,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(212, 212, 212))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addGap(34, 34, 34)

.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 189,
Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 189,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Report, javax.swing.GroupLayout.PREFERRED_SIZE, 187,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(26, 26, 26))
);

javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);


mainPanel.setLayout(mainPanelLayout);
mainPanelLayout.setHorizontalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
mainPanelLayout.createSequentialGroup()
.addContainerGap()

12 | P a g e
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
mainPanelLayout.setVerticalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(56, 56, 56))
);

menuBar.setBackground(resourceMap.getColor("menuBar.background")); // NOI18N
menuBar.setForeground(resourceMap.getColor("menuBar.foreground")); // NOI18N
menuBar.setName("menuBar"); // NOI18N

fileMenu.setBackground(resourceMap.getColor("fileMenu.background")); // NOI18N
fileMenu.setForeground(resourceMap.getColor("fileMenu.foreground")); // NOI18N
fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
fileMenu.setName("fileMenu"); // NOI18N

javax.swing.ActionMap actionMap =
org.jdesktop.application.Application.getInstance(ctbproject.CtbpROJECTApp.class).getContext
().getActionMap(CtbpROJECTView.class, this);
exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
exitMenuItem.setName("exitMenuItem"); // NOI18N
fileMenu.add(exitMenuItem);

menuBar.add(fileMenu);

helpMenu.setBackground(resourceMap.getColor("helpMenu.background")); // NOI18N
helpMenu.setForeground(resourceMap.getColor("helpMenu.foreground")); // NOI18N
helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
helpMenu.setName("helpMenu"); // NOI18N

aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
aboutMenuItem.setName("aboutMenuItem"); // NOI18N
helpMenu.add(aboutMenuItem);

menuBar.add(helpMenu);

statusPanel.setBackground(resourceMap.getColor("statusPanel.background")); //
NOI18N
statusPanel.setName("statusPanel"); // NOI18N

statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

statusMessageLabel.setName("statusMessageLabel"); // NOI18N

statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

progressBar.setName("progressBar"); // NOI18N

javax.swing.GroupLayout statusPanelLayout = new


javax.swing.GroupLayout(statusPanel);
statusPanel.setLayout(statusPanelLayout);
statusPanelLayout.setHorizontalGroup(

statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(statusPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(statusMessageLabel)

13 | P a g e
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 595,
Short.MAX_VALUE)
.addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(statusAnimationLabel)
.addContainerGap())
.addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 765,
Short.MAX_VALUE)
);
statusPanelLayout.setVerticalGroup(

statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
statusPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE,
47, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(statusMessageLabel)
.addComponent(statusAnimationLabel)
.addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3))
);

setComponent(mainPanel);
setMenuBar(menuBar);
setStatusBar(statusPanel);
}// </editor-fold>

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {


EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setContentPane(new Route());
frame.pack();
frame.setVisible(true);
}
}); // TODO add your handling code here:
}

private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {


EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setContentPane(new Bus());
frame.pack();
frame.setVisible(true);
}
}); // TODO add your handling code here:
}

private void ReportMouseClicked(java.awt.event.MouseEvent evt) {


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
re=new Report();
re.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
re.pack();
re.setVisible(true);
}

14 | P a g e
}); // TODO add your handling code here:
}

// Variables declaration - do not modify


private javax.swing.JButton Report;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel mainPanel;
private javax.swing.JMenuBar menuBar;
private javax.swing.JProgressBar progressBar;
private javax.swing.JLabel statusAnimationLabel;
private javax.swing.JLabel statusMessageLabel;
private javax.swing.JPanel statusPanel;
// End of variables declaration

private final Timer messageTimer;


private final Timer busyIconTimer;
private final Icon idleIcon;
private final Icon[] busyIcons = new Icon[15];
private int busyIconIndex = 0;
static Report re;
private JDialog aboutBox;
}

Following interface is maintain record of running and route recode

15 | P a g e
package ctbproject;

import java.awt.EventQueue;
import java.beans.Beans;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.persistence.RollbackException;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
*
* @author W.A.B. Janith
*/
public class Route extends JPanel {

public Route() {
initComponents();
if (!Beans.isDesignTime()) {
entityManager.getTransaction().begin();
}
}

/** This method is called from within the constructor to


* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

org.jdesktop.application.ResourceMap resourceMap =
org.jdesktop.application.Application.getInstance(ctbproject.CtbpROJECTApp.class).getContext
().getResourceMap(Route.class);
entityManager = java.beans.Beans.isDesignTime() ? null :
javax.persistence.Persistence.createEntityManagerFactory(resourceMap.getString("entityManag
er.persistenceUnit")).createEntityManager(); // NOI18N
query = java.beans.Beans.isDesignTime() ? null :
entityManager.createQuery(resourceMap.getString("query.query")); // NOI18N
list = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :
org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList
());
masterScrollPane = new javax.swing.JScrollPane();
masterTable = new javax.swing.JTable();
newButton = new javax.swing.JButton();
deleteButton = new javax.swing.JButton();
detailScrollPane = new javax.swing.JScrollPane();
detailTable = new javax.swing.JTable();
saveButton = new javax.swing.JButton();
refreshButton = new javax.swing.JButton();
deleteDetailButton = new javax.swing.JButton();
newDetailButton = new javax.swing.JButton();

FormListener formListener = new FormListener();

setBackground(resourceMap.getColor("Form.background")); // NOI18N
setName("Form"); // NOI18N

masterScrollPane.setName("masterScrollPane"); // NOI18N

16 | P a g e
masterTable.setName("masterTable"); // NOI18N

org.jdesktop.swingbinding.JTableBinding jTableBinding =
org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoB
inding.UpdateStrategy.READ_WRITE, list, masterTable);
org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${routeNo}"));
columnBinding.setColumnName("Route No");
columnBinding.setColumnClass(String.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${fromplace}"))
;
columnBinding.setColumnName("Fromplace");
columnBinding.setColumnClass(String.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${throughplace}
"));
columnBinding.setColumnName("Throughplace");
columnBinding.setColumnClass(String.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${toplace}"));
columnBinding.setColumnName("Toplace");
columnBinding.setColumnClass(String.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${far}"));
columnBinding.setColumnName("Far");
columnBinding.setColumnClass(java.math.BigDecimal.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${priceOfTicket
}"));
columnBinding.setColumnName("Price Of Ticket");
columnBinding.setColumnClass(java.math.BigDecimal.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${busTipe}"));
columnBinding.setColumnName("Bus Tipe");
columnBinding.setColumnClass(ctbSource.Bus.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${documentary}"
));
columnBinding.setColumnName("Documentary");
columnBinding.setColumnClass(java.math.BigDecimal.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${serviceDis}")
);
columnBinding.setColumnName("Service Dis");
columnBinding.setColumnClass(String.class);
bindingGroup.addBinding(jTableBinding);

masterScrollPane.setViewportView(masterTable);

newButton.setText(resourceMap.getString("newButton.text")); // NOI18N
newButton.setName("newButton"); // NOI18N
newButton.addActionListener(formListener);

deleteButton.setText(resourceMap.getString("deleteButton.text")); // NOI18N
deleteButton.setName("deleteButton"); // NOI18N

org.jdesktop.beansbinding.Binding binding =
org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.
UpdateStrategy.READ, masterTable,
org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), deleteButton,
org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);

deleteButton.addActionListener(formListener);

17 | P a g e
detailScrollPane.setName("detailScrollPane"); // NOI18N

detailTable.setName("detailTable"); // NOI18N

org.jdesktop.beansbinding.ELProperty eLProperty =
org.jdesktop.beansbinding.ELProperty.create("${selectedElement.runingList}");
jTableBinding =
org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoB
inding.UpdateStrategy.READ_WRITE, masterTable, eLProperty, detailTable);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${date}"));
columnBinding.setColumnName("Date");
columnBinding.setColumnClass(java.util.Date.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${vehicalNo}"))
;
columnBinding.setColumnName("Vehical No");
columnBinding.setColumnClass(String.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${tripNumber}")
);
columnBinding.setColumnName("Trip Number");
columnBinding.setColumnClass(Integer.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${numOfTickets}
"));
columnBinding.setColumnName("Num Of Tickets");
columnBinding.setColumnClass(Integer.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${value}"));
columnBinding.setColumnName("Value");
columnBinding.setColumnClass(java.math.BigDecimal.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${stchKm}"));
columnBinding.setColumnName("Stch Km");
columnBinding.setColumnClass(java.math.BigDecimal.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${stchKmService
}"));
columnBinding.setColumnName("Stch Km Service");
columnBinding.setColumnClass(java.math.BigDecimal.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${stchKmDead}")
);
columnBinding.setColumnName("Stch Km Dead");
columnBinding.setColumnClass(java.math.BigDecimal.class);
jTableBinding.setSourceUnreadableValue(java.util.Collections.emptyList());
bindingGroup.addBinding(jTableBinding);

detailScrollPane.setViewportView(detailTable);

saveButton.setText(resourceMap.getString("saveButton.text")); // NOI18N
saveButton.setName("saveButton"); // NOI18N
saveButton.addActionListener(formListener);

refreshButton.setText(resourceMap.getString("refreshButton.text")); // NOI18N
refreshButton.setName("refreshButton"); // NOI18N
refreshButton.addActionListener(formListener);

deleteDetailButton.setText(resourceMap.getString("deleteDetailButton.text")); //
NOI18N
deleteDetailButton.setName("deleteDetailButton"); // NOI18N

binding =
org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.

18 | P a g e
UpdateStrategy.READ, detailTable,
org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"),
deleteDetailButton, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);

deleteDetailButton.addActionListener(formListener);

newDetailButton.setText(resourceMap.getString("newDetailButton.text")); // NOI18N
newDetailButton.setName("newDetailButton"); // NOI18N

binding =
org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.
UpdateStrategy.READ, masterTable,
org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), newDetailButton,
org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);

newDetailButton.addActionListener(formListener);

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


this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(newButton)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(deleteButton))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(245, Short.MAX_VALUE)
.addComponent(newDetailButton)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(deleteDetailButton)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(refreshButton)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(saveButton))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(masterScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(detailScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE)))
.addContainerGap())
);

layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[]


{deleteButton, newButton});

layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[]


{deleteDetailButton, newDetailButton, refreshButton, saveButton});

layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()

19 | P a g e
.addComponent(masterScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 231,
Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(deleteButton)
.addComponent(newButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(detailScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 231,
Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(saveButton)
.addComponent(refreshButton)
.addComponent(deleteDetailButton)
.addComponent(newDetailButton))
.addContainerGap())
);

bindingGroup.bind();
}

// Code for dispatching events from components to event handlers.

private class FormListener implements java.awt.event.ActionListener {


FormListener() {}
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (evt.getSource() == newButton) {
Route.this.newButtonActionPerformed(evt);
}
else if (evt.getSource() == deleteButton) {
Route.this.deleteButtonActionPerformed(evt);
}
else if (evt.getSource() == saveButton) {
Route.this.saveButtonActionPerformed(evt);
}
else if (evt.getSource() == refreshButton) {
Route.this.refreshButtonActionPerformed(evt);
}
else if (evt.getSource() == deleteDetailButton) {
Route.this.deleteDetailButtonActionPerformed(evt);
}
else if (evt.getSource() == newDetailButton) {
Route.this.newDetailButtonActionPerformed(evt);
}
}
}// </editor-fold>

private void deleteDetailButtonActionPerformed(java.awt.event.ActionEvent evt) {


int index = masterTable.getSelectedRow();
ctbSource.Route R = list.get(masterTable.convertRowIndexToModel(index));
Collection<ctbSource.Runing> rs = R.getRuningList();
int[] selected = detailTable.getSelectedRows();
List<ctbSource.Runing> toRemove = new ArrayList<ctbSource.Runing>(selected.length);
for (int idx=0; idx<selected.length; idx++) {
selected[idx] = detailTable.convertRowIndexToModel(selected[idx]);
int count = 0;
Iterator<ctbSource.Runing> iter = rs.iterator();
while (count++ < selected[idx]) iter.next();
ctbSource.Runing r = iter.next();
toRemove.add(r);
entityManager.remove(r);
}
rs.removeAll(toRemove);

20 | P a g e
masterTable.clearSelection();
masterTable.setRowSelectionInterval(index, index);
}

private void newDetailButtonActionPerformed(java.awt.event.ActionEvent evt) {


int index = masterTable.getSelectedRow();
ctbSource.Route R = list.get(masterTable.convertRowIndexToModel(index));
Collection<ctbSource.Runing> rs = R.getRuningList();
if (rs == null) {
rs = new LinkedList<ctbSource.Runing>();
R.setRuningList((List)rs);
}
ctbSource.Runing r = new ctbSource.Runing();
entityManager.persist(r);
r.setRouteNo(R);
rs.add(r);
masterTable.clearSelection();
masterTable.setRowSelectionInterval(index, index);
int row = rs.size()-1;
detailTable.setRowSelectionInterval(row, row);
detailTable.scrollRectToVisible(detailTable.getCellRect(row, 0, true));
}

@SuppressWarnings("unchecked")
private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {
entityManager.getTransaction().rollback();
entityManager.getTransaction().begin();
java.util.Collection data = query.getResultList();
for (Object entity : data) {
entityManager.refresh(entity);
}
list.clear();
list.addAll(data);
}

private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {


int[] selected = masterTable.getSelectedRows();
List<ctbSource.Route> toRemove = new ArrayList<ctbSource.Route>(selected.length);
for (int idx=0; idx<selected.length; idx++) {
ctbSource.Route R =
list.get(masterTable.convertRowIndexToModel(selected[idx]));
toRemove.add(R);
entityManager.remove(R);
}
list.removeAll(toRemove);
}

private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {


ctbSource.Route R = new ctbSource.Route();
entityManager.persist(R);
list.add(R);
int row = list.size()-1;
masterTable.setRowSelectionInterval(row, row);
masterTable.scrollRectToVisible(masterTable.getCellRect(row, 0, true));
}

private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {


try {
entityManager.getTransaction().commit();
entityManager.getTransaction().begin();
} catch (RollbackException rex) {
rex.printStackTrace();
entityManager.getTransaction().begin();
List<ctbSource.Route> merged = new ArrayList<ctbSource.Route>(list.size());
for (ctbSource.Route R : list) {
merged.add(entityManager.merge(R));

21 | P a g e
}
list.clear();
list.addAll(merged);
}
}

// Variables declaration - do not modify


private javax.swing.JButton deleteButton;
private javax.swing.JButton deleteDetailButton;
private javax.swing.JScrollPane detailScrollPane;
private javax.swing.JTable detailTable;
private javax.persistence.EntityManager entityManager;
private java.util.List<ctbSource.Route> list;
private javax.swing.JScrollPane masterScrollPane;
private javax.swing.JTable masterTable;
private javax.swing.JButton newButton;
private javax.swing.JButton newDetailButton;
private javax.persistence.Query query;
private javax.swing.JButton refreshButton;
private javax.swing.JButton saveButton;
private org.jdesktop.beansbinding.BindingGroup bindingGroup;
// End of variables declaration

}
Now there is bus type record view interface

22 | P a g e
package ctbproject;

import java.awt.EventQueue;
import java.beans.Beans;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.RollbackException;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
*
* @author W.A.B. Janith
*/
public class Bus extends JPanel {

public Bus() {
initComponents();
if (!Beans.isDesignTime()) {
entityManager.getTransaction().begin();
}
}

/** This method is called from within the constructor to


* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

org.jdesktop.application.ResourceMap resourceMap =
org.jdesktop.application.Application.getInstance(ctbproject.CtbpROJECTApp.class).getContext
().getResourceMap(Bus.class);
entityManager = java.beans.Beans.isDesignTime() ? null :
javax.persistence.Persistence.createEntityManagerFactory(resourceMap.getString("entityManag
er.persistenceUnit")).createEntityManager(); // NOI18N
query = java.beans.Beans.isDesignTime() ? null :
entityManager.createQuery(resourceMap.getString("query.query")); // NOI18N
list = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :
org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList
());
masterScrollPane = new javax.swing.JScrollPane();
masterTable = new javax.swing.JTable();
busTipeLabel = new javax.swing.JLabel();
passengerAmountLabel = new javax.swing.JLabel();
busTipeField = new javax.swing.JTextField();
passengerAmountField = new javax.swing.JTextField();
saveButton = new javax.swing.JButton();
refreshButton = new javax.swing.JButton();
newButton = new javax.swing.JButton();
deleteButton = new javax.swing.JButton();

FormListener formListener = new FormListener();

setBackground(resourceMap.getColor("Form.background")); // NOI18N
setName("Form"); // NOI18N

masterScrollPane.setName("masterScrollPane"); // NOI18N

masterTable.setName("masterTable"); // NOI18N

23 | P a g e
org.jdesktop.swingbinding.JTableBinding jTableBinding =
org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoB
inding.UpdateStrategy.READ_WRITE, list, masterTable);
org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${busTipe}"));
columnBinding.setColumnName("Bus Tipe");
columnBinding.setColumnClass(String.class);
columnBinding =
jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${passengerAmou
nt}"));
columnBinding.setColumnName("Passenger Amount");
columnBinding.setColumnClass(Integer.class);
bindingGroup.addBinding(jTableBinding);

masterScrollPane.setViewportView(masterTable);

busTipeLabel.setForeground(resourceMap.getColor("busTipeLabel.foreground")); //
NOI18N
busTipeLabel.setText(resourceMap.getString("busTipeLabel.text")); // NOI18N
busTipeLabel.setName("busTipeLabel"); // NOI18N

passengerAmountLabel.setForeground(resourceMap.getColor("passengerAmountLabel.foreground"))
; // NOI18N
passengerAmountLabel.setText(resourceMap.getString("passengerAmountLabel.text"));
// NOI18N
passengerAmountLabel.setName("passengerAmountLabel"); // NOI18N

busTipeField.setName("busTipeField"); // NOI18N

org.jdesktop.beansbinding.Binding binding =
org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.
UpdateStrategy.READ_WRITE, masterTable,
org.jdesktop.beansbinding.ELProperty.create("${selectedElement.busTipe}"), busTipeField,
org.jdesktop.beansbinding.BeanProperty.create("text"));
binding.setSourceUnreadableValue(null);
bindingGroup.addBinding(binding);
binding =
org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.
UpdateStrategy.READ, masterTable,
org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), busTipeField,
org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);

passengerAmountField.setName("passengerAmountField"); // NOI18N

binding =
org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.
UpdateStrategy.READ_WRITE, masterTable,
org.jdesktop.beansbinding.ELProperty.create("${selectedElement.passengerAmount}"),
passengerAmountField, org.jdesktop.beansbinding.BeanProperty.create("text"));
binding.setSourceUnreadableValue(null);
bindingGroup.addBinding(binding);
binding =
org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.
UpdateStrategy.READ, masterTable,
org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"),
passengerAmountField, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);

saveButton.setText(resourceMap.getString("saveButton.text")); // NOI18N
saveButton.setName("saveButton"); // NOI18N
saveButton.addActionListener(formListener);

refreshButton.setText(resourceMap.getString("refreshButton.text")); // NOI18N
refreshButton.setName("refreshButton"); // NOI18N

24 | P a g e
refreshButton.addActionListener(formListener);

newButton.setText(resourceMap.getString("newButton.text")); // NOI18N
newButton.setName("newButton"); // NOI18N
newButton.addActionListener(formListener);

deleteButton.setText(resourceMap.getString("deleteButton.text")); // NOI18N
deleteButton.setName("deleteButton"); // NOI18N

binding =
org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.
UpdateStrategy.READ, masterTable,
org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), deleteButton,
org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);

deleteButton.addActionListener(formListener);

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


this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(newButton)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(deleteButton)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(refreshButton)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(saveButton))
.addGroup(layout.createSequentialGroup()
.addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(busTipeLabel)
.addComponent(passengerAmountLabel))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(busTipeField,
javax.swing.GroupLayout.DEFAULT_SIZE, 437, Short.MAX_VALUE)
.addComponent(passengerAmountField,
javax.swing.GroupLayout.DEFAULT_SIZE, 437, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(masterScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)))
.addContainerGap())
);

layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[]


{deleteButton, newButton, refreshButton, saveButton});

layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()

25 | P a g e
.addComponent(masterScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 236,
Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(busTipeLabel)
.addComponent(busTipeField, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(passengerAmountLabel)
.addComponent(passengerAmountField,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(saveButton)
.addComponent(refreshButton)
.addComponent(deleteButton)
.addComponent(newButton))
.addContainerGap())
);

bindingGroup.bind();
}

// Code for dispatching events from components to event handlers.

private class FormListener implements java.awt.event.ActionListener {


FormListener() {}
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (evt.getSource() == saveButton) {
Bus.this.saveButtonActionPerformed(evt);
}
else if (evt.getSource() == refreshButton) {
Bus.this.refreshButtonActionPerformed(evt);
}
else if (evt.getSource() == newButton) {
Bus.this.newButtonActionPerformed(evt);
}
else if (evt.getSource() == deleteButton) {
Bus.this.deleteButtonActionPerformed(evt);
}
}
}// </editor-fold>

@SuppressWarnings("unchecked")
private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {
entityManager.getTransaction().rollback();
entityManager.getTransaction().begin();
java.util.Collection data = query.getResultList();
for (Object entity : data) {
entityManager.refresh(entity);
}
list.clear();
list.addAll(data);
}

private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {


int[] selected = masterTable.getSelectedRows();
List<ctbSource.Bus> toRemove = new ArrayList<ctbSource.Bus>(selected.length);
for (int idx=0; idx<selected.length; idx++) {
ctbSource.Bus b = list.get(masterTable.convertRowIndexToModel(selected[idx]));

26 | P a g e
toRemove.add(b);
entityManager.remove(b);
}
list.removeAll(toRemove);
}

private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {


ctbSource.Bus b = new ctbSource.Bus();
entityManager.persist(b);
list.add(b);
int row = list.size()-1;
masterTable.setRowSelectionInterval(row, row);
masterTable.scrollRectToVisible(masterTable.getCellRect(row, 0, true));
}

private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {


try {
entityManager.getTransaction().commit();
entityManager.getTransaction().begin();
} catch (RollbackException rex) {
rex.printStackTrace();
entityManager.getTransaction().begin();
List<ctbSource.Bus> merged = new ArrayList<ctbSource.Bus>(list.size());
for (ctbSource.Bus b : list) {
merged.add(entityManager.merge(b));
}
list.clear();
list.addAll(merged);
}
}

// Variables declaration - do not modify


private javax.swing.JTextField busTipeField;
private javax.swing.JLabel busTipeLabel;
private javax.swing.JButton deleteButton;
private javax.persistence.EntityManager entityManager;
private java.util.List<ctbSource.Bus> list;
private javax.swing.JScrollPane masterScrollPane;
private javax.swing.JTable masterTable;
private javax.swing.JButton newButton;
private javax.swing.JTextField passengerAmountField;
private javax.swing.JLabel passengerAmountLabel;
private javax.persistence.Query query;
private javax.swing.JButton refreshButton;
private javax.swing.JButton saveButton;
private org.jdesktop.beansbinding.BindingGroup bindingGroup;
// End of variables declaration

27 | P a g e
Entity-Relationship Diagram
This relation diagram is Entity relation ship diagram it is characterized how to
relationship with table in Database.

Bus type

Passenger
amount

Bus type

To
Assign Through

From

Route Far

Route No
Price of ticket

Bus type
Documentary

R
u
Service District
n

Route No

Date

Number of ticket

Running
Number of trip

Stch..K.M
Vehicle number

Value
Stch..K.M Stch..K.M/Service

28 | P a g e
Database structure
MySql is used as the database management system of this project. The database named
ctbsource is the database of this system. In the ctbsource database there are many tables to
handle by operator. In the ctbsource database contains bus, runing and route tables currently.

Consider about the route table. It consists of all the data of route details of this system.

The above figure is a description of the route table, which we can understand what are the fields and
the corresponding data types of the fields. RouteNo field is the Primary Key of the route table.

In Route table there are not all route decodes. In that there is only fist 3 route recodes.

Consider about the runing table. It consists of all the data of running details of busses in this
system. This tables primary key is Run_no.

29 | P a g e
This is running table .there is some of recodes.

Consider about the bus table. It consists of all the data of bus type and amount of passenger of bus
in this system.

O/R mapping
After then I use new technology to connect and communicate with database. it is Object relational
mapping. Object-relational mapping (ORM, O/RM, and O/R mapping) in computer software is
a programming technique for converting data between incompatible type systems in object-
oriented programming languages. This creates, in effect, a "virtual object database" that can be used
from within the programming language. There are both free and commercial packages available that
perform object-relational mapping, although some programmers opt to create their own ORM tools.
Data management tasks in object-oriented (OO) programming are typically implemented by
manipulating objects that are almost always non-scalar values. For example, consider an address book
entry that represents a single person along with zero or more phone numbers and zero or more
addresses. This could be modeled in an object-oriented implementation by a "person object" with
"slots" to hold the data that comprise the entry: the person's name, a list of phone numbers, and a list
of addresses. The list of phone numbers would itself contain "phone number objects" and so on. The
address book entry is treated as a single value by the programming language (it can be referenced by a
single variable, for instance). Various methods can be associated with the object, such as a method to
return the preferred phone number, the home address, and so on.
However, many popular database products such as structured query language database management
systems (SQL DBMS) can only store and manipulate scalar values such as integers and strings
organized within normalized tables. Convert the object values into groups of simpler values for
storage in the database (and convert them back upon retrieval), only use simple scalar values within
the program. Object-relational mapping is used to implement the first approach.
The heart of the problem is translating those objects to forms that can be stored in the database for
easy retrieval, while preserving the properties of the objects and their relationships; these objects are
then said to be persistent.

30 | P a g e
Fist we billed persistence.xml file then we can billed persistence unite that is name is
ctbpROJECTPU

<?xml version="1.0" encoding="UTF-8"?>


<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="ctbpROJECTPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>ctbSource.Bus</class>
<class>ctbSource.Route</class>
<class>ctbSource.Runing</class>
<properties>
<property name="javax.persistence.jdbc.url"
value="jdbc:mysql://localhost:3306/ctbsource"/>
<property name="javax.persistence.jdbc.password" value="ijts"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.user" value="root"/>
</properties>
</persistence-unit>
</persistence>

After then we can b build entity beans file in using O/R mapping with our database ctbsource

This is Route entity beans class.

package ctbSource;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
*
* @author W.A.B. Janith
*/
@Entity
@Table(name = "route")
@NamedQueries({
@NamedQuery(name = "Route.findAll", query = "SELECT r FROM Route r"),

31 | P a g e
@NamedQuery(name = "Route.findByRouteNo", query = "SELECT r FROM Route r WHERE
r.routeNo = :routeNo"),
@NamedQuery(name = "Route.findByFromplace", query = "SELECT r FROM Route r
WHERE r.fromplace = :fromplace"),
@NamedQuery(name = "Route.findByThroughplace", query = "SELECT r FROM Route r
WHERE r.throughplace = :throughplace"),
@NamedQuery(name = "Route.findByToplace", query = "SELECT r FROM Route r WHERE
r.toplace = :toplace"),
@NamedQuery(name = "Route.findByFar", query = "SELECT r FROM Route r WHERE
r.far = :far"),
@NamedQuery(name = "Route.findByPriceOfTicket", query = "SELECT r FROM Route r
WHERE r.priceOfTicket = :priceOfTicket"),
@NamedQuery(name = "Route.findByDocumentary", query = "SELECT r FROM Route r
WHERE r.documentary = :documentary"),
@NamedQuery(name = "Route.findByServiceDis", query = "SELECT r FROM Route r
WHERE r.serviceDis = :serviceDis")})
public class Route implements Serializable {
@Transient
private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "RouteNo")
private String routeNo;
@Basic(optional = false)
@Column(name = "From_place")
private String fromplace;
@Basic(optional = false)
@Column(name = "Through_place")
private String throughplace;
@Basic(optional = false)
@Column(name = "To_place")
private String toplace;
@Basic(optional = false)
@Column(name = "Far")
private BigDecimal far;
@Basic(optional = false)
@Column(name = "PriceOfTicket")
private BigDecimal priceOfTicket;
@Basic(optional = false)
@Column(name = "Documentary")
private BigDecimal documentary;
@Basic(optional = false)
@Column(name = "serviceDis")
private String serviceDis;
@JoinColumn(name = "BusTipe", referencedColumnName = "BusTipe")
@ManyToOne(optional = false)
private Bus busTipe;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "routeNo")
private List<Runing> runingList;

public Route() {
}

public Route(String routeNo) {


this.routeNo = routeNo;
}

32 | P a g e
public Route(String routeNo, String fromplace, String throughplace, String
toplace, BigDecimal far, BigDecimal priceOfTicket, BigDecimal documentary, String
serviceDis) {
this.routeNo = routeNo;
this.fromplace = fromplace;
this.throughplace = throughplace;
this.toplace = toplace;
this.far = far;
this.priceOfTicket = priceOfTicket;
this.documentary = documentary;
this.serviceDis = serviceDis;
}

public String getRouteNo() {


return routeNo;
}

public void setRouteNo(String routeNo) {


String oldRouteNo = this.routeNo;
this.routeNo = routeNo;
changeSupport.firePropertyChange("routeNo", oldRouteNo, routeNo);
}

public String getFromplace() {


return fromplace;
}

public void setFromplace(String fromplace) {


String oldFromplace = this.fromplace;
this.fromplace = fromplace;
changeSupport.firePropertyChange("fromplace", oldFromplace, fromplace);
}

public String getThroughplace() {


return throughplace;
}

public void setThroughplace(String throughplace) {


String oldThroughplace = this.throughplace;
this.throughplace = throughplace;
changeSupport.firePropertyChange("throughplace", oldThroughplace,
throughplace);
}

public String getToplace() {


return toplace;
}

public void setToplace(String toplace) {


String oldToplace = this.toplace;
this.toplace = toplace;
changeSupport.firePropertyChange("toplace", oldToplace, toplace);
}

public BigDecimal getFar() {


return far;
}

public void setFar(BigDecimal far) {

33 | P a g e
BigDecimal oldFar = this.far;
this.far = far;
changeSupport.firePropertyChange("far", oldFar, far);
}

public BigDecimal getPriceOfTicket() {


return priceOfTicket;
}

public void setPriceOfTicket(BigDecimal priceOfTicket) {


BigDecimal oldPriceOfTicket = this.priceOfTicket;
this.priceOfTicket = priceOfTicket;
changeSupport.firePropertyChange("priceOfTicket", oldPriceOfTicket,
priceOfTicket);
}

public BigDecimal getDocumentary() {


return documentary;
}

public void setDocumentary(BigDecimal documentary) {


BigDecimal oldDocumentary = this.documentary;
this.documentary = documentary;
changeSupport.firePropertyChange("documentary", oldDocumentary,
documentary);
}

public String getServiceDis() {


return serviceDis;
}

public void setServiceDis(String serviceDis) {


String oldServiceDis = this.serviceDis;
this.serviceDis = serviceDis;
changeSupport.firePropertyChange("serviceDis", oldServiceDis, serviceDis);
}

public Bus getBusTipe() {


return busTipe;
}

public void setBusTipe(Bus busTipe) {


Bus oldBusTipe = this.busTipe;
this.busTipe = busTipe;
changeSupport.firePropertyChange("busTipe", oldBusTipe, busTipe);
}

public List<Runing> getRuningList() {


return runingList;
}

public void setRuningList(List<Runing> runingList) {


this.runingList = runingList;
}

@Override
public int hashCode() {
int hash = 0;
hash += (routeNo != null ? routeNo.hashCode() : 0);

34 | P a g e
return hash;
}

@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
not set
if (!(object instanceof Route)) {
return false;
}
Route other = (Route) object;
if ((this.routeNo == null && other.routeNo != null) || (this.routeNo !=
null && !this.routeNo.equals(other.routeNo))) {
return false;
}
return true;
}

@Override
public String toString() {
return "ctbSource.Route[routeNo=" + routeNo + "]";
}

public void addPropertyChangeListener(PropertyChangeListener listener) {


changeSupport.addPropertyChangeListener(listener);
}

public void removePropertyChangeListener(PropertyChangeListener listener) {


changeSupport.removePropertyChangeListener(listener);
}

This is runing entity beans class.

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package ctbSource;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

35 | P a g e
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
*
* @author W.A.B. Janith
*/
@Entity
@Table(name = "runing")
@NamedQueries({
@NamedQuery(name = "Runing.findAll", query = "SELECT r FROM Runing r"),
@NamedQuery(name = "Runing.findByRunno", query = "SELECT r FROM Runing r WHERE
r.runno = :runno"),
@NamedQuery(name = "Runing.findByDate", query = "SELECT r FROM Runing r WHERE
r.date = :date"),
@NamedQuery(name = "Runing.findByTripNumber", query = "SELECT r FROM Runing r
WHERE r.tripNumber = :tripNumber"),
@NamedQuery(name = "Runing.findByVehicalNo", query = "SELECT r FROM Runing r
WHERE r.vehicalNo = :vehicalNo"),
@NamedQuery(name = "Runing.findByValue", query = "SELECT r FROM Runing r WHERE
r.value = :value"),
@NamedQuery(name = "Runing.findByStchKm", query = "SELECT r FROM Runing r
WHERE r.stchKm = :stchKm"),
@NamedQuery(name = "Runing.findByStchKmService", query = "SELECT r FROM Runing
r WHERE r.stchKmService = :stchKmService"),
@NamedQuery(name = "Runing.findByStchKmDead", query = "SELECT r FROM Runing r
WHERE r.stchKmDead = :stchKmDead"),
@NamedQuery(name = "Runing.findByNumOfTickets", query = "SELECT r FROM Runing
r WHERE r.numOfTickets = :numOfTickets")})
public class Runing implements Serializable {
@Transient
private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "Run_no")
private Integer runno;
@Basic(optional = false)
@Column(name = "Date")
@Temporal(TemporalType.DATE)
private Date date;
@Column(name = "TripNumber")
private Integer tripNumber;
@Column(name = "VehicalNo")
private String vehicalNo;
@Basic(optional = false)
@Column(name = "Value")
private BigDecimal value;
@Basic(optional = false)
@Column(name = "Stch_Km")
private BigDecimal stchKm;
@Column(name = "Stch_Km_Service")
private BigDecimal stchKmService;
@Basic(optional = false)
@Column(name = "Stch_Km_Dead")
private BigDecimal stchKmDead;
@Basic(optional = false)

36 | P a g e
@Column(name = "NumOfTickets")
private int numOfTickets;
@JoinColumn(name = "RouteNo", referencedColumnName = "RouteNo")
@ManyToOne(optional = false)
private Route routeNo;

public Runing() {
}

public Runing(Integer runno) {


this.runno = runno;
}

public Runing(Integer runno, Date date, BigDecimal value, BigDecimal stchKm,


BigDecimal stchKmDead, int numOfTickets) {
this.runno = runno;
this.date = date;
this.value = value;
this.stchKm = stchKm;
this.stchKmDead = stchKmDead;
this.numOfTickets = numOfTickets;
}

public Integer getRunno() {


return runno;
}

public void setRunno(Integer runno) {


Integer oldRunno = this.runno;
this.runno = runno;
changeSupport.firePropertyChange("runno", oldRunno, runno);
}

public Date getDate() {


return date;
}

public void setDate(Date date) {


Date oldDate = this.date;
this.date = date;
changeSupport.firePropertyChange("date", oldDate, date);
}

public Integer getTripNumber() {


return tripNumber;
}

public void setTripNumber(Integer tripNumber) {


Integer oldTripNumber = this.tripNumber;
this.tripNumber = tripNumber;
changeSupport.firePropertyChange("tripNumber", oldTripNumber, tripNumber);
}

public String getVehicalNo() {


return vehicalNo;
}

public void setVehicalNo(String vehicalNo) {


String oldVehicalNo = this.vehicalNo;

37 | P a g e
this.vehicalNo = vehicalNo;
changeSupport.firePropertyChange("vehicalNo", oldVehicalNo, vehicalNo);
}

public BigDecimal getValue() {


return value;
}

public void setValue(BigDecimal value) {


BigDecimal oldValue = this.value;
this.value = value;
changeSupport.firePropertyChange("value", oldValue, value);
}

public BigDecimal getStchKm() {


return stchKm;
}

public void setStchKm(BigDecimal stchKm) {


BigDecimal oldStchKm = this.stchKm;
this.stchKm = stchKm;
changeSupport.firePropertyChange("stchKm", oldStchKm, stchKm);
}

public BigDecimal getStchKmService() {


return stchKmService;
}

public void setStchKmService(BigDecimal stchKmService) {


BigDecimal oldStchKmService = this.stchKmService;
this.stchKmService = stchKmService;
changeSupport.firePropertyChange("stchKmService", oldStchKmService,
stchKmService);
}

public BigDecimal getStchKmDead() {


return stchKmDead;
}

public void setStchKmDead(BigDecimal stchKmDead) {


BigDecimal oldStchKmDead = this.stchKmDead;
this.stchKmDead = stchKmDead;
changeSupport.firePropertyChange("stchKmDead", oldStchKmDead, stchKmDead);
}

public int getNumOfTickets() {


return numOfTickets;
}

public void setNumOfTickets(int numOfTickets) {


int oldNumOfTickets = this.numOfTickets;
this.numOfTickets = numOfTickets;
changeSupport.firePropertyChange("numOfTickets", oldNumOfTickets,
numOfTickets);
}

public Route getRouteNo() {


return routeNo;
}

38 | P a g e
public void setRouteNo(Route routeNo) {
Route oldRouteNo = this.routeNo;
this.routeNo = routeNo;
changeSupport.firePropertyChange("routeNo", oldRouteNo, routeNo);
}

@Override
public int hashCode() {
int hash = 0;
hash += (runno != null ? runno.hashCode() : 0);
return hash;
}

@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
not set
if (!(object instanceof Runing)) {
return false;
}
Runing other = (Runing) object;
if ((this.runno == null && other.runno != null) || (this.runno != null &&
!this.runno.equals(other.runno))) {
return false;
}
return true;
}

@Override
public String toString() {
return "ctbSource.Runing[runno=" + runno + "]";
}

public void addPropertyChangeListener(PropertyChangeListener listener) {


changeSupport.addPropertyChangeListener(listener);
}

public void removePropertyChangeListener(PropertyChangeListener listener) {


changeSupport.removePropertyChangeListener(listener);
}

This is bus entity beans class.

package ctbSource;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;

39 | P a g e
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
*
* @author W.A.B. Janith
*/
@Entity
@Table(name = "bus")
@NamedQueries({
@NamedQuery(name = "Bus.findAll", query = "SELECT b FROM Bus b"),
@NamedQuery(name = "Bus.findByBusTipe", query = "SELECT b FROM Bus b WHERE
b.busTipe = :busTipe"),
@NamedQuery(name = "Bus.findByPassengerAmount", query = "SELECT b FROM Bus b
WHERE b.passengerAmount = :passengerAmount")})
public class Bus implements Serializable {
@Transient
private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "BusTipe")
private String busTipe;
@Basic(optional = false)
@Column(name = "PassengerAmount")
private int passengerAmount;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "busTipe")
private List<Route> routeList;

public Bus() {
}

public Bus(String busTipe) {


this.busTipe = busTipe;
}

public Bus(String busTipe, int passengerAmount) {


this.busTipe = busTipe;
this.passengerAmount = passengerAmount;
}

public String getBusTipe() {


return busTipe;
}

public void setBusTipe(String busTipe) {


String oldBusTipe = this.busTipe;
this.busTipe = busTipe;
changeSupport.firePropertyChange("busTipe", oldBusTipe, busTipe);
}

public int getPassengerAmount() {


return passengerAmount;
}

public void setPassengerAmount(int passengerAmount) {


int oldPassengerAmount = this.passengerAmount;

40 | P a g e
this.passengerAmount = passengerAmount;
changeSupport.firePropertyChange("passengerAmount", oldPassengerAmount,
passengerAmount);
}

public List<Route> getRouteList() {


return routeList;
}

public void setRouteList(List<Route> routeList) {


this.routeList = routeList;
}

@Override
public int hashCode() {
int hash = 0;
hash += (busTipe != null ? busTipe.hashCode() : 0);
return hash;
}

@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
not set
if (!(object instanceof Bus)) {
return false;
}
Bus other = (Bus) object;
if ((this.busTipe == null && other.busTipe != null) || (this.busTipe !=
null && !this.busTipe.equals(other.busTipe))) {
return false;
}
return true;
}

@Override
public String toString() {
return busTipe;
}

public void addPropertyChangeListener(PropertyChangeListener listener) {


changeSupport.addPropertyChangeListener(listener);
}

public void removePropertyChangeListener(PropertyChangeListener listener) {


changeSupport.removePropertyChangeListener(listener);
}

41 | P a g e
Conclusion

Ctb report generater is very convinent to generate manthliy running report in by one click.
This system replaces the manual CTB running system with this desktop based running section
project and gains a great efficient for that process and save time than before. So this leads to keep
the office in a high efficiency. Now the balangoda deport can submit their monthly running report
forms through the software . And as another requirement is to filter data without limitations, is also
covered by this system. Now the user can filter the database as he/she wish to find the appropriate
data. This system will be a complete desktop base Runnig data recodes system after completing
the future developments which are discussed below.

Discussion
In this system we can implement All net work in CTB deport and can be used electronic
iquepment then we can extend out project in get record in detecting system.as well as using
Entieprise java beans (EJB 2.0)consept we can link all of deport in Island wide so its benifite
is Get source in short time
We can using ststitical testing in finaly develop in this system and increase profite and
income.

Bibliography.
http://www.oracle.com/technetwork/java/index.html

http://download.oracle.com/javase/tutorial/

http://www.java2s.com

http://hocjava.files.wordpress.com/2008/06/a-tutorial-on-jasperreports-ireport-and-jfreechart.pdf

42 | P a g e