* To change this license header, choose License Headers in Project Properties
Download 23.66 Kb.
|
KODLAR
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package travel.management.system; import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Home extends JFrame{ String username; public static void main(String[] args) { new Home("").setVisible(true); } public Home(String username) { super("Travel and Tourism Management System"); this.username = username; setForeground(Color.CYAN); setLayout(null); ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("travel/management/system/icons/home.jpg")); Image i2 = i1.getImage().getScaledInstance(1950, 1000,Image.SCALE_DEFAULT); ImageIcon i3 = new ImageIcon(i2); JLabel NewLabel = new JLabel(i3); NewLabel.setBounds(0, 0, 1950, 1000); add(NewLabel JLabel l1 = new JLabel("Travel and Tourism Management System"); l1.setForeground(Color.WHITE); l1.setFont(new Font("Tahoma", Font.PLAIN, 55)); l1.setBounds(500, 60, 1000, 100); NewLabel.add(l1); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu m1 = new JMenu("CUSTOMER"); m1.setForeground(Color.BLUE); menuBar.add(m1); JMenuItem mi1 = new JMenuItem("ADD CUSTOMER"); m1.add(mi1); JMenuItem mi2 = new JMenuItem("UPDATE CUSTOMER DETAIL"); m1.add(mi2); JMenuItem mi3 = new JMenuItem("VIEW CUSTOMER DETAILS"); m1.add(mi3); JMenuItem mi4 = new JMenuItem("DELETE CUSTOMER DETAILS"); m1.add(mi4); mi1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ try{ new AddCustomer(username).setVisible(true); }catch(Exception e ){} } }); mi2.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ try{ new UpdateCustomer(username).setVisible(true); }catch(Exception e ){} } }); mi3.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ try{ new ViewCustomers().setVisible(true); }catch(Exception e ){} } }); mi4.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ try{ new DeleteCustomer().setVisible(true); }catch(Exception e ){} } }); JMenu m2 = new JMenu("PACKAGES"); m2.setForeground(Color.RED); menuBar.add(m2); JMenuItem mi6 = new JMenuItem("CHECK PACKAGE"); m2.add(mi6); JMenuItem mi7 = new JMenuItem("BOOK PACKAGE"); m2.add(mi7); JMenuItem mi5 = new JMenuItem("VIEW PACKAGE"); m2.add(mi5); mi6.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ try{ new CheckPackage().setVisible(true); }catch(Exception e ){} } }) mi7.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ try{ new BookPackage(username).setVisible(true); }catch(Exception e ){} } }); mi5.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ try{ new ViewPackage(username).setVisible(true); }catch(Exception e ){} } }); JMenu m3 = new JMenu("HOTELS"); m3.setForeground(Color.BLUE); menuBar.add(m3); JMenuItem mi8 = new JMenuItem("BOOK HOTELS"); m3.add(mi8); JMenuItem mi9 = new JMenuItem("VIEW HOTELS"); m3.add(mi9); JMenuItem mi10 = new JMenuItem("VIEW BOOKED HOTEL"); m3.add(mi10); mi8.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ new BookHotel(username).setVisible(true); } }); mi9.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ try{ new CheckHotels().setVisible(true); }catch(Exception e ){} } }); mi10.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ try{ new ViewBookedHotel(username).setVisible(true); }catch(Exception e ){} } }); JMenu m4 = new JMenu("DESTINATION"); m4.setForeground(Color.RED); menuBar.add(m4); JMenuItem mi11 = new JMenuItem("DESTINATION"); m4.add(mi11); mi11.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ new Destination().setVisible(true); } }); JMenu m5 = new JMenu("PAYMENT"); m5.setForeground(Color.BLUE); menuBar.add(m5); JMenuItem mi12 = new JMenuItem("PAY USING PAYTM"); m5.add(mi12); mi12.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ new Payment().setVisible(true); } }); JMenu m6 = new JMenu("UTILITY"); m6.setForeground(Color.RED); menuBar.add(m6); JMenuItem mi13 = new JMenuItem("NOTEPAD"); m6.add(mi13); JMenuItem mi14 = new JMenuItem("CALCULATOR"); m6.add(mi14); mi13.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ try{ Runtime.getRuntime().exec("notepad.exe"); }catch(Exception e){ } } }); mi14.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ try{ Runtime.getRuntime().exec("calc.exe"); }catch(Exception e){ } } }); JMenu m7 = new JMenu("ABOUT"); m7.setForeground(Color.BLUE); menuBar.add(m7); JMenuItem mi15 = new JMenuItem("ABOUT"); m7.add(mi15); mi15.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ new About().setVisible(true); } }); setExtendedState(JFrame.MAXIMIZED_BOTH); setVisible(true); getContentPane().setBackground(Color.WHITE); } } /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package travel.management.system; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.sql.*; public class Login extends JFrame implements ActionListener{ private JTextField textField; private JPasswordField passwordField; private JButton b1,b2,b3; public Login() { setBackground(new Color(255, 255, 204)); setBounds(550, 250, 700, 400); panel = new JPanel(); panel.setBackground(Color.WHITE); setContentPane(panel); panel.setLayout(null); JLabel l1 = new JLabel("Username : "); l1.setBounds(124, 89, 95, 24); panel.add(l1); JLabel l2 = new JLabel("Password : "); l2.setBounds(124, 124, 95, 24); panel.add(l2); textField = new JTextField(); textField.setBounds(210, 93, 157, 20); panel.add(textField); passwordField = new JPasswordField(); passwordField.setBounds(210, 128, 157, 20); panel.add(passwordField); JLabel l3 = new JLabel(""); l3.setBounds(377, 79, 46, 34); panel.add(l3); JLabel l4 = new JLabel(""); l4.setBounds(377, 124, 46, 34); panel.add(l3); ImageIcon c1 = new ImageIcon(ClassLoader.getSystemResource("Travel/Management/System/icons/login.png")); Image i1 = c1.getImage().getScaledInstance(150, 150,Image.SCALE_DEFAULT); ImageIcon i2 = new ImageIcon(i1); JLabel l6 = new JLabel(i2); l6.setBounds(480, 70, 150, 150); add(l6); b1 = new JButton("Login"); b1.addActionListener(this); b1.setForeground(new Color(46, 139, 87)); b1.setBackground(new Color(176, 224, 230)); b1.setBounds(149, 181, 113, 25); panel.add(b1); b2 = new JButton("SignUp"); b2.addActionListener(this); b2.setForeground(new Color(139, 69, 19)); b2.setBackground(new Color(255, 235, 205)); b2.setBounds(289, 181, 113, 25); panel.add(b2) b3 = new JButton("Forgot Password"); b3.addActionListener(this); b3.setForeground(new Color(205, 92, 92)); b3.setBackground(new Color(253, 245, 230)); b3.setBounds(199, 231, 179, 25); panel.add(b3); JLabel l5 = new JLabel("Trouble in Login?"); l5.setFont(new Font("Tahoma", Font.PLAIN, 15)); l5.setForeground(new Color(255, 0, 0)); l5.setBounds(70, 235, 110, 20); panel.add(l5); JPanel panel2 = new JPanel(); panel2.setBackground(new Color(255, 255, 204)); panel2.setBounds(24, 40, 434, 263); panel.add(panel2); } public void actionPerformed(ActionEvent ae){ if(ae.getSource() == b1){ Boolean status = false; try { Conn con = new Conn(); String sql = "select * from account where username=? and password=?"; PreparedStatement st = con.c.prepareStatement(sql); st.setString(1, textField.getText()); st.setString(2, passwordField.getText()); ResultSet rs = st.executeQuery(); if (rs.next()) { this.setVisible(false); new Loading(textField.getText()).setVisible(true); } else JOptionPane.showMessageDialog(null, "Invalid Login or Password!"); } catch (Exception e2) { e2.printStackTrace(); } } if(ae.getSource() == b2){ setVisible(false); Signup su = new Signup(); su.setVisible(true); } if(ae.getSource() == b3){ setVisible(false); ForgotPassword forgot = new ForgotPassword(); forgot.setVisible(true); } } public static void main(String[] args) { new Login().setVisible(true); } }
* To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package travel.management.system; import java.awt.Color; import java.awt.Container; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; import javax.swing.*; /**
* @author Prity */ class CreatePackage extends JFrame implements ActionListener{ private Container c; private JLabel label,pid,pname,date,cost; private Font f; private JTextField tid,tname,tdate,tcost; private JButton back,log,save; // private String UserName,Password,Status; CreatePackage() { initcomponents(); } public void initcomponents() { c=this.getContentPane(); c.setLayout(null); this.setTitle("Package Pane"); this.setSize(400, 400); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f=new Font("",Font.BOLD,20); label=new JLabel("Create Package"); label.setBounds(150, 20, 200, 30); label.setFont(f); label.setForeground(Color.black); c.add(label); pid=new JLabel("PackageId"); pid.setBounds(20, 70, 100, 30); c.add(pid); pname=new JLabel("PackageName"); pname.setBounds(20, 120, 100, 30); c.add(pname); date=new JLabel("Date"); date.setBounds(20, 170, 100, 30); c.add(date); cost=new JLabel("Cost"); cost.setBounds(20, 220, 100, 30); c.add(cost); tid=new JTextField(); tid.setBounds(120, 70, 100, 30); c.add(tid); tname=new JTextField(); tname.setBounds(120, 120, 100, 30); c.add(tname); tdate=new JTextField(); tdate.setBounds(120, 170, 100, 30); c.add(tdate); tcost=new JTextField(); tcost.setBounds(120, 220, 100, 30); c.add(tcost); back=new JButton("Main Menu"); back.setBounds(20, 300, 100, 50); back.addActionListener(this); c.add(back); log=new JButton("Log Out"); log.setBounds(200, 300, 100, 50); log.addActionListener(this); c.add(log); save=new JButton("Save"); save.setBounds(230, 160, 120, 50); save.addActionListener(this); c.add(save); } @Override public void actionPerformed(ActionEvent e) { String clickbutton=e.getActionCommand(); if(clickbutton.equals(log.getText())) { Login l=new Login(); l.setVisible(true); this.setVisible(false); } else if(clickbutton.equals(back.getText())) { //AdminHome ad=new AdminHome(); //ad.setVisible(true); this.setVisible(false); } else if(clickbutton.equals(save.getText())) { createDB(); JOptionPane.showMessageDialog(null,"New Package Saved"); } else{} } public void createDB() { String query="INSERT INTO `package` VALUES('"+tid.getText()+"','"+tname.getText()+"','"+tdate.getText()+"','"+tcost.getText()+"')"; System.out.println(query); Connection con=null; Statement st=null; try{ Class.forName("com.mysql.jdbc.Driver"); con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root",""); System.out.println("Connection Established"); st=con.createStatement(); System.out.println("Statement Created"); st.execute(query); }catch(Exception e) { System.out.println(e); } finally{ try{ if(con!=null) { con.close(); System.out.println("Connection Closed"); } if(st!=null) { st.close(); System.out.println("Statement Closed"); } }catch(Exception e) { System.out.println(e); } } } public static void main(String[] args){ new CreatePackage().setVisible(true); } } Download 23.66 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling