Report Vms
Report Vms
Report Vms
A project report Submitted to Rajiv Gandhi Proudyogiki Vishwavidyalaya, Bhopal Towards partial fulfillment of The Degree of Bachelor of Engineering In Computer Science and Engineering 2011-2012
Guided by
Ms. Juhi Kanungo
CERTIFICATE
This is to certify that Mr. Gurdeep Singh Bhatia (CS-38) & Mr. Kunal Mehta (CS-51) B.E. (Computer Science and Engineering) Third year 2011-2012 of Computer Science and Engineering department of this Institute have completed the project work entitled Vehicle Management System based on syllabus.
Project Coordinator
Ms. Kavita Namdev
CERTIFICATE
This is to certify that the project work entitled Vehicle Management System submitted by Mr. Gurdeep Singh Bhatia (CS-38) & Mr. Kunal Mehta (CS-51), B.E. (Computer Science and Engineering) Third year 2011-2012 of Computer Science and Engineering Department of this institute based on syllabus and is approved as partial fulfillment for the award of the Bachelor of Engineering (in Computer Science and Engineering) Degree by Rajiv Gandhi Proudyogiki Vishwavidyalaya, Bhopal.
ACKNOWLEDGEMENT
There are two ways of spreading the light, to be a candle, or the mirror, which reflects it. In relation to the light of knowledge, this work carried out by us is just a mirror. There are some candles on the other side of the mirror. We would like to avail this opportunity to express our sincere thanks to all those who helped us in making this project. Even a most vivid collection of words, yield to express our heart fully thank towards one and all to have successfully assisted us in our expenditure of carrying out this project. We wish to express our deep sense of gratitude to H.O.D Mr. Sanjay Bansal, our project coordinator Ms. Kavita Namdev our project guide Ms. Juhi Kanungo and the whole faculty members of the department of Computer Science for encouraging and giving moral support, not only regarding this project but also throughout our studies at this institute. Also, to all my fellow classmates, friends and well wishers for their support and cooperation towards us.
CONTENTS
Chapter 1 Title Introduction 1.1 Purpose 1.2 Objectives 1.3 Scope 1.4 Problem Statement 1.4.1 Existing System 1.4.2Limitations 1.5 Proposed System 1.6 Intended Audience Literature Survey 2.1 Technologies 2.2 Tools Analysis 3.1 Detailed Statement of Problem 3.1.1 Problem Specification 3.1.2 Performance definition 3.1.3 Purpose 3.2 Functional Requirements 3.3 Non Functional Requirements 3.4 Use Case Model 3.2.1 Use Case Diagram 3.2.2 Use Case Specification 3.5 Activity Diagram 3.6 Class Diagram Design 4.1 Functional Model 4.1.1 Data Flow Diagram 4.2 Data Model 4.2.1 Entity Relationship Diagram 4.2.2 Database Design Page No. 12
15
22
28
5 6
Application Interface 5.1 Input / Output Interfaces Test Case Design 6.1 White Box Testing 6.2 Unit Testing 6.3 Integration Testing 6.2 System Testing 6.2 Black box Testing Output Screens 7.1 Screenshots of Code Screens 7.2 Important Coding Conclusion 7.1 Inferences Drawn 7.2 Future Scope 7.3 Limitations Users Manual References
39 42
44
73
A B
75 81
ABSTRACT
ABSTRACT
1. Aim:
This software design document describes the architecture and system design of Vehicle Management System (VMS) and provides an overview of the VMS system implementation. Its main purpose is to Provide the link between the Functional Specification and the detailed Design document. Detail the functionality which will be provided by each component or group of component and show how the various components interact in the design. Provide a basis for the VMS systems detailed design and development
2. Scope:
The Application Design outline in this document builds upon the scope define in the Requirement phase. Additionally this document provides mainly the details of the vehicle management system. Vehicle Management System is a complete solution for company's offering complete operational management for the day-to-day activities which are helpful to both the Management and the Customers. It is a Daily Accounting Software for all types of vehicles like in Transport industry, private or public service, cars, taxis, coaches, vans, picks up trucks, buses, trucks, rental services etc
3. Objectives:
Vehicle Management System is software which is helpful for bus operators, who wants to operate many bus trips in a day. Vehicle Management System is a desktop application for Windows operating systems which focused in the area of adding, editing and deleting the passengers, staff and the bus routes. In this software a manager can manage the vehicle routes and the staff, passengers details; he can also appoint other managers and booking clerk. He can add a
bus and its details including bus route details. He can also add the details of the staff and their duty time in the system
4. Formal Description:
Vehicle Management System is a complete solution for company's offering complete operational management for the day-to-day activities which are helpful to both the Management and the Customers. It is a Daily Accounting Software for all types of vehicles like in Transport industry, private or public service, cars, taxis, coaches, vans, picks up trucks, buses, trucks, rental services etc. It is most ideal for bus & taxi depots, garages, scrap yards, vehicle recovery businesses and other vehicle management companies. There are 2 intended users in our software. Manager Booking clerk
The manager can update the database time to time whenever required. He can also add new user as a manager or a booking clerk. The Booking clerk looks after the ticket selling and payment processes, registers passengers, baggage etc.
5. Modular Design:
VMS is a Management Information System specially designed for vehicle maintenance, job dispatching and route planning. VMS is a desktop-based system. Followings are the product features of VMS: Bus maintenance system Route Management Employee Management Passenger Management Bus maintenance system In Vehicle module a user can add a new Vehicle details to the database. Route Management Route Management module deals with the route management of the Vehicle. Employee Management In Employee Management personal details of employee can added to database. Passenger Management Details of every passenger are stored in the system
6. Technical Details:
Hardware Requirements:
For Windows 95 based computers , a 486 / 66 MHz or higher processor with 8MB
For Windows NT based computers , a 488 / 66 MHz or higher processor with 16 MB of RAM
For Windows 2000, XP based computers , a 700/850 MHz or higher processor with 512 MB of Ram
Software Requirements:
: Windows NT, 98, 2000, XP, 7, Vista. : Java 2 Runtime Environment(jdk) : MS Access2007
CHAPTER 1 INTRODUCTION
INTRODUCTION
1.1 Purpose
Vehicle Management System is software which is helpful for vehicle operators, who wants to operate many trips in a day. In this software a manager can manage the vehicle routes and the staff, passengers details; he can also appoint other managers and booking clerk. The proposed system is very useful for the operators and passengers. This avoids the overheads for the operators. They can minimize the working stress and can keep essential documents related to the vehicle and the passengers as a softcopy. The advantage of the proposed system is the reduction in the cost of the office equipments and the transaction is done quickly. Any operator can answer if any seats for a particular route in a particular day are available or not
1.2 Objective
The goal of this project is basically management convenience. This also does not require special efforts from the management staff. It reduces manpower, time and cost. Vehicle Management System is a desktop application written for Windows operating systems which focused in the area of adding, editing and deleting the passengers, staff and the vehicle routes all the data will be stored with security. Genuineness is assured as all booking information is stored in the database.
1.3 Scope
Vehicle Management System is a complete solution for company's offering complete operational management for the day-to-day activities which are helpful to both the Management and the Customers. It is a Daily Accounting Software for all types of vehicles like in Transport industry, private or public service, cars, taxis, coaches, vans, picks up trucks, buses, trucks, rental services etc. It is most ideal for bus & taxi depots, garages, scrap yards, vehicle recovery businesses and other vehicle management companies
1.4.2Limitations
Slow access to database More probability of error Less Storage Capacity No Search facility Difficult to search old records Difficult to update records
The manager can update the database time to time whenever required. He can also add new user as a manager or a booking clerk.
The Booking clerk looks after the ticket selling and payment processes, registers passengers, baggage etc.
LITERATURE SURVEY
Object oriented programming is a power full way of organizing and developing software. Object oriented programming uses a set of components called objects. These objects exist independently of each other and communicate with each other. Thats why object oriented program are more adoptable and more bug proof. JAVA is small and simple:
The most complex parts of c++ were excluded from java, such as pointers and memory management. These elements are complicated to use. JAVA is safe:
Another thing essential to javas success is that it is safe. Java provides security and several different levels. Before a java program is run, a verifier check each by code to make sure nothing suspicious is going on.
Platform independence is another way of saying that java is architectural neutral. The basically means that java programs dont care what system they are running on. JAVA is architectural neutral:
The JAVA designers made several hard decisions in the java languages and JVM is an attempt to alter the situation programs not running on the same machine after few days. Their goal was Write once; run anywhere, anytime, forever. JAVA is Distributed
Java is designed for the distributed environment of Internet because it handles TCP/IP protocols. The feature of inter-address-space messaging is done with the help of package Remote Method Invocation (RMI). This feature brings an unparalleled level of instructions to the client/server programming. JAVA is dynamic
Java programs carry with them substantial amounts of run time type information that is use to verify and resolve accesses to objects at run time. This is crucial to the robustness to the applet environment.
server side technology. J2EE is a platform independent, java centric environment from sun for developing, building and deploying web based enterprise application online. The J2EE platform consists of a set of services, APIs and protocols that provide functionality for developing multitiered web based application.At the client side tier, J2EE supports pure HTML as well as java applets or applications. It relies on JSP and Servlet codes to create HTML or other formatted data for the client. EJB provide another layer where the platforms logic is stored. An EJB server provides functions such as threading, concurrency, security and memory management. To reduce costs and fast-track enterprise application design and development, the java2 platform, Enterprise edition (J2EE) technology provides a component-based approach to the design, development, assembly and distributed application model, the ability to reuse components; integrated Extensible Markup Language (XML) based data interchange, a unified security model, and flexible transaction control. DISTRIBUTED MULTI TIERED APPLICATIONS The J2EE platform uses a multi tiered distributed application model. Application logic is divided into components according to function, and the various application components that make up a J2EE application are installed on different machines depending on the tier in the multi tiered J2EE environment to which the application component belongs. The figure shown below shows two multi tiered j2EE applications divided into the tiers described in the following list. The J2EE application parts shown in Figure Client-tier components run on the client machine. Web-tier components run on the J2EE server. Business-tier components run on the J2EE server. Enterprise information system (EIS)-tier software runs the EIS server.
developers. The IDE runs on many platforms including Windows, Linux, and Solaris. It is easy to install and use straight out of the box. The Net Beans IDE provides developers with all the tools they need to create professional cross-platform desktop, enterprise, web and mobile applications. Net Beans, along with Eclipse, is one of the most widely used Java IDE (Integrated Development Environment). The purpose of this document is to describe the steps needed to run Net beans 6.0.1 on a net based system, using Linux Java Virtual Machine and Linux compatibility mode. The major reasons for using NETBEANS are: a) It is the best IDE for Expediting Java Development. b) It provides a very easy way to connect one form to other. c) Easy connectivity of the forms. d) Its GUI makes it much more user friendly.
Java is used as the front end tool due to the following reasons: a) It is completely object oriented. b) Easy database linking and access. c) Proper object linking and embedding. d) It is platform independent. e) Low overhead profiling. f) Attaching to running applications. g) CPU Performance profiling. h) Memory leak debugging. i) Task-based profiling.
Microsoft Access is a Relational Database Management System. Using Access we can organize our data according to subject and can store information about how different subject are related. In general MS-Access database can have several small tables. Microsoft Office Access, previously known as Microsoft Access, is a relational database management system from Microsoft that combines the relational Microsoft Jet Database Engine with a graphical user interface and software development tools. It is a member of the 2007 Microsoft Office system. Access can use data stored in Access/Jet, Microsoft SQL Server, Oracle, or any ODBC-compliant data container (including MySQL and PostgreSQL). Skilled software developers and data architects use it to develop application software. Relatively unskilled programmers and nonprogrammer "power users" can use it to build simple applications. It supports some object-oriented techniques but falls short of being a fully object-oriented development tool. Access is used by small businesses, within departments of large corporations, and by hobby programmers to create ad hoc customized desktop systems for handling the creation and manipulation of data. Access can be used as a database for basic web based applications hosted on Microsoft's Internet Information Services and utilizing Microsoft Active Server Pages ASP. Most typical web applications should use tools like ASP/Microsoft SQL Server or the LAMP stack. Some professional application developers use Access for rapid application development, especially for the creation of prototypes and standalone applications that serve as tools for on-the-road salesmen. Access does not scale well if data access is via a network, so applications that are used by more than a handful of people tend to rely on Client-Server based solutions. However, an Access "front end" (the forms, reports, queries and VB code) can be used against a host of database back ends, including JET (file-based database engine, used in Access by default), Microsoft SQL Server, Oracle, and any other ODBC-compliant product. Features One of the benefits of Access from a programmer's perspective is its relative compatibility with SQL (structured query language) queries may be viewed and edited as SQL statements, and SQL statements can be used directly in Macros and VBA Modules to manipulate Access tables. Users may mix and use both VBA and "Macros" for programming forms and logic and offers object-oriented possibilities.
MSDE (Microsoft SQL Server Desktop Engine) 2000, a mini-version of MS SQL Server 2000, is included with the developer edition of Office XP and may be used with Access as an alternative to the Jet Database Engine. Unlike a modern RDBMS, the Access and the Jet Engine implements database triggers and stored procedures in a non-standard way. Stored Procedures are implemented in VBA, and Triggers are only available from embedded Forms. Both Triggers and Stored procedures are only available to applications built completely within the Access database management system. Client applications built with VB or C++ are not able to access these features. Starting in MS Access 2003 (Jet 4.0), there is a new syntax for creating queries with parameters, in a way that looks like creating stored procedures, but these procedures are still limited to one statement per procedure. Microsoft Access does allow forms to contain code that is triggered as changes are made to the underlying table (as long as the modifications are done only with that form), and it is common to use pass-through queries and other techniques in Access to run stored procedures in RDBMSs that support these. In ADP files (supported in MS Access 2003 and later), the database-related features are entirely different, because this type of file connects to a MSDE or Microsoft SQL Server, instead of using the Jet Engine. Thus, it supports the creation of nearly all objects in the underlying server (tables with constraints and triggers, views, stored procedures and UDF-s). However, only forms, reports, macros and modules are stored in the ADP file (the other objects are stored in the back-end database).
CHAPTER 3 ANALYSIS
ANALYSIS
3.1
IT PERFORM 24 X 365 OPERATION CAN HELP IN RESOLVING PROBLEMS ARISES WITHOUT PRIOR WARNINGS
3.1.3 Purpose
Our proposed system serves following purposes User friendly interface Fast access to database Less error More Storage Capacity
1. REQUIREMENTS: The system should have the requirements of the project. The developer should prepare the requirements of the project. The should prepare the requirements which are need for the software. 2. ANALYSIS: Analyze the requirements whether it provides proper operations/output and performs the task. 3. DESIGN: Project manager should design the layout of the project before going to implement time allocation; cost allocation and staff allocation will coming under design process. 4. IMPLEMENTATION: After encompassing all the diagrams, we have to generate code for each and every diagram i.e. from use case to deployment. 5. TESTING: After implementing the diagram with domain language, we have to test the particular projects. 6. MAINTAINENCE: The system should be easily updated. The system should utilize the interchangeable plugins software developed should maintain the cost and time schedule of the project.
ii. DESIGN CONSTRAINTS: a) The software shall be a standard system running in a windows environment. b) The system shall be developed using rational enterprise suite and oracle 10i database. iii. RELIABILITY: Specify the factors required to establish the required reliability of the software system at time of delivery. iv. AVAILABILITY: The system should have an availability of 99.99%. v. PORTABILITY: a) The system should be extremely via the USB drive. b) The system shall be easy to migrate or backed up via another use drive. vi. MAINTAINABILITY: a) The system shall utilize interchangeable plugins. b) The system shall be easily updateable for fixes and patches.
CHAPTER 4 DESIGN
DESIGN
4.1 Functional Model 4.1.1 Data Flow Diagram
A Data Flow Diagram (DFD) is a diagram that describes the flow of data and the processes that change or transform data throughout a system. Its a structured analysis and design tool that can be used for flowcharting in place of, or in association with, information oriented and process oriented system flowcharts. When analysts prepare the Data Flow Diagram, they specify the user needs at a level of detail that virtually determines the information flow into and out of the system and the required data resources. This network is constructed by using a set of symbols that do not imply a physical implementation. The Data Flow Diagram reviews the current physical system, prepares input and output specification, specifies the implementation plan etc. Rules for constructing a Data Flow Diagram
Arrows should not cross each other. Squares, Circles and files must bear names. Decomposed data flow squares and circles can have same names. Choose meaningful names for dataflow. Draw all data flows around the outside of the diagram.
Data Flow
Process
Storage
4.2
Data Model
Controlled Redundancy Data independence Accurate and integrating More information at low cost Recovery from failure Privacy and security Performance
BOOKING
FieldName Booking_No Pass_No PassName Bus_RegNo SeatNo Date_of_Travel Time_of_Travel Pass_From Destination Amount DataType Number Text Text Text Text Text Text Text Text Text Key Primary -
BUSES
FieldName Bus_RegNo BusNo Model Capacity DateBought Insurance_Status Date_Insured Insurance_Expiry DataType Text Text Text Number Date/Time Text Date/Time Date/Time Key Primary -
Emp
FieldName empNo Sname Fname Lname Gender DOB Designation Telephone E_Mail Address
DataType Text Text Text Text Text Date/Time Text Number Text Text
Key Primary -
Passenger
FieldName Pass_No Pass_Name Address Tel_No Date_of_Travel Depot To Pay_Status Booked_Status DataType Text Text Text Number Date/Time Text Text Text Text Key Primary -
Payment
FieldName Payment_No Pass_No Pass_Name Payment_Mode Date_Payment Amount_Paid Received_By DataType Text Text Text Text Date/Time Currency Text Key Primary -
Route
FieldName Route_No RouteName Depot DataType Text Text Text Key Primary -
Schedules
FieldName Route_Name empNo Driver_Name Trip_No Date_Scheduled Dept_Time DataType Text Text Text Number Date/Time Text Key -
Trips
FieldName Trip_No Bus_RegNo Route_No S_Date DataType Text Text Text Text Key Primary -
APPLICATION INTERFACE
5.1
INPUT DESIGN
Input design is the process of converting user-oriented input to a computer based format. Input design is a part of overall system design, which requires very careful attention .Often the collection of input data is the most expensive part of the system. The main objectives of the input design are 1. Produce cost effective method of input 2. Achieve highest possible level of accuracy 3. Ensure that the input is acceptable to and understood by the staff. Input Data The goal of designing input data is to make entry easy, logical and free from errors as possible. The entering data entry operators need to know the allocated space for each field; field sequence and which must match with that in the source document. The format in which the data fields are entered should be given in the input form .Here data entry is online; it makes use of processor that accepts commands and data from the operator through a key board. The input required is analyzed by the processor. It is then accepted or rejected. Input stages include the following processes Data Recording Data Transcription Data Conversion Data Verification
Data Control Data Transmission Data Correction One of the aims of the system analyst must be to select data capture method and devices,
which reduce the number of stages so as to reduce both the changes of errors and the cost .Input types, can be characterized as. External Internal Operational Computerized Interactive Input files can exist in document form before being input to the computer. Input design is rather complex since it involves procedures for capturing data as well as inputting it to the computer.
OUTPUT DESIGN
Outputs from computer systems are required primarily to communicate the results of processing to users. They are also used to provide a permanent copy of these result for latter consultation.Computer output is the most important and direct source of information to the users. Designing computer output should proceed in an organized well through out the manner. The right output must be available for the people who find the system easy o use. The outputs have been defined during the logical design stage. If not, they should defined at the beginning of the output designing terms of types of output connect, format, response etc, Various types of outputs are External outputs Internal outputs
Operational outputs Interactive outputs Turn around outputs All screens are informative and interactive in such a way that the user can ful fill his
softwares structure and implementation .It is usually applied to relatively small program units such as sub-routines or the operations associated with an object or as small module of the system. White box testing was performed at all levels of development of Online Recruitment system. We took all care to test the code and guarantee that it meets all the specifications as well as it is logically correct. All loops were tested and all internal data structures were evaluated and verified.
units or modules not the whole program.We have tested all windows individually. As the modules were build up testing was carried out simultaneously, tracking out each and every kind of input and checking the corresponding output until module is working correctly.
OUTPUT SCREENS
7.1
MAIN WINDOW
SCHEDULING WINDOW
BOOKING WINDOW
7.2
Important Coding
//Main.java
public class Main implements Runnable{ private final JFrame frame; public Main(JFrame frm){ this.frame=frm; }//constructor closed public void run(){ frame.setVisible(true); }//run method closed public static void main(String args[]){ new frmSplash(3000); EventQueue.invokeLater(new Main(new LoginScreen())); }//main method closed
}//class closed
//LoginScreen.java
import java.awt.Dimension;
import java.awt.Font; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPasswordField; import javax.swing.JTextField;
private JLabel lblUsername, lblPasswd, lblCat; public JTextField txtUser; private JPasswordField txtPasswd; private JButton btnLogin, btnCancel; private JComboBox cmbCat; private Connection con; Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
public LoginScreen() { super("System Login"); this.getContentPane().setLayout(null); this.setSize(370, 250); this.setResizable(false); this.setLocation((screen.width - 500) / 2, ((screen.height - 350) / 2)); this.setDefaultCloseOperation(EXIT_ON_CLOSE);
lblUsername = new JLabel("Username"); lblPasswd = new JLabel("Password"); txtUser = new JTextField(); txtPasswd = new JPasswordField(); lblCat = new JLabel("Login As"); cmbCat = new JComboBox(); cmbCat.addItem("Manager"); cmbCat.addItem("Booking Clerk"); btnLogin = new JButton("Login", new ImageIcon(ClassLoader.getSystemResource("images\\Login.png"))); btnCancel = new JButton("Cancel", new ImageIcon(ClassLoader.getSystemResource("images\\Cancel.png")));
lblUsername.setBounds(40, 30, 100, 25); lblPasswd.setBounds(40, 65, 100, 25); lblCat.setBounds(40, 100, 100, 25); txtUser.setBounds(150, 30, 160, 25); txtPasswd.setBounds(150, 65, 160, 25); cmbCat.setBounds(150, 100, 160, 25);
lblUsername.setFont(new Font("monospaced", Font.BOLD, 16)); lblPasswd.setFont(new Font("monospaced", Font.BOLD, 16)); lblCat.setFont(new Font("monospaced", Font.BOLD, 16)); cmbCat.setFont(new Font("monospaced", Font.BOLD, 16)); txtUser.setFont(new Font("monospaced", Font.CENTER_BASELINE, 16)); txtPasswd.setFont(new Font("monospaced", Font.CENTER_BASELINE, 16)); this.add(lblUsername); this.add(txtUser); this.add(lblPasswd); this.add(txtPasswd); this.add(btnLogin); this.add(btnCancel); this.add(lblCat); this.add(cmbCat); this.add(btnLogin); this.add(btnCancel);
ButtonListener listener = new ButtonListener(); btnLogin.addActionListener(listener); btnCancel.addActionListener(listener); con = DBConnection.getDBConnection(); if (con == null) { JOptionPane.showMessageDialog(null, "Error on establishing database connection", "Error", JOptionPane.ERROR_MESSAGE);
public void login() { String username = txtUser.getText(); String password = txtPasswd.getText(); String SQL; String category = cmbCat.getSelectedItem().toString(); SQL = "SELECT * FROM users WHERE username='" + username + "' AND password='" + password + "'AND Category='" + category + "'"; try { Statement stmt = con.createStatement(); stmt.execute(SQL); ResultSet rs = stmt.getResultSet(); boolean recordfound = rs.next(); if (recordfound) { LoadMDIWindow(); this.dispose(); } else { JOptionPane.showMessageDialog(null, "The system could not log you in.\n" + " Please make sure your username and password are correct", "Login Failure", JOptionPane.INFORMATION_MESSAGE); txtUser.setText(""); txtPasswd.setText(""); txtUser.requestFocus();
} } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Error on login operation", "Login Error", JOptionPane.ERROR_MESSAGE); }//try catch closed }//Login() closed public void LoadMDIWindow() { if (cmbCat.getSelectedItem().equals("Manager")) { new MDIWindow().LoginManager();
public void actionPerformed(ActionEvent e) { if (e.getSource() == btnLogin) { if (txtUser.getText() == null || txtUser.getText().equals("")) { JOptionPane.showMessageDialog(null, "Enter username", "Missing field", JOptionPane.DEFAULT_OPTION); txtUser.requestFocus(); return; } if (txtPasswd.getText() == null || txtPasswd.getText().equals("")) { JOptionPane.showMessageDialog(null, "Enter password", "Missing field", JOptionPane.DEFAULT_OPTION);
txtPasswd.requestFocus(); return; } login(); } else if (e.getSource() == btnCancel) { System.exit(0); }//if else closed }//actionPerformed() closed }//ButtonListner class closed
//MDIWindow.java
import java.awt.*; import java.text.*; import java.awt.event.*; import javax.swing.*; import java.io.*; import java.sql.*; import javax.swing.plaf.metal.*;
private JMenuItem mnuNewuser, mnuExit; private JMenuItem mnuBuses, mnuEmps, mnuRoutes, mnuPassengers; private JMenuItem mnuBooking, mnuScheduling, mnuPayment; private JMenuItem mnuBusRpt, mnuEmpRpt, mnuSchedRpt, mnuBookRpt; private JMenuItem mnuCalculator, mnuNotepad; private JMenuItem mnuUsrMannual; private JLabel welcome; public static JDesktopPane desktop; String StrBusinesTitle; public JButton NewJButton; Connection getConnection;
welcome = new JLabel("Welcome: Today is " + new java.util.Date() + " ", JLabel.CENTER); welcome.setFont(new Font("monospaced", Font.BOLD, 12));
welcome.setForeground(Color.black); desktop = new JDesktopPane(); desktop.setBorder(BorderFactory.createEmptyBorder()); desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); getContentPane().add(welcome, BorderLayout.PAGE_END, JLabel.CENTER); getContentPane().add(desktop, BorderLayout.CENTER);
setVisible(true); }//Constructor closed protected JMenuBar CreateJMenuBar() { JMenuBar menubar = new JMenuBar(); /**********CREATING OPERATIONS MENU***********************/ mnuOperations = new JMenu("Operations"); mnuOperations.setForeground((Color.blue)); mnuOperations.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuOperations.setMnemonic('O'); mnuOperations.setEnabled(false);
mnuNewuser = new JMenuItem("AddNew User"); mnuNewuser.setForeground(Color.blue); mnuNewuser.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuNewuser.setMnemonic('L'); mnuNewuser.setIcon(new ImageIcon(ClassLoader.getSystemResource("images/users.png"))); mnuNewuser.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.CTRL_MASK)); mnuNewuser.setActionCommand("newuser");
mnuNewuser.addActionListener(menulistener);
mnuExit = new JMenuItem("Exit"); mnuExit.setForeground(Color.blue); mnuExit.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuExit.setMnemonic('E'); mnuExit.setIcon(new ImageIcon(ClassLoader.getSystemResource("images/exit.png"))); mnuExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); mnuExit.setActionCommand("exit"); mnuExit.addActionListener(menulistener);
/****************CREATING FILES MENU ********************/ mnuFiles = new JMenu("Files"); mnuFiles.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuFiles.setForeground((Color.blue)); mnuFiles.setMnemonic('F'); mnuFiles.setEnabled(false);
mnuBuses.setEnabled(true); mnuBuses.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuBuses.setMnemonic('B'); mnuBuses.setIcon(new ImageIcon(ClassLoader.getSystemResource("images/Buses.png"))); mnuBuses.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK)); mnuBuses.setActionCommand("buses"); mnuBuses.addActionListener(menulistener);
mnuEmps = new JMenuItem("Employees"); mnuEmps.setForeground(Color.blue); mnuEmps.setEnabled(true); mnuEmps.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuEmps.setMnemonic('E'); mnuEmps.setIcon(new ImageIcon(ClassLoader.getSystemResource("images/Emps.png"))); mnuEmps.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK)); mnuEmps.setActionCommand("employees"); mnuEmps.addActionListener(menulistener);
mnuRoutes = new JMenuItem("Routes"); mnuRoutes.setEnabled(true); mnuRoutes.setForeground(Color.blue); mnuRoutes.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuRoutes.setMnemonic('R');
mnuPassengers = new JMenuItem("Passengerss"); mnuPassengers.setForeground(Color.blue); mnuPassengers.setEnabled(false); mnuPassengers.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuPassengers.setMnemonic('P'); mnuPassengers.setIcon(new ImageIcon(ClassLoader.getSystemResource("images/pass.png"))); mnuPassengers.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK)); mnuPassengers.setActionCommand("passengers"); mnuPassengers.addActionListener(menulistener);
mnuScheduling = new JMenuItem("Scheduling"); mnuScheduling.setEnabled(false); mnuScheduling.setForeground(Color.blue); mnuScheduling.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuScheduling.setMnemonic('S'); mnuScheduling.setIcon(new ImageIcon(ClassLoader.getSystemResource("images/schedule.png"))); mnuScheduling.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); mnuScheduling.setActionCommand("scheduling"); mnuScheduling.addActionListener(menulistener);
mnuBooking = new JMenuItem("Booking"); mnuBooking.setEnabled(false); mnuBooking.setForeground(Color.blue); mnuBooking.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuBooking.setMnemonic('B'); mnuBooking.setIcon(new ImageIcon(ClassLoader.getSystemResource("images/Booking.png"))); mnuBooking.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, ActionEvent.CTRL_MASK)); mnuBooking.setActionCommand("booking"); mnuBooking.addActionListener(menulistener);
mnuPayment = new JMenuItem("Payments"); mnuPayment.setForeground(Color.blue); mnuPayment.setEnabled(false); mnuPayment.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuPayment.setMnemonic('P'); mnuPayment.setIcon(new ImageIcon(ClassLoader.getSystemResource("images/Payments.png"))); mnuPayment.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK)); mnuPayment.setActionCommand("payments"); mnuPayment.addActionListener(menulistener);
/************************* CREATING REPORTS MENU ********************/ mnuReports = new JMenu("Reports "); mnuReports.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuReports.setForeground(Color.blue); mnuReports.setMnemonic('R');
mnuEmpRpt = new JMenuItem("Employee Report"); mnuEmpRpt.setForeground(Color.blue); mnuEmpRpt.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuEmpRpt.setMnemonic('P'); mnuEmpRpt.setIcon(new ImageIcon(ClassLoader.getSystemResource("images/empreport.png"))); mnuEmpRpt.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK)); mnuEmpRpt.setActionCommand("empreport"); mnuEmpRpt.addActionListener(menulistener);
mnuSchedRpt = new JMenuItem("Scheduling Report"); mnuSchedRpt.setForeground(Color.blue); mnuSchedRpt.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuSchedRpt.setMnemonic('S'); mnuSchedRpt.setIcon(new ImageIcon(ClassLoader.getSystemResource("images/schedreport.png"))); mnuSchedRpt.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK)); mnuSchedRpt.setActionCommand("schedulereport"); mnuSchedRpt.addActionListener(menulistener);
mnuBookRpt = new JMenuItem("Booking Report"); mnuBookRpt.setForeground(Color.blue); mnuBookRpt.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuBookRpt.setMnemonic('B'); mnuBookRpt.setIcon(new ImageIcon(ClassLoader.getSystemResource("images/bookreport.png"))); mnuBookRpt.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, ActionEvent.CTRL_MASK)); mnuBookRpt.setActionCommand("bookrepoort"); mnuBookRpt.addActionListener(menulistener);
/******************* CREATING TOOLS MENU ***************************/ mnuTools = new JMenu("Tools "); mnuTools.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuTools.setForeground(Color.blue); mnuTools.setMnemonic('T');
mnuNotepad = new JMenuItem("Notepad"); mnuNotepad.setForeground(Color.blue); mnuNotepad.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuNotepad.setMnemonic('N'); mnuNotepad.setIcon(new ImageIcon(ClassLoader.getSystemResource("images/notepad.png"))); mnuNotepad.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); mnuNotepad.setActionCommand("notepad"); mnuNotepad.addActionListener(menulistener);
/*********************** CREATING HELP MENU **************************/ mnuHelp = new JMenu("Help "); mnuHelp.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuHelp.setForeground(Color.blue);
mnuHelp.setMnemonic('H');
mnuUsrMannual = new JMenuItem("User Manual"); mnuUsrMannual.setForeground(Color.blue); mnuUsrMannual.setFont(new Font("monospaced", Font.PLAIN, 12)); mnuUsrMannual.setMnemonic('U'); mnuUsrMannual.setIcon(new ImageIcon(ClassLoader.getSystemResource("images/help.png"))); mnuUsrMannual.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK)); mnuUsrMannual.setActionCommand("mannual"); mnuUsrMannual.addActionListener(menulistener);
public void actionPerformed(ActionEvent e) { String ActCmd = e.getActionCommand(); if (ActCmd.equalsIgnoreCase("calculator")) { try { Runtime.getRuntime().exec("calc.exe"); } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Error,Cannot start calculator", "Applicaton Error", JOptionPane.ERROR_MESSAGE);
}//try catch closed } else if (ActCmd.equalsIgnoreCase("notepad")) { try { Runtime.getRuntime().exec("notepad.exe"); } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Error,Cannot start notepad", "Applicaton Error", JOptionPane.ERROR_MESSAGE); }//try catch closed } else if (ActCmd.equalsIgnoreCase("newuser")) { NewUser frm = new NewUser(); desktop.add(frm); frm.setVisible(true); } else if (ActCmd.equalsIgnoreCase("exit")) { ConfirmExit(); } else if (ActCmd.equalsIgnoreCase("buses")) { Buses frm = new Buses(); desktop.add(frm); frm.setVisible(true); } else if (ActCmd.equalsIgnoreCase("employees")) { Employee frm = new Employee(); desktop.add(frm); frm.setVisible(true); } else if (ActCmd.equalsIgnoreCase("routes")) { Route frm = new Route(); desktop.add(frm); frm.setVisible(true); } else if (ActCmd.equalsIgnoreCase("passengers")) {
Passengers frm = new Passengers(); desktop.add(frm); frm.setVisible(true); } else if (ActCmd.equalsIgnoreCase("scheduling")) { Schedule frm = new Schedule(); desktop.add(frm); frm.setVisible(true); } else if (ActCmd.equalsIgnoreCase("booking")) { Booking frm = new Booking(); desktop.add(frm); frm.setVisible(true); } else if (ActCmd.equalsIgnoreCase("payments")) { Payment frm=new Payment(); desktop.add(frm); frm.setVisible(true); }else if(ActCmd.equalsIgnoreCase("busreport")){ Bus_Details frm=new Bus_Details(); desktop.add(frm); frm.setVisible(true); }else if(ActCmd.equalsIgnoreCase("empreport")){ employee_report frm=new employee_report(); desktop.add(frm); frm.setVisible(true); }else if(ActCmd.equalsIgnoreCase("schedulereport")){ Scheduling_report frm=new Scheduling_report(); desktop.add(frm);
ConfirmExit(); }
WindowEvent e) { }
private void ConfirmExit() { String ObjButtons[] = {"Yes", "No"}; int PromptResult = JOptionPane.showOptionDialog(null, "Are you sure to exit?", "Confirm exit", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, ObjButtons, ObjButtons[1]); if (PromptResult == 0) { System.exit(0); }//if closed }//ConfirmExit() closed protected boolean isLoaded(String FormTitle) { JInternalFrame Form[] = desktop.getAllFrames(); for (int i = 0; i < Form.length; i++) { if (Form[i].getTitle().equalsIgnoreCase(FormTitle)) { Form[i].show(); try { Form[i].setIcon(true); Form[i].setSelected(true); } catch (Exception e) {
public void LoginManager() { mnuOperations.setEnabled(true); mnuFiles.setEnabled(true); mnuBooking.setEnabled(true); mnuScheduling.setEnabled(true); mnuPayment.setEnabled(true); mnuRoutes.setEnabled(true); mnuEmps.setEnabled(true); mnuBuses.setEnabled(true); mnuPassengers.setEnabled(true); }//LoginManager() closed public void LoginSupervisor() { mnuFiles.setEnabled(true); mnuScheduling.setEnabled(true); mnuPayment.setEnabled(true); mnuRoutes.setEnabled(true); mnuEmps.setEnabled(true); mnuBuses.setEnabled(true);
}//LoginSupervisor() closed public void LoginClerk() { mnuBooking.setEnabled(true); mnuPayment.setEnabled(true); mnuFiles.setEnabled(true); mnuPassengers.setEnabled(true); }//LoginClerk() closed }//class closed
// DBConnection.java
public class DBConnection { public static Connection getDBConnection() { Connection connection; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); connection = DriverManager.getConnection("jdbc:odbc:Bus"); return connection; } catch (Exception ex) { return null; }//try catch closed }//getDBConnection() closed
}//class closed
//Buses.java
import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.text.*; import javax.swing.*; import java.io.*; import java.text.*; import java.sql.*; import java.awt.print.*; import javax.swing.table.AbstractTableModel;
private static JTable tblBusList; private JScrollPane jsp; private JButton btnAddNew, btnRefresh, btnClose, btnUpdate, btnPrint; private JPanel tablePanel; private JPanel buttonPanel; private Statement stmt; Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
tblBusList = new JTable(new AbstractTable()); javax.swing.table.TableColumn column = null; for (int i = 0; i < 7; i++) { column = tblBusList.getColumnModel().getColumn(i); if (i == 4) { sdf.format(i); }//if btnClosed }//for btnClosed jsp = new JScrollPane(tblBusList); tablePanel = new JPanel(new GridLayout()); tablePanel.add(jsp);
btnAddNew = new JButton("Add New", new ImageIcon(ClassLoader.getSystemResource("Images/addnew.png"))); btnUpdate = new JButton("Update", new ImageIcon(ClassLoader.getSystemResource("Images/Update.png"))); btnRefresh = new JButton("Refresh", new ImageIcon(ClassLoader.getSystemResource("Images/Refresh.png"))); btnClose = new JButton("Close", new ImageIcon(ClassLoader.getSystemResource("Images/exit.png")));
btnPrint = new JButton("Print", new ImageIcon(ClassLoader.getSystemResource("Images/print.png"))); buttonPanel = new javax.swing.JPanel(new java.awt.FlowLayout()); buttonPanel.add(btnAddNew); buttonPanel.add(btnUpdate); buttonPanel.add(btnRefresh); buttonPanel.add(btnPrint); buttonPanel.add(btnClose);
try { stmt = DBConnection.getDBConnection().createStatement(); } catch (Exception excp) { JOptionPane.showMessageDialog(null, "Error on database connection", "Statement error", JOptionPane.ERROR_MESSAGE); }//try catch closed
public void actionPerformed(java.awt.event.ActionEvent e) { AddEntry frm = new AddEntry(); MDIWindow.desktop.add(frm); frm.setVisible(true); try {
public void actionPerformed(ActionEvent evt) { Bus_Details frm = new Bus_Details(); MDIWindow.desktop.add(frm); frm.setVisible(true); try {
public void actionPerformed(java.awt.event.ActionEvent e) { String regNo, busNo, Model, capacity, db, is, ie, id; regNo = tblBusList.getValueAt(getSelectedRow(), 0).toString(); busNo = tblBusList.getValueAt(getSelectedRow(), 1).toString(); Model = tblBusList.getValueAt(getSelectedRow(), 2).toString(); capacity = tblBusList.getValueAt(getSelectedRow(), 3).toString(); db = tblBusList.getValueAt(getSelectedRow(), 4).toString(); is = tblBusList.getValueAt(getSelectedRow(), 5).toString(); ie = tblBusList.getValueAt(getSelectedRow(), 6).toString(); id = tblBusList.getValueAt(getSelectedRow(), 7).toString(); UpdateEntry frm = new UpdateEntry(regNo, busNo, Model, capacity, db, is, ie, id); MDIWindow.desktop.add(frm); frm.setVisible(true); } }); }//constructor closed public static int getSelectedRow() { tblBusList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION );
return selectedRow; }
private String[] columnNames = {"RegNo", "BusNo", "Model", "Capacity", "Date purchased", "Insurance Status", "Date Insured", "Expiry Date" }; private Object[][] data = new Object[50][50];
public void setValueAt(Object value, int row, int col) { data[row][col] = value; fireTableCellUpdated(row, col); } }
public void reloaded() { try { String sql = ("SELECT * FROM Buses ORDER BY BusNo"); int Numrow = 0;
ResultSet result = stmt.executeQuery(sql); while (result.next()) { tblBusList.setValueAt(result.getString(1).trim(), Numrow, 0); tblBusList.setValueAt(result.getString(2).trim(), Numrow, 1); tblBusList.setValueAt(result.getString(3).trim(), Numrow, 2); tblBusList.setValueAt(result.getString(4).trim(), Numrow, 3); tblBusList.setValueAt(result.getDate(5), Numrow, 4); tblBusList.setValueAt(result.getString(6).trim(), Numrow, 5); tblBusList.setValueAt(result.getDate(7), Numrow, 6); tblBusList.setValueAt(result.getDate(8), Numrow, 7); sdf.format(7); Numrow++; }//while closed } catch (SQLException sqlex) { JOptionPane.showMessageDialog(null, "Error on retrieving values", "Error", JOptionPane.ERROR_MESSAGE); }//try catch closed }//reloaded() closed public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException { Graphics2D g2 = (Graphics2D) g; g2.setColor(Color.black); int fontHeight = g2.getFontMetrics().getHeight(); int fontDesent = g2.getFontMetrics().getDescent();
double pageWidth = pageFormat.getImageableWidth(); double tableWidth = (double) tblBusList.getColumnModel().getTotalColumnWidth(); double scale = 1; if (tableWidth >= pageWidth) { scale = pageWidth / tableWidth; }
double oneRowHeight = (tblBusList.getRowHeight() + tblBusList.getRowMargin()) * scale; int numRowsOnAPage = (int) ((pageHeight - headerHeightOnPage) / oneRowHeight); double pageHeightForTable = oneRowHeight * numRowsOnAPage; int totalNumPages = (int) Math.ceil(((double) tblBusList.getRowCount()) / numRowsOnAPage); if (pageIndex >= totalNumPages) { return NO_SUCH_PAGE; }
g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY()); g2.drawString("Page: " + (pageIndex + 1), (int) pageWidth / 2 - 35, (int) (pageHeight + fontHeight - fontDesent));//bottom center
g2.translate(0f, headerHeightOnPage); g2.translate(0f, -pageIndex * pageHeightForTable); if (pageIndex + 1 == totalNumPages) { int lastRowPrinted = numRowsOnAPage * pageIndex; int numRowsLeft = tblBusList.getRowCount() - lastRowPrinted; g2.setClip(0, (int) (pageHeightForTable * pageIndex), (int) Math.ceil(tableWidthOnPage), (int) Math.ceil(oneRowHeight * numRowsLeft)); } else { g2.setClip(0, (int) (pageHeightForTable * pageIndex), (int) Math.ceil(tableWidthOnPage), (int) Math.ceil(pageHeightForTable)); } g2.scale(scale, scale); tblBusList.paint(g2); g2.scale(1 / scale, 1 / scale); g2.translate(0f, pageIndex * pageHeightForTable); g2.translate(0f, -headerHeightOnPage); g2.setClip(0, 0, (int) Math.ceil(tableWidthOnPage), (int) Math.ceil(headerHeightOnPage)); g2.scale(scale, scale); tblBusList.getTableHeader().paint(g2);//paint header at top
CHAPTER 8 CONCLUSION
CONCLUSION
7.3 Limitations
As it is a real world application so actually we have no authorization to implement payment system so we can only show a dummy transaction for bus ticket booking. Not any security manager for testing invalid login id. Not actual transactions are made. It is just a simulation. Passengers cannot view the bus and route details by themselves, they have to enquire through the booking clerk.
USER MANUAL
USER MANUAL
Before you compile the project you have to set the ODBC connection then only it will work properly Let us see How to set ODBC connection (MS Access)
1. Click Start button +Click Settings
4. Then you get ODBC Data Source Administrator window (shown below) +Click Add Button
5. Create New Data Source (shown below) +select Microsoft Access Driver (*.mdb,*.accdb) + press Finish button
6. ODBC Microsoft Access Set up (shown below) + gives Data Source Name +select Database (Press select button) +select your database (shown below) + Press Ok button
7. Before you close the window make sure that your DSN name is correct or not (shown below) +Press Ok button
Now you got the DSN name (Bus) this is the way for connecting ODBC.
BIBLIOGRAPHY
BIBLIOGRAPHY
References:
www.roseindia.net www.netbeans.org www.rationalrose.com www.office.microsoft.com www.wikipedia.com Java The Complete Reference - Herbert Schildt