150100000698
Project Documentation
ADIT IT420
Object Oriented Programming in Java
Name: Wu Jian Min Student ID: 150100000698 Class: IT420 Object Oriented Programming in Java Country: Brunei Darussalam Lecturer Name: Ms. Grace N. Balayan
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
150100000698
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.
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.
* 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.
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
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
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
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
150100000698
150100000698
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
150100000698
Item Name Background Image Btn 1 Btn 2 Btn 3 Btn 4 Btn 5 Btn 6 Btn 7 Btn 8 Btn 9
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
150100000698
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
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
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
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
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
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
150100000698
Item Name Background Image Btn 1 Btn 2 Btn 3 Btn 4 Btn 5 Btn 6 Btn 7 Btn 8 Btn 9 Btn 10
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
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
150100000698
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
150100000698
150100000698
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
150100000698
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
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
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
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
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
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
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
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
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
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
150100000698
4. Screen Design
Main Menu
Customer Informaiton
150100000698
Car Information
150100000698
150100000698
150100000698
150100000698
5. Program Design
Start
Home Page
Customer Page
Exit page
150100000698
Start
Customer Page
150100000698
Start
Car Page
150100000698
Start
Rental Page
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 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
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(); }
// login function_________________________________________________________________
150100000698
passJLabel = new JLabel(); passJLabel.setBounds( 70,315,70,25 ); passJLabel.setText( "Password: " ); contentPane.add( passJLabel );
150100000698
public void actionPerformed( ActionEvent event ) { LoginJButton_acp( event );//calling Login Button function } } );
new ActionListener() { public void actionPerformed (ActionEvent event ) { CancelButton_acp( event );//calling Cancel Button function } }
Wu Jian Min Page 47
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);
150100000698
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
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
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______________________________________________________________________ __
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;
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 JLabel homelabel; private JLabel customerlabel; private JLabel expenseslabel; private JLabel carlabel; private JLabel logoutlabel;
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"};
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;
public customers(rental mer) { merri = mer; customerinfo(); } public void customerinfo() { Container customer = getContentPane();
Wu Jian Min Page 53
150100000698
System.out.println("rental Homepage");
150100000698
mainmenujp = new JPanel(); mainmenujp.setBounds(655,11,295,65);//position untuk button dibawah,x,y,w,h mainmenujp.setLayout( null ); customer.add(mainmenujp);
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);
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
// CUSTOMER label
150100000698
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.setBounds(0, 0, 0, 0); carlabel.setIcon( new ImageIcon("Label.jpg")); carlabel.setHorizontalAlignment(JLabel.CENTER); carlabel.setSize(0, 0); carinfolabeljp.add( carlabel );
// LOGOUT label
150100000698
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
150100000698
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
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______________________________________________________________________
150100000698
JTable expensestable = new JTable(expensesmodel); JScrollPane expensesscrollPane = new JScrollPane(expensestable); expensesinfoareajp.add(expensesscrollPane, BorderLayout.CENTER);
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
150100000698
//car table_______________________________________________________________
Wu Jian Min Page 62
150100000698
carmodel = new DefaultTableModel(cartableheader, 200); JTable cartable = new JTable(carmodel); JScrollPane carscrollPane = new JScrollPane(cartable); carinfoareajp.add(carscrollPane, BorderLayout.CENTER);
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
150100000698
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");
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);
System.out.println("rental home"); } }
Wu Jian Min Page 65
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);
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
150100000698
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
150100000698
customermenujp.add( viewB); viewB.addActionListener( new ActionListener() { public void actionPerformed ( ActionEvent event ) { view_customer = new viewcustomer();//calling view customer page } } ); }
} );
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
150100000698
expensesmenujp.add( addB ); addB.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent event ) { add_exp = new addexpenses(); } } );
150100000698
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
150100000698
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
150100000698
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);
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();
carmenujp.add( addB ); addB.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent event )
Wu Jian Min Page 75
150100000698
carmenujp.add( editB); editB.addActionListener( new ActionListener() { public void actionPerformed ( ActionEvent event ) { edit_car = new editcar();//calling edit car page } } );
150100000698
viewB = new JButton(); viewB.setLocation(15, 150); viewB.setSize(110, 50); viewB.setText("View");// jangan lupa text lebal
carmenujp.add( viewB); viewB.addActionListener( new ActionListener() { public void actionPerformed ( ActionEvent event ) { view_car = new viewcar();//calling view car page } } );
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
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
150100000698
System.out.println("Logging Out..."); } } );
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
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
150100000698
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
150100000698
150100000698
} }
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
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();
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
150100000698
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
IT 420 Wu Jian Min Vector data = new Vector(); Vector row = null;
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();
expensesmodel.setRowCount(0);
150100000698
JOptionPane.showMessageDialog(null, "Unable to Open database"); } }// end expenses table call //calling car table_______________________________________________________________________ public void cartablelist() { String car_Course = "";
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
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
150100000698
//Adding Customers__________________________________________________________________ _________________ public class addcustomer extends JDialog { private Connection con; private Statement s; private ResultSet rs;
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;
150100000698
customeradd();
setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - Add" ); setSize( 530, 500 ); CUSTOMER setVisible( true ); setLocationRelativeTo(null); // size background
cladd.setLayout(null);
Wu Jian Min Page 91
150100000698
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);
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);
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
150100000698
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);
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
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);
150100000698
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);
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);
150100000698
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
150100000698
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; }
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();
}
Wu Jian Min Page 100
150100000698
Statement s = con.createStatement();
ResultSet rs = s.getResultSet();
while (rs.next()) { a += 1; }
150100000698
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(); }
150100000698
a = 0; JOptionPane.showMessageDialog(null, "New customer details have been added!", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE);
} } );
150100000698
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 );
150100000698
//Edit customer__________________________________________________________________
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 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
150100000698
customeredit();
setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - Edit" ); setSize( 530, 500 ); setVisible( true ); setLocationRelativeTo(null); }
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);
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);
150100000698
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);
150100000698
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);
150100000698
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
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
150100000698
emailfield = new JTextField(); emailfield.setLocation(150, 365); emailfield.setSize( 200, 20); cladd.add(emailfield); emailfield.setEditable(false);
150100000698
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();
150100000698
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
150100000698
exception.printStackTrace(); } JOptionPane.showMessageDialog(null, "Customer " + cname + "'s details have been updated", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE); } } } );
150100000698
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 );
150100000698
ResultSet rs = s.getResultSet();
} rs.close(); } catch (SQLException exception) { JOptionPane.showMessageDialog(null, "Customer ID not Found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); } }
String cdatereg = dateregfield.getText(); String cname = namefield.getText(); String caddress = addressArea.getText(); String ccontact = contactfield.getText();
Wu Jian Min Page 119
150100000698
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
150100000698
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
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); }
IT 420 Wu Jian Min private Connection con; private Statement s; private ResultSet rs;
150100000698
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;
150100000698
setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - View" ); setSize( 530, 500 ); setVisible( true ); setLocationRelativeTo(null); }
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 );
150100000698
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
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
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);
maleRB = new JRadioButton(); maleRB.setLocation(150, 130); maleRB.setText("Male"); maleRB.setSize( 60, 20); cladd.add(maleRB); genderBG.add(maleRB);
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
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
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);
150100000698
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 );
150100000698
ResultSet rs = s.getResultSet();
} 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
150100000698
private void customercboxevent(ItemEvent event ) { if((event.getStateChange() == ItemEvent.SELECTED) && (customercbox.getSelectedIndex() != 0)) { customer_ID = (String) customercbox.getSelectedItem(); } if (customer_ID != "0") { 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
150100000698
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
150100000698
tempItem = "";
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
public class addexpenses extends JDialog { private Connection con; private Statement s; private ResultSet rs;
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;
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;
150100000698
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
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);
150100000698
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
150100000698
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
150100000698
} } ); 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);
150100000698
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();
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);
150100000698
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(
150100000698
JOptionPane.showMessageDialog(null, "Please complete all the fields", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); valid = false; setVisible(false); }
totalrental = a * b;
Wu Jian Min Page 147
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);
} } });
new ActionListener()
Wu Jian Min Page 148
150100000698
noguestfield.setText("");
texpfield.setText(""); } } );
new ActionListener()
Wu Jian Min Page 149
150100000698
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);
noguestfield.setText("");
texpfield.setText(""); }
150100000698
String expno = expIDfield.getText(); String cname = cnamefield.getText(); String cpaydate = paydatefield.getText(); String cenddate = enddatefield.getText(); String evtname = evtnamefield.getText();
ResultSet rs = s.getResultSet();
while (rs.next()) { a += 1;
Wu Jian Min Page 151
150100000698
if(a <= 1) { a += 1;
a += 1;
} rs.close();
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;
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
150100000698
private void customercboxevent(ItemEvent event ) { if((event.getStateChange() == ItemEvent.SELECTED)) { customer_ID = (String) customercbox.getSelectedItem(); } String cname = "";
s.execute("SELECT customer_ID, FullName FROM Customer_info WHERE customer_ID = '" + customer_ID + "'");
ResultSet rs = s.getResultSet();
}
Wu Jian Min Page 155
150100000698
ResultSet rs = s.getResultSet();
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 = "";
s.execute("SELECT Car_ID, Rental_PerMonth FROM Events WHERE Car_ID = '" + Car_ID + "'");
150100000698
ResultSet rs = s.getResultSet();
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(); } }
public class editexpenses extends JDialog { private Connection con; private Statement s;
Wu Jian Min Page 159
150100000698
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 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);
expensesedit();
Wu Jian Min Page 160
150100000698
setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - Edit" ); setSize( 530, 340 ); setVisible( true ); setLocationRelativeTo(null);
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 );
150100000698
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
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);
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);
Wu Jian Min Page 164
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
150100000698
} } ); 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
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);
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); }
Float a = Float.parseFloat(noguestfield.getText());
Wu Jian Min Page 168
150100000698
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+"");
150100000698
cnamefield.setText(""); evtnamefield.setText("");
noguestfield.setText("");
texpfield.setText("");
150100000698
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("");
150100000698
String cpaydate = paydatefield.getText(); String cname = cnamefield.getText(); String evtname = evtnamefield.getText(); String cenddate = enddatefield.getText(); String noguest = noguestfield.getText();
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
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); } } } );
150100000698
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 ); }
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(); }
150100000698
ResultSet rs = s.getResultSet();
} 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());
150100000698
visible();
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();
150100000698
noguest = rs.getString("No_Of_Months");
texp = rs.getString("TotalRental");
} rs.close(); }
noguestfield.setText(noguest);
texpfield.setText(texp);
Wu Jian Min Page 178
150100000698
} private void evtIDcomboevent(ItemEvent event ) { if((event.getStateChange() == ItemEvent.SELECTED)) { Car_ID = (String) evtIDcombo.getSelectedItem(); } String ename = "";
try {
Wu Jian Min Page 179
150100000698
Statement s = con.createStatement();
s.execute("SELECT Car_ID, Rental_PerMonth FROM Events WHERE Car_ID = '" + Car_ID + "'");
ResultSet rs = s.getResultSet();
evtnamefield.setText(ename); }
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);
} {
cnamefield.setEditable(true); evtIDcombo.setEnabled(true);
noguestfield.setEditable(true);
IT 420 Wu Jian Min private Connection con; private Statement s; private ResultSet rs;
150100000698
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();
150100000698
setTitle( "Car Rental Brueni Pte Ltd. - View" ); setSize( 530, 340 ); setVisible( true ); setLocationRelativeTo(null);
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 );
150100000698
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
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);
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);
150100000698
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
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
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);
150100000698
noguestfield.setText(noguest);
new ActionListener() { public void actionPerformed( ActionEvent event ) { setVisible( false ); return; } } );
150100000698
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) {
150100000698
JOptionPane.showMessageDialog(null, "Rent ID not Found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); } }
ResultSet rs = s.getResultSet();
} rs.close(); }
Wu Jian Min Page 192
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();
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(); }
150100000698
noguestfield.setText(noguest);
texpfield.setText(texp);
150100000698
} private void evtIDcomboevent(ItemEvent event ) { if((event.getStateChange() == ItemEvent.SELECTED)) { Car_ID = (String) evtIDcombo.getSelectedItem(); } String ename = "";
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
150100000698
ename = rs.getString("Rental_PerMonth");
public class deleteexpenses extends JDialog { private Connection con; private Statement s; private ResultSet rs;
private JLabel labelname, labelname1, expIDlabel, paydatelabel, cIDlabel, cnamelabel, evtIDlabel, evtnamelabel, noguestlabel, texplabel, enddatelabel;
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);
expensesdelete();
setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - Delete" ); setSize( 530, 340 ); setVisible( true ); setLocationRelativeTo(null);
Wu Jian Min Page 198
150100000698
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);
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 ); } } );
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
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);
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 );
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
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);
noguestfield.setText(noguest);
Wu Jian Min Page 205
150100000698
texpfield.setText(texp);
new ActionListener() { public void actionPerformed( ActionEvent event ) { delete = JOptionPane.showConfirmDialog(null, "Confirm delete this rental?", "Car Rental Brueni Pte Ltd.", JOptionPane.YES_NO_OPTION);
}
Wu Jian Min Page 206
150100000698
else { return; } } } );
loadexpensesid();
150100000698
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 ); }
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
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
150100000698
JOptionPane.showMessageDialog(null, "Customer " + cname + " rental have been deleted", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE);
} rs.close(); }
Wu Jian Min Page 210
150100000698
catch (SQLException exception) { JOptionPane.showMessageDialog(null, "Rental ID not found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); return; }
ResultSet rs = s.getResultSet();
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();
150100000698
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");
150100000698
noguestfield.setText(noguest); expfield.setText(texp);
if(event.getStateChange() == ItemEvent.SELECTED)
Wu Jian Min Page 214
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();
150100000698
ename = rs.getString("Rental_PerMonth");
evtnamefield.setText(ename); }
noguestfield.setEditable(false);
150100000698
//Adding Car________________________________________________________________________ ___________ public class addcar extends JDialog { private Connection con; private Statement s; private ResultSet rs;
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
150100000698
caradd();
setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - Add" ); setSize( 530, 260 ); setVisible( true ); setLocationRelativeTo(null); // size background CAR
caradd.setLayout(null);
Wu Jian Min Page 218
150100000698
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);
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);
150100000698
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);
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");
new ActionListener()
Wu Jian Min Page 222
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(
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 {
150100000698
Statement s = con.createStatement();
ResultSet rs = s.getResultSet();
while (rs.next()) { a += 1; }
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(); }
a = 0; JOptionPane.showMessageDialog(null, "New car details have been added!", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE);
150100000698
} } );
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 );
//Edit car__________________________________________________________________
150100000698
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;
caredit();
150100000698
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 );
150100000698
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
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);
150100000698
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);
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);
150100000698
new ActionListener() { public void actionPerformed( ActionEvent event ) { //rIDfield.setText(""); carbrandfield.setText(""); carmodelfield.setText(""); noofseatfield.setText(""); carcolorfield.setText(""); evtnamefield.setText("");
150100000698
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
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();
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
150100000698
JOptionPane.showMessageDialog(null, "Car_ID " + rID + "'s details have been updated", "Car Rental Brueni Pte Ltd.", JOptionPane.INFORMATION_MESSAGE); } } } );
new ActionListener() { public void actionPerformed( ActionEvent event ) { setVisible( false ); return; } } );
Wu Jian Min Page 238
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 );
ResultSet rs = s.getResultSet();
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();
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");
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);
IT 420 Wu Jian Min private void visible() { carbrandfield.setEditable(true); carmodelfield.setEditable(true); noofseatfield.setEditable(true); carcolorfield.setEditable(true); evtnamefield.setEditable(true); }
150100000698
public class viewcar extends JDialog { private Connection con; private Statement s; private ResultSet rs;
private JComboBox carcbox; private JTextField rIDfield, carbrandfield, carmodelfield, noofseatfield, carcolorfield, evtnamefield;
Wu Jian Min Page 243
150100000698
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);
carview();
setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - View" ); setSize( 530, 260 ); setVisible( true ); setLocationRelativeTo(null);
150100000698
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
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
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
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);
150100000698
evtnamefield = new JTextField(); evtnamefield.setLocation(370, 130); evtnamefield.setSize( 90, 20); car.add(evtnamefield); evtnamefield.setEditable(false);
150100000698
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 ); }
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(); } }
150100000698
ResultSet rs = s.getResultSet();
} rs.close(); } catch (SQLException exception) { JOptionPane.showMessageDialog(null, "Car ID not Found", "Car Rental Brueni Pte Ltd.", JOptionPane.ERROR_MESSAGE); exception.printStackTrace(); }
}*/
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();
150100000698
evtname = rs.getString("Rental_PerMonth");
} rs.close(); }
carbrandfield.setText(rcarbrand); carmodelfield.setText(rcarmodel);
noofseatfield.setText(rnoofseats); carcolorfield.setText(rcarcolor);
evtnamefield.setText(evtname);
150100000698
public class deletecar extends JDialog { private Connection con; private Statement s; private ResultSet rs;
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);
cardelete();
setResizable(false); setTitle( "Car Rental Brueni Pte Ltd. - Delete" ); setSize( 530, 260 ); setVisible( true ); setLocationRelativeTo(null);
150100000698
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);
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 ); } } );
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);
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);
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);
150100000698
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);
else { return; } }
Wu Jian Min Page 262
150100000698
loadcarid();
new ActionListener() { public void actionPerformed( ActionEvent event ) { setVisible( false ); return; } } );
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 ); }
//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();
150100000698
s.execute("UPDATE Events WHERE Car_ID = '" + Car_ID + "' "); //SET hide = '"+0+"'
ResultSet rs = s.getResultSet();
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);
150100000698
} 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
150100000698
private void getcardetails() { String rcarbrand = carbrandfield.getText(); String rcarmodel = carmodelfield.getText(); String rnoofseats = noofseatfield.getText(); String rcarcolor = carcolorfield.getText(); String evtname = evtnamefield.getText();
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
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(); }
}
Wu Jian Min Page 268
150100000698
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); } }
150100000698
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
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
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
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
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
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
Before
After
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
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
Before
After
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
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
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
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
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
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
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
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
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
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
150100000698
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
Before
After
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
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
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
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
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.
150100000698
Software requirement
Java
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.
150100000698
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.
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/