Vehicle Parking Management Code
Vehicle Parking Management Code
}catch(Exception e){
e.printStackTrace();
}
b1 = new JButton("Print");
add(b1,"South");
JScrollPane sp = new JScrollPane(t1);
add(sp);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae){
try{
t1.print();
}catch(Exception e){}
}
public static void main(String[] args){
new CustomerDetails().setVisible(true);
}
}
package Parking;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class NewCustomer extends JFrame implements ActionListener{
JLabel l1,l2,l3,l4,l5,l6,l7,l8;
JTextField t1,t2,t3,t4,t5,t6,t7,t8;
JButton b1,b2;
NewCustomer(){
setLocation(600,200);
setSize(700,500);
JPanel p = new JPanel();
p.setLayout(null);
p.setBackground(Color.WHITE);
p.setBackground(new Color(173,216,230));
JLabel title = new JLabel("New Customer");
title.setBounds(180, 10, 200, 26);
title.setFont(new Font("Tahoma", Font.PLAIN, 24));
p.add(title);
l1 = new JLabel("Customer Name");
l1.setBounds(100, 80, 100, 20);
t1 = new JTextField();
t1.setBounds(240, 80, 200, 20);
p.add(l1);
p.add(t1);
l2 = new JLabel("Vehicle No");
l2.setBounds(100, 120, 100, 20);
t8 = new JTextField();
t8.setBounds(240, 120, 200, 20);
p.add(l2);
p.add(t8);
l3 = new JLabel("Address");
l3.setBounds(100, 160, 100, 20);
t3 = new JTextField();
t3.setBounds(240, 160, 200, 20);
p.add(l3);
p.add(t3);
l5 = new JLabel("City");
l5.setBounds(100, 200, 100, 20);
t5 = new JTextField();
t5.setBounds(240, 200, 200, 20);
p.add(l5);
p.add(t5);
l4 = new JLabel("State");
l4.setBounds(100, 240, 100, 20);
t4 = new JTextField();
t4.setBounds(240, 240, 200, 20);
p.add(l4);
p.add(t4);
l6 = new JLabel("Email");
l6.setBounds(100, 280, 100, 20);
t6 = new JTextField();
t6.setBounds(240, 280, 200, 20);
p.add(l6);
p.add(t6);
l7 = new JLabel("Phone Number");
l7.setBounds(100, 320, 100, 20);
t7 = new JTextField();
t7.setBounds(240, 320, 200, 20);
p.add(l7);
p.add(t7);
b1 = new JButton("Next");
b1.setBounds(120, 390, 100, 25);
b2 = new JButton("Cancel");
b2.setBounds(250, 390, 100, 25);
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
b2.setBackground(Color.BLACK);
b2.setForeground(Color.WHITE);
p.add(b1);
p.add(b2);
setLayout(new BorderLayout());
add(p,"Center");
ImageIcon ic1 = new ImageIcon(ClassLoader.getSystemResource("icon/hicon1.jpg"));
Image i3 = ic1.getImage().getScaledInstance(150, 300,Image.SCALE_DEFAULT);
ImageIcon ic2 = new ImageIcon(i3);
l8 = new JLabel(ic2);
add(l8,"West");
//for changing the color of the whole Frame
getContentPane().setBackground(Color.WHITE);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent ae){
if(ae.getSource() == b1){
String name = t1.getText();
String meter = t8.getText();
String address = t3.getText();
String state = t4.getText();
String city = t5.getText();
String email = t6.getText();
String phone = t7.getText();
String q1 = "insert into customer
values('"+name+"','"+meter+"','"+address+"','"+city+"','"+state+"','"+email+"','"+phone+"')";
String q2 = "insert into login values('"+meter+"', '', '', '', '')";
try{
Conn c1 = new Conn();
c1.s.executeUpdate(q1);
c1.s.executeUpdate(q2);
JOptionPane.showMessageDialog(null,"Customer Details Added Successfully");
this.setVisible(false);
new MeterInfo(meter).setVisible(true);
}catch(Exception ex){
ex.printStackTrace();
}
}else if(ae.getSource() ==b2){
this.setVisible(false);
}
}
public static void main(String[] args){
new NewCustomer().setVisible(true);
}
}
add(jsp,"Center");
add(b1,"South");
b1.addActionListener(this);
setLocation(750,100);
}
public void actionPerformed(ActionEvent ae){
try{
Conn c = new Conn();
String day = c2.getSelectedItem();
t1.setText("\tBharati Vidyapeeth Parking \nParking BILL FOR "+day+" ,\n\n\n");
// Use single quotes around the meter value if it's a string
ResultSet rs = c.s.executeQuery("select * from customer where meter='" + meter + "'");
if(rs.next()){
t1.append("\n Customer Name:" + rs.getString("name"));
t1.append("\n Vehicle Number: " + rs.getString("meter"));
t1.append("\n Address: " + rs.getString("address"));
t1.append("\n State: " + rs.getString("state"));
t1.append("\n City: " + rs.getString("city"));
t1.append("\n Email: " + rs.getString("email"));
t1.append("\n Phone Number: " + rs.getString("phone"));
t1.append("\n-------------------------------------------------------------");
t1.append("\n");
}
rs = c.s.executeQuery("select * from meter_info where meter_number='" + meter + "'");
if(rs.next()){
t1.append("\n Vehicle Location: " + rs.getString("meter_location"));
t1.append("\n Vehicle Type: " + rs.getString("meter_type"));
// t1.append("\n Phase Code: " + rs.getString("phase_code"));
// t1.append("\n Bill Type: " + rs.getString("bill_type"));
// t1.append("\n Days: " + rs.getString("days"));
t1.append("\n");
}
rs = c.s.executeQuery("select * from bill where meter='" + meter + "' AND month='" +
c2.getSelectedItem() + "'");
if(rs.next()){
t1.append("\n Day: \t" + rs.getString("month"));
t1.append("\n Hours: \t" + rs.getString("units"));
t1.append("\n Total Charges: \t" + rs.getString("total_bill"));
t1.append("\n---------------------------------------------------------------");
t1.append("\n TOTAL PAYABLE: \t" + rs.getString("total_bill"));
}
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args){
new GenerateBill("").setVisible(true);
}
}
package Parking;
import java.sql.*;
public class Conn{
Connection c;
Statement s;
public Conn(){
try{
Class.forName("com.mysql.jdbc.Driver");
c =DriverManager.getConnection("jdbc:mysql://localhost:3307/parking","root","");
s =c.createStatement();
}catch(Exception e){
System.out.println(e);
}
}
}