Anda di halaman 1dari 298

IT 420 Wu Jian Min

150100000698

Advanced Diploma in Information Technology

Project Documentation
ADIT IT420
Object Oriented Programming in Java

Project Title: Car Rental

Name: Wu Jian Min Student ID: 150100000698 Class: IT420 Object Oriented Programming in Java Country: Brunei Darussalam Lecturer Name: Ms. Grace N. Balayan

Wu Jian Min Page 1

IT 420 Wu Jian Min

150100000698

Contents
1. Proposal

Page

1.1 Introduction ...................................................................................................................3 1.2 Problem background.....................................................................................................4 1.3 Proposed system and Objective.....................................................................................5 2. File Specification............................................................................................................6 3. Input Specification........................................................................................................ 9 4. Screen Design...............................................................................................................32 5. Program Design............................................................................................................37 6. Coding...........................................................................................................................41 7. Testing 7.1 Test Plan........................................................................................................................264 7.2 Test Case.......................................................................................................................265 7.3 Test Log........................................................................................................................285 8. Conclusion.....................................................................................................................286 9. Hardware and Software Requirement........................................................................287 10. Implementation...........................................................................................................288 11. Reference.....................................................................................................................290

Wu Jian Min Page 2

IT 420 Wu Jian Min

150100000698

1. Proposal 1.1 Introduction


Car Rental Brunei Pte Ltd is founded in 2000 by Mr. Lee in Bandar Seri Begawan. Today, the rental shop has more than 1000 cars. And he has hired 5 persons to work in the shop. The shop holds varies kind of band of cars. He recently has 3500 members. His business is very well. About 300 cars have been rent. Mr. Lee is planning to open a new branch in Time Square Mall near The Brunei International Airport. He is planning to improve the system of the current rental shop before opening the new branch. He hopes his rental car system of the current rental shop will be improved so that he would be able to manage the new branch to attract more customers to come to his rental shop. He hopes his new shop will please his new customers and his members. The current Car Rental Brunei Pte Ltd is still using the old fashion card system to keep the information of the customers. Every car has different ID number. The shop gives a new membership card to every new customer. Every membership card has different ID number. The information and the rental cars of the customers will be recorded in record rental cards that will be stored in no-rented drawer in the shop. If a customer wants to rent a car, he has to show his membership card. The record rental card of the customer will be found according to the ID number of the membership. After finding the rental card in the no-rented drawer, the rental car will be recorded in the record rental card. Then the record rental card will be stored in another drawer called a rented drawer. If the customer returns the car, his rental card will be retrieved from the rented drawer again by tracking the ID number of the membership card or the car. After recording the returning of the car, the rental card will be placed in the no-rented drawer.

Wu Jian Min Page 3

IT 420 Wu Jian Min 1.2. Problem Background

150100000698

The current manual system has many disadvantages. It has a lot of repetitive work to do. If a customer wants to rent a car, the customer has to show his membership card. His record rental card will be retrieved from a drawer. The process of finding the record rental card of the customer is slow. Sometimes, the record rental card cannot be found if it has been misplaced. Sometimes, the customer wants to rent a car but he forgets to bring the membership card. The information of the customer will be written down in a note. In order to find his rental card, all of the rental cards have to be looked through. It is a painful and frustrated job.

Wu Jian Min Page 4

IT 420 Wu Jian Min 1.3. Proposed System and Objective

150100000698

In order to improve the current system of the Car Rental Brunei Pte Ltd, Mr. Lee has contacted me to help him to improve his current shop. I will create a database using Microsoft Access to store the information of the customers, and the rental cars. The database will be link to Java. The new system will completely take over the old fashion manual system.

The new system of the program will be based on follow:

* Password is required before entering this programming. * It is easy to manage and to use. * It is able to upgrade easily. * It is small and easy to install. * It will automatically back up by itself or manually make a back up file. The main benefit of the new computerized system is to find the information of the member easily and quickly by typing the information of the member, such as customer ID. This benefit not only saves a tremendous amount of time to find the rental card of the customer in a drawer, but also improves the traffic of renting cars to every customer. Before applying the new system, the staff has to deal with customer one by one. But, after applying the new system, the staff will be able to serve more than one customer. The objective of the program is to improve the process of renting any car to any customer to become easier and faster without going through the hard manual system again.

Wu Jian Min Page 5

IT 420 Wu Jian Min

150100000698

2. File Specification:
Customer_info table

Table Description No 1 2 3 4 5 6 7 8 9 Column Customer_ID Date_reg FullName Address Contact_no Gender Nationality DateOfBirth Email Data Types Text Text Text Text Text Text Text Text Text Max Width 4 50 50 50 50 50 50 50 50

Wu Jian Min Page 6

IT 420 Wu Jian Min Event Table

150100000698

Table Description No 1 2 3 4 5 6 Column Car_ID Car_brand Car_model No_Of_Seat Car_Color Data Types Text Text Text Text Text Max Width 4 50 50 50 50 50

Rental_PerMonth Text

Wu Jian Min Page 7

IT 420 Wu Jian Min Expenses Table

150100000698

Table Description No 1 2 3 4 5 6 7 8 9 Column Rent_ID Customer_ID FullName Car_ID Data Types Text Text Text Text Max Width 4 50 50 50 50 50 50 50 50

Date_Start_Renting Text No_Of_Month Date_End_Renting TotalRental hide Text Text Text Text

Wu Jian Min Page 8

IT 420 Wu Jian Min

150100000698

3. Input Specification
Login Menu

Background Image

Label1
label 2 label 3 Textbox 1 Textbox 2 Button 1 Button 2

Item Name Background Image Label1 Label 2 Label 3 Textbox 1 Textbox 2 Button 1 Button 2

Name Car Rental Brunei Pte Ltd Username Password Login Cancel

Description Display Background Image To display heading Display label for username Display label for password To enter username To enter password To process main menu screen To cancel the task

Wu Jian Min Page 9

IT 420 Wu Jian Min

150100000698

Wu Jian Min Page 10

IT 420 Wu Jian Min Main Menu

150100000698

Btn 1 Btn 2 Btn 3 Btn 4 Btn 5 Btn 6 Background Image

Item Name Background Image Btn 1 Btn 2 Btn 3 Btn 4 Btn 5 Btn 6

Name -

Description Display Background Image To process home screen To process customer screen To process car info screen To process rental screen To process logout screen To process exit screen

Wu Jian Min Page 11

IT 420 Wu Jian Min Customer Screen

150100000698

Background Image Btn 7 Btn 8 Btn 9

Btn 1 Btn 2 Btn 3 Btn 4 Btn 5 Btn 6 Customer Info Table

Item Name Background Image Btn 1 Btn 2 Btn 3 Btn 4 Btn 5 Btn 6 Btn 7 Btn 8 Btn 9

Name Add Edit View

Description Display Background Image To process home screen To process customer screen To process car info screen To process rental screen To process logout screen To process exit screen To add customer info To edit customer info To view customer info

Wu Jian Min Page 12

IT 420 Wu Jian Min

150100000698

Wu Jian Min Page 13

IT 420 Wu Jian Min Add customer info screen

150100000698

Title 1 Lbl 1 Lbl 2 Lbl 3 Lbl 4 Lbl 5 Lbl 6 Lbl 7 Lbl 8 Btn 1 txt1 Txt2
Radio btn 3

Background Image Lbl 9 Txt9

Txt4 Txt5 Txt6 Txt7 Txt8 Btn 2 Btn 3

Wu Jian Min Page 14

IT 420 Wu Jian Min

150100000698

Item Name Background Image Title 1 Lbl 1 Lbl 2 Lbl 3 Lbl 4 Lbl 5 Lbl 6 Lbl 7 Lbl 8 Lbl 9 Txt 1 Txt 2 Radio button 3 Txt 4 Txt 5 Txt 6 Txt 7 Txt 8 Txt 9 Btn 1 Btn 2 Btn 3

Name Add customer information Customer ID Customer Name Gender Address Contact No Nationality Date Of Birth Email Registraton Date Male/Female Save Clear Back

Description Display Background Image To display title Display label for customer ID Display label for customer Name Display label for Gender Display label for Address Display label for Contact No Display label for Nationality Display label for Date Of Birth Display label for Email Display label for Registration Date To enter customer ID To enter Customer Name To enter Gender To enter Address To enter Contact No To enter Nationality To enter Date Of Birth To enter Email To enter Registration Date To save the info To clear the info To process customer screen

Wu Jian Min Page 15

IT 420 Wu Jian Min Edit Customer screen

150100000698

Title 1 Lbl 1 Lbl 2 Lbl 3 Lbl 4 Lbl 5 Lbl 6 Lbl 7 Lbl 8 Btn 1 txt1 Txt2
Radio btn 3

Background Image Lbl 9 Txt9

Txt4 Txt5 Txt6 Txt7 Txt8 Btn 2 Btn 3

Wu Jian Min Page 16

IT 420 Wu Jian Min

150100000698

Item Name Background Image Title 1 Lbl 1 Lbl 2 Lbl 3 Lbl 4 Lbl 5 Lbl 6 Lbl 7 Lbl 8 Lbl 9 Txt 1 Txt 2 Radio button 3 Txt 4 Txt 5 Txt 6 Txt 7 Txt 8 Txt 9 Btn 1 Btn 2 Btn 3

Name Add customer information Customer ID Customer Name Gender Address Contact No Nationality Date Of Birth Email Registraton Date Male/Female Edit Clear Back

Description Display Background Image To display title Display label for customer ID Display label for customer Name Display label for Gender Display label for Address Display label for Contact No Display label for Nationality Display label for Date Of Birth Display label for Email Display label for Registration Date To show customer ID To show customer Name To show Gender To show Address To show Contact No To show Nationality To show Date Of Birth To show Email To show Registration Date To edit the info To clear the info To process customer screen

Wu Jian Min Page 17

IT 420 Wu Jian Min View customer screen

150100000698

Title 1 Lbl 1 Lbl 2 Lbl 3 Lbl 4 Lbl 5 Lbl 6 Lbl 7 Lbl 8 Btn 1 txt1 Txt2
Radio btn 3

Background Image Lbl 9 Txt9

Txt4 Txt5 Txt6 Txt7 Txt8 Btn 2 Btn 3

Wu Jian Min Page 18

IT 420 Wu Jian Min

150100000698

Item Name Background Image Title 1 Lbl 1 Lbl 2 Lbl 3 Lbl 4 Lbl 5 Lbl 6 Lbl 7 Lbl 8 Lbl 9 Txt 1 Txt 2 Radio button 3 Txt 4 Txt 5 Txt 6 Txt 7 Txt 8 Txt 9 Btn 1

Name Add customer information Customer ID Customer Name Gender Address Contact No Nationality Date Of Birth Email Registraton Date Male/Female Back

Description Display Background Image To display title Display label for customer ID Display label for Customer Name Display label for Gender Display label for Address Display label for Contact No Display label for Nationality Display label for Date Of Birth Display label for Email Display label for Registration Date To enter customer ID To enter Customer Name To enter Gender To enter Address To enter Contact No To enter Nationality To enter Date Of Birth To enter Email To enter Registration Date To process customer screen

Wu Jian Min Page 19

IT 420 Wu Jian Min Car information screen

150100000698

Background Image Btn Btn Btn Btn1

Btn 1 Btn 2 Btn 3 Btn 4 Btn 5 Btn 6 Car Info Table

Item Name Background Image Btn 1 Btn 2 Btn 3 Btn 4 Btn 5 Btn 6 Btn 7 Btn 8 Btn 9 Btn 10

Name Add Edit View Delete

Description Display Background Image To process home screen To process customer screen To process car info screen To process rental screen To process logout screen To process exit screen To add car info To edit car info To view car info To delete car info

Wu Jian Min Page 20

IT 420 Wu Jian Min Add the information of car screen

150100000698

Title 1 Lbl1 Lbl2 Lbl3 Btn 1 Txt 1 Txt 2 Txt 3 Btn 2 Lbl4 Lbl5 Lbl6 Btn 3 Txt 4 Txt 5 Txt 6

Item Name Title 1 Lbl 1 Lbl 2 Lbl 3 Lbl 4 Lbl 5 Lbl 6 Txt 1 Txt 2 Txt 3 Txt 4 Txt 5 Txt 6 Btn 1 Btn 2

Name Add Car Info Car ID Car Brand Car model No of seats Car color Rental Per Month Save Clear

Description Display the name of title To display label for Car ID To display label for Car Brand To display label for Car model To display label for No of seats To display label for Car color To display label for Rental Per Month To enter Car ID To enter Car Brand To enter Car model To enter No of seats To enter Car color To enter Rental Per Month To save the information of car screen To clear the information of car screen

Wu Jian Min Page 21

IT 420 Wu Jian Min Edit the information of car screen


Title 1 Lbl1 Lbl2 Lbl3 Btn 1 Txt 1 Txt 2 Txt 3 Btn 2 Lbl4 Lbl5 Lbl6

150100000698

Txt 4 Txt 5 Txt 6

Btn 3

Item Name Title 1 Lbl 1 Lbl 2 Lbl 3 Lbl 4 Lbl 5 Lbl 6 Txt 1 Txt 2 Txt 3 Txt 4 Txt 5 Txt 6 Btn 1 Btn 2 Btn 3

Name Add Car Info Car ID Car Brand Car model No of seats Car color Rental Per Month Edit Clear Back

Description Display the name of title To display label for Car ID To display label for Car Brand To display label for Car model To display label for No of seats To display label for Car color To display label for Rental Per Month To enter Car ID To enter Car Brand To enter Car model To enter No of seats To enter Car color To enter Rental Per Month To edit the information of car screen To clear the information of car screen To go back to main menu

Wu Jian Min Page 22

IT 420 Wu Jian Min View the information of car screen

150100000698

Title 1 Lbl1 Lbl2 Lbl3 Btn 1


Item Name Title 1 Lbl 1 Lbl 2 Lbl 3 Lbl 4 Lbl 5 Lbl 6 Txt 1 Txt 2 Txt 3 Txt 4 Txt 5 Txt 6 Btn 1 Name Add Car Info Car ID Car Brand Car model No of seats Car color Rental Per Month Back Description Display the name of title To display label for Car ID To display label for Car Brand To display label for Car model To display label for No of seats To display label for Car color To display label for Rental Per Month To enter Car ID To enter Car Brand To enter Car model To enter No of seats To enter Car color To enter Rental Per Month To go back to main menu

Txt 1 Txt 2 Txt 3

Lbl4 Lbl5 Lbl6

Txt 4 Txt 5 Txt 6

Wu Jian Min Page 23

IT 420 Wu Jian Min Delete the information of car screen

150100000698

Title 1 Lbl1 Lbl2 Lbl3 Btn 1


Item Name Title 1 Lbl 1 Lbl 2 Lbl 3 Lbl 4 Lbl 5 Lbl 6 Txt 1 Txt 2 Txt 3 Txt 4 Txt 5 Txt 6 Btn 1 Btn 2

Txt 1 Txt 2 Txt 3 Btn 2


Name Add Car Info Car ID Car Brand Car model No of seats Car color Rental Per Month Delete Back

Lbl4 Lbl5 Lbl6

Txt 4 Txt 5 Txt 6

Description Display the name of title To display label for Car ID To display label for Car Brand To display label for Car model To display label for No of seats To display label for Car color To display label for Rental Per Month To enter Car ID To enter Car Brand To enter Car model To enter No of seats To enter Car color To enter Rental Per Month To delete the information of car screen To go back to main menu

Wu Jian Min Page 24

IT 420 Wu Jian Min Rental Information

150100000698

Background Image Btn 7 Btn 8 Btn 9

Btn 1 Btn 2 Btn 3 Btn 4 Btn 5 Btn 6 Rental Info Table

Btn1

Item Name Background Image Btn 1 Btn 2 Btn 3 Btn 4 Btn 5 Btn 6 Btn 7 Btn 8 Btn 9 Btn 10

Name Add Edit View Delete

Description Display Background Image To process home screen To process customer screen To process car info screen To process rental screen To process logout screen To process exit screen To add rental info To edit rental info To view rental info To delete rental info

Wu Jian Min Page 25

IT 420 Wu Jian Min Add the information of rental screen

150100000698

Title 1 Lbl1 Lbl2 Lbl3 Lbl4 Lbl5 Btn 1 Txt 1 Combox 2 Combox 3 Txt 4 Txt 5 Btn 2 Lbl6 Lbl7 Lbl8 Lbl9 Btn 4 Btn 3 Txt 6 Txt 7 Txt 8 Txt 9

Wu Jian Min Page 26

IT 420 Wu Jian Min

150100000698

Item Name Title 1 Lbl 1 Lbl 2 Lbl 3 Lbl 4 Lbl 5 Lbl 6 Lbl 7 Lbl 8 Lbl 9 Txt 1 Combox 2 Combox 3 Txt 4 Txt 5 Txt 6 Txt 7 Txt 8 Txt 9 Btn 1 Btn 2 Btn 3 Btn 4

Name Add Rental Info Rental ID Customer ID Car ID No of months Total Rental Date Start Renting Customer Name Rental Per Month Date End Renting Save Clear Back Total

Description Display the name of title To display label for Rental ID To display label for Customer ID To display label for Car ID To display label for No of months To display label for Total Rental To display label for Date Start Renting To display label for Customer Name To display label for Rental Per Month To display label for Date End Renting To enter Rental ID To select Customer ID To select Car ID To enter No of months To enter Total Rental To enter Date Start Renting To enter Customer Name To enter Rental Per Month To enter Date End Renting To save the information of rental To clear the information of rental To go back to main menu To sum the amount of total rental

Wu Jian Min Page 27

IT 420 Wu Jian Min Edit the information of rental screen

150100000698

Title 1 Lbl1 Lbl2 Lbl3 Lbl4 Lbl5 Btn 1 Txt 1 Combox 2 Combox 3 Txt 4 Txt 5 Btn 2 Lbl6 Lbl7 Lbl8 Lbl9 Btn 4 Btn 3 Txt 6 Txt 7 Txt 8 Txt 9

Wu Jian Min Page 28

IT 420 Wu Jian Min

150100000698

Item Name Title 1 Lbl 1 Lbl 2 Lbl 3 Lbl 4 Lbl 5 Lbl 6 Lbl 7 Lbl 8 Lbl 9 Txt 1 Combox 2 Combox 3 Txt 4 Txt 5 Txt 6 Txt 7 Txt 8 Txt 9 Btn 1 Btn 2 Btn 3 Btn 4

Name Edit Rental Info Rental ID Customer ID Car ID No of months Total Rental Date Start Renting Customer Name Rental Per Month Date End Renting Edit Clear Back Total

Description Display the name of title To display label for Rental ID To display label for Customer ID To display label for Car ID To display label for No of months To display label for Total Rental To display label for Date Start Renting To display label for Customer Name To display label for Rental Per Month To display label for Date End Renting To select Rental ID To display Customer ID To display Car ID To display No of months To display Total Rental To display Date Start Renting To display Customer Name To display Rental Per Month To display Date End Renting To edit the information of rental To clear the information of rental To go back to main menu To sum the amount of total rental

Wu Jian Min Page 29

IT 420 Wu Jian Min View the information of rental screen

150100000698

Title 1 Lbl1 Lbl2 Lbl3 Lbl4 Lbl5 Btn 1 Txt 1 Combox 2 Combox 3 Txt 4 Txt 5 Lbl6 Lbl7 Lbl8 Lbl9 Txt 6 Txt 7 Txt 8 Txt 9

Wu Jian Min Page 30

IT 420 Wu Jian Min

150100000698

Item Name Title 1 Lbl 1 Lbl 2 Lbl 3 Lbl 4 Lbl 5 Lbl 6 Lbl 7 Lbl 8 Lbl 9 Txt 1 Combox 2 Combox 3 Txt 4 Txt 5 Txt 6 Txt 7 Txt 8 Txt 9 Btn 1

Name Edit Rental Info Rental ID Customer ID Car ID No of months Total Rental Date Start Renting Customer Name Rental Per Month Date End Renting Back

Description Display the name of title To display label for Rental ID To display label for Customer ID To display label for Car ID To display label for No of months To display label for Total Rental To display label for Date Start Renting To display label for Customer Name To display label for Rental Per Month To display label for Date End Renting To select Rental ID To display Customer ID To display Car ID To display No of months To display Total Rental To display Date Start Renting To display Customer Name To display Rental Per Month To display Date End Renting To go back to main menu

Wu Jian Min Page 31

IT 420 Wu Jian Min Delete the information of rental screen

150100000698

Title 1 Lbl1 Lbl2 Lbl3 Lbl4 Lbl5 Btn 1 Txt 1 Combox 2 Combox 3 Txt 4 Txt 5 Btn 2 Lbl6 Lbl7 Lbl8 Lbl9 Txt 6 Txt 7 Txt 8 Txt 9

Wu Jian Min Page 32

IT 420 Wu Jian Min

150100000698

Item Name Title 1 Lbl 1 Lbl 2 Lbl 3 Lbl 4 Lbl 5 Lbl 6 Lbl 7 Lbl 8 Lbl 9 Txt 1 Combox 2 Combox 3 Txt 4 Txt 5 Txt 6 Txt 7 Txt 8 Txt 9 Btn 1 Btn 2

Name Edit Rental Info Rental ID Customer ID Car ID No of months Total Rental Date Start Renting Customer Name Rental Per Month Date End Renting Delete Back

Description Display the name of title To display label for Rental ID To display label for Customer ID To display label for Car ID To display label for No of months To display label for Total Rental To display label for Date Start Renting To display label for Customer Name To display label for Rental Per Month To display label for Date End Renting To select Rental ID To display Customer ID To display Car ID To display No of months To display Total Rental To display Date Start Renting To display Customer Name To display Rental Per Month To display Date End Renting To delete the information of rental To go back to main menu

Wu Jian Min Page 33

IT 420 Wu Jian Min

150100000698

4. Screen Design
Main Menu

Customer Informaiton

Add information of customer

Wu Jian Min Page 34

IT 420 Wu Jian Min Edit information of customer

150100000698

Car Information

Add the information of car

Wu Jian Min Page 35

IT 420 Wu Jian Min Edit the information of car

150100000698

View the information of car

Delete the information of car

Wu Jian Min Page 36

IT 420 Wu Jian Min Rental information

150100000698

Add the information of rental

Edit the information of rental

Wu Jian Min Page 37

IT 420 Wu Jian Min View the information of rental

150100000698

Delete the information of rental

To log out the programming

Wu Jian Min Page 38

IT 420 Wu Jian Min

150100000698

5. Program Design
Start

Home Page

Customer Page

Car Info Page

Rental Info Page

Log out page

Exit page

Wu Jian Min Page 39

IT 420 Wu Jian Min

150100000698

Start

Customer Page

Click Add Button

Click Edit Button

Click view Button

Wu Jian Min Page 40

IT 420 Wu Jian Min

150100000698

Start

Car Page

Click Add Button

Click Edit Button

Click view Button

Click Delete Button

Wu Jian Min Page 41

IT 420 Wu Jian Min

150100000698

Start

Rental Page

Click Add Button

Click Edit Button

Click view Button

Click Delete Button

Wu Jian Min Page 42

IT 420 Wu Jian Min

150100000698

6. Coding
import javax.swing.*; import java.awt.*; import java.io.*; import java.awt.event.*; import java.awt.Image.*; import javax.swing.table.*; import javax.swing.border.*; import javax.swing.JOptionPane.*; import javax.swing.JTable.*; import java.util.*; import java.lang.Runtime.*; import java.text.*; import javax.swing.border.TitledBorder.*; import java.util.Date; import java.text.SimpleDateFormat; import java.sql.*; import java.util.Calendar; public class rental extends JFrame { private Connection con; private Statement s; private ResultSet rs; private int i; private customers cl; private JLabel userJLabel;
Wu Jian Min Page 43

IT 420 Wu Jian Min private JLabel passJLabel; private JTextField userTextField; private JPasswordField passJPasswordField; private JButton LoginJButton; private JButton CancelButton;

150100000698

private DefaultTableModel customermodel; private DefaultTableModel carmodel; //new private DefaultTableModel expensesmodel; private DefaultTableModel schedmodel;

private JLabel backgroundJLabel;

private addcustomer add_customer; private editcustomer edit_customer; private viewcustomer view_customer;

private addcar add_car; private editcar edit_car; private viewcar view_car; private deletecar del_car;

private addexpenses add_exp; private editexpenses edit_exp; private viewexpenses view_exp; private deleteexpenses del_exp;
Wu Jian Min Page 44

IT 420 Wu Jian Min

150100000698

public rental()// trying to connect to rental Database { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String dataSourceName = "rental"; String dbURL = "jdbc:odbc:" + dataSourceName; Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement(); }

catch (Exception err) { System.out.println( "Error: " + err ); }

System.out.println("Accessing Database..."); login();//calling the login function }

// login function_________________________________________________________________

public void login() { Container contentPane = getContentPane(); contentPane.setLayout(null);

Wu Jian Min Page 45

IT 420 Wu Jian Min userJLabel = new JLabel();

150100000698

userJLabel.setBounds( 70,270,70,25);//x, y, w, h userJLabel.setText( "Username: " ); contentPane.add( userJLabel );

userTextField = new JTextField(); userTextField.setBounds( 160,270,85,25); contentPane.add( userTextField );

passJLabel = new JLabel(); passJLabel.setBounds( 70,315,70,25 ); passJLabel.setText( "Password: " ); contentPane.add( passJLabel );

passJPasswordField = new JPasswordField(); passJPasswordField.setBounds( 160,315,85,25); contentPane.add( passJPasswordField );

LoginJButton = new JButton("Login");

//LoginJButton.setIcon( new ImageIcon("login logo.jpg")); LoginJButton.setBounds(265,270,80,15);//x,y,w,h LoginJButton.setSize(90,25); contentPane.add(LoginJButton); LoginJButton.addActionListener(

Wu Jian Min Page 46

IT 420 Wu Jian Min new ActionListener() {

150100000698

public void actionPerformed( ActionEvent event ) { LoginJButton_acp( event );//calling Login Button function } } );

CancelButton = new JButton("Cancel");

//CancelButton.setIcon( new ImageIcon("Toolbar-Regular-Delete-icon.png"));

CancelButton.setBounds( 265,315,80,15); CancelButton.setSize(90,25); contentPane.add( CancelButton ); CancelButton.addActionListener(

new ActionListener() { public void actionPerformed (ActionEvent event ) { CancelButton_acp( event );//calling Cancel Button function } }
Wu Jian Min Page 47

IT 420 Wu Jian Min );

150100000698

backgroundJLabel = new JLabel(); backgroundJLabel.setBounds(0,0,750,230); backgroundJLabel.setIcon( new ImageIcon("login form pic.jpg")); // background LOGIN backgroundJLabel.setSize(400,400); contentPane.add( backgroundJLabel);

setResizable(false); setTitle( "Car Rental Brueni Pte Ltd." ); setSize( 400, 400 ); //login form size setVisible( true ); setLocationRelativeTo(null);

addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent event) { frameWindowClosing(event); } } ); }

Wu Jian Min Page 48

IT 420 Wu Jian Min

150100000698

//cancel button function__________________________________________________________

public void CancelButton_acp( ActionEvent event) { userTextField.setText( "" );//clearing the userid field passJPasswordField.setText( "" );//clearing the password field } //Login button function___________________________________________________________

public void LoginJButton_acp(ActionEvent event) { String User;//variable for the username String Password;//variable for the password

User = userTextField.getText(); Password = passJPasswordField.getText();

if (User.equals("CarRental") && Password.equals("12345"))// Don't forget PASSWORD { JOptionPane.showMessageDialog(null,"Welcome to Car Rental Brunei Pte Ltd.","Car Rental Brunei Pte Ltd.",JOptionPane.INFORMATION_MESSAGE); System.out.println("Connected to rental");

setVisible(false);
Wu Jian Min Page 49

IT 420 Wu Jian Min cl = new customers ( this );

150100000698

} else { JOptionPane.showMessageDialog(null,"Invalid Username and Password!","Car Rental Brunei Pte Ltd.",JOptionPane.ERROR_MESSAGE); CancelButton_acp(event);//clears the textfields of both the username and password i += 1; if (i>=3) { JOptionPane.showMessageDialog(null, "Sorry the application will terminate!", "Car Rental Brunei Pte Ltd.", JOptionPane.ERROR_MESSAGE); System.out.println("Disconnected from rental 3attempts reach"); System.exit(0);//the system shuts down when the max 3 attempts reach } } }

// Main Menu______________________________________________________________________ __

public class customers extends JFrame { private ResultSet rs;


Wu Jian Min Page 50

IT 420 Wu Jian Min private Connection con; private Statement s;

150100000698

private JPanel customerhomeareajp; private JPanel customerinfoareajp; private JPanel expensesinfoareajp; private JPanel carinfoareajp; private JPanel logoutareajp;

private JPanel customerhomelabeljp; private JPanel customerinfolabeljp; private JPanel expensesinfolabeljp; private JPanel carinfolabeljp; private JPanel logoutlabeljp;

private JPanel mainmenujp;

private JPanel customermenujp; private JPanel expensesmenujp; private JPanel carmenujp;

private JTextArea homearea, homearea1, homearea2, homearea3;

private JButton homeB; private JButton customerinfoB; private JButton expensesinfoB;


Wu Jian Min Page 51

IT 420 Wu Jian Min private JButton carinfoB; private JButton logoutB; private JButton exitB;

150100000698

private JButton addB; private JButton editB; private JButton viewB; private JButton deleteB;

private TitledBorder customermainborder; private TitledBorder areaborder; private TitledBorder menuborder;

private JLabel homelabel; private JLabel customerlabel; private JLabel expenseslabel; private JLabel carlabel; private JLabel logoutlabel;

private JLabel backgroundlabel;

private rental merri; Font font = new Font("Gigi",Font.BOLD, 20); JTable table; String[] ctableheader = {"Customer ID", "Reg Date", "Full Name", "Address", "Contact No", "Gender", "Nationality", "Date Of Birth", "Email"};

Wu Jian Min Page 52

IT 420 Wu Jian Min

150100000698

String[] expensestableheader = {"Rent ID", "Customer Name", "Date Start Renting", "Car ID", "Rental per month", "No of months", "Date End Renting", "Total Rental"}; String[] cartableheader = {"Car ID", "Car brand", "Car model", "No of seats", "Car color", "Rental per month"};

String customer_Course; String customer_ID; String Date_reg; String FullName; String Address; String Contact_no; String Gender; String Nationality; String DateOfBirth; String Email;

String[][] data = new String[200][8]; int i = 0;

public customers(rental mer) { merri = mer; customerinfo(); } public void customerinfo() { Container customer = getContentPane();
Wu Jian Min Page 53

IT 420 Wu Jian Min customer.setLayout( null );

150100000698

System.out.println("rental Homepage");

customerhomelabeljp = new JPanel(); customerhomelabeljp.setBounds(0, 0, 0, 0); customerhomelabeljp.setLayout( null ); customer.add(customerhomelabeljp);

customerinfolabeljp = new JPanel(); customerinfolabeljp.setBounds(0, 0, 0, 0); customerinfolabeljp.setLayout( null ); customer.add(customerinfolabeljp);

expensesinfolabeljp = new JPanel(); expensesinfolabeljp.setBounds(0, 0, 0, 0); expensesinfolabeljp.setLayout( null ); customer.add(expensesinfolabeljp);

//new carinfolabeljp = new JPanel(); carinfolabeljp.setBounds(0, 0, 0, 0); carinfolabeljp.setLayout( null ); customer.add(carinfolabeljp);

logoutlabeljp = new JPanel();


Wu Jian Min Page 54

IT 420 Wu Jian Min logoutlabeljp.setBounds(0, 0, 0, 0); logoutlabeljp.setLayout( null ); customer.add(logoutlabeljp);

150100000698

mainmenujp = new JPanel(); mainmenujp.setBounds(655,11,295,65);//position untuk button dibawah,x,y,w,h mainmenujp.setLayout( null ); customer.add(mainmenujp);

customermainborder = new TitledBorder("Main Menu"); mainmenujp.setBorder(customermainborder);

customerhomeareajp = new JPanel(); customerhomeareajp.setBounds(120, 100, 770, 230); customerhomeareajp.setLayout( null ); customerhomeareajp.setVisible(false); customer.add(customerhomeareajp);

customerinfoareajp = new JPanel(); customerinfoareajp.setBounds( 185, 80, 770, 285);//position untuk customer info area customerinfoareajp.setLayout( null ); customerinfoareajp.setVisible(false); customer.add(customerinfoareajp);

expensesinfoareajp = new JPanel();


Wu Jian Min Page 55

IT 420 Wu Jian Min

150100000698

expensesinfoareajp.setBounds(185, 80, 770, 285); expensesinfoareajp.setLayout( null ); expensesinfoareajp.setVisible(false); customer.add(expensesinfoareajp); carinfoareajp = new JPanel(); carinfoareajp.setBounds(185, 80, 770, 285); carinfoareajp.setLayout( null ); carinfoareajp.setVisible(false); customer.add(carinfoareajp);

logoutareajp = new JPanel(); logoutareajp.setBounds(120, 130, 650, 230); logoutareajp.setLayout( null ); logoutareajp.setVisible(false); customer.add(logoutareajp );

homelabel = new JLabel(); homelabel.setText(""); homelabel.setBounds(0, 0, 0, 0); homelabel.setIcon( new ImageIcon("")); homelabel.setHorizontalAlignment(JLabel.CENTER); homelabel.setSize(0, 0); customerhomelabeljp.add( homelabel ); // HOME label

customerlabel = new JLabel(); customerlabel.setText("customer");


Wu Jian Min Page 56

// CUSTOMER label

IT 420 Wu Jian Min customerlabel.setBounds(0, 0, 0, 0);

150100000698

customerlabel.setIcon( new ImageIcon("Label.jpg")); customerlabel.setHorizontalAlignment(JLabel.CENTER); customerlabel.setSize(0, 0); customerinfolabeljp.add( customerlabel );

expenseslabel = new JLabel(); expenseslabel.setText("expenses"); // EXPENSES label expenseslabel.setBounds(0, 0, 0, 0); expenseslabel.setIcon( new ImageIcon("Label.jpg")); expenseslabel.setHorizontalAlignment(JLabel.CENTER); expenseslabel.setSize(0, 0); expensesinfolabeljp.add( expenseslabel );

carlabel = new JLabel(); carlabel.setText("car"); // CAR label

carlabel.setBounds(0, 0, 0, 0); carlabel.setIcon( new ImageIcon("Label.jpg")); carlabel.setHorizontalAlignment(JLabel.CENTER); carlabel.setSize(0, 0); carinfolabeljp.add( carlabel );

logoutlabel = new JLabel(); logoutlabel.setText("logout"); logoutlabel.setBounds(0, 0, 0, 0);

// LOGOUT label

logoutlabel.setIcon( new ImageIcon("Label.jpg"));


Wu Jian Min Page 57

IT 420 Wu Jian Min

150100000698

logoutlabel.setHorizontalAlignment(JLabel.CENTER); logoutlabel.setSize(0, 0); logoutlabeljp.add( logoutlabel );

customermenujp = new JPanel(); customermenujp.setBounds( 35 , 80 , 140, 285); customermenujp.setLayout( null ); customermenujp.setVisible(false); customer.add(customermenujp);

expensesmenujp = new JPanel(); expensesmenujp.setBounds( 35 , 80, 140, 285); expensesmenujp.setLayout( null ); expensesmenujp.setVisible(false); customer.add(expensesmenujp);

carmenujp = new JPanel(); carmenujp.setBounds( 35 , 80, 140, 285); carmenujp.setLayout( null ); carmenujp.setVisible(false); customer.add(carmenujp);

//customer table_______________________________________________________________ customerinfoareajp.setLayout( new BorderLayout() ); customermodel = new DefaultTableModel(ctableheader, 200); JTable ctable = new JTable(customermodel);
Wu Jian Min Page 58

IT 420 Wu Jian Min

150100000698

JScrollPane customerscrollPane = new JScrollPane(ctable); customerinfoareajp.add(customerscrollPane, BorderLayout.CENTER);

customerscrollPane.setVisible(true); customerscrollPane.getViewport().add(ctable); customerscrollPane.setBackground(Color.black); ctable.setEnabled(false); customerinfoareajp.add(customerscrollPane, BorderLayout.CENTER); TableColumn customercolumn = null; for (int i = 0; i < 7; i++) { customercolumn = ctable.getColumnModel().getColumn(i); if ( i == 0) { customercolumn.setPreferredWidth(80); } else if (i == 1) { customercolumn.setPreferredWidth(70); } else if (i == 2) { customercolumn.setPreferredWidth(80); } else if (i == 3) {
Wu Jian Min Page 59

IT 420 Wu Jian Min

150100000698

customercolumn.setPreferredWidth(100); } else if (i == 4) { customercolumn.setPreferredWidth(70); } else if (i == 5) { customercolumn.setPreferredWidth(80); } else if (i == 6) { customercolumn.setPreferredWidth(50); } else { customercolumn.setPreferredWidth(10); } } //customer table end

//Rental table______________________________________________________________________

expensesinfoareajp.setLayout( new BorderLayout() ); expensesmodel = new DefaultTableModel(expensestableheader, 100);


Wu Jian Min Page 60

IT 420 Wu Jian Min

150100000698

JTable expensestable = new JTable(expensesmodel); JScrollPane expensesscrollPane = new JScrollPane(expensestable); expensesinfoareajp.add(expensesscrollPane, BorderLayout.CENTER);

expensesscrollPane.setVisible(true); expensesscrollPane.getViewport().add(expensestable); expensesscrollPane.setBackground(Color.black); expensestable.setEnabled(false);

expensesinfoareajp.add(expensesscrollPane, BorderLayout.CENTER);

TableColumn expensescolumn = null; for (int i = 0; i < 6; i++) { expensescolumn = expensestable.getColumnModel().getColumn(i); if ( i == 0) { expensescolumn.setPreferredWidth(5); } else if (i == 1) { expensescolumn.setPreferredWidth(50); } else if (i == 2) { expensescolumn.setPreferredWidth(10);
Wu Jian Min Page 61

IT 420 Wu Jian Min } else if (i == 3) {

150100000698

expensescolumn.setPreferredWidth(50); } else if (i == 4) { expensescolumn.setPreferredWidth(10); } else if (i == 5) { expensescolumn.setPreferredWidth(10); } else if (i == 6) { expensescolumn.setPreferredWidth(10); } else { expensescolumn.setPreferredWidth(10); } }

//Rental table end

//car table_______________________________________________________________
Wu Jian Min Page 62

IT 420 Wu Jian Min carinfoareajp.setLayout( new BorderLayout() );

150100000698

carmodel = new DefaultTableModel(cartableheader, 200); JTable cartable = new JTable(carmodel); JScrollPane carscrollPane = new JScrollPane(cartable); carinfoareajp.add(carscrollPane, BorderLayout.CENTER);

carscrollPane.setVisible(true); carscrollPane.getViewport().add(cartable); carscrollPane.setBackground(Color.black); cartable.setEnabled(false);

carinfoareajp.add(carscrollPane, BorderLayout.CENTER);

TableColumn carcolumn = null; for (int i = 0; i < 6; i++) { carcolumn = cartable.getColumnModel().getColumn(i); if ( i == 0) { carcolumn.setPreferredWidth(80); } else if (i == 1) { carcolumn.setPreferredWidth(70); } else if (i == 2)
Wu Jian Min Page 63

IT 420 Wu Jian Min {

150100000698

carcolumn.setPreferredWidth(80); } else if (i == 3) { carcolumn.setPreferredWidth(100); } else if (i == 4) { carcolumn.setPreferredWidth(70); }

else { carcolumn.setPreferredWidth(10); } } //car table end //Home button____________________________________________________________________ homeB = new JButton(); homeB.setLocation(20,20); // home button location homeB.setSize(40, 40); //home button size //homeB.setText("Home");

homeB.setIcon( new ImageIcon("home-icon.png"));

Wu Jian Min Page 64

IT 420 Wu Jian Min mainmenujp.add(homeB);

150100000698

homeB.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent event ) { customerhomelabeljp.setVisible(true); customerinfolabeljp.setVisible(false); expensesinfolabeljp.setVisible(false); carinfolabeljp.setVisible(false);//new logoutlabeljp.setVisible(false);

mainmenujp.setVisible(true); customermenujp.setVisible(false); expensesmenujp.setVisible(false); carmenujp.setVisible(false);//new customerhomeareajp.setVisible(false); customerinfoareajp.setVisible(false); expensesinfoareajp.setVisible(false); carinfoareajp.setVisible(false);//new logoutareajp.setVisible(false);

System.out.println("rental home"); } }
Wu Jian Min Page 65

IT 420 Wu Jian Min );

150100000698

//Customer Button_____________________________________________________________________ ___ customerinfoB = new JButton(); customerinfoB.setLocation(65,20); customerinfoB.setIcon( new ImageIcon("user-info-icon.png")); customerinfoB.setSize(40, 40); //customer button size mainmenujp.add(customerinfoB); customerinfoB.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent event ) { customerhomelabeljp.setVisible(false); customerinfolabeljp.setVisible(true); expensesinfolabeljp.setVisible(false); carinfolabeljp.setVisible(false);//new logoutlabeljp.setVisible(false);

mainmenujp.setVisible(true); customermenujp.setVisible(true); expensesmenujp.setVisible(false); carmenujp.setVisible(false);//new customerhomeareajp.setVisible(false); customerinfoareajp.setVisible(true);


Wu Jian Min Page 66

IT 420 Wu Jian Min

150100000698

expensesinfoareajp.setVisible(false); carinfoareajp.setVisible(false);//new logoutareajp.setVisible(false); areaborder = new TitledBorder("Customer Information"); customerinfoareajp.setBorder(areaborder); System.out.println("rental customerdetails table"); customertablelist(); menuborder = new TitledBorder("Menu"); customermenujp.setBorder(menuborder);

addB = new JButton(); addB.setLocation(15,30); addB.setSize(110,50); addB.setText("Add"); addB.setIcon( new ImageIcon("add-icon.png")); customermenujp.add( addB ); addB.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent event ) { add_customer = new addcustomer();// calling add customer page } }
Wu Jian Min Page 67

IT 420 Wu Jian Min );

150100000698

editB = new JButton(); editB.setLocation(15, 90); editB.setSize(110, 50); editB.setText("Edit");

editB.setIcon( new ImageIcon("Text-Edit-icon.png"));

customermenujp.add( editB); editB.addActionListener( new ActionListener() { public void actionPerformed ( ActionEvent event ) { edit_customer = new editcustomer();//calling edit customer page } } );

viewB = new JButton(); viewB.setLocation(15, 150); viewB.setSize(110, 50); viewB.setText("View"); viewB.setIcon( new ImageIcon("Windows-View-Detail-icon.png"));
Wu Jian Min Page 68

IT 420 Wu Jian Min

150100000698

customermenujp.add( viewB); viewB.addActionListener( new ActionListener() { public void actionPerformed ( ActionEvent event ) { view_customer = new viewcustomer();//calling view customer page } } ); }

} );

//Rental Button_____________________________________________________________________ ___

expensesinfoB = new JButton(); expensesinfoB.setLocation(155,20); expensesinfoB.setSize(40, 40);

Wu Jian Min Page 69

IT 420 Wu Jian Min expensesinfoB.setIcon( new ImageIcon("dollar sign.gif")); mainmenujp.add(expensesinfoB); expensesinfoB.addActionListener( new ActionListener() {

150100000698

public void actionPerformed( ActionEvent event ) { customerhomelabeljp.setVisible(false); customerinfolabeljp.setVisible(false); expensesinfolabeljp.setVisible(true); carinfolabeljp.setVisible(false); logoutlabeljp.setVisible(false);

mainmenujp.setVisible(true); customermenujp.setVisible(false); expensesmenujp.setVisible(true); carmenujp.setVisible(false);//new customerhomeareajp.setVisible(false); customerinfoareajp.setVisible(false); expensesinfoareajp.setVisible(true); carinfoareajp.setVisible(false); logoutareajp.setVisible(false); areaborder = new TitledBorder("Rental Information"); expensesinfoareajp.setBorder(areaborder); System.out.println("rental expenses table"); expensestablelist();
Wu Jian Min Page 70

IT 420 Wu Jian Min

150100000698

menuborder = new TitledBorder("Menu"); expensesmenujp.setBorder(menuborder);

addB = new JButton(); addB.setLocation(15,30); addB.setSize(110, 50); addB.setText("Add");

addB.setIcon( new ImageIcon("add-icon.png"));

expensesmenujp.add( addB ); addB.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent event ) { add_exp = new addexpenses(); } } );

editB = new JButton(); editB.setLocation(15, 90); editB.setSize(110, 50); editB.setText("Edit");


Wu Jian Min Page 71

IT 420 Wu Jian Min

150100000698

editB.setIcon( new ImageIcon("Text-Edit-icon.png"));

expensesmenujp.add( editB); editB.addActionListener( new ActionListener() { public void actionPerformed ( ActionEvent event ) { edit_exp = new editexpenses();//calling edit expense page } } );

viewB = new JButton(); viewB.setLocation(15, 150); viewB.setSize(110, 50); viewB.setText("View"); viewB.setIcon( new ImageIcon("Windows-View-Detail-icon.png")); expensesmenujp.add( viewB); viewB.addActionListener( new ActionListener() { public void actionPerformed ( ActionEvent event )
Wu Jian Min Page 72

IT 420 Wu Jian Min {

150100000698

view_exp = new viewexpenses();//calling view expense page } } );

deleteB = new JButton(); deleteB.setLocation(15, 210); deleteB.setSize(110, 50); deleteB.setText("Delete");

deleteB.setIcon( new ImageIcon("Symbols-Delete-icon.png"));

expensesmenujp.add(deleteB); deleteB.addActionListener( new ActionListener() { public void actionPerformed ( ActionEvent event ) { del_exp = new deleteexpenses();//calling delete expense page } } );
Wu Jian Min Page 73

IT 420 Wu Jian Min

150100000698

} } ); //Car Button_____________________________________________________________________ ___

carinfoB = new JButton(); carinfoB.setLocation(110,20); //car button location carinfoB.setSize(40, 40); //car button size carinfoB.setIcon( new ImageIcon("car sign.gif")); mainmenujp.add(carinfoB); carinfoB.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent event ) { customerhomelabeljp.setVisible(false); customerinfolabeljp.setVisible(false); expensesinfolabeljp.setVisible(false); carinfolabeljp.setVisible(true);//new logoutlabeljp.setVisible(false);

mainmenujp.setVisible(true); customermenujp.setVisible(false); expensesmenujp.setVisible(false);


Wu Jian Min Page 74

IT 420 Wu Jian Min

150100000698

carmenujp.setVisible(true);//new customerhomeareajp.setVisible(false); customerinfoareajp.setVisible(false); expensesinfoareajp.setVisible(false); carinfoareajp.setVisible(true);//new logoutareajp.setVisible(false); areaborder = new TitledBorder("Car Information"); carinfoareajp.setBorder(areaborder); System.out.println("car rental table"); cartablelist();

menuborder = new TitledBorder("Menu"); carmenujp.setBorder(menuborder);

addB = new JButton(); addB.setLocation(15,30); addB.setSize(110, 50); addB.setText("Add");

addB.setIcon( new ImageIcon("add-icon.png"));

carmenujp.add( addB ); addB.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent event )
Wu Jian Min Page 75

IT 420 Wu Jian Min {

150100000698

add_car = new addcar();//calling add car page } } );

editB = new JButton(); editB.setLocation(15, 90); editB.setSize(110, 50); editB.setText("Edit");

editB.setIcon( new ImageIcon("Text-Edit-icon.png"));// testing

carmenujp.add( editB); editB.addActionListener( new ActionListener() { public void actionPerformed ( ActionEvent event ) { edit_car = new editcar();//calling edit car page } } );

Wu Jian Min Page 76

IT 420 Wu Jian Min

150100000698

viewB = new JButton(); viewB.setLocation(15, 150); viewB.setSize(110, 50); viewB.setText("View");// jangan lupa text lebal

viewB.setIcon( new ImageIcon("Windows-View-Detail-icon.png"));// testing

carmenujp.add( viewB); viewB.addActionListener( new ActionListener() { public void actionPerformed ( ActionEvent event ) { view_car = new viewcar();//calling view car page } } );

deleteB = new JButton(); deleteB.setLocation(15, 210); deleteB.setSize(110, 50); deleteB.setText("Delete");

deleteB.setIcon( new ImageIcon("Symbols-Delete-icon.png"));// testing


Wu Jian Min Page 77

IT 420 Wu Jian Min

150100000698

carmenujp.add(deleteB); deleteB.addActionListener( new ActionListener() { public void actionPerformed ( ActionEvent event ) { del_car = new deletecar();//calling delete car page } } );

} } );

//logout Button_____________________________________________________________________ ____ logoutB = new JButton(); logoutB.setLocation(200,20); logoutB.setSize(40, 40); //logout button size

logoutB.setIcon( new ImageIcon("logout-icon.png"));

Wu Jian Min Page 78

IT 420 Wu Jian Min

150100000698

mainmenujp.add(logoutB); logoutB.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { customerhomelabeljp.setVisible(false); customerinfolabeljp.setVisible(false); expensesinfolabeljp.setVisible(false); carinfolabeljp.setVisible(false); logoutlabeljp.setVisible(true);

mainmenujp.setVisible(true); customermenujp.setVisible(false); expensesmenujp.setVisible(false); carmenujp.setVisible(false); customerhomeareajp.setVisible(false); customerinfoareajp.setVisible(false); expensesinfoareajp.setVisible(false); carinfoareajp.setVisible(false); logoutareajp.setVisible(false); JOptionPane.showMessageDialog(null,"Thank You for using Car Rental Brueni Pte Ltd. Database!","Car Rental Brueni Pte Ltd.",JOptionPane.INFORMATION_MESSAGE); merri = new rental(); setVisible(false);
Wu Jian Min Page 79

IT 420 Wu Jian Min

150100000698

System.out.println("Logging Out..."); } } );

//Exit BUtton_____________________________________________________________________ ______

exitB = new JButton(); exitB.setLocation(245,20); exitB.setSize(40, 40); // exit button size

exitB.setIcon( new ImageIcon("delete-icon.png"));

mainmenujp.add(exitB); exitB.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) {

JOptionPane.showMessageDialog(null,"Thank You for using Car Rental Brueni Pte Ltd. Database!","Car Rental Brueni Pte Ltd.",JOptionPane.INFORMATION_MESSAGE); merri = new rental(); setVisible(false);
Wu Jian Min Page 80

IT 420 Wu Jian Min

150100000698

System.out.println("System Logout..."); } } );

Font font = new Font("Gigi",Font.BOLD, 28); Font font1 = new Font("Gigi",Font.BOLD, 16); Font font2 = new Font("Gigi",Font.BOLD, 20);

homearea = new JTextArea(); homearea.setBounds( 50, 150, 100, 100); homearea.setText(" "); homearea.setFont(font); homearea.setForeground(Color.red); homearea.setLineWrap(true); homearea.setWrapStyleWord(true); homearea.setEditable(false); homearea.setSize(0, 0); customer.add(homearea);

homearea1 = new JTextArea(); homearea1.setBounds( 30, 300, 100, 100); homearea1.setText(" "); homearea1.setFont(font1);
Wu Jian Min Page 81

IT 420 Wu Jian Min

150100000698

homearea1.setForeground(Color.red); homearea1.setLineWrap(true); homearea1.setWrapStyleWord(true); homearea1.setEditable(false); homearea1.setSize(0, 0); customer.add(homearea1);

homearea2 = new JTextArea(); homearea2.setBounds( 30, 325, 100, 100); homearea2.setText(" "); homearea2.setFont(font1); homearea2.setForeground(Color.red); homearea2.setLineWrap(true); homearea2.setWrapStyleWord(true); homearea2.setEditable(false); homearea2.setSize(0, 0); customer.add(homearea2);

homearea3= new JTextArea(); homearea3.setBounds( 125, 205, 100, 100); homearea3.setText(" "); homearea3.setFont(font2); homearea3.setForeground(Color.red); homearea3.setLineWrap(true); homearea3.setWrapStyleWord(true);
Wu Jian Min Page 82

IT 420 Wu Jian Min

150100000698

homearea3.setEditable(false); homearea3.setSize(0, 0); customer.add(homearea3);

//Background____________________________________________ backgroundJLabel = new JLabel(); backgroundJLabel.setBounds(0,0,880,400); backgroundJLabel.setIcon( new ImageIcon("Background Home.jpg"));

backgroundJLabel.setSize(999,400); customer.add( backgroundJLabel);

setResizable(false); setTitle( "Car Rental Brueni Pte Ltd." );

setSize( 999, 400 );// size for each home menu

setVisible( true ); setLocationRelativeTo(null);

addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent event) {


Wu Jian Min Page 83

IT 420 Wu Jian Min frameWindowClosing(event); } } );

150100000698

} }

//calling customer table_________________________________________________________________ public void customertablelist() { String customer_Course = "";

try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s = con.createStatement();

ResultSet rs = s.executeQuery("Select customer_ID, Date_reg, FullName, Address, Contact_no, Gender, Nationality, DateOfBirth, Email FROM Customer_info ORDER BY customer_ID desc"); Vector data = new Vector();
Wu Jian Min Page 84

IT 420 Wu Jian Min Vector row = null;

150100000698

ResultSetMetaData md = rs.getMetaData(); int columns = md.getColumnCount();

while (rs.next()) { row = new Vector(columns); for (int x = 1; x <= columns; x++ ) { row.addElement(rs.getObject(x)); } data.addElement(row);

rs.close(); s.close();

customermodel.setRowCount(0);

for (int x = 0; x < data.size(); x++) { customermodel.addRow((Vector)data.elementAt(x)); } } catch(Exception e) { JOptionPane.showMessageDialog(null, "Unable to Open database");
Wu Jian Min Page 85

IT 420 Wu Jian Min

150100000698

} }//end of customer table call

//calling expenses table_______________________________________________________________________ public void expensestablelist() { String expenses_Course = "";

try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s = con.createStatement(); ResultSet rs = s.executeQuery("Select Rent_ID, FullName, Date_Start_Renting, Car_ID, Rental_PerMonth, No_Of_Months, Date_End_Renting, TotalRental FROM Expenses WHERE hide = '"+ 1 +"' ORDER BY Date_Start_Renting desc");//notice

Wu Jian Min Page 86

IT 420 Wu Jian Min Vector data = new Vector(); Vector row = null;

150100000698

ResultSetMetaData md = rs.getMetaData(); int columns = md.getColumnCount();

while (rs.next()) { row = new Vector (columns); for (int x = 1; x <= columns; x++ ) { row.addElement(rs.getObject(x)); } data.addElement(row);

rs.close(); s.close();

expensesmodel.setRowCount(0);

for (int x = 0; x < data.size(); x++) { expensesmodel.addRow((Vector)data.elementAt(x)); } } catch(Exception e)


Wu Jian Min Page 87

IT 420 Wu Jian Min {

150100000698

JOptionPane.showMessageDialog(null, "Unable to Open database"); } }// end expenses table call //calling car table_______________________________________________________________________ public void cartablelist() { String car_Course = "";

try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s = con.createStatement(); ResultSet rs = s.executeQuery("Select Car_ID, Car_brand, Car_model, No_Of_Seats, Car_Color, Rental_PerMonth FROM Events ORDER BY Car_ID desc");//notice

Vector data = new Vector(); Vector row = null;

ResultSetMetaData md = rs.getMetaData(); int columns = md.getColumnCount();


Wu Jian Min Page 88

IT 420 Wu Jian Min

150100000698

while (rs.next()) { row = new Vector (columns); for (int x = 1; x <= columns; x++ ) { row.addElement(rs.getObject(x)); } data.addElement(row);

rs.close(); s.close();

carmodel.setRowCount(0);

for (int x = 0; x < data.size(); x++) { carmodel.addRow((Vector)data.elementAt(x)); } } catch(Exception e) { JOptionPane.showMessageDialog(null, "Unable to Open database"); } }// end car table call

Wu Jian Min Page 89

IT 420 Wu Jian Min

150100000698

//Adding Customers__________________________________________________________________ _________________ public class addcustomer extends JDialog { private Connection con; private Statement s; private ResultSet rs;

private JLabel Addcustomerheader, backgroundlabel;

private JLabel labelname, cIDlabel, datereglabel, namelabel, addresslabel, contactlabel, genderlabel, nationalitylabel, dateofbirthlabel, emaillabel; private JRadioButton maleRB, femaleRB; private ButtonGroup genderBG; private JTextField cIDfield, dateregfield, namefield, contactfield, nationalityfield, dateofbirthfield, emailfield; private JTextArea addressArea; private JButton savecustomer, backtomain, clearcustomer;

GregorianCalendar calendar = new GregorianCalendar(); String Date_reg; int day, month, year; private String cID, cdatereg, cname, caddress, ccontact, cgender, cnationality, cdateofbirth, cemail; private String customer_ID, FullName, Address, Contact_no, Gender, Nationality, DateOfBirth, Email;

Wu Jian Min Page 90

IT 420 Wu Jian Min private int i, a; boolean valid = true;

150100000698

Font font = new Font("Arial",Font.BOLD, 20);

public addcustomer() { super( new Frame(), "", true);//jgn lupa title

customeradd();

setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - Add" ); setSize( 530, 500 ); CUSTOMER setVisible( true ); setLocationRelativeTo(null); // size background

public void customeradd() { Container cladd = getContentPane();

cladd.setLayout(null);
Wu Jian Min Page 91

IT 420 Wu Jian Min

150100000698

System.out.println("Accessing Add Customer");

Addcustomerheader = new JLabel();

Addcustomerheader.setBounds(100, 300, 110, 10); Addcustomerheader.setHorizontalAlignment(JLabel.CENTER); Addcustomerheader.setIcon( new ImageIcon("Label1.jpg")); Addcustomerheader.setSize(494, 106); cladd.add( Addcustomerheader ); labelname = new JLabel(); labelname.setLocation(50, 30); labelname.setSize(300, 20); labelname.setFont(font); labelname.setForeground(Color.RED); labelname.setText("Add Customer Information"); labelname.setHorizontalAlignment(JLabel.LEFT); cladd.add(labelname);

cIDlabel = new JLabel(); cIDlabel.setLocation(50, 70); cIDlabel.setSize(100, 20); cIDlabel.setText("Customer ID: "); cIDlabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(cIDlabel);

cIDfield = new JTextField();


Wu Jian Min Page 92

IT 420 Wu Jian Min cIDfield.setLocation(150, 70); cIDfield.setSize( 50, 20); cladd.add(cIDfield); cIDfield.setEditable(false);

150100000698

datereglabel = new JLabel(); datereglabel.setLocation(230, 70); datereglabel.setSize(130, 20); datereglabel.setText("Registration Date :" ); datereglabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(datereglabel);

day = calendar.get(Calendar.DATE); month =(int)calendar.get(Calendar.MONTH)+1; year = calendar.get(Calendar.YEAR);

Date_reg = day + " - " + month + " - " + year;

dateregfield = new JTextField(Date_reg); dateregfield.setLocation(350, 70); dateregfield.setSize( 100, 20); cladd.add(dateregfield); dateregfield.setHorizontalAlignment(JLabel.CENTER); dateregfield.setEditable(false); namelabel = new JLabel(); namelabel.setLocation(50, 100);
Wu Jian Min Page 93

IT 420 Wu Jian Min namelabel.setSize(200, 20);

150100000698

namelabel.setText("Customer Name: "); namelabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(namelabel);

namefield = new JTextField(); namefield.setLocation(150, 100); namefield.setSize( 300, 20); cladd.add(namefield); namefield.setEditable(true);

genderlabel = new JLabel(); genderlabel.setLocation(50, 130); genderlabel.setSize( 100, 20); genderlabel.setText("Gender: "); genderlabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(genderlabel);

genderBG = new ButtonGroup();

maleRB = new JRadioButton(); maleRB.setLocation(150, 130); maleRB.setText("Male"); maleRB.setSize( 60, 20); cladd.add(maleRB); genderBG.add(maleRB);
Wu Jian Min Page 94

IT 420 Wu Jian Min

150100000698

femaleRB = new JRadioButton(); femaleRB.setLocation(250, 130); femaleRB.setText("Female"); femaleRB.setSize( 70, 20); cladd.add(femaleRB); genderBG.add(femaleRB); femaleRB.setSelected(true);

addresslabel = new JLabel(); addresslabel.setLocation(50, 160); addresslabel.setSize(100, 20); addresslabel.setText("Address: "); addresslabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(addresslabel);

addressArea = new JTextArea(); addressArea.setLocation(150, 160); addressArea.setSize( 300, 100); addressArea.setText("- Address Here - "); addressArea.setLineWrap(true); addressArea.setWrapStyleWord(true); cladd.add(addressArea); addressArea.setEditable(true);

Wu Jian Min Page 95

IT 420 Wu Jian Min contactlabel = new JLabel();

150100000698

contactlabel.setLocation(50, 275); contactlabel.setSize(100, 20); contactlabel.setText("Contact No: "); contactlabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(contactlabel);

contactfield = new JTextField(); contactfield.setLocation(150, 275); contactfield.setSize( 100, 20); cladd.add(contactfield); contactfield.setEditable(true);

nationalitylabel = new JLabel(); nationalitylabel.setLocation(50, 305); nationalitylabel.setSize(100, 20); nationalitylabel.setText("Nationality: "); nationalitylabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(nationalitylabel);

nationalityfield = new JTextField(); nationalityfield.setLocation(150, 305); nationalityfield.setSize( 200, 20); cladd.add(nationalityfield); nationalityfield.setEditable(true);

Wu Jian Min Page 96

IT 420 Wu Jian Min

150100000698

dateofbirthlabel = new JLabel(); dateofbirthlabel.setLocation(50, 335); dateofbirthlabel.setSize(100, 20); dateofbirthlabel.setText("Date Of Birth: "); dateofbirthlabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(dateofbirthlabel);

dateofbirthfield = new JTextField(); dateofbirthfield.setLocation(150, 335); dateofbirthfield.setSize( 200, 20); cladd.add(dateofbirthfield); dateofbirthfield.setEditable(true);

emaillabel = new JLabel(); emaillabel.setLocation(50, 365); emaillabel.setSize(100, 20); emaillabel.setText("Email: "); emaillabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(emaillabel);

emailfield = new JTextField(); emailfield.setLocation(150, 365); emailfield.setSize( 200, 20); cladd.add(emailfield); emailfield.setEditable(true);

Wu Jian Min Page 97

IT 420 Wu Jian Min

150100000698

clearcustomer = new JButton(); clearcustomer.setLocation( 190, 400); clearcustomer.setText("Clear");

clearcustomer.setIcon( new ImageIcon("clear-icon.png")); clearcustomer.setSize(110, 45); cladd.add(clearcustomer); clearcustomer.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) { cIDfield.setText(""); namefield.setText(""); contactfield.setText(""); addressArea.setText(""); nationalityfield.setText(""); dateofbirthfield.setText(""); emailfield.setText(""); } } );

a = 0;
Wu Jian Min Page 98

IT 420 Wu Jian Min savecustomer = new JButton();

150100000698

savecustomer.setLocation(50, 400); savecustomer.setText("Save");

savecustomer.setIcon( new ImageIcon("Save-icon.png"));

savecustomer.setSize(110, 45); cladd.add(savecustomer); savecustomer.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) { if(namefield.getText().equals("") || addressArea.getText().equals("") || contactfield.getText().equals("") || nationalityfield.getText().equals("") || dateofbirthfield.getText().equals("") || emailfield.getText().equals("")) { JOptionPane.showMessageDialog(null,"Please complete all the fields","Car Rental Brueni Pte Ltd.",JOptionPane.ERROR_MESSAGE);//displays this message when user leaves the textfields empty valid = false; setVisible( false ); return; }

Wu Jian Min Page 99

IT 420 Wu Jian Min

150100000698

if(valid == true) { String cID = cIDfield.getText(); String cdatereg = dateregfield.getText(); String cname = namefield.getText(); String caddress = addressArea.getText(); String ccontact = contactfield.getText(); String cnationality = nationalityfield.getText(); String cdateofbirth = dateofbirthfield.getText(); String cemail = emailfield.getText();

if (maleRB.isSelected()) { cgender = maleRB.getText(); } else if (femaleRB.isSelected()) { cgender = femaleRB.getText();

}
Wu Jian Min Page 100

IT 420 Wu Jian Min

150100000698

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "","");

Statement s = con.createStatement();

s.execute("SELECT customer_ID FROM Customer_info");

ResultSet rs = s.getResultSet();

while (rs.next()) { a += 1; }

if( a <=0) { a += 1; } else if (a >= 1 ) { a += 1; }


Wu Jian Min Page 101

IT 420 Wu Jian Min rs.close();

150100000698

} catch (SQLException exception) { exception.printStackTrace(); }

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("INSERT INTO Customer_info(customer_ID, Date_reg, FullName, Address, Contact_no, Gender, Nationality, DateOfBirth, Email) VALUES ('" + a + "','" + cdatereg + "','" + cname + "', '" + caddress + "', '" + ccontact + "','" + cgender + "','" + cnationality + "','" + cdateofbirth + "','" + cemail + "')"); ResultSet rs = s.getResultSet(); }

catch (SQLException exception) { exception.printStackTrace(); }


Wu Jian Min Page 102

IT 420 Wu Jian Min

150100000698

a = 0; JOptionPane.showMessageDialog(null, "New customer details have been added!", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE);

cIDfield.setText(""); namefield.setText(""); contactfield.setText(""); addressArea.setText(""); nationalityfield.setText(""); emailfield.setText(""); dateofbirthfield.setText("");

} } );

backtomain = new JButton(); backtomain.setLocation(330, 400); backtomain.setText("Back");

backtomain.setIcon( new ImageIcon("back-icon.png"));

Wu Jian Min Page 103

IT 420 Wu Jian Min

150100000698

backtomain.setSize(110, 45); cladd.add(backtomain); backtomain.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) { setVisible( false ); return; } } );

backgroundlabel = new JLabel(); backgroundlabel.setBounds(0, 0, 530, 500); backgroundlabel.setHorizontalAlignment(JLabel.CENTER); backgroundlabel.setIcon( new ImageIcon("bg cust.jpg")); backgroundlabel.setSize(530, 500); cladd.add( backgroundlabel );

} }//end of add customer

Wu Jian Min Page 104

IT 420 Wu Jian Min

150100000698

//Edit customer__________________________________________________________________

public class editcustomer extends JDialog {

private Connection con; private Statement s; private ResultSet rs;

private JLabel Addcustomerheader, backgroundlabel;

private JLabel labelname, SIDlabel, cIDlabel, datereglabel, namelabel, addresslabel, contactlabel, genderlabel, nationalitylabel, dateofbirthlabel, emaillabel; private JRadioButton maleRB, femaleRB; private ButtonGroup genderBG; private JComboBox customercbox; private JTextField SIDfield, dateregfield, namefield, contactfield, nationalityfield, dateofbirthfield, emailfield;

private JTextArea addressArea; private JButton editcustomerbutton, backtomain, clearcustomer;

private String cdatereg, cname, caddress, ccontact, cgender, cnationality, cdateofbirth, cemail; private String customer_ID, Date_reg, Name, Address, Contact_no, Gender, Nationality, DateOfBirth, Email;
Wu Jian Min Page 105

IT 420 Wu Jian Min

150100000698

boolean valid = true; Font font = new Font("Arial",Font.BOLD, 20);

public editcustomer() { super( new Frame(), "Update Customer", true);

customeredit();

setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - Edit" ); setSize( 530, 500 ); setVisible( true ); setLocationRelativeTo(null); }

public void customeredit() { Container cladd = getContentPane();

cladd.setLayout(null); System.out.println("Accessing Edit Customer");

Wu Jian Min Page 106

IT 420 Wu Jian Min

150100000698

Addcustomerheader = new JLabel(); Addcustomerheader.setBounds(0, 0, 90, 20); Addcustomerheader.setHorizontalAlignment(JLabel.CENTER); Addcustomerheader.setIcon( new ImageIcon("Label1.jpg")); Addcustomerheader.setSize(494, 106); cladd.add( Addcustomerheader );

labelname = new JLabel(); labelname.setLocation(50, 30); labelname.setSize(300, 20); labelname.setFont(font); labelname.setForeground(Color.RED); labelname.setText("Edit Customer Information"); labelname.setHorizontalAlignment(JLabel.LEFT); cladd.add(labelname);

cIDlabel = new JLabel(); cIDlabel.setLocation(50, 70); cIDlabel.setSize(100, 20); cIDlabel.setText("Customer ID: "); cIDlabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(cIDlabel);

customercbox = new JComboBox();


Wu Jian Min Page 107

IT 420 Wu Jian Min

150100000698

customercbox.setLocation(150, 70); customercbox.setSize( 50, 20); customercbox.addItem(""); customercbox.setSelectedIndex(0); cladd.add(customercbox); customercbox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { customercboxevent( event );

} } ); loadcustomerid();

datereglabel = new JLabel(); datereglabel.setLocation(230, 70); datereglabel.setSize(130, 20); datereglabel.setText("Registration Date :" ); datereglabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(datereglabel);

dateregfield = new JTextField(Date_reg);


Wu Jian Min Page 108

IT 420 Wu Jian Min

150100000698

dateregfield.setLocation(350, 70); dateregfield.setSize( 100, 20); cladd.add(dateregfield); dateregfield.setHorizontalAlignment(JLabel.CENTER); dateregfield.setEditable(false);

namelabel = new JLabel(); namelabel.setLocation(50, 100); namelabel.setSize(200, 20); namelabel.setText("Customer Name: "); namelabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(namelabel);

namefield = new JTextField(); namefield.setLocation(150, 100); namefield.setSize( 300, 20); cladd.add(namefield); namefield.setEditable(false);

genderlabel = new JLabel(); genderlabel.setLocation(50, 130); genderlabel.setSize( 100, 20); genderlabel.setText("Gender: "); genderlabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(genderlabel);

Wu Jian Min Page 109

IT 420 Wu Jian Min

150100000698

genderBG = new ButtonGroup();

maleRB = new JRadioButton(); maleRB.setLocation(150, 130); maleRB.setText("Male"); maleRB.setSize( 60, 20); cladd.add(maleRB); genderBG.add(maleRB);

femaleRB = new JRadioButton(); femaleRB.setLocation(250, 130); femaleRB.setText("Female"); femaleRB.setSize( 70, 20); cladd.add(femaleRB); genderBG.add(femaleRB); femaleRB.setSelected(true);

addresslabel = new JLabel(); addresslabel.setLocation(50, 160); addresslabel.setSize(100, 20); addresslabel.setText("Address: "); addresslabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(addresslabel);

addressArea = new JTextArea();


Wu Jian Min Page 110

IT 420 Wu Jian Min

150100000698

addressArea.setLocation(150, 160); addressArea.setSize( 300, 100); addressArea.setLineWrap(true); addressArea.setWrapStyleWord(true); cladd.add(addressArea); addressArea.setEditable(false);

contactlabel = new JLabel(); contactlabel.setLocation(50, 275); contactlabel.setSize(100, 20); contactlabel.setText("Contact No: "); contactlabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(contactlabel);

contactfield = new JTextField(); contactfield.setLocation(150, 275); contactfield.setSize( 100, 20); cladd.add(contactfield); contactfield.setEditable(false);

nationalitylabel = new JLabel(); nationalitylabel.setLocation(50, 305); nationalitylabel.setSize(100, 20); nationalitylabel.setText("Nationality: "); nationalitylabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(nationalitylabel);
Wu Jian Min Page 111

IT 420 Wu Jian Min

150100000698

nationalityfield = new JTextField(); nationalityfield.setLocation(150, 305); nationalityfield.setSize( 200, 20); cladd.add(nationalityfield); nationalityfield.setEditable(false);

dateofbirthlabel = new JLabel(); dateofbirthlabel.setLocation(50, 335); dateofbirthlabel.setSize(100, 20); dateofbirthlabel.setText("Date Of Birth: "); dateofbirthlabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(dateofbirthlabel);

dateofbirthfield = new JTextField(); dateofbirthfield.setLocation(150, 335); dateofbirthfield.setSize( 200, 20); cladd.add(dateofbirthfield); dateofbirthfield.setEditable(false);

emaillabel = new JLabel(); emaillabel.setLocation(50, 365); emaillabel.setSize(100, 20); emaillabel.setText("Email: "); emaillabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(emaillabel);
Wu Jian Min Page 112

IT 420 Wu Jian Min

150100000698

emailfield = new JTextField(); emailfield.setLocation(150, 365); emailfield.setSize( 200, 20); cladd.add(emailfield); emailfield.setEditable(false);

clearcustomer = new JButton(); clearcustomer.setLocation( 190, 400); clearcustomer.setText("Clear");

clearcustomer.setIcon( new ImageIcon("clear-icon.png"));

clearcustomer.setSize(110, 45); cladd.add(clearcustomer); clearcustomer.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) {

namefield.setText(""); contactfield.setText(""); addressArea.setText("");


Wu Jian Min Page 113

IT 420 Wu Jian Min

150100000698

nationalityfield.setText(""); emailfield.setText(""); dateofbirthfield.setText(""); } } );

dateregfield.setText(cdatereg); namefield.setText(cname); addressArea.setText(caddress); contactfield.setText(ccontact); nationalityfield.setText(cnationality); dateofbirthfield.setText(cdateofbirth); emailfield.setText(cemail);

editcustomerbutton = new JButton(); editcustomerbutton.setLocation(50, 400); editcustomerbutton.setText("Edit");

editcustomerbutton.setIcon( new ImageIcon("page-edit-icon.png"));

editcustomerbutton.setSize(110, 45); cladd.add(editcustomerbutton); editcustomerbutton.addActionListener(

Wu Jian Min Page 114

IT 420 Wu Jian Min new ActionListener() {

150100000698

public void actionPerformed( ActionEvent event ) { if(namefield.getText().equals("") || addressArea.getText().equals("") || contactfield.getText().equals("") || nationalityfield.getText().equals("") || dateofbirthfield.getText().equals("") || emailfield.getText().equals("")) { JOptionPane.showMessageDialog(null,"Please complete all the fields","Car Rental Brueni Pte Ltd.",JOptionPane.ERROR_MESSAGE);//displays this message when user leaves the textfields empty valid = false; setVisible( false ); return; } if(valid == true) { String cdatereg = dateregfield.getText(); String cname = namefield.getText(); String caddress = addressArea.getText(); String ccontact = contactfield.getText(); String cnationality = nationalityfield.getText(); String cdateofbirth = dateofbirthfield.getText(); String cemail = emailfield.getText();

Wu Jian Min Page 115

IT 420 Wu Jian Min

150100000698

if (maleRB.isSelected()) { cgender = maleRB.getText(); } else if (femaleRB.isSelected()) { cgender = femaleRB.getText();

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("UPDATE Customer_info SET FullName = '" + cname + "', Address = '" + caddress +"', Contact_no = '" + ccontact +"', Gender = '" + cgender + "', Nationality = '" + cnationality +"', DateOfBirth = '" + cdateofbirth + "', Email = '" + cemail + "' WHERE customer_ID = '" + customer_ID + "'"); visibilityfield(); System.out.println("customer ID '" + customer_ID + "' details is updated"); } catch (SQLException exception) {
Wu Jian Min Page 116

IT 420 Wu Jian Min

150100000698

exception.printStackTrace(); } JOptionPane.showMessageDialog(null, "Customer " + cname + "'s details have been updated", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE); } } } );

backtomain = new JButton(); backtomain.setLocation(330, 400); backtomain.setText("Back");

backtomain.setIcon( new ImageIcon("back-icon.png"));

backtomain.setSize(110, 45); cladd.add(backtomain); backtomain.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) {


Wu Jian Min Page 117

IT 420 Wu Jian Min

150100000698

setVisible( false ); return; } } );

backgroundlabel = new JLabel(); backgroundlabel.setBounds(0, 0, 530, 500); backgroundlabel.setHorizontalAlignment(JLabel.CENTER); backgroundlabel.setIcon( new ImageIcon("bg cust.jpg")); backgroundlabel.setSize(530, 500); cladd.add( backgroundlabel );

} private void loadcustomerid() { try {

Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT customer_ID FROM Customer_info");


Wu Jian Min Page 118

IT 420 Wu Jian Min

150100000698

ResultSet rs = s.getResultSet();

while (rs.next()) { customercbox.addItem( rs.getString("customer_ID"));

} rs.close(); } catch (SQLException exception) { JOptionPane.showMessageDialog(null, "Customer ID not Found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); } }

private void getcustomerdetails() {

String cdatereg = dateregfield.getText(); String cname = namefield.getText(); String caddress = addressArea.getText(); String ccontact = contactfield.getText();
Wu Jian Min Page 119

IT 420 Wu Jian Min String cnationality = nationalityfield.getText();

150100000698

String cdateofbirth = dateofbirthfield.getText(); String cemail = emailfield.getText();

String tempItem = "";

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Date_reg, FullName, Address, Contact_no, Gender, Nationality, DateOfBirth, Email FROM Customer_info WHERE customer_ID = '" + customer_ID + "'");

ResultSet rs = s.getResultSet();

if(rs.next()) { cdatereg = rs.getString("Date_reg"); cname = rs.getString("FullName"); tempItem = rs.getString("Gender"); caddress = rs.getString("Address"); ccontact = rs.getString("Contact_no"); cnationality = rs.getString("Nationality"); cdateofbirth = rs.getString("DateOfBirth");
Wu Jian Min Page 120

IT 420 Wu Jian Min

150100000698

cemail = rs.getString("Email"); } rs.close(); } catch (SQLException exception) { exception.printStackTrace(); }

dateregfield.setText(cdatereg); namefield.setText(cname); addressArea.setText(caddress); contactfield.setText(ccontact); nationalityfield.setText(cnationality); dateofbirthfield.setText(cdateofbirth); emailfield.setText(cemail);

if (tempItem.equals("Male")) { maleRB.setSelected(true); femaleRB.setSelected(false); } else if(tempItem.equals("Female")) { femaleRB.setSelected(true);


Wu Jian Min Page 121

IT 420 Wu Jian Min maleRB.setSelected(false); }

150100000698

tempItem = "";

} private void customercboxevent(ItemEvent event ) { if((event.getStateChange() == ItemEvent.SELECTED) && (customercbox.getSelectedIndex() != 0)) { customer_ID = (String) customercbox.getSelectedItem(); } if (customer_ID != "0") { getcustomerdetails(); visible(); } } private void visibilityfield() { namefield.setEditable(false); maleRB.setEnabled(false); femaleRB.setEnabled(false); customercbox.setEnabled(false); dateregfield.setEditable(false); addressArea.setEditable(false);
Wu Jian Min Page 122

IT 420 Wu Jian Min contactfield.setEditable(false); nationalityfield.setEditable(false); dateofbirthfield.setEditable(false); emailfield.setEditable(false); }

150100000698

private void visible() { namefield.setEditable(true); maleRB.setEnabled(true); femaleRB.setEnabled(true); customercbox.setEnabled(true); dateregfield.setEditable(true); addressArea.setEditable(true); contactfield.setEditable(true); nationalityfield.setEditable(true); dateofbirthfield.setEditable(true); emailfield.setEditable(true); }

}//end of edit customer //view customer__________________________________________________________________

public class viewcustomer extends JDialog {

Wu Jian Min Page 123

IT 420 Wu Jian Min private Connection con; private Statement s; private ResultSet rs;

150100000698

private JLabel Addcustomerheader, backgroundlabel;

private JLabel labelname, SIDlabel, cIDlabel, datereglabel, namelabel, addresslabel, contactlabel, genderlabel, nationalitylabel, dateofbirthlabel, emaillabel; private JRadioButton maleRB, femaleRB; private ButtonGroup genderBG; private JComboBox customercbox; private JTextField SIDfield, dateregfield, namefield, contactfield, nationalityfield, dateofbirthfield, emailfield; private JTextArea addressArea; private JButton backtomain;

private String cdatereg, cname, caddress, ccontact, cgender, cnationality, cdateofbirth, cemail; private String customer_ID, Date_reg, FullName, Address, Contact_no, Gender, Nationality, DateOfBirth, Email;

Font font = new Font("Arial",Font.BOLD, 20);

public viewcustomer() { super( new Frame(), "View Customer", true);

Wu Jian Min Page 124

IT 420 Wu Jian Min customerview();

150100000698

setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - View" ); setSize( 530, 500 ); setVisible( true ); setLocationRelativeTo(null); }

public void customerview() { Container cladd = getContentPane();

cladd.setLayout(null); System.out.println("Accessing View Customer");

Addcustomerheader = new JLabel(); Addcustomerheader.setBounds(0, 0, 90, 20); Addcustomerheader.setHorizontalAlignment(JLabel.CENTER); Addcustomerheader.setIcon( new ImageIcon("Label1.jpg")); Addcustomerheader.setSize(494, 106); cladd.add( Addcustomerheader );

labelname = new JLabel(); labelname.setLocation(50, 30); labelname.setSize(315, 20);


Wu Jian Min Page 125

IT 420 Wu Jian Min labelname.setFont(font);

150100000698

labelname.setForeground(Color.RED); labelname.setText("View Customer Information"); labelname.setHorizontalAlignment(JLabel.LEFT); cladd.add(labelname);

cIDlabel = new JLabel(); cIDlabel.setLocation(50, 70); cIDlabel.setSize(100, 20); cIDlabel.setText("Customer ID: "); cIDlabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(cIDlabel);

customercbox = new JComboBox(); customercbox.setLocation(150, 70); customercbox.setSize( 50, 20); customercbox.addItem(""); customercbox.setSelectedIndex(0); cladd.add(customercbox); customercbox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { customercboxevent( event ); visibilityfield();
Wu Jian Min Page 126

IT 420 Wu Jian Min } } ); loadcustomerid();

150100000698

datereglabel = new JLabel(); datereglabel.setLocation(230, 70); datereglabel.setSize(130, 20); datereglabel.setText("Registration Date :" ); datereglabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(datereglabel);

dateregfield = new JTextField(Date_reg); dateregfield.setLocation(350, 70); dateregfield.setSize( 100, 20); cladd.add(dateregfield); dateregfield.setHorizontalAlignment(JLabel.CENTER); dateregfield.setEditable(false);

namelabel = new JLabel(); namelabel.setLocation(50, 100); namelabel.setSize(200, 20); namelabel.setText("Customer Name: "); namelabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(namelabel);
Wu Jian Min Page 127

IT 420 Wu Jian Min

150100000698

namefield = new JTextField(); namefield.setLocation(150, 100); namefield.setSize( 300, 20); cladd.add(namefield); namefield.setEditable(false);

genderlabel = new JLabel(); genderlabel.setLocation(50, 130); genderlabel.setSize( 100, 20); genderlabel.setText("Gender: "); genderlabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(genderlabel);

genderBG = new ButtonGroup();

maleRB = new JRadioButton(); maleRB.setLocation(150, 130); maleRB.setText("Male"); maleRB.setSize( 60, 20); cladd.add(maleRB); genderBG.add(maleRB);

femaleRB = new JRadioButton(); femaleRB.setLocation(250, 130);


Wu Jian Min Page 128

IT 420 Wu Jian Min femaleRB.setText("Female"); femaleRB.setSize( 70, 20); cladd.add(femaleRB); genderBG.add(femaleRB);

150100000698

addresslabel = new JLabel(); addresslabel.setLocation(50, 160); addresslabel.setSize(100, 20); addresslabel.setText("Address: "); addresslabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(addresslabel);

addressArea = new JTextArea(); addressArea.setLocation(150, 160); addressArea.setSize( 300, 100); addressArea.setLineWrap(true); addressArea.setWrapStyleWord(true); cladd.add(addressArea); addressArea.setEditable(false);

contactlabel = new JLabel(); contactlabel.setLocation(50, 275); contactlabel.setSize(100, 20); contactlabel.setText("Contact No: "); contactlabel.setHorizontalAlignment(JLabel.LEFT);
Wu Jian Min Page 129

IT 420 Wu Jian Min cladd.add(contactlabel);

150100000698

contactfield = new JTextField(); contactfield.setLocation(150, 275); contactfield.setSize( 100, 20); cladd.add(contactfield); contactfield.setEditable(false);

nationalitylabel = new JLabel(); nationalitylabel.setLocation(50, 305); nationalitylabel.setSize(100, 20); nationalitylabel.setText("Nationality: "); nationalitylabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(nationalitylabel);

nationalityfield = new JTextField(); nationalityfield.setLocation(150, 305); nationalityfield.setSize( 200, 20); cladd.add(nationalityfield); nationalityfield.setEditable(false);

dateofbirthlabel = new JLabel(); dateofbirthlabel.setLocation(50, 335); dateofbirthlabel.setSize(100, 20); dateofbirthlabel.setText("Date Of Birth: "); dateofbirthlabel.setHorizontalAlignment(JLabel.LEFT);
Wu Jian Min Page 130

IT 420 Wu Jian Min cladd.add(dateofbirthlabel);

150100000698

dateofbirthfield = new JTextField(); dateofbirthfield.setLocation(150, 335); dateofbirthfield.setSize( 200, 20); cladd.add(dateofbirthfield); dateofbirthfield.setEditable(false);

emaillabel = new JLabel(); emaillabel.setLocation(50, 365); emaillabel.setSize(100, 20); emaillabel.setText("Email: "); emaillabel.setHorizontalAlignment(JLabel.LEFT); cladd.add(emaillabel);

emailfield = new JTextField(); emailfield.setLocation(150, 365); emailfield.setSize( 200, 20); cladd.add(emailfield); emailfield.setEditable(false);

backtomain = new JButton(); backtomain.setLocation(50, 400); backtomain.setText("Back");

Wu Jian Min Page 131

IT 420 Wu Jian Min backtomain.setIcon( new ImageIcon("back-icon.png"));

150100000698

backtomain.setSize(110, 45); cladd.add(backtomain); backtomain.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) { setVisible( false ); return; } } );

backgroundlabel = new JLabel(); backgroundlabel.setBounds(0, 0, 530, 500); backgroundlabel.setHorizontalAlignment(JLabel.CENTER); backgroundlabel.setIcon( new ImageIcon("bg cust.jpg")); backgroundlabel.setSize(530, 500); cladd.add( backgroundlabel );

} private void loadcustomerid()


Wu Jian Min Page 132

IT 420 Wu Jian Min { try {

150100000698

Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT customer_ID FROM Customer_info");

ResultSet rs = s.getResultSet();

while (rs.next()) { customercbox.addItem( rs.getString("customer_ID"));

} rs.close(); } catch (SQLException exception) { JOptionPane.showMessageDialog(null, "Customer ID not Found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); } }
Wu Jian Min Page 133

IT 420 Wu Jian Min

150100000698

private void customercboxevent(ItemEvent event ) { if((event.getStateChange() == ItemEvent.SELECTED) && (customercbox.getSelectedIndex() != 0)) { customer_ID = (String) customercbox.getSelectedItem(); } if (customer_ID != "0") { getcustomerdetails(); } }

private void getcustomerdetails() {

String cdatereg = dateregfield.getText(); String cname = namefield.getText(); String caddress = addressArea.getText(); String ccontact = contactfield.getText(); String cnationality = nationalityfield.getText(); String cdateofbirth = dateofbirthfield.getText(); String cemail = emailfield.getText(); maleRB.setEnabled(false); femaleRB.setEnabled(false); String tempItem = "";
Wu Jian Min Page 134

IT 420 Wu Jian Min

150100000698

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Date_reg, FullName, Address, Contact_no, Gender, Nationality, DateOfBirth, Email FROM Customer_info WHERE customer_ID = '" + customer_ID + "'");

ResultSet rs = s.getResultSet();

if(rs.next()) { cdatereg = rs.getString("Date_reg"); cname = rs.getString("FullName"); caddress = rs.getString("Address"); ccontact = rs.getString("Contact_no"); tempItem = rs.getString("Gender"); cnationality = rs.getString("Nationality"); cdateofbirth = rs.getString("DateOfBirth"); cemail = rs.getString("Email"); } rs.close(); } catch (SQLException exception)
Wu Jian Min Page 135

IT 420 Wu Jian Min { exception.printStackTrace(); }

150100000698

dateregfield.setText(cdatereg); namefield.setText(cname); addressArea.setText(caddress); contactfield.setText(ccontact); nationalityfield.setText(cnationality); dateofbirthfield.setText(cdateofbirth); emailfield.setText(cemail);

if (tempItem.equals("Male")) { maleRB.setSelected(true); femaleRB.setSelected(false); } else if(tempItem.equals("Female")) { femaleRB.setSelected(true); maleRB.setSelected(false); }

tempItem = "";

Wu Jian Min Page 136

IT 420 Wu Jian Min } private void visibilityfield() { namefield.setEditable(false); maleRB.setEnabled(false); femaleRB.setEnabled(false); dateregfield.setEditable(false); addressArea.setEditable(false); contactfield.setEditable(false); nationalityfield.setEditable(false); dateofbirthfield.setEditable(false); emailfield.setEditable(false); }

150100000698

}//end of view customer //add Rental_____________________________________________________________________ _

public class addexpenses extends JDialog { private Connection con; private Statement s; private ResultSet rs;

private JLabel Addexpensesheader, backgroundlabel;

Wu Jian Min Page 137

IT 420 Wu Jian Min

150100000698

private JLabel labelname, labelname1, expIDlabel, paydatelabel, cIDlabel, cnamelabel, evtIDlabel, evtnamelabel, noguestlabel, texplabel, enddatelabel;

private JTextField expIDfield, paydatefield, cnamefield, evtnamefield, noguestfield, texpfield, enddatefield; private JComboBox customercbox, evtIDcombo;

GregorianCalendar calendar=new GregorianCalendar(); String Paymentdate; String Enddate; int day, month, year;

/*GregorianCalendar calendar=new GregorianCalendar(); String Enddate; int day, month, year;*/

private JButton totalB, saveexpB, backtomain, clearB;

private String expno, cpaydate, cID, cname, evtid, cenddate; private Float noguest, texp, evtname;

private String Rent_ID, customer_ID, FullName, Car_ID, Rental_PerMonth, No_Of_Months, TotalRental; boolean valid = true; private int i, a;

Font font = new Font("Arial",Font.BOLD, 20);


Wu Jian Min Page 138

IT 420 Wu Jian Min

150100000698

Font font1 = new Font("Arial",Font.BOLD, 16);

public addexpenses() { super( new Frame(), "Add Expenses", true);

expensesadd();

setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - Add" ); setSize( 530, 340 ); setVisible( true ); setLocationRelativeTo(null);

} public void expensesadd() { Container exp = getContentPane(); exp.setLayout(null); System.out.println("Accessing Add Expenses");

Addexpensesheader = new JLabel(); Addexpensesheader.setBounds(0, 0, 90, 20); Addexpensesheader.setHorizontalAlignment(JLabel.CENTER); Addexpensesheader.setIcon( new ImageIcon("Label1.jpg")); Addexpensesheader.setSize(494, 101);
Wu Jian Min Page 139

IT 420 Wu Jian Min exp.add( Addexpensesheader );

150100000698

labelname = new JLabel(); labelname.setLocation(35, 30); labelname.setSize(300, 20); labelname.setFont(font); labelname.setForeground(Color.red); labelname.setText("Add Rental Information"); labelname.setHorizontalAlignment(JLabel.LEFT); exp.add(labelname);

expIDlabel = new JLabel(); expIDlabel.setLocation(20, 70); expIDlabel.setSize(100, 20); expIDlabel.setText("Rental ID: "); expIDlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(expIDlabel);

expIDfield = new JTextField(); expIDfield.setLocation(120, 70); expIDfield.setSize( 70, 20); exp.add(expIDfield); expIDfield.setEditable(false);

paydatelabel = new JLabel();


Wu Jian Min Page 140

IT 420 Wu Jian Min

150100000698

paydatelabel.setLocation(215, 70); paydatelabel.setSize(130, 20); paydatelabel.setText("Date Start Renting:" ); paydatelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(paydatelabel);

day = calendar.get(Calendar.DATE); month =(int)calendar.get(Calendar.MONTH)+1; year = calendar.get(Calendar.YEAR);

Paymentdate = day + " - " + month + " - " + year;

paydatefield = new JTextField(Paymentdate); paydatefield.setLocation(340, 70); paydatefield.setSize( 100, 20); exp.add(paydatefield); paydatefield.setHorizontalAlignment(JLabel.CENTER); paydatefield.setEditable(false);

enddatelabel = new JLabel(); enddatelabel.setLocation(215, 160); enddatelabel.setSize(130, 20); enddatelabel.setText("Date End Renting:" ); enddatelabel.setHorizontalAlignment(JLabel.LEFT);
Wu Jian Min Page 141

IT 420 Wu Jian Min exp.add(enddatelabel);

150100000698

Enddate = day + " - " + month + " - " + year;

enddatefield = new JTextField(Enddate); enddatefield.setLocation(340, 160); enddatefield.setSize( 100, 20); exp.add(enddatefield); enddatefield.setHorizontalAlignment(JLabel.CENTER); enddatefield.setEditable(false);

cIDlabel = new JLabel(); cIDlabel.setLocation(20, 100); cIDlabel.setSize(100, 20); cIDlabel.setText("Customer ID: "); cIDlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(cIDlabel);

customercbox = new JComboBox(); customercbox.setLocation(120, 100); customercbox.setSize( 70, 20); customercbox.addItem(""); customercbox.setSelectedIndex(0); exp.add(customercbox); customercbox.addItemListener( new ItemListener()
Wu Jian Min Page 142

IT 420 Wu Jian Min {

150100000698

public void itemStateChanged(ItemEvent event) { customercboxevent( event );

} } ); loadcustomerid();

cnamelabel = new JLabel(); cnamelabel.setLocation(215, 100); cnamelabel.setSize(100, 20); cnamelabel.setText("Customer Name: "); cnamelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(cnamelabel);

cnamefield = new JTextField(); cnamefield.setLocation(340, 100); cnamefield.setSize( 100, 20); exp.add(cnamefield); cnamefield.setHorizontalAlignment(JLabel.LEFT); cnamefield.setEditable(false);

evtIDlabel = new JLabel();


Wu Jian Min Page 143

IT 420 Wu Jian Min

150100000698

evtIDlabel.setLocation(20, 130); evtIDlabel.setSize(100, 20); evtIDlabel.setText("Car ID: "); evtIDlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(evtIDlabel);

evtIDcombo = new JComboBox(); evtIDcombo.setLocation(120, 130); evtIDcombo.setSize( 70, 20); evtIDcombo.addItem(""); evtIDcombo.setSelectedIndex(0); exp.add(evtIDcombo); evtIDcombo.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { evtIDcomboevent( event );

} } ); loadeventid();

evtnamelabel = new JLabel(); evtnamelabel.setLocation(215, 130);


Wu Jian Min Page 144

IT 420 Wu Jian Min evtnamelabel.setSize(115, 20);

150100000698

evtnamelabel.setText("Rental Per Month: "); evtnamelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(evtnamelabel); evtnamefield = new JTextField(); evtnamefield.setLocation(340, 130); evtnamefield.setSize( 100, 20); exp.add(evtnamefield); evtnamefield.setHorizontalAlignment(JLabel.LEFT); evtnamefield.setEditable(false);

noguestlabel = new JLabel(); noguestlabel.setLocation(20, 160); noguestlabel.setSize(130, 20); noguestlabel.setText("No of months: "); noguestlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(noguestlabel);

noguestfield = new JTextField(); noguestfield.setLocation(120, 160); noguestfield.setSize( 70, 20); exp.add(noguestfield); noguestfield.setEditable(true);

texplabel = new JLabel();


Wu Jian Min Page 145

IT 420 Wu Jian Min texplabel.setLocation(20, 190); texplabel.setSize(100, 20);

150100000698

texplabel.setText("Total Rental: "); texplabel.setHorizontalAlignment(JLabel.LEFT); exp.add(texplabel);

texpfield = new JTextField(); texpfield.setLocation(120, 190); texpfield.setSize( 70, 20); exp.add(texpfield); texpfield.setEditable(false);

totalB = new JButton(); totalB.setLocation(215, 190); totalB.setText("Total"); totalB.setSize(80, 20); exp.add(totalB); totalB.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) { if(noguestfield.getText().equals("")) {

Wu Jian Min Page 146

IT 420 Wu Jian Min

150100000698

JOptionPane.showMessageDialog(null, "Please complete all the fields", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); valid = false; setVisible(false); }

if(valid == true) { noguest = Float.parseFloat(noguestfield.getText());

String cname = cnamefield.getText();

Float a = Float.parseFloat(noguestfield.getText()); Float b = Float.parseFloat(evtnamefield.getText());

Float totalrental; try {

totalrental = a * b;
Wu Jian Min Page 147

IT 420 Wu Jian Min

150100000698

texpfield.setText(""+totalrental);

JOptionPane.showMessageDialog(null, ""+ cname +" total amount is $" + totalrental + "", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE); System.out.println(""+cname+"'s total rental is $"+totalrental+""); } catch(Exception ex) { System.out.println("Exception:"+ex);

} } });

clearB = new JButton(); clearB.setLocation( 150, 230); clearB.setText("Clear");

clearB.setIcon( new ImageIcon("clear-icon.png")); clearB.setSize(110, 45); exp.add(clearB); clearB.addActionListener(

new ActionListener()
Wu Jian Min Page 148

IT 420 Wu Jian Min {

150100000698

public void actionPerformed( ActionEvent event ) { expIDfield.setText(""); cnamefield.setText(""); evtnamefield.setText("");

noguestfield.setText("");

texpfield.setText(""); } } );

saveexpB = new JButton(); saveexpB.setLocation(20, 230); saveexpB.setText("Save");

saveexpB.setIcon( new ImageIcon("Save-icon.png")); saveexpB.setSize(110, 45); exp.add(saveexpB); saveexpB.addActionListener(

new ActionListener()
Wu Jian Min Page 149

IT 420 Wu Jian Min {

150100000698

public void actionPerformed( ActionEvent event ) {

if(cnamefield.getText().equals("") || evtnamefield.getText().equals("") || noguestfield.getText().equals("")) { JOptionPane.showMessageDialog(null, "Please complete all the field", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); valid = false; setVisible(false);

expIDfield.setText(""); cnamefield.setText(""); evtnamefield.setText("");

noguestfield.setText("");

texpfield.setText(""); }

if(valid == true) { String cli=((String)customercbox.getSelectedItem()); String evt=((String)evtIDcombo.getSelectedItem());


Wu Jian Min Page 150

IT 420 Wu Jian Min

150100000698

String expno = expIDfield.getText(); String cname = cnamefield.getText(); String cpaydate = paydatefield.getText(); String cenddate = enddatefield.getText(); String evtname = evtnamefield.getText();

String texp = texpfield.getText();

String noguest = noguestfield.getText();

a = 0; try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Rent_ID FROM Expenses");

ResultSet rs = s.getResultSet();

while (rs.next()) { a += 1;
Wu Jian Min Page 151

IT 420 Wu Jian Min

150100000698

if(a <= 1) { a += 1;

} else if (a >= 1 ) { System.out.println(" New ID added");

a += 1;

} rs.close();

} catch (SQLException exception) { exception.printStackTrace(); }

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "","");


Wu Jian Min Page 152

IT 420 Wu Jian Min

150100000698

Statement s = con.createStatement();

s.execute("INSERT INTO Expenses(Rent_ID, Date_Start_Renting, customer_ID, FullName, Car_ID, Rental_PerMonth, No_Of_Months, Date_End_Renting, TotalRental, hide) VALUES ('" + a + "','" + cpaydate + "','" + customercbox.getSelectedItem() + "', '" + cname + "', '" + evtIDcombo.getSelectedItem() + "','" + evtname +"', '" + noguest + "', '" + cenddate + "', '"+ texp +"', '"+1+"')"); ResultSet rs = s.getResultSet(); JOptionPane.showMessageDialog(null, "New rental have been added!", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE);

a = 0;

cnamefield.setText(""); evtnamefield.setText(""); noguestfield.setText(""); texpfield.setText("");

catch (SQLException exception) { exception.printStackTrace(); } } }


Wu Jian Min Page 153

IT 420 Wu Jian Min

150100000698

} );

backtomain = new JButton(); backtomain.setLocation(282, 230); backtomain.setText("Back"); backtomain.setIcon( new ImageIcon("back-icon.png")); backtomain.setSize(110, 45); exp.add(backtomain); backtomain.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) { setVisible( false ); return; } } ); backgroundlabel = new JLabel(); backgroundlabel.setBounds(0, 0, 530, 340); backgroundlabel.setHorizontalAlignment(JLabel.CENTER); backgroundlabel.setIcon( new ImageIcon("bg rental.jpg")); backgroundlabel.setSize(530, 340);
Wu Jian Min Page 154

IT 420 Wu Jian Min exp.add( backgroundlabel ); }

150100000698

private void customercboxevent(ItemEvent event ) { if((event.getStateChange() == ItemEvent.SELECTED)) { customer_ID = (String) customercbox.getSelectedItem(); } String cname = "";

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT customer_ID, FullName FROM Customer_info WHERE customer_ID = '" + customer_ID + "'");

ResultSet rs = s.getResultSet();

if(rs.next()) { cname = rs.getString("FullName");

}
Wu Jian Min Page 155

IT 420 Wu Jian Min rs.close(); }

150100000698

catch (SQLException exception) { exception.printStackTrace(); }

cnamefield.setText(cname); } private void loadcustomerid() { try {

Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT customer_ID FROM Customer_info");

ResultSet rs = s.getResultSet();

while (rs.next()) { customercbox.addItem( rs.getString("customer_ID"));

Wu Jian Min Page 156

IT 420 Wu Jian Min } rs.close(); } catch (SQLException exception) {

150100000698

JOptionPane.showMessageDialog(null, "Customer ID not Found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); } } private void evtIDcomboevent(ItemEvent event ) { if((event.getStateChange() == ItemEvent.SELECTED)) { Car_ID = (String) evtIDcombo.getSelectedItem(); } String ename = "";

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Car_ID, Rental_PerMonth FROM Events WHERE Car_ID = '" + Car_ID + "'");

Wu Jian Min Page 157

IT 420 Wu Jian Min

150100000698

ResultSet rs = s.getResultSet();

if(rs.next()) { ename = rs.getString("Rental_PerMonth");

} rs.close(); } catch (SQLException exception) { exception.printStackTrace(); }

evtnamefield.setText(ename); } private void loadeventid() { try {

Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Car_ID FROM Events");


Wu Jian Min Page 158

IT 420 Wu Jian Min

150100000698

ResultSet rs = s.getResultSet();

while (rs.next()) { evtIDcombo.addItem( rs.getString("Car_ID")); } rs.close(); } catch (SQLException exception) { JOptionPane.showMessageDialog(null, "Car ID not Found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); } }

}//end of add Rental //Edit Rental __________________________________________________________________

public class editexpenses extends JDialog { private Connection con; private Statement s;
Wu Jian Min Page 159

IT 420 Wu Jian Min private ResultSet rs;

150100000698

private JLabel Addexpensesheader, backgroundlabel;

private JLabel labelname, labelname1, expIDlabel, paydatelabel, cIDlabel, cnamelabel, evtIDlabel, evtnamelabel, noguestlabel, texplabel, enddatelabel;

private JTextField paydatefield, cnamefield, customerIDfield, evtnamefield, noguestfield, texpfield, enddatefield; private JComboBox expIDcbox, evtIDcombo;

private JButton totalB, saveexpB, backtomain, clearB;

private String expno, cpaydate, cID, cname, evtid, cenddate; private Float noguest, texp, evtname; private String Rent_ID, Date_Start_Renting, customer_ID, FullName, Car_ID, Rental_PerMonth, No_Of_Months, Date_End_Renting, TotalRental; boolean valid = true;

Font font = new Font("Arial",Font.BOLD, 20); Font font1 = new Font("Arial",Font.BOLD, 16);

public editexpenses() { super( new Frame(), "Edit Expenses", true);

expensesedit();
Wu Jian Min Page 160

IT 420 Wu Jian Min

150100000698

setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - Edit" ); setSize( 530, 340 ); setVisible( true ); setLocationRelativeTo(null);

public void expensesedit() { Container exp = getContentPane();

exp.setLayout(null); System.out.println("Accessing Edit Expenses");

Addexpensesheader = new JLabel(); Addexpensesheader.setBounds(0, 0, 90, 20); Addexpensesheader.setHorizontalAlignment(JLabel.CENTER); Addexpensesheader.setIcon( new ImageIcon("Label1.jpg")); Addexpensesheader.setSize(494, 102); exp.add( Addexpensesheader );

labelname = new JLabel(); labelname.setLocation(35, 30); labelname.setSize(300, 20);


Wu Jian Min Page 161

IT 420 Wu Jian Min labelname.setFont(font);

150100000698

labelname.setForeground(Color.red); labelname.setText("Edit Rental Information"); labelname.setHorizontalAlignment(JLabel.LEFT); exp.add(labelname);

expIDlabel = new JLabel(); expIDlabel.setLocation(20, 70); expIDlabel.setSize(100, 20); expIDlabel.setText("Rental ID: "); expIDlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(expIDlabel);

expIDcbox = new JComboBox(); expIDcbox.setLocation(120, 70); expIDcbox.setSize( 70, 20); expIDcbox.addItem(""); expIDcbox.setSelectedIndex(0); exp.add(expIDcbox); expIDcbox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { expIDcboxevent( event ); }
Wu Jian Min Page 162

IT 420 Wu Jian Min } ); loadexpensesid();

150100000698

paydatelabel = new JLabel(); paydatelabel.setLocation(215, 70); paydatelabel.setSize(130, 20); paydatelabel.setText("Date Start Renting:" ); paydatelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(paydatelabel);

paydatefield = new JTextField(Date_Start_Renting); paydatefield.setLocation(340, 70); paydatefield.setSize( 100, 20); exp.add(paydatefield); paydatefield.setHorizontalAlignment(JLabel.CENTER); paydatefield.setEditable(false);

enddatelabel = new JLabel(); enddatelabel.setLocation(215, 160); enddatelabel.setSize(130, 20); enddatelabel.setText("Date End Renting:" ); enddatelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(enddatelabel);

enddatefield = new JTextField(Date_End_Renting);


Wu Jian Min Page 163

IT 420 Wu Jian Min

150100000698

enddatefield.setLocation(340, 160); enddatefield.setSize( 100, 20); exp.add(enddatefield); enddatefield.setHorizontalAlignment(JLabel.CENTER); enddatefield.setEditable(false);

cIDlabel = new JLabel(); cIDlabel.setLocation(20, 100); cIDlabel.setSize(100, 20); cIDlabel.setText("Customer ID: "); cIDlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(cIDlabel);

customerIDfield = new JTextField(); customerIDfield.setLocation(120, 100); customerIDfield.setSize( 70, 20); exp.add(customerIDfield); customerIDfield.setHorizontalAlignment(JLabel.LEFT); customerIDfield.setEditable(false);

cnamelabel = new JLabel(); cnamelabel.setLocation(215, 100); cnamelabel.setSize(100, 20); cnamelabel.setText("Customer Name: "); cnamelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(cnamelabel);
Wu Jian Min Page 164

IT 420 Wu Jian Min

150100000698

cnamefield = new JTextField(); cnamefield.setLocation(340, 100); cnamefield.setSize( 100, 20); exp.add(cnamefield); cnamefield.setHorizontalAlignment(JLabel.LEFT); cnamefield.setEditable(false);

evtIDlabel = new JLabel(); evtIDlabel.setLocation(20, 130); evtIDlabel.setSize(100, 20); evtIDlabel.setText("Car ID: "); evtIDlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(evtIDlabel);

evtIDcombo = new JComboBox(); evtIDcombo.setLocation(120, 130); evtIDcombo.setSize( 70, 20); evtIDcombo.addItem(""); evtIDcombo.setSelectedIndex(0); exp.add(evtIDcombo); evtIDcombo.setEnabled(false); evtIDcombo.addItemListener( new ItemListener() {
Wu Jian Min Page 165

IT 420 Wu Jian Min

150100000698

public void itemStateChanged(ItemEvent event) { evtIDcomboevent( event );

} } ); loadeventid();

evtnamelabel = new JLabel(); evtnamelabel.setLocation(215, 130); evtnamelabel.setSize(115, 20); evtnamelabel.setText("Rental Per Month: "); evtnamelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(evtnamelabel);;

evtnamefield = new JTextField(); evtnamefield.setLocation(340, 130); evtnamefield.setSize( 100, 20); exp.add(evtnamefield); evtnamefield.setHorizontalAlignment(JLabel.LEFT); evtnamefield.setEditable(false); noguestlabel = new JLabel(); noguestlabel.setLocation(20, 160); noguestlabel.setSize(130, 20); noguestlabel.setText("No Of Month: ");
Wu Jian Min Page 166

IT 420 Wu Jian Min

150100000698

noguestlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(noguestlabel);

noguestfield = new JTextField(); noguestfield.setLocation(120, 160); noguestfield.setSize( 70, 20); exp.add(noguestfield); noguestfield.setEditable(false);

texplabel = new JLabel(); texplabel.setLocation(20, 190); texplabel.setSize(100, 20); texplabel.setText("Total Rental: "); texplabel.setHorizontalAlignment(JLabel.LEFT); exp.add(texplabel);

texpfield = new JTextField(); texpfield.setLocation(120, 190); texpfield.setSize( 70, 20); exp.add(texpfield); texpfield.setEditable(false);

totalB = new JButton(); totalB.setLocation(215, 190); totalB.setText("Total"); totalB.setSize(80, 20);


Wu Jian Min Page 167

IT 420 Wu Jian Min exp.add(totalB); totalB.addActionListener(

150100000698

new ActionListener() { public void actionPerformed( ActionEvent event ) { if(noguestfield.getText().equals("")) { JOptionPane.showMessageDialog(null, "Please complete all the field", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); valid = false; setVisible(false); }

if(valid == true) { noguest = Float.parseFloat(noguestfield.getText());

String cname = cnamefield.getText();

Float a = Float.parseFloat(noguestfield.getText());
Wu Jian Min Page 168

IT 420 Wu Jian Min Float b = Float.parseFloat(evtnamefield.getText());

150100000698

Float totalrental; try {

totalrental = a * b; texpfield.setText(""+totalrental);

JOptionPane.showMessageDialog(null, ""+ cname +" total amount is $" + totalrental + "", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE); System.out.println(""+cname+"'s total rental is $"+totalrental+"");

} catch(Exception ex) { System.out.println("Exception:"+ex);

} } }); clearB = new JButton(); clearB.setLocation( 150, 230);


Wu Jian Min Page 169

IT 420 Wu Jian Min clearB.setText("Clear");

150100000698

clearB.setIcon( new ImageIcon("clear-icon.png"));

clearB.setSize(110, 45); exp.add(clearB); clearB.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) {

cnamefield.setText(""); evtnamefield.setText("");

noguestfield.setText("");

texpfield.setText("");

} } ); saveexpB = new JButton(); saveexpB.setLocation(20, 230); saveexpB.setText("Edit");


Wu Jian Min Page 170

IT 420 Wu Jian Min

150100000698

saveexpB.setIcon( new ImageIcon("page-edit-icon.png")); saveexpB.setSize(110, 45); exp.add(saveexpB); saveexpB.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) { if(cnamefield.getText().equals("") || evtnamefield.getText().equals("") || noguestfield.getText().equals("")) { JOptionPane.showMessageDialog(null, "Please complete all the field", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); valid = false; setVisible(false);

cnamefield.setText(""); evtnamefield.setText("");

noguestfield.setText("");

texpfield.setText("");

Wu Jian Min Page 171

IT 420 Wu Jian Min

150100000698

if(valid == true) { String evt=((String)evtIDcombo.getSelectedItem());

String cpaydate = paydatefield.getText(); String cname = cnamefield.getText(); String evtname = evtnamefield.getText(); String cenddate = enddatefield.getText(); String noguest = noguestfield.getText();

String texp = texpfield.getText();

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("UPDATE Expenses SET Car_ID = '"+evtIDcombo.getSelectedItem()+"', FullName = '" + cname + "', Rental_PerMonth = '" + evtname + "', No_Of_Months = '" + noguest + "', TotalRental = '" + texp + "' WHERE Rent_ID = '" + Rent_ID +"' AND hide = '" +1+"' "); visibilityfield();
Wu Jian Min Page 172

IT 420 Wu Jian Min

150100000698

System.out.println("Expense No ' " + Rent_ID + "' details have been updated"); } catch (SQLException exception) { exception.printStackTrace(); } JOptionPane.showMessageDialog(null, "Customer " + cname + " rental have been updated", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE); } } } );

backtomain = new JButton(); backtomain.setLocation(282, 230); backtomain.setText("Back");

backtomain.setIcon( new ImageIcon("back-icon.png")); backtomain.setSize(110, 45); exp.add(backtomain); backtomain.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event )


Wu Jian Min Page 173

IT 420 Wu Jian Min {

150100000698

setVisible( false ); return; } } );

backgroundlabel = new JLabel(); backgroundlabel.setBounds(0, 0, 530, 340); backgroundlabel.setHorizontalAlignment(JLabel.CENTER); backgroundlabel.setIcon( new ImageIcon("bg rental.jpg")); //Background untuk EDIT backgroundlabel.setSize(530, 340); exp.add( backgroundlabel ); }

private void loadexpensesid() {

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Rent_ID FROM Expenses WHERE hide = '"+1+"' ");


Wu Jian Min Page 174

IT 420 Wu Jian Min ResultSet rs = s.getResultSet(); while( rs.next()) { expIDcbox.addItem(

150100000698

rs.getString("Rent_ID"));

} rs.close(); } catch (SQLException exception) { JOptionPane.showMessageDialog(null, "Rental ID not Found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); }

private void loadeventid() { try {

Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

Wu Jian Min Page 175

IT 420 Wu Jian Min

150100000698

s.execute("SELECT Car_ID FROM Events");

ResultSet rs = s.getResultSet();

while (rs.next()) { evtIDcombo.addItem( rs.getString("Car_ID"));

} rs.close(); } catch (SQLException exception) { JOptionPane.showMessageDialog(null, "Car ID not Found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); }

} private void getexpensesdetails() { String cpaydate = paydatefield.getText(); String cID = customerIDfield.getText(); String cname = cnamefield.getText(); String evt=((String)evtIDcombo.getSelectedItem());

Wu Jian Min Page 176

IT 420 Wu Jian Min

150100000698

String evtname = evtnamefield.getText(); String cenddate = enddatefield.getText(); String noguest = noguestfield.getText();

String texp = texpfield.getText();

visible();

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Rent_ID, Date_Start_Renting, customer_ID, FullName, Car_ID, Rental_PerMonth, No_Of_Months, Date_End_Renting, TotalRental FROM Expenses WHERE Rent_ID = '"+ Rent_ID +"'");

ResultSet rs = s.getResultSet();

if(rs.next()) { cpaydate = rs.getString("Date_Start_Renting"); cenddate = rs.getString("Date_End_Renting"); cID = rs.getString("customer_ID"); cname = rs.getString("FullName");


Wu Jian Min Page 177

IT 420 Wu Jian Min

150100000698

evt = rs.getString("Car_ID"); evtname = rs.getString("Rental_PerMonth")

noguest = rs.getString("No_Of_Months");

texp = rs.getString("TotalRental");

} rs.close(); }

catch (SQLException exception) { exception.printStackTrace(); }

paydatefield.setText(cpaydate); enddatefield.setText(cenddate); customerIDfield.setText(cID); cnamefield.setText(cname); evtIDcombo.setSelectedItem(evt); evtnamefield.setText(evtname);

noguestfield.setText(noguest);

texpfield.setText(texp);
Wu Jian Min Page 178

IT 420 Wu Jian Min

150100000698

private void expIDcboxevent(ItemEvent event ) {

if(event.getStateChange() == ItemEvent.SELECTED) { Rent_ID = (String) expIDcbox.getSelectedItem(); } if (Rent_ID != "0") { getexpensesdetails(); }

} private void evtIDcomboevent(ItemEvent event ) { if((event.getStateChange() == ItemEvent.SELECTED)) { Car_ID = (String) evtIDcombo.getSelectedItem(); } String ename = "";

try {
Wu Jian Min Page 179

IT 420 Wu Jian Min Connection con = DriverManager.getConnection("jdbc:odbc:rental", "","");

150100000698

Statement s = con.createStatement();

s.execute("SELECT Car_ID, Rental_PerMonth FROM Events WHERE Car_ID = '" + Car_ID + "'");

ResultSet rs = s.getResultSet();

if(rs.next()) { ename = rs.getString("Rental_PerMonth");

} rs.close(); } catch (SQLException exception) { exception.printStackTrace(); }

evtnamefield.setText(ename); }

private void visibilityfield() {

Wu Jian Min Page 180

IT 420 Wu Jian Min paydatefield.setEditable(false); enddatefield.setEditable(false); expIDcbox.setEnabled(false); customerIDfield.setEditable(false); cnamefield.setEditable(false); evtIDcombo.setEnabled(false); evtnamefield.setEditable(false);

150100000698

noguestfield.setEditable(false);

texpfield.setEditable(false);

} {

private void visible()

cnamefield.setEditable(true); evtIDcombo.setEnabled(true);

noguestfield.setEditable(true);

}//end of edit RENTAL //View RENTAL __________________________________________________________________

public class viewexpenses extends JDialog {


Wu Jian Min Page 181

IT 420 Wu Jian Min private Connection con; private Statement s; private ResultSet rs;

150100000698

private JLabel Addexpensesheader, backgroundlabel;

private JLabel labelname, labelname1, expIDlabel, paydatelabel, cIDlabel, cnamelabel, evtIDlabel, evtnamelabel, noguestlabel, texplabel, enddatelabel; private JRadioButton cashRB, cardRB, chequeRB; private ButtonGroup paymodegroup; private JTextField paydatefield, cnamefield, customerIDfield, evtnamefield, noguestfield, texpfield, enddatefield; private JComboBox expIDcbox, evtIDcombo; private JButton backtomain; private String expno, cpaydate, cID, cname, evtid, cenddate; private String noguest, texp, evtname; private String Rent_ID, Date_Start_Renting, customer_ID, FullName, Car_ID, Rental_PerMonth, No_Of_Months, Date_End_Renting, TotalRental;

Font font = new Font("Arial",Font.BOLD, 20); Font font1 = new Font("Arial",Font.BOLD, 16); public viewexpenses() { super( new Frame(), "Add Expenses", true);

expensesview();

Wu Jian Min Page 182

IT 420 Wu Jian Min setResizable(false);

150100000698

setTitle( "Car Rental Brueni Pte Ltd. - View" ); setSize( 530, 340 ); setVisible( true ); setLocationRelativeTo(null);

} public void expensesview() { Container exp = getContentPane();

exp.setLayout(null); System.out.println("Accessing View Expenses");

Addexpensesheader = new JLabel(); Addexpensesheader.setBounds(0, 0, 90, 20); Addexpensesheader.setHorizontalAlignment(JLabel.CENTER); Addexpensesheader.setIcon( new ImageIcon("Label1.jpg")); Addexpensesheader.setSize(494, 102); exp.add( Addexpensesheader );

labelname = new JLabel(); labelname.setLocation(35, 30); labelname.setSize(300, 20); labelname.setFont(font); labelname.setForeground(Color.red);


Wu Jian Min Page 183

IT 420 Wu Jian Min

150100000698

labelname.setText("View Rental Information"); labelname.setHorizontalAlignment(JLabel.LEFT); exp.add(labelname);

expIDlabel = new JLabel(); expIDlabel.setLocation(20, 70); expIDlabel.setSize(100, 20); expIDlabel.setText("Rental ID: "); expIDlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(expIDlabel);

expIDcbox = new JComboBox(); expIDcbox.setLocation(120, 70); expIDcbox.setSize( 70, 20); expIDcbox.addItem(""); expIDcbox.setSelectedIndex(0); exp.add(expIDcbox); expIDcbox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { expIDcboxevent( event ); } }
Wu Jian Min Page 184

IT 420 Wu Jian Min ); loadexpensesid();

150100000698

paydatelabel = new JLabel(); paydatelabel.setLocation(215, 70); paydatelabel.setSize(130, 20); paydatelabel.setText("Date Start Renting :" ); paydatelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(paydatelabel);

paydatefield = new JTextField(Date_Start_Renting); paydatefield.setLocation(340, 70); paydatefield.setSize( 100, 20); exp.add(paydatefield); paydatefield.setHorizontalAlignment(JLabel.CENTER); paydatefield.setEditable(false);

enddatelabel = new JLabel(); enddatelabel.setLocation(215, 160); enddatelabel.setSize(130, 20); enddatelabel.setText("Date End Renting :" ); enddatelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(enddatelabel);

enddatefield = new JTextField(Date_End_Renting); enddatefield.setLocation(340, 160);


Wu Jian Min Page 185

IT 420 Wu Jian Min enddatefield.setSize( 100, 20); exp.add(enddatefield);

150100000698

enddatefield.setHorizontalAlignment(JLabel.CENTER); enddatefield.setEditable(false);

cIDlabel = new JLabel(); cIDlabel.setLocation(20, 100); cIDlabel.setSize(100, 20); cIDlabel.setText("Customer ID: "); cIDlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(cIDlabel);

customerIDfield = new JTextField(); customerIDfield.setLocation(120, 100); customerIDfield.setSize( 70, 20); exp.add(customerIDfield); customerIDfield.setHorizontalAlignment(JLabel.LEFT); customerIDfield.setEditable(false);

cnamelabel = new JLabel(); cnamelabel.setLocation(215, 100); cnamelabel.setSize(100, 20); cnamelabel.setText("Customer Name: "); cnamelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(cnamelabel);

Wu Jian Min Page 186

IT 420 Wu Jian Min cnamefield = new JTextField();

150100000698

cnamefield.setLocation(340, 100); cnamefield.setSize( 100, 20); exp.add(cnamefield); cnamefield.setHorizontalAlignment(JLabel.LEFT); cnamefield.setEditable(false);

evtIDlabel = new JLabel(); evtIDlabel.setLocation(20, 130); evtIDlabel.setSize(100, 20); evtIDlabel.setText("Car ID: "); evtIDlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(evtIDlabel);

evtIDcombo = new JComboBox(); evtIDcombo.setLocation(120, 130); evtIDcombo.setSize( 70, 20); evtIDcombo.addItem(""); evtIDcombo.setSelectedIndex(0); exp.add(evtIDcombo); evtIDcombo.setEnabled(false); evtIDcombo.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event)
Wu Jian Min Page 187

IT 420 Wu Jian Min {

150100000698

evtIDcomboevent( event );

} } ); loadeventid();

evtnamelabel = new JLabel(); evtnamelabel.setLocation(215, 130); evtnamelabel.setSize(115, 20); evtnamelabel.setText("Rental Per Month: "); evtnamelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(evtnamelabel);

evtnamefield = new JTextField(); evtnamefield.setLocation(340, 130); evtnamefield.setSize( 100, 20); exp.add(evtnamefield); evtnamefield.setHorizontalAlignment(JLabel.LEFT); evtnamefield.setEditable(false);

noguestlabel = new JLabel(); noguestlabel.setLocation(20, 160); noguestlabel.setSize(130, 20); noguestlabel.setText("No Of Month: ");
Wu Jian Min Page 188

IT 420 Wu Jian Min

150100000698

noguestlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(noguestlabel);

noguestfield = new JTextField(); noguestfield.setLocation(120, 160); noguestfield.setSize( 70, 20); exp.add(noguestfield); noguestfield.setEditable(false);

texplabel = new JLabel(); texplabel.setLocation(20, 190); texplabel.setSize(100, 20); texplabel.setText("Total Rental: "); texplabel.setHorizontalAlignment(JLabel.LEFT); exp.add(texplabel);

texpfield = new JTextField(); texpfield.setLocation(120, 190); texpfield.setSize( 70, 20); exp.add(texpfield); texpfield.setEditable(false);

paydatefield.setText(cpaydate); enddatefield.setText(cenddate); cnamefield.setText(cname); evtnamefield.setText(evtname);


Wu Jian Min Page 189

IT 420 Wu Jian Min

150100000698

noguestfield.setText(noguest);

texpfield.setText(texp); backtomain = new JButton(); backtomain.setLocation(20, 230); backtomain.setText("Back");

backtomain.setIcon( new ImageIcon("back-icon.png")); backtomain.setSize(110, 45); exp.add(backtomain); backtomain.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) { setVisible( false ); return; } } );

backgroundlabel = new JLabel(); backgroundlabel.setBounds(0, 0, 530, 340); backgroundlabel.setHorizontalAlignment(JLabel.CENTER);


Wu Jian Min Page 190

IT 420 Wu Jian Min

150100000698

backgroundlabel.setIcon( new ImageIcon("bg rental.jpg")); backgroundlabel.setSize(530, 340); exp.add( backgroundlabel ); }

private void loadexpensesid() {

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement(); s.execute("SELECT Rent_ID FROM Expenses WHERE hide = '"+1+"' ");

ResultSet rs = s.getResultSet(); while( rs.next()) { expIDcbox.addItem( rs.getString("Rent_ID")); } rs.close(); } catch (SQLException exception) {

Wu Jian Min Page 191

IT 420 Wu Jian Min

150100000698

JOptionPane.showMessageDialog(null, "Rent ID not Found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); } }

private void loadeventid() { try {

Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Car_ID FROM Events");

ResultSet rs = s.getResultSet();

while (rs.next()) { evtIDcombo.addItem( rs.getString("Car_ID"));

} rs.close(); }
Wu Jian Min Page 192

IT 420 Wu Jian Min catch (SQLException exception) {

150100000698

JOptionPane.showMessageDialog(null, "Car ID not Found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); }

} private void getexpensesdetails() { String cpaydate = paydatefield.getText(); String cenddate = enddatefield.getText(); String cID = customerIDfield.getText(); String cname = cnamefield.getText(); String evt=((String)evtIDcombo.getSelectedItem()); String evtname = evtnamefield.getText();

String noguest = noguestfield.getText();

String texp = texpfield.getText();

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

Wu Jian Min Page 193

IT 420 Wu Jian Min

150100000698

s.execute("SELECT Rent_ID, Date_Start_Renting, customer_ID, FullName, Car_ID, Rental_PerMonth, Date_End_Renting, No_Of_Months, TotalRental FROM Expenses WHERE Rent_ID = '"+ Rent_ID +"'");

ResultSet rs = s.getResultSet();

if(rs.next()) { cpaydate = rs.getString("Date_Start_Renting"); cenddate = rs.getString("Date_End_Renting"); cID = rs.getString("customer_ID"); cname = rs.getString("FullName"); evt = rs.getString("Car_ID"); evtname = rs.getString("Rental_PerMonth");

noguest = rs.getString("No_Of_Months");

texp = rs.getString("TotalRental");

} rs.close(); }

Wu Jian Min Page 194

IT 420 Wu Jian Min

150100000698

catch (SQLException exception) { exception.printStackTrace(); }

paydatefield.setText(cpaydate); enddatefield.setText(cenddate); customerIDfield.setText(cID); cnamefield.setText(cname); evtIDcombo.setSelectedItem(evt); evtnamefield.setText(evtname);

noguestfield.setText(noguest);

texpfield.setText(texp);

private void expIDcboxevent(ItemEvent event ) {

if(event.getStateChange() == ItemEvent.SELECTED) { Rent_ID = (String) expIDcbox.getSelectedItem(); }


Wu Jian Min Page 195

IT 420 Wu Jian Min if (Rent_ID != "0") { getexpensesdetails(); }

150100000698

} private void evtIDcomboevent(ItemEvent event ) { if((event.getStateChange() == ItemEvent.SELECTED)) { Car_ID = (String) evtIDcombo.getSelectedItem(); } String ename = "";

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Car_ID, Rental_PerMonth FROM Events WHERE Car_ID = '" + Car_ID + "'");

ResultSet rs = s.getResultSet();

if(rs.next()) {
Wu Jian Min Page 196

IT 420 Wu Jian Min

150100000698

ename = rs.getString("Rental_PerMonth");

} rs.close(); } catch (SQLException exception) { exception.printStackTrace(); }

evtnamefield.setText(ename); } }//end of view RENTAL //Delete RENTAL __________________________________________________________________

public class deleteexpenses extends JDialog { private Connection con; private Statement s; private ResultSet rs;

private JLabel Addexpensesheader, backgroundlabel;

private JLabel labelname, labelname1, expIDlabel, paydatelabel, cIDlabel, cnamelabel, evtIDlabel, evtnamelabel, noguestlabel, texplabel, enddatelabel;

Wu Jian Min Page 197

IT 420 Wu Jian Min

150100000698

private JTextField paydatefield, cnamefield, customerIDfield, evtnamefield, noguestfield, texpfield, enddatefield; private JComboBox expIDcbox, evtIDcombo;

private JButton deleteB, backtomain; private int a, i, delete; private String expno, cpaydate, cID, cname, evtid, cenddate; private String noguest, texp, evtname; private String Rent_ID, Date_Start_Renting, customer_ID, FullName, Car_ID, Rental_PerMonth, Date_End_Renting, No_Of_Months, TotalRental; boolean valid = true;

Font font = new Font("Arial",Font.BOLD, 20); Font font1 = new Font("Arial",Font.BOLD, 16);

public deleteexpenses() { super( new Frame(), "Add Expenses", true);

expensesdelete();

setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - Delete" ); setSize( 530, 340 ); setVisible( true ); setLocationRelativeTo(null);
Wu Jian Min Page 198

IT 420 Wu Jian Min

150100000698

public void expensesdelete() { Container exp = getContentPane();

exp.setLayout(null); System.out.println("Accessing Delete Expenses");

Addexpensesheader = new JLabel(); Addexpensesheader.setBounds(0, 0, 90, 20); Addexpensesheader.setHorizontalAlignment(JLabel.CENTER); Addexpensesheader.setIcon( new ImageIcon("Label1.jpg")); Addexpensesheader.setSize(494, 102); exp.add( Addexpensesheader );

labelname = new JLabel(); labelname.setLocation(35, 30); labelname.setSize(300, 20); labelname.setFont(font); labelname.setForeground(Color.red); labelname.setText("Delete Rental Information"); labelname.setHorizontalAlignment(JLabel.LEFT); exp.add(labelname);

Wu Jian Min Page 199

IT 420 Wu Jian Min

150100000698

expIDlabel = new JLabel(); expIDlabel.setLocation(20, 70); expIDlabel.setSize(100, 20); expIDlabel.setText("Rent ID: "); expIDlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(expIDlabel);

expIDcbox = new JComboBox(); expIDcbox.setLocation(120, 70); expIDcbox.setSize( 70, 20); expIDcbox.addItem(""); expIDcbox.setSelectedIndex(0); exp.add(expIDcbox); expIDcbox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { expIDcboxevent( event ); } } );

paydatelabel = new JLabel();


Wu Jian Min Page 200

IT 420 Wu Jian Min

150100000698

paydatelabel.setLocation(215, 70); paydatelabel.setSize(130, 20); paydatelabel.setText("Date Start Renting :" ); paydatelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(paydatelabel);

paydatefield = new JTextField(Date_Start_Renting); paydatefield.setLocation(340, 70); paydatefield.setSize( 100, 20); exp.add(paydatefield); paydatefield.setHorizontalAlignment(JLabel.CENTER); paydatefield.setEditable(false);

enddatelabel = new JLabel(); enddatelabel.setLocation(215, 160); enddatelabel.setSize(130, 20); enddatelabel.setText("Date End Renting :" ); enddatelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(enddatelabel);

enddatefield = new JTextField(Date_End_Renting); enddatefield.setLocation(340, 160); enddatefield.setSize( 100, 20); exp.add(enddatefield); enddatefield.setHorizontalAlignment(JLabel.CENTER);
Wu Jian Min Page 201

IT 420 Wu Jian Min enddatefield.setEditable(false);

150100000698

cIDlabel = new JLabel(); cIDlabel.setLocation(20, 100); cIDlabel.setSize(100, 20); cIDlabel.setText("Customer ID: "); cIDlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(cIDlabel);

customerIDfield = new JTextField(); customerIDfield.setLocation(120, 100); customerIDfield.setSize( 70, 20); exp.add(customerIDfield); customerIDfield.setHorizontalAlignment(JLabel.LEFT); customerIDfield.setEditable(false);

cnamelabel = new JLabel(); cnamelabel.setLocation(215, 100); cnamelabel.setSize(100, 20); cnamelabel.setText("Customer Name: "); cnamelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(cnamelabel);

cnamefield = new JTextField(); cnamefield.setLocation(340, 100); cnamefield.setSize( 170, 20);


Wu Jian Min Page 202

IT 420 Wu Jian Min exp.add(cnamefield);

150100000698

cnamefield.setHorizontalAlignment(JLabel.LEFT); cnamefield.setEditable(false);

evtIDlabel = new JLabel(); evtIDlabel.setLocation(20, 130); evtIDlabel.setSize(100, 20); evtIDlabel.setText("Car ID: "); evtIDlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(evtIDlabel);

evtIDcombo = new JComboBox(); evtIDcombo.setLocation(120, 130); evtIDcombo.setSize( 70, 20); evtIDcombo.addItem(""); evtIDcombo.setSelectedIndex(0); exp.add(evtIDcombo); evtIDcombo.setEnabled(false); evtIDcombo.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { evtIDcomboevent( event );

Wu Jian Min Page 203

IT 420 Wu Jian Min } } ); loadeventid();

150100000698

evtnamelabel = new JLabel(); evtnamelabel.setLocation(215, 130); evtnamelabel.setSize(115, 20); evtnamelabel.setText("Rental Per Month: "); evtnamelabel.setHorizontalAlignment(JLabel.LEFT); exp.add(evtnamelabel);

evtnamefield = new JTextField(); evtnamefield.setLocation(340, 130); evtnamefield.setSize( 100, 20); exp.add(evtnamefield); evtnamefield.setHorizontalAlignment(JLabel.LEFT); evtnamefield.setEditable(false);

noguestlabel = new JLabel(); noguestlabel.setLocation(20, 160); noguestlabel.setSize(130, 20); noguestlabel.setText("No Of Month: "); noguestlabel.setHorizontalAlignment(JLabel.LEFT); exp.add(noguestlabel);
Wu Jian Min Page 204

IT 420 Wu Jian Min

150100000698

noguestfield = new JTextField(); noguestfield.setLocation(120, 160); noguestfield.setSize( 70, 20); exp.add(noguestfield); noguestfield.setEditable(false);

texplabel = new JLabel(); texplabel.setLocation(20, 190); texplabel.setSize(100, 20); texplabel.setText("Total Rental: "); texplabel.setHorizontalAlignment(JLabel.LEFT); exp.add(texplabel);

texpfield = new JTextField(); texpfield.setLocation(120, 190); texpfield.setSize( 70, 20); exp.add(texpfield); texpfield.setEditable(false);

paydatefield.setText(cpaydate); enddatefield.setText(cenddate); cnamefield.setText(cname); evtnamefield.setText(evtname);

noguestfield.setText(noguest);
Wu Jian Min Page 205

IT 420 Wu Jian Min

150100000698

texpfield.setText(texp);

deleteB = new JButton(); deleteB.setLocation(20, 230); deleteB.setText("Delete");

deleteB.setIcon( new ImageIcon("Open-Folder-Delete-icon.png"));

deleteB.setSize(110, 45); exp.add(deleteB); deleteB.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) { delete = JOptionPane.showConfirmDialog(null, "Confirm delete this rental?", "Car Rental Brueni Pte Ltd.", JOptionPane.YES_NO_OPTION);

if(delete == JOptionPane.YES_OPTION) { delexp();

}
Wu Jian Min Page 206

IT 420 Wu Jian Min

150100000698

else { return; } } } );

loadexpensesid();

backtomain = new JButton(); backtomain.setLocation(150, 230); backtomain.setText("Back");

backtomain.setIcon( new ImageIcon("back-icon.png"));

backtomain.setSize(110, 45); exp.add(backtomain); backtomain.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event )


Wu Jian Min Page 207

IT 420 Wu Jian Min {

150100000698

setVisible( false ); return; } } );

backgroundlabel = new JLabel(); backgroundlabel.setBounds(0, 0, 530, 340); backgroundlabel.setHorizontalAlignment(JLabel.CENTER); backgroundlabel.setIcon( new ImageIcon("bg rental.jpg"));// Background untuk Delete backgroundlabel.setSize(530, 340); exp.add( backgroundlabel ); }

private void delexp() {

String evt=((String)evtIDcombo.getSelectedItem()); String cpaydate = paydatefield.getText(); String cenddate = enddatefield.getText(); String cname = cnamefield.getText(); String evtname = evtnamefield.getText(); String cID = customerIDfield.getText(); String noguest = noguestfield.getText();
Wu Jian Min Page 208

IT 420 Wu Jian Min

150100000698

String texp = texpfield.getText(); try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement(); visibility();

s.execute("UPDATE Expenses SET hide = '"+0+"' WHERE Rent_ID = '" + Rent_ID + "' ");

ResultSet rs = s.getResultSet();

cnamefield.setText(""); evtnamefield.setText("");

noguestfield.setText("");

texpfield.setText(""); System.out.println("Expense No ' " + Rent_ID + "' details have been deleted"); } catch (SQLException exception) { exception.printStackTrace(); }
Wu Jian Min Page 209

IT 420 Wu Jian Min

150100000698

JOptionPane.showMessageDialog(null, "Customer " + cname + " rental have been deleted", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE);

private void loadexpensesid() {

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Rent_ID FROM Expenses WHERE hide = '"+1+"' ");

ResultSet rs = s.getResultSet(); while( rs.next()) { expIDcbox.addItem( rs.getString("Rent_ID"));

} rs.close(); }
Wu Jian Min Page 210

IT 420 Wu Jian Min

150100000698

catch (SQLException exception) { JOptionPane.showMessageDialog(null, "Rental ID not found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); return; }

private void loadeventid() { try {

Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Car_ID FROM Events");

ResultSet rs = s.getResultSet();

while (rs.next()) { evtIDcombo.addItem( rs.getString("Car_ID"));


Wu Jian Min Page 211

IT 420 Wu Jian Min

150100000698

} rs.close(); } catch (SQLException exception) { JOptionPane.showMessageDialog(null, "Car ID not found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); }

private void getexpensesdetails() { String cpaydate = paydatefield.getText(); String cenddate = enddatefield.getText(); String cID = customerIDfield.getText(); String cname = cnamefield.getText(); String evt=((String)evtIDcombo.getSelectedItem()); String evtname = evtnamefield.getText();

String noguest = noguestfield.getText();

String texp = texpfield.getText();


Wu Jian Min Page 212

IT 420 Wu Jian Min

150100000698

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Rent_ID, Date_Start_Renting, customer_ID, FullName, Car_ID, Rental_PerMonth, Date_End_Renting, No_Of_Months, TotalRental, hide FROM Expenses WHERE Rent_ID = '"+ Rent_ID +"'");

ResultSet rs = s.getResultSet();

if(rs.next()) { cpaydate = rs.getString("Date_Start_Renting"); cenddate = rs.getString("Date_End_Renting"); cID = rs.getString("customer_ID"); cname = rs.getString("FullName"); evt = rs.getString("Car_ID"); evtname = rs.getString("Rental_PerMonth"); noguest = rs.getString("No_Of_Months"); texp = rs.getString("TotalRental");

Wu Jian Min Page 213

IT 420 Wu Jian Min } rs.close(); }

150100000698

catch (SQLException exception) { exception.printStackTrace(); }

paydatefield.setText(cpaydate); enddatefield.setText(cenddate); customerIDfield.setText(cID); cnamefield.setText(cname); evtIDcombo.setSelectedItem(evt); evtnamefield.setText(evtname);

noguestfield.setText(noguest); expfield.setText(texp);

private void expIDcboxevent(ItemEvent event ) {

if(event.getStateChange() == ItemEvent.SELECTED)
Wu Jian Min Page 214

IT 420 Wu Jian Min {

150100000698

Rent_ID = (String) expIDcbox.getSelectedItem(); } if (Rent_ID != "0") { getexpensesdetails(); }

} private void evtIDcomboevent(ItemEvent event ) { if((event.getStateChange() == ItemEvent.SELECTED)) { Car_ID = (String) evtIDcombo.getSelectedItem(); } String ename = ""; try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Car_ID, Rental_PerMonth FROM Events WHERE Car_ID = '" + Car_ID + "'");

ResultSet rs = s.getResultSet();

Wu Jian Min Page 215

IT 420 Wu Jian Min if(rs.next()) {

150100000698

ename = rs.getString("Rental_PerMonth");

} rs.close(); } catch (SQLException exception) { exception.printStackTrace(); }

evtnamefield.setText(ename); }

private void visibility() { paydatefield.setEditable(false); enddatefield.setEditable(false); customerIDfield.setEditable(false); cnamefield.setEditable(false); evtIDcombo.setEnabled(false); evtnamefield.setEditable(false);

noguestfield.setEditable(false);

Wu Jian Min Page 216

IT 420 Wu Jian Min texpfield.setEditable(false);

150100000698

}//end of delete RENTAL

//Adding Car________________________________________________________________________ ___________ public class addcar extends JDialog { private Connection con; private Statement s; private ResultSet rs;

private JLabel Addcarheader, backgroundlabel;

private JLabel labelname, rIDlabel, carbrandlabel, carmodellabel, noofseatslabel, carcolorlabel, evtnamelabel;

private JTextField rIDfield, carbrandfield, carmodelfield, noofseatfield, carcolorfield, evtnamefield; private JButton savecar, backtomain, clearcar; private String rID, rcarbrand, rcarmodel, rnoofseats, rcarcolor; private Float evtname;
Wu Jian Min Page 217

IT 420 Wu Jian Min

150100000698

private String Car_ID, Car_brand, Car_model, No_Of_Seats, Car_Color, Rental_PerMonth;

private int i, a; boolean valid = true;

Font font = new Font("Arial",Font.BOLD, 20);

public addcar() { super( new Frame(), "", true);

caradd();

setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - Add" ); setSize( 530, 260 ); setVisible( true ); setLocationRelativeTo(null); // size background CAR

public void caradd() { Container caradd = getContentPane();

caradd.setLayout(null);
Wu Jian Min Page 218

IT 420 Wu Jian Min

150100000698

System.out.println("Accessing Add Car");

Addcarheader = new JLabel(); Addcarheader.setBounds(100, 300, 110, 10); Addcarheader.setHorizontalAlignment(JLabel.CENTER); Addcarheader.setIcon( new ImageIcon("Label1.jpg")); Addcarheader.setSize(494, 106); caradd.add( Addcarheader ); labelname = new JLabel(); labelname.setLocation(50, 30); labelname.setSize(300, 20); labelname.setFont(font); labelname.setForeground(Color.RED); labelname.setText("Add Car Information"); labelname.setHorizontalAlignment(JLabel.LEFT); caradd.add(labelname);

rIDlabel = new JLabel(); rIDlabel.setLocation(50, 70); rIDlabel.setSize(90, 20); rIDlabel.setText("Car ID: "); rIDlabel.setHorizontalAlignment(JLabel.LEFT); caradd.add(rIDlabel);

rIDfield = new JTextField(); rIDfield.setLocation(150, 70);


Wu Jian Min Page 219

IT 420 Wu Jian Min rIDfield.setSize( 50, 20); caradd.add(rIDfield); rIDfield.setEditable(false);

150100000698

carbrandlabel = new JLabel(); carbrandlabel.setLocation(50, 100); carbrandlabel.setSize(130, 20); carbrandlabel.setText("Car Brand :" ); carbrandlabel.setHorizontalAlignment(JLabel.LEFT); caradd.add(carbrandlabel);

carbrandfield = new JTextField(); carbrandfield.setLocation(150, 100); carbrandfield.setSize( 90, 20); caradd.add(carbrandfield); carbrandfield.setHorizontalAlignment(JLabel.LEFT); carbrandfield.setEditable(true);

carmodellabel = new JLabel(); carmodellabel.setLocation(50, 130); carmodellabel.setSize(200, 20); carmodellabel.setText("Car model: "); carmodellabel.setHorizontalAlignment(JLabel.LEFT); caradd.add(carmodellabel);

carmodelfield = new JTextField();


Wu Jian Min Page 220

IT 420 Wu Jian Min

150100000698

carmodelfield.setLocation(150, 130); carmodelfield.setSize( 90, 20); caradd.add(carmodelfield); carmodelfield.setEditable(true);

noofseatslabel = new JLabel(); noofseatslabel.setLocation(250, 70); noofseatslabel.setSize( 100, 20); noofseatslabel.setText("No Of Seats: "); noofseatslabel.setHorizontalAlignment(JLabel.LEFT); caradd.add(noofseatslabel); noofseatfield = new JTextField(); noofseatfield.setLocation(370, 70); noofseatfield.setSize( 90, 20); caradd.add(noofseatfield); noofseatfield.setEditable(true);

carcolorlabel = new JLabel(); carcolorlabel.setLocation(250, 100); carcolorlabel.setSize(100, 20); carcolorlabel.setText("Car color: "); carcolorlabel.setHorizontalAlignment(JLabel.LEFT); caradd.add(carcolorlabel);

carcolorfield = new JTextField(); carcolorfield.setLocation(370, 100);


Wu Jian Min Page 221

IT 420 Wu Jian Min carcolorfield.setSize( 90, 20); caradd.add(carcolorfield); carcolorfield.setEditable(true);

150100000698

evtnamelabel = new JLabel(); evtnamelabel.setLocation(250, 130); evtnamelabel.setSize(130, 20); evtnamelabel.setText("Rental Per Month: "); evtnamelabel.setHorizontalAlignment(JLabel.LEFT); caradd.add(evtnamelabel);

evtnamefield = new JTextField(); evtnamefield.setLocation(370, 130); evtnamefield.setSize( 90, 20); caradd.add(evtnamefield); evtnamefield.setEditable(true); clearcar = new JButton(); clearcar.setLocation( 190, 170); clearcar.setText("Clear");

clearcar.setIcon( new ImageIcon("clear-icon.png")); clearcar.setSize(110, 45); caradd.add(clearcar); clearcar.addActionListener(

new ActionListener()
Wu Jian Min Page 222

IT 420 Wu Jian Min {

150100000698

public void actionPerformed( ActionEvent event ) { rIDfield.setText(""); carbrandfield.setText(""); carmodelfield.setText(""); noofseatfield.setText(""); carcolorfield.setText(""); evtnamefield.setText("");

} } ); a = 0; savecar = new JButton(); savecar.setLocation(50, 170); savecar.setText("Save"); savecar.setIcon( new ImageIcon("Save-icon.png")); savecar.setSize(110, 45); caradd.add(savecar); savecar.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event )


Wu Jian Min Page 223

IT 420 Wu Jian Min {

150100000698

if(carbrandfield.getText().equals("") || carmodelfield.getText().equals("") || noofseatfield.getText().equals("") || carcolorfield.getText().equals("") || evtnamefield.getText().equals("")) { JOptionPane.showMessageDialog(null,"Please complete all the fields","Car Rental Brueni Pte Ltd.",JOptionPane.ERROR_MESSAGE);//displays this message when user leaves the textfields empty valid = false; setVisible( false ); return; } if(valid == true) { String rID = rIDfield.getText(); String rcarbrand = carbrandfield.getText(); String rcarmodel = carmodelfield.getText(); String rnoofseats = noofseatfield.getText(); String rcarcolor = carcolorfield.getText(); String evtname = evtnamefield.getText();

try {

Wu Jian Min Page 224

IT 420 Wu Jian Min Connection con = DriverManager.getConnection("jdbc:odbc:rental", "","");

150100000698

Statement s = con.createStatement();

s.execute("SELECT Car_ID FROM Events");

ResultSet rs = s.getResultSet();

while (rs.next()) { a += 1; }

if( a <=0) { a += 1; } else if (a >= 1 ) { a += 1; } rs.close();

} catch (SQLException exception)


Wu Jian Min Page 225

IT 420 Wu Jian Min { exception.printStackTrace(); }

150100000698

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement(); s.execute("INSERT INTO Events(Car_ID, Car_brand, Car_model, No_Of_Seats, Car_Color, Rental_PerMonth) VALUES ('" + a + "','" + rcarbrand + "','" + rcarmodel + "', '" + rnoofseats + "', '" + rcarcolor + "', '" + evtname + "')"); ResultSet rs = s.getResultSet(); }

catch (SQLException exception) { exception.printStackTrace(); }

a = 0; JOptionPane.showMessageDialog(null, "New car details have been added!", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE);

rIDfield.setText(""); carbrandfield.setText(""); carmodelfield.setText("");


Wu Jian Min Page 226

IT 420 Wu Jian Min

150100000698

noofseatfield.setText(""); carcolorfield.setText(""); evtnamefield.setText("");

} } );

backtomain = new JButton(); backtomain.setLocation(330, 170); backtomain.setText("Back");

backtomain.setIcon( new ImageIcon("back-icon.png"));

backtomain.setSize(110, 45); caradd.add(backtomain); backtomain.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) {


Wu Jian Min Page 227

IT 420 Wu Jian Min

150100000698

setVisible( false ); return; } } );

backgroundlabel = new JLabel(); backgroundlabel.setBounds(0, 0, 530, 260); backgroundlabel.setHorizontalAlignment(JLabel.CENTER); backgroundlabel.setIcon( new ImageIcon("bg rental.jpg")); backgroundlabel.setSize(530, 260); caradd.add( backgroundlabel );

} }//end of add car

//Edit car__________________________________________________________________

public class editcar extends JDialog {

private Connection con; private Statement s; private ResultSet rs;

private JLabel Addcarheader, backgroundlabel;


Wu Jian Min Page 228

IT 420 Wu Jian Min

150100000698

private JLabel labelname, rIDlabel, carbrandlabel, carmodellabel, noofseatslabel, carcolorlabel, evtnamelabel;

private JTextField rIDfield, carbrandfield, carmodelfield, noofseatfield, carcolorfield, evtnamefield; private JButton editcarbutton, backtomain, clearcar; private JComboBox carcbox;

private String rID, rcarbrand, rcarmodel, rnoofseats, rcarcolor; private Float evtname; private String Car_ID, Car_brand, Car_model, No_Of_Seats, Car_Color, Rental_PerMonth;

boolean valid = true; Font font = new Font("Arial",Font.BOLD, 20);

public editcar() { super( new Frame(), "Update Car", true);

caredit();

setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - Edit" );


Wu Jian Min Page 229

IT 420 Wu Jian Min setSize( 530, 260 ); setVisible( true ); setLocationRelativeTo(null); }

150100000698

public void caredit() { Container caradd = getContentPane();

caradd.setLayout(null); System.out.println("Accessing Edit Car");

Addcarheader = new JLabel(); Addcarheader.setBounds(0, 0, 90, 20); Addcarheader.setHorizontalAlignment(JLabel.CENTER); Addcarheader.setIcon( new ImageIcon("Label1.jpg")); Addcarheader.setSize(494, 106); caradd.add( Addcarheader );

labelname = new JLabel(); labelname.setLocation(50, 30); labelname.setSize(300, 20); labelname.setFont(font); labelname.setForeground(Color.RED);


Wu Jian Min Page 230

IT 420 Wu Jian Min

150100000698

labelname.setText("Edit Car Information"); labelname.setHorizontalAlignment(JLabel.LEFT); caradd.add(labelname);

rIDlabel = new JLabel(); rIDlabel.setLocation(50, 70); rIDlabel.setSize(100, 20); rIDlabel.setText("Car ID: "); rIDlabel.setHorizontalAlignment(JLabel.LEFT); caradd.add(rIDlabel);

carcbox = new JComboBox(); carcbox.setLocation(150, 70); carcbox.setSize( 50, 20); carcbox.addItem(""); carcbox.setSelectedIndex(0); caradd.add(carcbox); carcbox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { carcboxevent( event );

} }
Wu Jian Min Page 231

IT 420 Wu Jian Min ); loadcarid();

150100000698

carbrandlabel = new JLabel(); carbrandlabel.setLocation(50, 100); carbrandlabel.setSize(130, 20); carbrandlabel.setText("Car Brand :" ); carbrandlabel.setHorizontalAlignment(JLabel.LEFT); caradd.add(carbrandlabel);

carbrandfield = new JTextField(); carbrandfield.setLocation(150, 100); carbrandfield.setSize( 90, 20); caradd.add(carbrandfield); carbrandfield.setHorizontalAlignment(JLabel.CENTER); carbrandfield.setEditable(true);

carmodellabel = new JLabel(); carmodellabel.setLocation(50, 130); carmodellabel.setSize(200, 20); carmodellabel.setText("Car model: "); carmodellabel.setHorizontalAlignment(JLabel.LEFT); caradd.add(carmodellabel);

carmodelfield = new JTextField();


Wu Jian Min Page 232

IT 420 Wu Jian Min

150100000698

carmodelfield.setLocation(150, 130); carmodelfield.setSize( 90, 20); caradd.add(carmodelfield); carmodelfield.setEditable(true);

noofseatslabel = new JLabel(); noofseatslabel.setLocation(250, 70); noofseatslabel.setSize( 100, 20); noofseatslabel.setText("No Of Seats: "); noofseatslabel.setHorizontalAlignment(JLabel.LEFT); caradd.add(noofseatslabel);

noofseatfield = new JTextField(); noofseatfield.setLocation(370, 70); noofseatfield.setSize( 90, 20); caradd.add(noofseatfield); noofseatfield.setEditable(true);

carcolorlabel = new JLabel(); carcolorlabel.setLocation(250, 100); carcolorlabel.setSize(100, 20); carcolorlabel.setText("Car color: "); carcolorlabel.setHorizontalAlignment(JLabel.LEFT); caradd.add(carcolorlabel);

Wu Jian Min Page 233

IT 420 Wu Jian Min

150100000698

carcolorfield = new JTextField(); carcolorfield.setLocation(370, 100); carcolorfield.setSize( 90, 20); caradd.add(carcolorfield); carcolorfield.setEditable(true);

evtnamelabel = new JLabel(); evtnamelabel.setLocation(250, 130); evtnamelabel.setSize(130, 20); evtnamelabel.setText("Rental Per Month: "); evtnamelabel.setHorizontalAlignment(JLabel.LEFT); caradd.add(evtnamelabel);

evtnamefield = new JTextField(); evtnamefield.setLocation(370, 130); evtnamefield.setSize( 90, 20); caradd.add(evtnamefield); evtnamefield.setEditable(true);

clearcar = new JButton(); clearcar.setLocation( 190, 170); clearcar.setText("Clear");


Wu Jian Min Page 234

IT 420 Wu Jian Min

150100000698

clearcar.setIcon( new ImageIcon("clear-icon.png"));

clearcar.setSize(110, 45); caradd.add(clearcar); clearcar.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) { //rIDfield.setText(""); carbrandfield.setText(""); carmodelfield.setText(""); noofseatfield.setText(""); carcolorfield.setText(""); evtnamefield.setText("");

} } ); carbrandfield.setText(rcarbrand); carmodelfield.setText(rcarmodel); noofseatfield.setText(rnoofseats); carcolorfield.setText(rcarcolor);


Wu Jian Min Page 235

IT 420 Wu Jian Min editcarbutton = new JButton();

150100000698

editcarbutton.setLocation(50, 170); editcarbutton.setText("Edit");

editcarbutton.setIcon( new ImageIcon("page-edit-icon.png")); editcarbutton.setSize(110, 45); caradd.add(editcarbutton); editcarbutton.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) { if(carbrandfield.getText().equals("") || carmodelfield.getText().equals("") || noofseatfield.getText().equals("") || carcolorfield.getText().equals("") || evtnamefield.getText().equals("")) { JOptionPane.showMessageDialog(null,"Please complete all the fields","Car Rental Brueni Pte Ltd.",JOptionPane.ERROR_MESSAGE);//displays this message when user leaves the textfields empty valid = false; setVisible( false ); return; }

if(valid == true) {
Wu Jian Min Page 236

IT 420 Wu Jian Min

150100000698

//String rID = rIDfield.getText(); String rcarbrand = carbrandfield.getText(); String rcarmodel = carmodelfield.getText(); String rnoofseats = noofseatfield.getText(); String rcarcolor = carcolorfield.getText(); String evtname = evtnamefield.getText();

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("UPDATE Events SET Car_brand = '" + rcarbrand + "', Car_model = '" + rcarmodel +"', No_Of_Seats = '" + rnoofseats +"', Car_Color = '" + rcarcolor + "', Rental_PerMonth = '" + evtname +"' WHERE Car_ID = '" + Car_ID + "'"); visibilityfield(); System.out.println("Car ID '" + Car_ID + "' details is updated"); } catch (SQLException exception) { exception.printStackTrace(); }
Wu Jian Min Page 237

IT 420 Wu Jian Min

150100000698

JOptionPane.showMessageDialog(null, "Car_ID " + rID + "'s details have been updated", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE); } } } );

backtomain = new JButton(); backtomain.setLocation(330, 170); backtomain.setText("Back");

backtomain.setIcon( new ImageIcon("back-icon.png")); backtomain.setSize(110, 45); caradd.add(backtomain); backtomain.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) { setVisible( false ); return; } } );
Wu Jian Min Page 238

IT 420 Wu Jian Min

150100000698

backgroundlabel = new JLabel(); backgroundlabel.setBounds(0, 0, 530, 260); backgroundlabel.setHorizontalAlignment(JLabel.CENTER); backgroundlabel.setIcon( new ImageIcon("bg rental.jpg")); backgroundlabel.setSize(530, 260); caradd.add( backgroundlabel );

} private void loadcarid() { try {

Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Car_ID FROM Events");

ResultSet rs = s.getResultSet();

while (rs.next()) { carcbox.addItem( rs.getString("Car_ID"));

Wu Jian Min Page 239

IT 420 Wu Jian Min

150100000698

} rs.close(); } catch (SQLException exception) { JOptionPane.showMessageDialog(null, "Car ID not Found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); }

private void getcardetails() { String rcarbrand = carbrandfield.getText(); String rcarmodel = carmodelfield.getText(); String rnoofseats = noofseatfield.getText(); String rcarcolor = carcolorfield.getText(); String evtname = evtnamefield.getText();

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

Wu Jian Min Page 240

IT 420 Wu Jian Min

150100000698

s.execute("SELECT Car_ID, Car_brand, Car_model, No_Of_Seats, Car_Color, Rental_PerMonth FROM Events WHERE Car_ID = '" + Car_ID + "'");

ResultSet rs = s.getResultSet();

if(rs.next()) { rcarbrand = rs.getString("Car_brand"); rcarmodel = rs.getString("Car_model"); rnoofseats = rs.getString("No_Of_Seats"); rcarcolor = rs.getString("Car_Color"); evtname = rs.getString("Rental_PerMonth");

} rs.close(); } catch (SQLException exception) { exception.printStackTrace(); }

carbrandfield.setText(rcarbrand); carmodelfield.setText(rcarmodel); noofseatfield.setText(rnoofseats); carcolorfield.setText(rcarcolor); evtnamefield.setText(evtname);


Wu Jian Min Page 241

IT 420 Wu Jian Min

150100000698

private void carcboxevent(ItemEvent event ) { if((event.getStateChange() == ItemEvent.SELECTED) && (carcbox.getSelectedIndex() != 0)) { Car_ID = (String) carcbox.getSelectedItem(); } if (Car_ID != "0") { getcardetails(); visible(); } } private void visibilityfield() { carbrandfield.setEditable(false); carmodelfield.setEditable(false); noofseatfield.setEditable(false); carcolorfield.setEditable(false); evtnamefield.setEditable(false);

Wu Jian Min Page 242

IT 420 Wu Jian Min private void visible() { carbrandfield.setEditable(true); carmodelfield.setEditable(true); noofseatfield.setEditable(true); carcolorfield.setEditable(true); evtnamefield.setEditable(true); }

150100000698

}//end of edit car //View car __________________________________________________________________

public class viewcar extends JDialog { private Connection con; private Statement s; private ResultSet rs;

private JLabel Addcarheader, backgroundlabel;

private JLabel labelname, rIDlabel, carbrandlabel, carmodellabel, noofseatslabel, carcolorlabel, evtnamelabel;

private JComboBox carcbox; private JTextField rIDfield, carbrandfield, carmodelfield, noofseatfield, carcolorfield, evtnamefield;
Wu Jian Min Page 243

IT 420 Wu Jian Min

150100000698

private JButton backtomain;

private String rID, rcarbrand, rcarmodel, rnoofseats, rcarcolor; private String evtname; private String Car_ID, Car_brand, Car_model, No_Of_Seats, Car_Color, Rental_PerMonth;

Font font = new Font("Arial",Font.BOLD, 20); Font font1 = new Font("Arial",Font.BOLD, 16);

public viewcar() { super( new Frame(), "Add Car", true);

carview();

setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - View" ); setSize( 530, 260 ); setVisible( true ); setLocationRelativeTo(null);

public void carview() {


Wu Jian Min Page 244

IT 420 Wu Jian Min Container car = getContentPane();

150100000698

car.setLayout(null); System.out.println("Accessing View car");

Addcarheader = new JLabel(); Addcarheader.setBounds(0, 0, 90, 20); Addcarheader.setHorizontalAlignment(JLabel.CENTER); Addcarheader.setIcon( new ImageIcon("Label1.jpg")); Addcarheader.setSize(494, 102); car.add( Addcarheader );

labelname = new JLabel(); labelname.setLocation(35, 30); labelname.setSize(300, 20); labelname.setFont(font); labelname.setForeground(Color.red); labelname.setText("View Car Information"); labelname.setHorizontalAlignment(JLabel.LEFT); car.add(labelname);

rIDlabel = new JLabel(); rIDlabel.setLocation(50, 70); rIDlabel.setSize(100, 20); rIDlabel.setText("Car ID: ");
Wu Jian Min Page 245

IT 420 Wu Jian Min

150100000698

rIDlabel.setHorizontalAlignment(JLabel.LEFT); car.add(rIDlabel);

carcbox = new JComboBox(); carcbox.setLocation(150, 70); carcbox.setSize( 70, 20); carcbox.addItem(""); carcbox.setSelectedIndex(0); car.add(carcbox); carcbox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { carcboxevent( event ); } } ); loadcarid();

carbrandlabel = new JLabel(); carbrandlabel.setLocation(50, 100); carbrandlabel.setSize(130, 20); carbrandlabel.setText("Car Brand :" ); carbrandlabel.setHorizontalAlignment(JLabel.LEFT); car.add(carbrandlabel);
Wu Jian Min Page 246

IT 420 Wu Jian Min

150100000698

carbrandfield = new JTextField(); carbrandfield.setLocation(150, 100); carbrandfield.setSize( 90, 20); car.add(carbrandfield); carbrandfield.setHorizontalAlignment(JLabel.CENTER); carbrandfield.setEditable(false);

carmodellabel = new JLabel(); carmodellabel.setLocation(50, 130); carmodellabel.setSize(200, 20); carmodellabel.setText("Car model: "); carmodellabel.setHorizontalAlignment(JLabel.LEFT); car.add(carmodellabel);

carmodelfield = new JTextField(); carmodelfield.setLocation(150, 130); carmodelfield.setSize( 90, 20); car.add(carmodelfield); carmodelfield.setEditable(false);

noofseatslabel = new JLabel(); noofseatslabel.setLocation(250, 70); noofseatslabel.setSize( 100, 20); noofseatslabel.setText("No Of Seats: ");
Wu Jian Min Page 247

IT 420 Wu Jian Min

150100000698

noofseatslabel.setHorizontalAlignment(JLabel.LEFT); car.add(noofseatslabel);

noofseatfield = new JTextField(); noofseatfield.setLocation(370, 70); noofseatfield.setSize( 90, 20); car.add(noofseatfield); noofseatfield.setEditable(false);

carcolorlabel = new JLabel(); carcolorlabel.setLocation(250, 100); carcolorlabel.setSize(100, 20); carcolorlabel.setText("Car color: "); carcolorlabel.setHorizontalAlignment(JLabel.LEFT); car.add(carcolorlabel);

carcolorfield = new JTextField(); carcolorfield.setLocation(370, 100); carcolorfield.setSize( 90, 20); car.add(carcolorfield); carcolorfield.setEditable(false);

evtnamelabel = new JLabel(); evtnamelabel.setLocation(250, 130); evtnamelabel.setSize(130, 20);


Wu Jian Min Page 248

IT 420 Wu Jian Min

150100000698

evtnamelabel.setText("Rental Per Month: "); evtnamelabel.setHorizontalAlignment(JLabel.LEFT); car.add(evtnamelabel);

evtnamefield = new JTextField(); evtnamefield.setLocation(370, 130); evtnamefield.setSize( 90, 20); car.add(evtnamefield); evtnamefield.setEditable(false);

backtomain = new JButton(); backtomain.setLocation(50, 170); backtomain.setText("Back");

backtomain.setIcon( new ImageIcon("back-icon.png"));

backtomain.setSize(110, 45); car.add(backtomain); backtomain.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event )


Wu Jian Min Page 249

IT 420 Wu Jian Min {

150100000698

setVisible( false ); return; } } );

backgroundlabel = new JLabel(); backgroundlabel.setBounds(0, 0, 530, 260); backgroundlabel.setHorizontalAlignment(JLabel.CENTER); backgroundlabel.setIcon( new ImageIcon("bg rental.jpg")); //Background untuk VIEW backgroundlabel.setSize(530, 260); car.add( backgroundlabel ); }

private void loadcarid() {

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Car_ID FROM Events");


Wu Jian Min Page 250

IT 420 Wu Jian Min

150100000698

ResultSet rs = s.getResultSet(); while( rs.next()) { carcbox.addItem( rs.getString("Car_ID")); } rs.close(); } catch (SQLException exception) { JOptionPane.showMessageDialog(null, "Car ID not Found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); } }

/*private void loadeventid() { try {

Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();


Wu Jian Min Page 251

IT 420 Wu Jian Min

150100000698

s.execute("SELECT Car_ID FROM Events");

ResultSet rs = s.getResultSet();

while (rs.next()) { evtIDcombo.addItem( rs.getString("Car_ID"));

} rs.close(); } catch (SQLException exception) { JOptionPane.showMessageDialog(null, "Car ID not Found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); }

}*/

private void getcardetails() { String rcarbrand = carbrandfield.getText(); String rcarmodel = carmodelfield.getText();


Wu Jian Min Page 252

IT 420 Wu Jian Min

150100000698

String rnoofseats = noofseatfield.getText(); String rcarcolor = carcolorfield.getText(); String evtname = evtnamefield.getText();

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Car_ID, Car_brand, Car_model, No_Of_Seats, Car_Color, Rental_PerMonth FROM Events WHERE Car_ID = '"+ Car_ID +"'");

ResultSet rs = s.getResultSet();

if(rs.next()) { rcarbrand = rs.getString("Car_brand"); rcarmodel = rs.getString("Car_model"); rnoofseats = rs.getString("No_Of_Seats"); rcarcolor = rs.getString("Car_Color");

Wu Jian Min Page 253

IT 420 Wu Jian Min

150100000698

evtname = rs.getString("Rental_PerMonth");

} rs.close(); }

catch (SQLException exception) { exception.printStackTrace(); }

carbrandfield.setText(rcarbrand); carmodelfield.setText(rcarmodel);

noofseatfield.setText(rnoofseats); carcolorfield.setText(rcarcolor);

evtnamefield.setText(evtname);

private void carcboxevent(ItemEvent event ) {


Wu Jian Min Page 254

IT 420 Wu Jian Min

150100000698

if(event.getStateChange() == ItemEvent.SELECTED) { Car_ID = (String) carcbox.getSelectedItem(); } if (Car_ID != "0") { getcardetails(); }

} }//end of view RENTAL

//Delete car __________________________________________________________________

public class deletecar extends JDialog { private Connection con; private Statement s; private ResultSet rs;

private JLabel Addcarheader, backgroundlabel;

private JLabel labelname, rIDlabel, carbrandlabel, carmodellabel, noofseatslabel, carcolorlabel, evtnamelabel;

Wu Jian Min Page 255

IT 420 Wu Jian Min

150100000698

private JTextField rIDfield, carbrandfield, carmodelfield, noofseatfield, carcolorfield, evtnamefield; private JComboBox carcbox;

private JButton deleteB, backtomain; private int a, i, delete; private String rID, rcarbrand, rcarmodel, rnoofseats, rcarcolor; private String evtname; private String Car_ID, Car_brand, Car_model, No_Of_Seats, Car_Color, Rental_PerMonth; boolean valid = true;

Font font = new Font("Arial",Font.BOLD, 20); Font font1 = new Font("Arial",Font.BOLD, 16);

public deletecar() { super( new Frame(), "Add Car", true);

cardelete();

setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - Delete" ); setSize( 530, 260 ); setVisible( true ); setLocationRelativeTo(null);

Wu Jian Min Page 256

IT 420 Wu Jian Min }

150100000698

public void cardelete() { Container car = getContentPane();

car.setLayout(null); System.out.println("Accessing Delete Car");

Addcarheader = new JLabel(); Addcarheader.setBounds(0, 0, 90, 20); Addcarheader.setHorizontalAlignment(JLabel.CENTER); Addcarheader.setIcon( new ImageIcon("Label1.jpg")); Addcarheader.setSize(494, 102); car.add( Addcarheader );

labelname = new JLabel(); labelname.setLocation(35, 30); labelname.setSize(300, 20); labelname.setFont(font); labelname.setForeground(Color.red); labelname.setText("Delete Car Information"); labelname.setHorizontalAlignment(JLabel.LEFT); car.add(labelname);

Wu Jian Min Page 257

IT 420 Wu Jian Min rIDlabel = new JLabel(); rIDlabel.setLocation(50, 70); rIDlabel.setSize(100, 20); rIDlabel.setText("Car ID: ");

150100000698

rIDlabel.setHorizontalAlignment(JLabel.LEFT); car.add(rIDlabel);

carcbox = new JComboBox(); carcbox.setLocation(150, 70); carcbox.setSize( 70, 20); carcbox.addItem(""); carcbox.setSelectedIndex(0); car.add(carcbox); carcbox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { carcboxevent( event ); } } );

carbrandlabel = new JLabel(); carbrandlabel.setLocation(50, 100);


Wu Jian Min Page 258

IT 420 Wu Jian Min carbrandlabel.setSize(130, 20);

150100000698

carbrandlabel.setText("Car Brand :" ); carbrandlabel.setHorizontalAlignment(JLabel.LEFT); car.add(carbrandlabel);

carbrandfield = new JTextField(); carbrandfield.setLocation(150, 100); carbrandfield.setSize( 90, 20); car.add(carbrandfield); carbrandfield.setHorizontalAlignment(JLabel.CENTER); carbrandfield.setEditable(false);

carmodellabel = new JLabel(); carmodellabel.setLocation(50, 130); carmodellabel.setSize(200, 20);; carmodellabel.setText("Car model: "); carmodellabel.setHorizontalAlignment(JLabel.LEFT); car.add(carmodellabel);

carmodelfield = new JTextField(); carmodelfield.setLocation(150, 130); carmodelfield.setSize( 90, 20); car.add(carmodelfield); carmodelfield.setEditable(false);

noofseatslabel = new JLabel();


Wu Jian Min Page 259

IT 420 Wu Jian Min

150100000698

noofseatslabel.setLocation(250, 70); noofseatslabel.setSize( 100, 20); noofseatslabel.setText("No Of Seats: "); noofseatslabel.setHorizontalAlignment(JLabel.LEFT); car.add(noofseatslabel);

noofseatfield = new JTextField(); noofseatfield.setLocation(370, 70); noofseatfield.setSize( 90, 20); car.add(noofseatfield); noofseatfield.setEditable(false);

carcolorlabel = new JLabel(); carcolorlabel.setLocation(250, 100); carcolorlabel.setSize(100, 20); carcolorlabel.setText("Car color: "); carcolorlabel.setHorizontalAlignment(JLabel.LEFT); car.add(carcolorlabel);

carcolorfield = new JTextField(); carcolorfield.setLocation(370, 100); carcolorfield.setSize( 90, 20); car.add(carcolorfield); carcolorfield.setEditable(false);

Wu Jian Min Page 260

IT 420 Wu Jian Min

150100000698

evtnamelabel = new JLabel(); evtnamelabel.setLocation(250, 130); evtnamelabel.setSize(130, 20); evtnamelabel.setText("Rental Per Month: "); evtnamelabel.setHorizontalAlignment(JLabel.LEFT); car.add(evtnamelabel);

evtnamefield = new JTextField(); evtnamefield.setLocation(370, 130); evtnamefield.setSize( 90, 20); car.add(evtnamefield); evtnamefield.setEditable(false);

carbrandfield.setText(rcarbrand); carmodelfield.setText(rcarmodel); noofseatfield.setText(rnoofseats); carcolorfield.setText(rcarcolor); evtnamefield.setText(evtname);

deleteB = new JButton(); deleteB.setLocation(50, 170); deleteB.setText("Delete");

Wu Jian Min Page 261

IT 420 Wu Jian Min

150100000698

deleteB.setIcon( new ImageIcon("Open-Folder-Delete-icon.png"));

deleteB.setSize(110, 45); car.add(deleteB); deleteB.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) { delete = JOptionPane.showConfirmDialog(null, "Confirm delete this car information?", "Car Rental Brueni Pte Ltd.", JOptionPane.YES_NO_OPTION);

if(delete == JOptionPane.YES_OPTION) { delcar();

else { return; } }
Wu Jian Min Page 262

IT 420 Wu Jian Min } );

150100000698

loadcarid();

backtomain = new JButton(); backtomain.setLocation(190, 170); backtomain.setText("Back");

backtomain.setIcon( new ImageIcon("back-icon.png"));

backtomain.setSize(110, 45); car.add(backtomain); backtomain.addActionListener(

new ActionListener() { public void actionPerformed( ActionEvent event ) { setVisible( false ); return; } } );

Wu Jian Min Page 263

IT 420 Wu Jian Min

150100000698

backgroundlabel = new JLabel(); backgroundlabel.setBounds(0, 0, 530, 260); backgroundlabel.setHorizontalAlignment(JLabel.CENTER); backgroundlabel.setIcon( new ImageIcon("bg rental.jpg"));// Background untuk Delete backgroundlabel.setSize(530, 260); car.add( backgroundlabel ); }

private void delcar() {

//String evt=((String)evtIDcombo.getSelectedItem());

String rcarbrand = carbrandfield.getText(); String rcarmodel = carmodelfield.getText(); String rnoofseats = noofseatfield.getText(); String rcarcolor = carcolorfield.getText(); String evtname = evtnamefield.getText();

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement(); visibility();


Wu Jian Min Page 264

IT 420 Wu Jian Min

150100000698

s.execute("UPDATE Events WHERE Car_ID = '" + Car_ID + "' "); //SET hide = '"+0+"'

ResultSet rs = s.getResultSet();

carbrandfield.setText(""); carmodelfield.setText(""); noofseatfield.setText(""); carcolorfield.setText(""); evtnamefield.setText("");

System.out.println("Car ID ' " + Car_ID + "' details have been deleted"); } catch (SQLException exception) { exception.printStackTrace(); } JOptionPane.showMessageDialog(null, "Car ID " + rID + " Car info have been deleted", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE);

private void loadcarid()


Wu Jian Min Page 265

IT 420 Wu Jian Min {

150100000698

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Car_ID FROM Events "); //WHERE hide = '"+1+"' "

ResultSet rs = s.getResultSet(); while( rs.next()) { carcbox.addItem( rs.getString("Car_ID"));

} rs.close(); } catch (SQLException exception) { JOptionPane.showMessageDialog(null, "Car ID not found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace();
Wu Jian Min Page 266

IT 420 Wu Jian Min return; }

150100000698

private void getcardetails() { String rcarbrand = carbrandfield.getText(); String rcarmodel = carmodelfield.getText(); String rnoofseats = noofseatfield.getText(); String rcarcolor = carcolorfield.getText(); String evtname = evtnamefield.getText();

try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.execute("SELECT Car_ID, Car_brand, Car_model, No_Of_Seats, Car_Color, Rental_PerMonth FROM Events WHERE Car_ID = '"+ Car_ID +"'");

ResultSet rs = s.getResultSet();
Wu Jian Min Page 267

IT 420 Wu Jian Min

150100000698

if(rs.next()) { rcarbrand = rs.getString("Car_brand"); rcarmodel = rs.getString("Car_model"); rnoofseats = rs.getString("No_Of_Seats"); rcarcolor = rs.getString("Car_Color"); evtname = rs.getString("Rental_PerMonth");

} rs.close(); }

catch (SQLException exception) { exception.printStackTrace(); }

carbrandfield.setText(rcarbrand); carmodelfield.setText(rcarmodel); noofseatfield.setText(rnoofseats); carcolorfield.setText(rcarcolor); evtnamefield.setText(evtname);

}
Wu Jian Min Page 268

IT 420 Wu Jian Min

150100000698

private void carcboxevent(ItemEvent event ) {

if(event.getStateChange() == ItemEvent.SELECTED) { Car_ID = (String) carcbox.getSelectedItem(); } if (Car_ID != "0") { getcardetails(); }

private void visibility() { carbrandfield.setEditable(false); carmodelfield.setEditable(false); noofseatfield.setEditable(false); carcolorfield.setEditable(false); evtnamefield.setEditable(false);

Wu Jian Min Page 269

IT 420 Wu Jian Min

150100000698

}//end of delete car public void frameWindowClosing(WindowEvent event) { try { Connection con = DriverManager.getConnection("jdbc:odbc:rental", "",""); Statement s = con.createStatement();

s.close(); con.close(); System.out.println("Connection to rental has ended"); } catch (SQLException sqlException) { sqlException.printStackTrace(); } finally { System.exit(0); } }

public static void main( String[] args ) {

Wu Jian Min Page 270

IT 420 Wu Jian Min rental application = new rental();

150100000698

application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

} // end method main }// end of the program

Wu Jian Min Page 271

IT 420 Wu Jian Min

150100000698

8. Testing
Test Plan

Test Case 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Objective
To login the programming

To go to customer menu. To add new customer information To fill in new customer information and save it. To edit customer information. To edit certain information of customer. To view information of customer. To go to car information menu To go to add the new car information To fill in the car information and save it To edit the car information To modify the certain car information To go to Rental Menu To add a new rental information To fill in the rental information and save it To go to edit rental information screen To edit the certain rental information To go to view rental information screen To select Rental ID and view it To log out the program

Wu Jian Min Page 272

IT 420 Wu Jian Min

150100000698

Test Case Objectives Test Data Expected Result Actual Result Conclusion

1 To login the programming Username is CarRental, Password is 12345 A message Welcome come to Car Rental Brunei will prompt Refer to screen capture Actual result matched expected result

Test Case

Before

After

Wu Jian Min Page 273

IT 420 Wu Jian Min

150100000698

Test Case Objectives Test Data Expected Result Actual Result Conclusion

2 To go to customer menu. Click customer icon on main menu. Customer Menu should appears
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 274

IT 420 Wu Jian Min

150100000698

Test Case Objectives Test Data Expected Result Actual Result Conclusion

3 To add new customer information Click Add Button Add customer information dialog box shows up.
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 275

IT 420 Wu Jian Min


Test Case Objectives Test Data Expected Result

150100000698

4 To fill in new customer information and save it. Click Save Button after completing to fill information The information automatically save with the message New customer details have been added.
Refer to screen capture Actual result matched expected result

Actual Result Conclusion

Before

After

Wu Jian Min Page 276

IT 420 Wu Jian Min


Test Case Objectives Test Data Expected Result Actual Result Conclusion

150100000698 5 To edit customer information. Click Edit Button Edit Customer Information dialog shows up.
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 277

IT 420 Wu Jian Min


Test Case Objectives Test Data Expected Result

150100000698

6 To edit certain information of customer. Click Edit Button after editing the certain of information Information will be updated and a meassage Customer Edwards details have been updated will show up.
Refer to screen capture Actual result matched expected result

Actual Result Conclusion

Before

After

Wu Jian Min Page 278

IT 420 Wu Jian Min


Test Case Objectives Test Data Expected Result Actual Result Conclusion

150100000698 7 To view information of customer. Click View Button View Customer Information dialog will show up.
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 279

IT 420 Wu Jian Min


Test Case Objectives Test Data Expected Result Actual Result Conclusion

150100000698

8 To go to car information menu Click car icon in main menu Car Information menu should appear
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 280

IT 420 Wu Jian Min


Test Case Objectives Test Data Expected Result Actual Result Conclusion

150100000698

9 To go to add the new car information Click Add Button in main menu Add Car Information menu should appear
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 281

IT 420 Wu Jian Min


Test Case Objectives Test Data Expected Result Actual Result Conclusion

150100000698

10 To fill in the car information and save it Click Save Button The data will be saved with a message
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 282

IT 420 Wu Jian Min


Test Case Objectives Test Data Expected Result Actual Result Conclusion

150100000698

11 To edit the car information Click Edit Button in main menu Edit Car Information menu should appear
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 283

IT 420 Wu Jian Min


Test Case Objectives Test Data Expected Result Actual Result Conclusion

150100000698

12 To modify the certain car information Click Edit Button The car information will be updated with a message
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 284

IT 420 Wu Jian Min


Test Case Objectives Test Data Expected Result Actual Result Conclusion

150100000698

13 To go to Rental Menu Click Rental icon in main menu The Rental Menu will be appeared
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 285

IT 420 Wu Jian Min


Test Case Objectives Test Data Expected Result Actual Result Conclusion

150100000698

14 To add a new rental information Click Add Button The Rental Menu will be appeared
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 286

IT 420 Wu Jian Min


Test Case Objectives Test Data Expected Result Actual Result Conclusion

150100000698 15 To fill in the rental information and save it Click Save Button The data will be saved with a message
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 287

IT 420 Wu Jian Min

150100000698

Test Case Objectives Test Data Expected Result Actual Result Conclusion

16 To go to edit rental information screen Click Edit Button Edit Rental Information screen will appear
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 288

IT 420 Wu Jian Min

150100000698

Test Case Objectives Test Data Expected Result

17 To edit the certain rental informaiton To modify the certain information and click Edit button The rental information will be updated and a new message will come out
Refer to screen capture Actual result matched expected result

Actual Result Conclusion

Before

After

Wu Jian Min Page 289

IT 420 Wu Jian Min

150100000698

Test Case Objectives Test Data Expected Result Actual Result Conclusion

18 To go to view rental information screen Click View button View rental information will appear
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 290

IT 420 Wu Jian Min

150100000698

Test Case Objectives Test Data Expected Result Actual Result Conclusion

19 To select Rental ID and view it Select Rental ID The information of rental will be display
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 291

IT 420 Wu Jian Min

150100000698

Test Case Objectives Test Data Expected Result Actual Result Conclusion

20 To log out the program Click log out icon A message will be shown
Refer to screen capture Actual result matched expected result

Before

After

Wu Jian Min Page 292

IT 420 Wu Jian Min Test Log Test Case 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Result Successful Successful Successful Successful Successful Successful Successful Successful Successful Successful Successful Successful Successful Successful Successful Successful Successful Successful Successful Successful

150100000698

Wu Jian Min Page 293

IT 420 Wu Jian Min

150100000698

8. Conclusion
Strength 1. The program is easy to store information. 2. The program is easy to add, edit, view and delete the information. 3. An error message always display when user input invalid information. Weakness 1. The appearance of this program is too simple. 2. This program doesnt back up. Enhancement 1. Adding more background information about this company. 2. To make design of appearance more attractive.

Wu Jian Min Page 294

IT 420 Wu Jian Min

150100000698

9. Hardware and Software Requirement Hardware requirement:


Screen Resolution 1024 by 768 pixels, 16 bit or 32 bit color quality or higher resolution Monitor Window XP or higher operating system

Memory (RAM) of 1GB Minimum requirements.


CPU: Pentium 3 or higher Optical Mouse 104-key Windows keyboard DVD multi recorder 700 MB CD-ROM

Software requirement
Java

Wu Jian Min Page 295

IT 420 Wu Jian Min

150100000698

10. Implementation
User Guide 1. Insert CD into your CD-ROM. 2. Copy all file into your bin>>jdk1.6>>C Drive 3. Looking and open Administrative Tools in Control Panel 4. Double click Data Sources (ODBC) and select System DSN 5. Click Add button and select Microsoft Access Driver (*.mdb) and click finish.

6. Select Database from your bin>>jdk1.6>>C Drive that is rental.mdb and click OK.

7. Open Command Prompt 8. Type cd\

Wu Jian Min Page 296

IT 420 Wu Jian Min 9. Type cd jdk1.6\bin 10. Type java rental

150100000698

11. Press Enter key

12. Type the username and password. Username is CarRental and Password is 12345

13. Now, you can click the icon on Main Menu control to go to different screen.

Wu Jian Min Page 297

IT 420 Wu Jian Min


14.

150100000698

Reference
1. The guideline book of OOP in Java

2. http://www.colourbox.com/image/abstract-3d-illustration-of-computer-mouseconnected-to-dollar-sign-image-1996601

3. http://www.java2s.com/

4. http://www.freejavaguide.com/

Wu Jian Min Page 298

Anda mungkin juga menyukai