About The Project

  Building a "Hotel Management System" Desktop Application in IntelliJ IDEA , using Java programming language, "Java Swing" library and Java Database Connectivity (JDBC) to MysSQL, using XAMPP Local Host Server.



Project Setup
      1. Install MySQL if not installed.

      2. At first, Create a database in MySQL named as "hotel_management_system".

      3. Then create tables named as:

      • "Employee", 
      • "Customer", 
      • "Login", 
      • "Driver", 
      • "Room".
      4. Insert values of login table.

      5. Install IntelliJ IDE.

      6. Create a new project named as "HotelManagementSystem" and start coding the Java Classes.



HotelManagementSystem/db
/hotel_management_system.sql


-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Feb 07, 2024 at 03:02 PM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.0.30

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `hotel_management_system`
--

-- --------------------------------------------------------

--
-- Table structure for table `customer`
--

CREATE TABLE `customer` (
  `id` varchar(30) DEFAULT NULL,
  `number` varchar(30) DEFAULT NULL,
  `name` varchar(30) DEFAULT NULL,
  `gender` varchar(30) DEFAULT NULL,
  `country` varchar(30) DEFAULT NULL,
  `room_number` varchar(30) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `deposit` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `customer`
--

INSERT INTO `customer` (`id`, `number`, `name`, `gender`, `country`, `room_number`, `status`, `deposit`) VALUES
('Personal Identification Number', '111222333444', 'Simona', 'Female', 'Romania', '3009', 'Yes', '40'),
('Passport', '444333222111', 'Enrique', 'Male', 'Spain', '3010', 'Yes', '100'),
('Passport', '222333444111', 'Constantin', 'Male', 'Romania', '3011', 'Yes', '60'),
('Passport', '333444111222', 'Marinela', 'Female', 'Romania', '3011', 'Yes', '70');

-- --------------------------------------------------------

--
-- Table structure for table `driver`
--

CREATE TABLE `driver` (
  `name` varchar(30) DEFAULT NULL,
  `age` varchar(10) DEFAULT NULL,
  `gender` varchar(20) DEFAULT NULL,
  `company` varchar(30) DEFAULT NULL,
  `brand` varchar(30) DEFAULT NULL,
  `available` varchar(10) DEFAULT NULL,
  `location` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `driver`
--

INSERT INTO `driver` (`name`, `age`, `gender`, `company`, `brand`, `available`, `location`) VALUES
('Stefan', '30', 'Male', 'Hotel Marriott', 'Audi', 'Yes', 'Bucharest'),
('Robert', '28', 'Male', 'Hotel Marriott', 'BMW', 'Yes', 'Bucharest'),
('Adrian', '', 'Male', 'Hotel Marriott', '', 'Yes', 'Bucharest'),
('Ionut', '45', 'Male', 'Hotel Marriott', 'Mercedes', 'Yes', 'Bucharest'),
('Liviu', '39', 'Male', 'Hotel Marriott', 'Dacia', 'Yes', 'Bucharest');

-- --------------------------------------------------------

--
-- Table structure for table `employee`
--

CREATE TABLE `employee` (
  `name` varchar(30) DEFAULT NULL,
  `age` varchar(10) DEFAULT NULL,
  `gender` varchar(10) NOT NULL,
  `job` varchar(30) DEFAULT NULL,
  `salary` varchar(30) DEFAULT NULL,
  `phone` varchar(30) DEFAULT NULL,
  `personal_identification_number` varchar(30) DEFAULT NULL,
  `email` varchar(40) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `employee`
--

INSERT INTO `employee` (`name`, `age`, `gender`, `job`, `salary`, `phone`, `personal_identification_number`, `email`) VALUES
('Elena', '30', 'female', 'Room Service', '600', '0721234567', '2940510453256', 'elena@gmail.com'),
('Madalina', '40', 'female', 'Waiter/Waitress', '550', '077654321', '2990222654875', 'madalina@gmail.com'),
('Cornelia', '40', 'female', 'Kitchen Staff', '1000', '0755123456', '2841028344552', 'cornelia@gmail.com'),
('Daniela', '45', 'female', 'Accountant', '12200', '0787654321', '2790524316245', 'daniela'),
('George', '40', 'null', 'Manager', '1700', '0700012345', '1840322355346', 'george@gmail.com'),
('Razban', '42', 'male', 'Kitchen Staff', '2000', '0712345600', '1860610235645', 'razvan@gmail.com'),
('Monica', '25', 'female', 'Waiter/Waitress', '700', '0722233344', '2990424234564', 'mihaela'),
('Rodica', '24', 'female', 'Housekeeping', '520', '0788012345', '2001028355446', 'rodica@gmail.com'),
('Jeanine', '25', 'female', 'Front Desk Clerks', '600', '0733344555', '2991206235446', 'jeanine@gmail.com');

-- --------------------------------------------------------

--
-- Table structure for table `login`
--

CREATE TABLE `login` (
  `username` varchar(40) DEFAULT NULL,
  `password` varchar(40) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `login`
--

INSERT INTO `login` (`username`, `password`) VALUES
('admin', '123456');

-- --------------------------------------------------------

--
-- Table structure for table `room`
--

CREATE TABLE `room` (
  `room_number` varchar(20) DEFAULT NULL,
  `availability` varchar(20) DEFAULT NULL,
  `clean_status` varchar(20) DEFAULT NULL,
  `price` varchar(20) DEFAULT NULL,
  `bed_type` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `room`
--

INSERT INTO `room` (`room_number`, `availability`, `clean_status`, `price`, `bed_type`) VALUES
('1001', 'Available', 'Cleaned', '100', 'Double Bed'),
('1002', 'Occupied', 'Dirty', '50', 'Single Bed'),
('1003', 'Occupied', 'Cleaned', '60', 'Single Bed'),
('1004', 'Occupied', 'Cleaned', '65', 'Single Bed'),
('2005', 'Occupied', 'Cleaned', '60', 'Single Bed'),
('2006', 'Occupied', 'Cleaned', '100', 'Double Bed'),
('2007', 'Available', 'Dirty', '50', 'Single Bed'),
('2007', 'Available', 'Cleaned', '160', 'Double Bed'),
('3009', 'Occupied', 'Cleaned', '120', 'Double Bed'),
('3010', 'Occupied', 'Cleaned', '70', 'Single Bed'),
('3011', 'Occupied', 'Cleaned', '130', 'Double Bed'),
('3012', 'Available', 'Cleaned', '80', 'Single Bed');
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;






src/hotel/AddDrivers.java

package hotel;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

/**
 * This class represents the window for adding drivers to the system.
 */
public class AddDrivers extends JFrame implements ActionListener {

	private final JPanel contentPane;
	private final JTextField t1, t2, t3, t4, t5;
	private final JComboBox<String> comboBox, comboBox_1;
	private final JButton b1, b2;

	/**
	 * Main method to launch the AddDrivers window.
	 *
	 * @param args Command-line arguments.
	 */
	public static void main(String[] args) {
		new AddDrivers().setVisible(true);
	}

	/**
	 * Constructor to initialize the AddDrivers window.
	 */
	public AddDrivers() {


		setBounds(450, 200, 1000, 500);
		contentPane = new JPanel();
		setContentPane(contentPane);
		contentPane.setLayout(null);


		// Center the frame on the screen
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int screenWidth = (int) screenSize.getWidth();
		int screenHeight = (int) screenSize.getHeight();
		int frameWidth = getWidth();
		int frameHeight = getHeight();

		int x = (screenWidth - frameWidth) / 2;
		int y = (screenHeight - frameHeight) / 2;

		setLocation(x, y);



		ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/eleven.jpg"));
		Image i3 = i1.getImage().getScaledInstance(500, 300, Image.SCALE_DEFAULT);
		ImageIcon i2 = new ImageIcon(i3);
		JLabel l15 = new JLabel(i2);
		l15.setBounds(400, 30, 500, 370);
		add(l15);

		JLabel l10 = new JLabel("Add Drivers");
		l10.setFont(new Font("Tahoma", Font.BOLD, 18));
		l10.setBounds(194, 10, 120, 22);
		contentPane.add(l10);

		// Labels and text fields for driver information
		JLabel l1 = new JLabel("Name");
		l1.setForeground(new Color(25, 25, 112));
		l1.setFont(new Font("Tahoma", Font.BOLD, 14));
		l1.setBounds(64, 70, 102, 22);
		contentPane.add(l1);

		t1 = new JTextField();
		t1.setBounds(174, 70, 156, 20);
		contentPane.add(t1);

		JLabel l2 = new JLabel("Age");
		l2.setForeground(new Color(25, 25, 112));
		l2.setFont(new Font("Tahoma", Font.BOLD, 14));
		l2.setBounds(64, 110, 102, 22);
		contentPane.add(l2);

		t2 = new JTextField();
		t2.setBounds(174, 110, 156, 20);
		contentPane.add(t2);

		JLabel l3 = new JLabel("Gender");
		l3.setForeground(new Color(25, 25, 112));
		l3.setFont(new Font("Tahoma", Font.BOLD, 14));
		l3.setBounds(64, 150, 102, 22);
		contentPane.add(l3);

		comboBox = new JComboBox<>(new String[]{"Male", "Female"});
		comboBox.setBounds(176, 150, 154, 20);
		contentPane.add(comboBox);

		JLabel l4 = new JLabel("Car Company");
		l4.setForeground(new Color(25, 25, 112));
		l4.setFont(new Font("Tahoma", Font.BOLD, 14));
		l4.setBounds(64, 190, 102, 22);
		contentPane.add(l4);

		t3 = new JTextField();
		t3.setBounds(174, 190, 156, 20);
		contentPane.add(t3);

		JLabel l5 = new JLabel("Car Brand");
		l5.setForeground(new Color(25, 25, 112));
		l5.setFont(new Font("Tahoma", Font.BOLD, 14));
		l5.setBounds(64, 230, 102, 22);
		contentPane.add(l5);

		t4 = new JTextField();
		t4.setBounds(174, 230, 156, 20);
		contentPane.add(t4);

		JLabel l6 = new JLabel("Available");
		l6.setForeground(new Color(25, 25, 112));
		l6.setFont(new Font("Tahoma", Font.BOLD, 14));
		l6.setBounds(64, 270, 102, 22);
		contentPane.add(l6);

		comboBox_1 = new JComboBox<>(new String[]{"Yes", "No"});
		comboBox_1.setBounds(176, 270, 154, 20);
		contentPane.add(comboBox_1);

		JLabel l7 = new JLabel("Location");
		l7.setForeground(new Color(25, 25, 112));
		l7.setFont(new Font("Tahoma", Font.BOLD, 14));
		l7.setBounds(64, 310, 102, 22);
		contentPane.add(l7);

		t5 = new JTextField();
		t5.setBounds(174, 310, 156, 20);
		contentPane.add(t5);

		// Buttons for adding and going back
		b1 = new JButton("Add");
		b1.addActionListener(this);
		b1.setBounds(64, 380, 111, 33);
		b1.setBackground(Color.BLACK);
		b1.setForeground(Color.WHITE);
		contentPane.add(b1);

		b2 = new JButton("Back");
		b2.addActionListener(this);
		b2.setBounds(198, 380, 111, 33);
		b2.setBackground(Color.BLACK);
		b2.setForeground(Color.WHITE);
		contentPane.add(b2);

		contentPane.setBackground(Color.WHITE);
	}

	/**
	 * This method is called when an action is performed, such as clicking a button.
	 *
	 * @param ae The ActionEvent associated with the action.
	 */
	public void actionPerformed(ActionEvent ae) {
		try {
			if (ae.getSource() == b1) {
				try {
					DBConnection c = new DBConnection();
					String name = t1.getText();
					String age = t2.getText();
					String gender = (String) comboBox.getSelectedItem();
					String company = t3.getText();
					String brand = t4.getText();
					String available = (String) comboBox_1.getSelectedItem();
					String location = t5.getText();
					String str = "INSERT INTO driver values( '" + name + "', '" + age + "', '" + gender + "','" + company + "', '" + brand + "', '" + available + "','" + location + "')";

					c.s.executeUpdate(str);
					JOptionPane.showMessageDialog(null, "Driver Successfully Added");
					this.setVisible(false);
				} catch (Exception ee) {
					System.out.println(ee);
				}
			} else if (ae.getSource() == b2) {
				this.setVisible(false);
			}
		} catch (Exception eee) {
			throw new RuntimeException(eee);
		}
	}
}





src/hotel/AddEmployee.java
package hotel;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class AddEmployee extends JFrame {

    JTextField textField, textField_1, textField_2, textField_3, textField_4, textField_5, textField_6;
    JComboBox<String> c1;


    public AddEmployee(){
        getContentPane().setForeground(Color.BLUE);
        getContentPane().setBackground(Color.WHITE);
        setTitle("Add Employee Details");




        setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        setSize(778,486);
        getContentPane().setLayout(null);



        JLabel PassportNo = new JLabel("Name");
        PassportNo.setFont(new Font("Tahoma", Font.PLAIN, 17));
        PassportNo.setBounds(60, 30, 150, 27);
        add(PassportNo);

        textField = new JTextField();
        textField.setBounds(200, 30, 150, 27);
        add(textField);

        JButton Next = new JButton("Save");
        Next.setBounds(200, 420, 150, 30);
        Next.setBackground(Color.BLACK);
        Next.setForeground(Color.WHITE);
        add(Next);

        JLabel Age = new JLabel("Age");
        Age.setFont(new Font("Tahoma", Font.PLAIN, 17));
        Age.setBounds(60, 80, 150, 27);
        add(Age);

        textField_1 = new JTextField();
        textField_1.setBounds(200, 80, 150, 27);
        add(textField_1);

        JLabel Gender = new JLabel("Gender");
        Gender.setFont(new Font("Tahoma", Font.PLAIN, 17));
        Gender.setBounds(60, 120, 150, 27);
        add(Gender);

        JRadioButton NewRadioButton = new JRadioButton("MALE");
        NewRadioButton.setBackground(Color.WHITE);
        NewRadioButton.setBounds(200, 120, 70, 27);
        add(NewRadioButton);

        JRadioButton Female = new JRadioButton("FEMALE");
        Female.setBackground(Color.WHITE);
        Female.setBounds(280, 120, 70, 27);
        add(Female);


        JLabel job = new JLabel("Job");
        job.setFont(new Font("Tahoma", Font.PLAIN, 17));
        job.setBounds(60, 170, 150, 27);
        add(job);

        String[] course = {"Front Desk Clerks", "Porters", "Housekeeping", "Kitchen Staff", "Room Service", "Waiter/Waitress", "Manager", "Accountant", "Chef"};
        c1 = new JComboBox<>(course);
        c1.setBackground(Color.WHITE);
        c1.setBounds(200,170,150,30);
        add(c1);

        JLabel Nationality = new JLabel("Salary");
        Nationality.setFont(new Font("Tahoma", Font.PLAIN, 17));
        Nationality.setBounds(60, 220, 150, 27);
        add(Nationality);

        textField_3 = new JTextField();
        textField_3.setBounds(200, 220, 150, 27);
        add(textField_3);

        JLabel Name = new JLabel("Phone");
        Name.setFont(new Font("Tahoma", Font.PLAIN, 17));
        Name.setBounds(60, 270, 150, 27);
        add(Name);

        textField_4 = new JTextField();
        textField_4.setBounds(200, 270, 150, 27);
        add(textField_4);

        JLabel PIN = new JLabel("Personal Identification Number");
        PIN.setFont(new Font("Tahoma", Font.PLAIN, 17));
        PIN.setBounds(60, 320, 150, 27);
        add(PIN);

        textField_5 = new JTextField();
        textField_5.setBounds(200, 320, 150, 27);
        add(textField_5);


        JLabel email = new JLabel("Email");
        email.setFont(new Font("Tahoma", Font.PLAIN, 17));
        email.setBounds(60, 370, 150, 27);
        add(email);

        textField_6 = new JTextField();
        textField_6.setBounds(200, 370, 150, 27);
        add(textField_6);

        setVisible(true);


        JLabel AddPassengers = new JLabel("Add Employee Details");
        AddPassengers.setForeground(Color.BLUE);
        AddPassengers.setFont(new Font("Tahoma", Font.PLAIN, 31));
        AddPassengers.setBounds(450, 24, 442, 35);
        add(AddPassengers);


        ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/tenth.jpg"));
        Image i3 = i1.getImage().getScaledInstance(500, 500,Image.SCALE_DEFAULT);
        ImageIcon i2 = new ImageIcon(i3);
        JLabel image = new JLabel(i2);
        image.setBounds(410,80,480,410);
        add(image);


        Next.addActionListener(ae -> {
            String name = textField.getText();
            String age = textField_1.getText();
            String salary = textField_3.getText();
            String phone = textField_4.getText();
            String personal_identification_number = textField_5.getText();
            String email1 = textField_6.getText();

            String gender = null;

            if(NewRadioButton.isSelected()){
                gender = "male";

            }else if(Female.isSelected()){
                gender = "female";
            }


            String s6 = (String)c1.getSelectedItem();

            try {
                DBConnection c = new DBConnection();
                String str = "INSERT INTO employee values( '" + name + "', '" + age + "', '" + gender + "','" + s6 + "', '" + salary  + "', '" + phone + "','" + personal_identification_number + "', '"+ email1 +"')";

                c.s.executeUpdate(str);
                JOptionPane.showMessageDialog(null,"Employee Added");
                setVisible(false);

            } catch (Exception e) {
                e.printStackTrace();
            }
        });

        setSize(900,600);
        setVisible(true);
        setLocation(530,200);


        getContentPane().setForeground(Color.BLUE);
        getContentPane().setBackground(Color.WHITE);
        setTitle("Add Employee Details");

        setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        setSize(900, 600);
        setLayout(null);



        // Calculate the central position
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int screenWidth = (int) screenSize.getWidth();
        int screenHeight = (int) screenSize.getHeight();
        int frameWidth = getWidth();
        int frameHeight = getHeight();

        int x = (screenWidth - frameWidth) / 2;
        int y = (screenHeight - frameHeight) / 2;

        setLocation(x, y);


        // Event listener for window movement
        addComponentListener(new ComponentAdapter() {
            public void componentMoved(ComponentEvent e) {
                // If the window is moved, reposition it to the center of the screen
                int frameX = getLocation().x;
                int frameY = getLocation().y;
                int newX = frameX + (frameWidth / 2);
                int newY = frameY + (frameHeight / 2);

                setLocation(newX - (frameWidth / 2), newY - (frameHeight / 2));
            }
        });


        setVisible(true);
    }


    public static void main(String[] args) {
        new AddEmployee();
    }
}






src/hotel/AddRoom.java
package hotel;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class AddRoom extends JFrame implements ActionListener {

    // Panel to hold the components
    private JPanel contentPane;

    // Text fields for room details
    private JTextField t1, t2, t3, t4;

    // Combo boxes for room status and type
    private JComboBox comboBox, comboBox_1, comboBox_2, comboBox_3;

    // Buttons for actions
    JButton b1, b2;

    // Constructor
    public AddRoom() {
        // Set frame dimensions and location
        setBounds(450, 200, 1000, 450);
        contentPane = new JPanel();
        setContentPane(contentPane);
        contentPane.setLayout(null);

        // Center the frame on the screen
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int screenWidth = (int) screenSize.getWidth();
        int screenHeight = (int) screenSize.getHeight();
        int frameWidth = getWidth();
        int frameHeight = getHeight();
        int x = (screenWidth - frameWidth) / 2;
        int y = (screenHeight - frameHeight) / 2;
        setLocation(x, y);

        // Adding image to the frame
        ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/twelve.jpg"));
        Image i3 = i1.getImage().getScaledInstance(500, 300, Image.SCALE_DEFAULT);
        ImageIcon i2 = new ImageIcon(i3);
        JLabel l15 = new JLabel(i2);
        l15.setBounds(400, 30, 500, 370);
        add(l15);

        // Title label
        JLabel l10 = new JLabel("Add Rooms");
        l10.setFont(new Font("Tahoma", Font.BOLD, 18));
        l10.setBounds(194, 10, 120, 22);
        contentPane.add(l10);

        // Room Number label and text field
        JLabel l1 = new JLabel("Room Number");
        l1.setForeground(new Color(25, 25, 112));
        l1.setFont(new Font("Tahoma", Font.BOLD, 14));
        l1.setBounds(64, 70, 102, 22);
        contentPane.add(l1);
        t4 = new JTextField();
        t4.setBounds(174, 70, 156, 20);
        contentPane.add(t4);

        // Availability label and combo box
        JLabel l2 = new JLabel("Availability");
        l2.setForeground(new Color(25, 25, 112));
        l2.setFont(new Font("Tahoma", Font.BOLD, 14));
        l2.setBounds(64, 110, 102, 22);
        contentPane.add(l2);
        comboBox = new JComboBox(new String[]{"Available", "Occupied"});
        comboBox.setBounds(176, 110, 154, 20);
        contentPane.add(comboBox);

        // Cleaning Status label and combo box
        JLabel l3 = new JLabel("Cleaning Status");
        l3.setForeground(new Color(25, 25, 112));
        l3.setFont(new Font("Tahoma", Font.BOLD, 14));
        l3.setBounds(64, 150, 102, 22);
        contentPane.add(l3);
        comboBox_2 = new JComboBox(new String[]{"Cleaned", "Dirty"});
        comboBox_2.setBounds(176, 150, 154, 20);
        contentPane.add(comboBox_2);

        // Price label and text field
        JLabel l4 = new JLabel("Price");
        l4.setForeground(new Color(25, 25, 112));
        l4.setFont(new Font("Tahoma", Font.BOLD, 14));
        l4.setBounds(64, 190, 102, 22);
        contentPane.add(l4);
        t2 = new JTextField();
        t2.setBounds(174, 190, 156, 20);
        contentPane.add(t2);

        // Bed Type label and combo box
        JLabel l5 = new JLabel("Bed Type");
        l5.setForeground(new Color(25, 25, 112));
        l5.setFont(new Font("Tahoma", Font.BOLD, 14));
        l5.setBounds(64, 230, 102, 22);
        contentPane.add(l5);
        comboBox_3 = new JComboBox(new String[]{"Single Bed", "Double Bed"});
        comboBox_3.setBounds(176, 230, 154, 20);
        contentPane.add(comboBox_3);

        // Add button
        b1 = new JButton("Add");
        b1.addActionListener(this);
        b1.setBounds(64, 321, 111, 33);
        b1.setBackground(Color.BLACK);
        b1.setForeground(Color.WHITE);
        contentPane.add(b1);

        // Back button
        b2 = new JButton("Back");
        b2.addActionListener(this);
        b2.setBounds(198, 321, 111, 33);
        b2.setBackground(Color.BLACK);
        b2.setForeground(Color.WHITE);
        contentPane.add(b2);

        // Set background color of the panel
        contentPane.setBackground(Color.WHITE);
    }

    // Action performed method to handle button clicks
    public void actionPerformed(ActionEvent ae) {
        try {
            if (ae.getSource() == b1) {
                try {
                    // Database connection and insertion
                    DBConnection c = new DBConnection();
                    String room = t4.getText();
                    String available = (String) comboBox.getSelectedItem();
                    String status = (String) comboBox_2.getSelectedItem();
                    String price = t2.getText();
                    String type = (String) comboBox_3.getSelectedItem();
                    String str = "INSERT INTO room values( '" + room + "', '" + available + "', '" + status + "','" + price + "', '" + type + "')";
                    c.s.executeUpdate(str);
                    JOptionPane.showMessageDialog(null, "Room Successfully Added");
                    this.setVisible(false);
                } catch (Exception ee) {
                    // Exception handling
                    System.out.println(ee);
                }
            } else if (ae.getSource() == b2) {
                // Close the window
                this.setVisible(false);
            }
        } catch (Exception eee) {
            // Exception handling
            throw new RuntimeException(eee);
        }
    }


    public static void main(String[] args) {
        // Crearea unei instanțe a ferestrei AddRoom și afișarea ei
        SwingUtilities.invokeLater(() -> {
            AddRoom addRoom = new AddRoom();
            addRoom.setVisible(true);
        });
    }
}










src/hotel/CheckOut.java
package hotel;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;

import javax.swing.*;
import javax.swing.border.EmptyBorder;

// Define CheckOut class as a subclass of JFrame
public class CheckOut extends JFrame {
	Connection conn = null;
	PreparedStatement pst = null;
	private JPanel contentPane;
	private JTextField t1;
	private Choice c1;

	// Main method to launch the application
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					CheckOut frame = new CheckOut();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	// Method to close the window
	public void close() {
		this.dispose();
	}

	// Constructor for CheckOut class
	public CheckOut() throws SQLException {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(530, 200, 800, 294);

		// Create content pane
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		// Center the frame on the screen
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int screenWidth = (int) screenSize.getWidth();
		int screenHeight = (int) screenSize.getHeight();
		int frameWidth = getWidth();
		int frameHeight = getHeight();
		int x = (screenWidth - frameWidth) / 2;
		int y = (screenHeight - frameHeight) / 2;
		setLocation(x, y);

		// Load image icon for decoration
		ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/sixth.jpg"));
		Image i3 = i1.getImage().getScaledInstance(400, 225, Image.SCALE_DEFAULT);
		ImageIcon i2 = new ImageIcon(i3);
		JLabel l1 = new JLabel(i2);
		l1.setBounds(300, 0, 500, 225);
		add(l1);

		// Label for Check Out title
		JLabel lblCheckOut = new JLabel("Check Out ");
		lblCheckOut.setFont(new Font("Tahoma", Font.PLAIN, 20));
		lblCheckOut.setBounds(70, 11, 140, 35);
		contentPane.add(lblCheckOut);

		// Label and choice for selecting customer number
		JLabel lblName = new JLabel("Number :");
		lblName.setBounds(20, 85, 80, 14);
		contentPane.add(lblName);

		c1 = new Choice();
		try {
			// Fetch customer numbers from the database
			DBConnection c = new DBConnection();
			ResultSet rs = c.s.executeQuery("select * from customer");
			while (rs.next()) {
				c1.add(rs.getString("number"));
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		c1.setBounds(130, 82, 150, 20);
		contentPane.add(c1);

		// Button for retrieving customer details
		ImageIcon i4 = new ImageIcon(ClassLoader.getSystemResource("icons/tick.png"));
		Image i5 = i4.getImage().getScaledInstance(20, 20, Image.SCALE_DEFAULT);
		ImageIcon i6 = new ImageIcon(i5);
		JButton l2 = new JButton(i6);
		l2.setBounds(290, 82, 20, 20);
		add(l2);

		l2.addActionListener(ae -> {
			System.out.println("Hi");
			try {
				// Retrieve customer details based on selected number
				DBConnection c = new DBConnection();
				String number = c1.getSelectedItem();
				ResultSet rs = c.s.executeQuery("select * from customer where number = " + number);

				if (rs.next()) {
					System.out.println("clicked");
					t1.setText(rs.getString("room_number"));
				}
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		});

		// Label and text field for room number
		JLabel lblRoomNumber = new JLabel("Room Number:");
		lblRoomNumber.setBounds(20, 132, 86, 20);
		contentPane.add(lblRoomNumber);

		t1 = new JTextField();
		t1.setBounds(130, 132, 150, 20);
		contentPane.add(t1);

		// Button to check out customer
		JButton btnCheckOut = new JButton("Check Out");
		btnCheckOut.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// Retrieve selected customer number and room number
				String id = c1.getSelectedItem();
				String s1 = t1.getText();
				String deleteSQL = "Delete from customer where number = " + id;
				String q2 = "update room set availability = 'Available' where room_number = " + s1;

				// Perform database operations to check out customer
				DBConnection c = new DBConnection();

				try {
					c.s.executeUpdate(deleteSQL);
					c.s.executeUpdate(q2);
					JOptionPane.showMessageDialog(null, "Check Out Successful");
					new Reception().setVisible(true);
					setVisible(false);
				} catch (SQLException e1) {
					System.out.println(e1.getMessage());
				}
			}
		});
		btnCheckOut.setBounds(50, 200, 100, 25);
		btnCheckOut.setBackground(Color.BLACK);
		btnCheckOut.setForeground(Color.WHITE);
		contentPane.add(btnCheckOut);

		// Button to navigate back to Reception window
		JButton btnExit = new JButton("Back");
		btnExit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new Reception().setVisible(true);
				setVisible(false);
			}
		});
		btnExit.setBounds(160, 200, 100, 25);
		btnExit.setBackground(Color.BLACK);
		btnExit.setForeground(Color.WHITE);
		contentPane.add(btnExit);

		// Set background color
		getContentPane().setBackground(Color.WHITE);
	}
}












src/hotel/CustomerInfo.java
package hotel;

import net.proteanit.sql.DbUtils;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.sql.ResultSet;

public class CustomerInfo extends JFrame {

	public static void main(String[] args) {
		// Launch the application
		EventQueue.invokeLater(() -> {
			try {
				// Create and display the frame
				CustomerInfo frame = new CustomerInfo();
				frame.setVisible(true);
			} catch (Exception e) {
				e.printStackTrace();
			}
		});
	}

	public CustomerInfo() {
		// Set up the frame
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(530, 200, 900, 600);
		// Create and configure the content pane
		JPanel contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);


		// Center the frame on the screen
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int screenWidth = (int) screenSize.getWidth();
		int screenHeight = (int) screenSize.getHeight();
		int frameWidth = getWidth();
		int frameHeight = getHeight();

		int x = (screenWidth - frameWidth) / 2;
		int y = (screenHeight - frameHeight) / 2;

		setLocation(x, y);



		// Create and configure the "Back" button
		JButton btnExit = new JButton("Back");
		btnExit.addActionListener(e -> {
			// Navigate back to the reception window
			new Reception().setVisible(true);
			setVisible(false);
		});
		btnExit.setBounds(450, 510, 120, 30);
		btnExit.setBackground(Color.BLACK);
		btnExit.setForeground(Color.WHITE);
		contentPane.add(btnExit);

		// Create and configure the "Load Data" button
		JButton btnLoadData = new JButton("Load Data");
		btnLoadData.addActionListener(arg0 -> {
			try {
				// Fetch customer data from the database
				DBConnection c = new DBConnection();
				String displayCustomersql = "select * from Customer";
				ResultSet rs = c.s.executeQuery(displayCustomersql);
				// Display the data in a table
				JTable table = new JTable();
				table.setBounds(0, 40, 900, 450);
				contentPane.add(table);
				table.setModel(DbUtils.resultSetToTableModel(rs));
			} catch (Exception e) {
				e.printStackTrace();
			}
		});
		btnLoadData.setBounds(300, 510, 120, 30);
		btnLoadData.setBackground(Color.BLACK);
		btnLoadData.setForeground(Color.WHITE);
		contentPane.add(btnLoadData);

		// Labels for column headers
		JLabel lblId = new JLabel("ID");
		lblId.setBounds(31, 11, 46, 14);
		contentPane.add(lblId);

		JLabel l1 = new JLabel("Number");
		l1.setBounds(150, 11, 46, 14);
		contentPane.add(l1);

		JLabel lblNewLabel = new JLabel("Name");
		lblNewLabel.setBounds(270, 11, 65, 14);
		contentPane.add(lblNewLabel);

		JLabel lblGender = new JLabel("Gender");
		lblGender.setBounds(360, 11, 46, 14);
		contentPane.add(lblGender);

		JLabel lblCountry = new JLabel("Country");
		lblCountry.setBounds(480, 11, 46, 14);
		contentPane.add(lblCountry);

		JLabel lblRoom = new JLabel("Room");
		lblRoom.setBounds(600, 11, 46, 14);
		contentPane.add(lblRoom);

		JLabel lblStatus = new JLabel("Check-in Status");
		lblStatus.setBounds(680, 11, 100, 14);
		contentPane.add(lblStatus);

		JLabel lblNewLabel_1 = new JLabel("Deposit");
		lblNewLabel_1.setBounds(800, 11, 100, 14);
		contentPane.add(lblNewLabel_1);

		// Set background color
		getContentPane().setBackground(Color.WHITE);
	}
}












src/hotel/DBConnection.java
package hotel;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * The DBConnection class establishes a connection to the MySQL database
 * for the Hotel Management System.
 */
public class DBConnection {
    // Connection and Statement objects for database interaction
    private Connection c;
    Statement s;

    /**
     * Constructor for DBConnection.
     * Attempts to establish a connection to the MySQL database.
     */
    public DBConnection() {
        try {
            // Load the new MySQL JDBC driver
            Class.forName("com.mysql.cj.jdbc.Driver");

            // Establish a connection to the database
            String url = "jdbc:mysql://localhost/hotel_management_system";
            String user = "root";
            String password = "";

            c = DriverManager.getConnection(url, user, password);

            // Create a Statement object for executing SQL queries
            s = c.createStatement();

        } catch (ClassNotFoundException | SQLException e) {
            // Handle exceptions, print error details to console
            e.printStackTrace();
        }
    }

    /**
     * Close the database connection.
     */
    public void closeConnection() {
        try {
            if (c != null) {
                c.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}



src/hotel/Dashboard.java
package hotel;

import javax.swing.*;
import java.awt.*;

public class Dashboard extends JFrame {

    public static void main(String[] args) {
        // Create and display the dashboard window
        new Dashboard().setVisible(true);
    }

    public Dashboard() {
        super("Hotel Management System");

        // Set layout to BorderLayout for better component positioning
        setLayout(new BorderLayout());

        // Load and set background image
        ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/third.jpg"));
        Image i2 = i1.getImage().getScaledInstance(1950, 1000, Image.SCALE_DEFAULT);
        ImageIcon i3 = new ImageIcon(i2);
        JLabel backgroundLabel = new JLabel(i3);
        add(backgroundLabel, BorderLayout.CENTER); // Adding backgroundLabel to the center

        // Create a panel for vertical spacing
        JPanel topPanel = new JPanel();
        topPanel.setOpaque(false); // Make the panel transparent
        topPanel.setPreferredSize(new Dimension(1950, 100)); // Set the desired distance from the top
        backgroundLabel.setLayout(new BorderLayout()); // Set layout for backgroundLabel
        backgroundLabel.add(topPanel, BorderLayout.NORTH); // Adding topPanel to the top

        // Add label for system welcome message over the image with top margin
        JLabel systemWelcomeLabel = new JLabel("Our Hotel Welcomes You");
        systemWelcomeLabel.setForeground(Color.WHITE);
        systemWelcomeLabel.setFont(new Font("Tahoma", Font.PLAIN, 46));
        systemWelcomeLabel.setHorizontalAlignment(SwingConstants.CENTER); // Center text horizontally
        systemWelcomeLabel.setBorder(BorderFactory.createEmptyBorder(40, 0, 0, 0)); // Add top margin
        backgroundLabel.add(systemWelcomeLabel, BorderLayout.NORTH); // Adding systemWelcomeLabel to the top

        // Create menu bar
        JMenuBar menuBar = new JMenuBar();
        setJMenuBar(menuBar);

        // Add menu items for hotel management system
        JMenu hotelManagementMenu = new JMenu("Hotel Management");
        hotelManagementMenu.setForeground(Color.BLACK); // Set menu text color to black
        menuBar.add(hotelManagementMenu);

        JMenuItem receptionMenuItem = new JMenuItem("Reception");
        hotelManagementMenu.add(receptionMenuItem);

        // Add menu items for admin functions
        JMenu adminMenu = new JMenu("Admin");
        adminMenu.setForeground(Color.BLACK); // Set menu text color to black
        menuBar.add(adminMenu);

        // Add menu items for admin actions (Add Employee, Add Rooms, Add Drivers)
        JMenuItem addEmployeeMenuItem = new JMenuItem("Add Employee");
        adminMenu.add(addEmployeeMenuItem);

        // ActionListener for Add Employee menu item
        addEmployeeMenuItem.addActionListener(ae -> {
            try {
                new AddEmployee().setVisible(true);
            } catch(Exception e) {
                throw new RuntimeException(e);
            }
        });

        JMenuItem addRoomsMenuItem = new JMenuItem("Add Rooms");
        adminMenu.add(addRoomsMenuItem);

        // ActionListener for Add Rooms menu item
        addRoomsMenuItem.addActionListener(ae -> {
            try {
                new AddRoom().setVisible(true);
            } catch(Exception e) {
                throw new RuntimeException(e);
            }
        });

        // ActionListener for Reception menu item
        receptionMenuItem.addActionListener(ae -> new Reception());

        JMenuItem addDriversMenuItem = new JMenuItem("Add Drivers");
        adminMenu.add(addDriversMenuItem);

        // ActionListener for Add Drivers menu item
        addDriversMenuItem.addActionListener(ae -> {
            try {
                new AddDrivers().setVisible(true);
            } catch(Exception e) {
                throw new RuntimeException(e);
            }
        });

        // Set size, visibility, and background color
        setSize(1950, 1090);
        setVisible(true);
        getContentPane().setBackground(Color.WHITE);
    }
}











src/hotel/Employee.java
package hotel;

import java.awt.*;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import net.proteanit.sql.DbUtils;

import javax.swing.JTable;
import java.sql.*;	
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Employee extends JFrame {
	Connection conn = null;
	private JPanel contentPane;
	private JTable table;
	private JLabel lblNewLabel;
	private JLabel lblJob;
	private JLabel lblName;
	private JLabel lblDepartment;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Employee frame = new Employee();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	public void close()
	{
		this.dispose();
	}
	/**
	 * Create the frame.
	 * @throws SQLException 
	 */
	public Employee() throws SQLException {
		//DBConnection = Javaconnect.getDBConnection();
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(430, 200, 1000, 600);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);


		// Center the frame on the screen
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int screenWidth = (int) screenSize.getWidth();
		int screenHeight = (int) screenSize.getHeight();
		int frameWidth = getWidth();
		int frameHeight = getHeight();

		int x = (screenWidth - frameWidth) / 2;
		int y = (screenHeight - frameHeight) / 2;

		setLocation(x, y);


		table = new JTable();
		table.setBounds(0, 34, 1000, 450);
		contentPane.add(table);
		
		JButton btnLoadData = new JButton("Load Data");
		btnLoadData.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try{
                                    DBConnection c = new DBConnection();
				String displayCustomersql = "select * from Employee";
				ResultSet rs = c.s.executeQuery(displayCustomersql);
				table.setModel(DbUtils.resultSetToTableModel(rs));
			}
				catch(Exception e1){
					e1.printStackTrace();
				}
			}
			
		});
		btnLoadData.setBounds(350, 500, 120, 30);
                btnLoadData.setBackground(Color.BLACK);
                btnLoadData.setForeground(Color.WHITE);
		contentPane.add(btnLoadData);
		
		JButton btnExit = new JButton("Back");
		btnExit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new Reception().setVisible(true);
                                setVisible(false);
			}
		});
		btnExit.setBounds(510, 500, 120, 30);
                btnExit.setBackground(Color.BLACK);
                btnExit.setForeground(Color.WHITE);
		contentPane.add(btnExit);
		
		lblNewLabel = new JLabel("Name");
		lblNewLabel.setBounds(41, 11, 46, 14);
		contentPane.add(lblNewLabel);
		
		lblJob = new JLabel("Age");
		lblJob.setBounds(159, 11, 46, 14);
		contentPane.add(lblJob);
		
		lblName = new JLabel("Gender");
		lblName.setBounds(273, 11, 46, 14);
		contentPane.add(lblName);
		
		lblDepartment = new JLabel("Job");
		lblDepartment.setBounds(416, 11, 86, 14);
		contentPane.add(lblDepartment);
                
                JLabel l1 = new JLabel("Salary");
		l1.setBounds(536, 11, 86, 14);
		contentPane.add(l1);
                
                JLabel l2 = new JLabel("Phone");
		l2.setBounds(656, 11, 86, 14);
		contentPane.add(l2);
                
                JLabel l3 = new JLabel("Aadhar");
		l3.setBounds(786, 11, 86, 14);
		contentPane.add(l3);
                
                JLabel l4 = new JLabel("Gmail");
		l4.setBounds(896, 11, 86, 14);
		contentPane.add(l4);
                
                getContentPane().setBackground(Color.WHITE);
	}
}
















src/hotel/Login.java
package hotel;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;

public class Login extends JFrame implements ActionListener {

    // Components for the login window
    JLabel l1, l2;
    JTextField t1;
    JPasswordField t2;
    JButton b1, b2;

    // Constructor to initialize the login window
    Login() {
        super("Login");

        // Set layout to null for manual component placement
        setLayout(null);

        // Username label
        l1 = new JLabel("Username");
        l1.setBounds(40, 20, 100, 30);
        add(l1);

        // Password label
        l2 = new JLabel("Password");
        l2.setBounds(40, 70, 100, 30);
        add(l2);

        // Username text field
        t1 = new JTextField();
        t1.setBounds(150, 20, 150, 30);
        add(t1);

        // Password field for secure input
        t2 = new JPasswordField();
        t2.setBounds(150, 70, 150, 30);
        add(t2);

        // Logo image
        ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/second.jpg"));
        Image i2 = i1.getImage().getScaledInstance(200, 200, Image.SCALE_DEFAULT);
        ImageIcon i3 = new ImageIcon(i2);
        JLabel l3 = new JLabel(i3);
        l3.setBounds(350, 10, 150, 150);
        add(l3);

        // Login button
        b1 = new JButton("Login");
        b1.setBounds(40, 140, 120, 30);
        b1.setFont(new Font("serif", Font.BOLD, 15));
        b1.addActionListener(this);
        b1.setBackground(Color.BLACK);
        b1.setForeground(Color.WHITE);
        add(b1);

        // Cancel button
        b2 = new JButton("Cancel");
        b2.setBounds(180, 140, 120, 30);
        b2.setFont(new Font("serif", Font.BOLD, 15));
        b2.setBackground(Color.BLACK);
        b2.setForeground(Color.WHITE);
        add(b2);

        b2.addActionListener(this);

        // Set background color
        getContentPane().setBackground(Color.WHITE);

        // Set window visibility and size
        setSize(600, 300);
        // Center the window on the screen
        setLocationRelativeTo(null);
        // Close the application when the window is closed
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        // Set window visibility after all components are added
        setVisible(true);
    }

    // ActionListener method to handle button clicks
    public void actionPerformed(ActionEvent ae) {
        if (ae.getSource() == b1) {
            try {
                // Establish database connection
                DBConnection c1 = new DBConnection();
                String u = t1.getText();
                String v = new String(t2.getPassword()); // Use getPassword() for security

                // Check login credentials
                String q = "select * from login where username='" + u + "' and password='" + v + "'";
                ResultSet rs = c1.s.executeQuery(q);

                if (rs.next()) {
                    // If login is successful, open Dashboard
                    new Dashboard().setVisible(true);
                    setVisible(false);
                } else {
                    // If login fails, show error message
                    JOptionPane.showMessageDialog(null, "Invalid login");
                    setVisible(false);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (ae.getSource() == b2) {
            // Close the application if Cancel button is clicked
            System.exit(0);
        }
    }

    // Main method to start the Login window
    public static void main(String[] arg) {
        new Login();
    }
}















src/hotel/MainScreen.java

package hotel;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class MainScreen extends JFrame implements ActionListener {

        JLabel l1;
        JButton b1;

        public MainScreen() {
                // Schedule the Swing components creation on the event dispatch thread
                SwingUtilities.invokeLater(() -> {
                        // Set frame properties
                        setSize(1366, 430);
                        setLayout(null);

                        // Load and set background image
                        ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/first.jpg"));
                        Image i3 = i1.getImage().getScaledInstance(1366, 390, Image.SCALE_DEFAULT);
                        ImageIcon i2 = new ImageIcon(i3);
                        l1 = new JLabel(i2);
                        l1.setBounds(0, 0, 1366, 390);
                        add(l1);

                        // Add label with text
                        JLabel lid = new JLabel("Hotel Management System");
                        lid.setBounds(30, 200, 1500, 100);
                        lid.setFont(new Font("serif", Font.PLAIN, 70));
                        lid.setForeground(Color.white);
                        l1.add(lid);

                        // Add "Next" button centered under the text
                        b1 = new JButton("Next");
                        b1.setBackground(Color.WHITE);
                        b1.setForeground(Color.BLACK);
                        b1.setBounds(600, 325, 150, 50); // Centered under the text
                        add(b1);

                        // Timer for the blinking effect
                        Timer timer = new Timer(500, new ActionListener() {
                                private boolean visible = true;

                                @Override
                                public void actionPerformed(ActionEvent e) {
                                        SwingUtilities.invokeLater(() -> {
                                                lid.setVisible(visible);
                                                b1.repaint(); // Force repaint of the button
                                        });
                                        visible = !visible;
                                }
                        });
                        timer.start();

                        // Add action listener for the button
                        b1.addActionListener(this);

                        // Center the JFrame on the screen
                        setLocationRelativeTo(null);

                        // Set frame visibility
                        setVisible(true);
                });
        }

        // Action performed when the button is clicked
        public void actionPerformed(ActionEvent ae) {
                // Open the Login window and hide the current window
                new Login().setVisible(true);
                this.setVisible(false);
        }

        // Main method to start the application
        public static void main(String[] args) {
                new MainScreen();
        }
}

















src/hotel/ManagerInfo.java
package hotel;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import net.proteanit.sql.DbUtils;

// Define ManagerInfo class as a subclass of JFrame
public class ManagerInfo extends JFrame {
	Connection conn = null;
	private JPanel contentPane;
	private JTable table;
	private JLabel lblNewLabel;
	private JLabel lblJob;
	private JLabel lblName;
	private JLabel lblDepartment;

	// Main method to launch the application
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ManagerInfo frame = new ManagerInfo();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	// Method to close the window
	public void close() {
		this.dispose();
	}

	// Constructor for ManagerInfo class
	public ManagerInfo() throws SQLException {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(430, 200, 1000, 600);

		// Create content pane
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		// Center the frame on the screen
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int screenWidth = (int) screenSize.getWidth();
		int screenHeight = (int) screenSize.getHeight();
		int frameWidth = getWidth();
		int frameHeight = getHeight();
		int x = (screenWidth - frameWidth) / 2;
		int y = (screenHeight - frameHeight) / 2;
		setLocation(x, y);

		// Create table to display data
		table = new JTable();
		table.setBounds(0, 34, 1000, 450);
		contentPane.add(table);

		// Button to load data from the database
		JButton btnLoadData = new JButton("Load Data");
		btnLoadData.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					// Establish database connection
					DBConnection c = new DBConnection();
					// SQL query to fetch manager information
					String displayCustomersql = "select * from Employee where job = 'Manager'";
					ResultSet rs = c.s.executeQuery(displayCustomersql);
					// Set table model with retrieved data
					table.setModel(DbUtils.resultSetToTableModel(rs));
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}
		});
		btnLoadData.setBounds(350, 500, 120, 30);
		btnLoadData.setBackground(Color.BLACK);
		btnLoadData.setForeground(Color.WHITE);
		contentPane.add(btnLoadData);

		// Button to navigate back to Reception window
		JButton btnExit = new JButton("Back");
		btnExit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new Reception().setVisible(true);
				setVisible(false);
			}
		});
		btnExit.setBounds(510, 500, 120, 30);
		btnExit.setBackground(Color.BLACK);
		btnExit.setForeground(Color.WHITE);
		contentPane.add(btnExit);

		// Labels for table columns
		lblNewLabel = new JLabel("Name");
		lblNewLabel.setBounds(41, 11, 46, 14);
		contentPane.add(lblNewLabel);

		lblJob = new JLabel("Age");
		lblJob.setBounds(159, 11, 46, 14);
		contentPane.add(lblJob);

		lblName = new JLabel("Gender");
		lblName.setBounds(273, 11, 46, 14);
		contentPane.add(lblName);

		lblDepartment = new JLabel("Job");
		lblDepartment.setBounds(416, 11, 86, 14);
		contentPane.add(lblDepartment);

		// Additional labels for table columns
		JLabel l1 = new JLabel("Salary");
		l1.setBounds(536, 11, 86, 14);
		contentPane.add(l1);

		JLabel l2 = new JLabel("Phone");
		l2.setBounds(656, 11, 86, 14);
		contentPane.add(l2);

		JLabel l3 = new JLabel("Personal Identification Number");
		l3.setBounds(786, 11, 86, 14);
		contentPane.add(l3);

		JLabel l4 = new JLabel("Gmail");
		l4.setBounds(896, 11, 86, 14);
		contentPane.add(l4);

		// Set background color
		getContentPane().setBackground(Color.WHITE);
	}
}














src/hotel/NewCustomer.java
package hotel;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class NewCustomer extends JFrame {
	Connection conn = null;
	PreparedStatement pst = null;
	private JPanel contentPane;
	private JTextField t1, t2, t3, t4, t5, t6;
	JComboBox comboBox;
	JRadioButton r1, r2;
	Choice c1;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		// Launch the application on the event dispatch thread
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					NewCustomer frame = new NewCustomer();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public NewCustomer() throws SQLException {
		// Set frame dimensions and initialize content pane
		setBounds(530, 200, 850, 550);
		contentPane = new JPanel();
		setContentPane(contentPane);
		contentPane.setLayout(null);

		// Center the frame on the screen
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int screenWidth = (int) screenSize.getWidth();
		int screenHeight = (int) screenSize.getHeight();
		int frameWidth = getWidth();
		int frameHeight = getHeight();
		int x = (screenWidth - frameWidth) / 2;
		int y = (screenHeight - frameHeight) / 2;
		setLocation(x, y);

		// Add an image
		ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/fifth.png"));
		Image i3 = i1.getImage().getScaledInstance(300, 400, Image.SCALE_DEFAULT);
		ImageIcon i2 = new ImageIcon(i3);
		JLabel l1 = new JLabel(i2);
		l1.setBounds(480, 10, 300, 500);
		add(l1);

		// Add labels and input fields
		JLabel lblName = new JLabel("New Customer Form");
		lblName.setFont(new Font("Yu Mincho", Font.PLAIN, 20));
		lblName.setBounds(118, 11, 260, 53);
		contentPane.add(lblName);

		// Add ID label and combo box
		JLabel lblId = new JLabel("ID :");
		lblId.setBounds(35, 76, 200, 14);
		contentPane.add(lblId);
		comboBox = new JComboBox(new String[]{"Passport", "Personal Identification Number\t", "Voter Id", "Driving license"});
		comboBox.setBounds(271, 73, 150, 20);
		contentPane.add(comboBox);

		// Add Number label and text field
		JLabel l2 = new JLabel("Number :");
		l2.setBounds(35, 111, 200, 14);
		contentPane.add(l2);
		t1 = new JTextField();
		t1.setBounds(271, 111, 150, 20);
		contentPane.add(t1);
		t1.setColumns(10);

		// Add Name label and text field
		JLabel lblName_1 = new JLabel("Name :");
		lblName_1.setBounds(35, 151, 200, 14);
		contentPane.add(lblName_1);
		t2 = new JTextField();
		t2.setBounds(271, 151, 150, 20);
		contentPane.add(t2);
		t2.setColumns(10);

		// Add Gender label and radio buttons
		JLabel lblGender = new JLabel("Gender :");
		lblGender.setBounds(35, 191, 200, 14);
		contentPane.add(lblGender);
		r1 = new JRadioButton("Male");
		r1.setFont(new Font("Raleway", Font.BOLD, 14));
		r1.setBackground(Color.WHITE);
		r1.setBounds(271, 191, 80, 12);
		add(r1);
		r2 = new JRadioButton("Female");
		r2.setFont(new Font("Raleway", Font.BOLD, 14));
		r2.setBackground(Color.WHITE);
		r2.setBounds(350, 191, 100, 12);
		add(r2);

		// Add Country label and text field
		JLabel lblCountry = new JLabel("Country :");
		lblCountry.setBounds(35, 231, 200, 14);
		contentPane.add(lblCountry);
		t3 = new JTextField();
		t3.setBounds(271, 231, 150, 20);
		contentPane.add(t3);
		t3.setColumns(10);

		// Add Allocated Room Number label and choice component
		JLabel lblReserveRoomNumber = new JLabel("Allocated Room Number :");
		lblReserveRoomNumber.setBounds(35, 274, 200, 14);
		contentPane.add(lblReserveRoomNumber);
		c1 = new Choice();
		try {
			DBConnection c = new DBConnection();
			ResultSet rs = c.s.executeQuery("select * from room");
			while (rs.next()) {
				c1.add(rs.getString("room_number"));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		c1.setBounds(271, 274, 150, 20);
		contentPane.add(c1);

		// Add Checked-In label and text field
		JLabel lblCheckInStatus = new JLabel("Checked-In :");
		lblCheckInStatus.setBounds(35, 316, 200, 14);
		contentPane.add(lblCheckInStatus);
		t5 = new JTextField();
		t5.setBounds(271, 316, 150, 20);
		contentPane.add(t5);
		t5.setColumns(10);

		// Add Deposit label
		JLabel lblDeposit = new JLabel("Deposit:");
		lblDeposit.setBounds(35, 359, 200, 14);
		contentPane.add(lblDeposit);

// Add Deposit text field
		t6 = new JTextField();
		t6.setBounds(271, 359, 150, 20);
		contentPane.add(t6);
		t6.setColumns(10);

// Add button to submit the form
		JButton btnNewButton = new JButton("Add");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// Establish database connection
				DBConnection c = new DBConnection();
				String radio = null;

				// Determine selected gender
				if (r1.isSelected()) {
					radio = "Male";
				} else if (r2.isSelected()) {
					radio = "Female";
				}

				// Get selected room number
				String s6 = c1.getSelectedItem();

				try {
					// Retrieve form inputs
					String s1 = (String) comboBox.getSelectedItem();
					String s2 = t1.getText();
					String s3 = t2.getText();
					String s4 = radio;
					String s5 = t3.getText();
					String s7 = t5.getText();
					String s8 = t6.getText();

					// Construct SQL queries
					String q1 = "insert into customer values('" + s1 + "','" + s2 + "','" + s3 + "','" + s4 + "','" + s5 + "','" + s6 + "','" + s7 + "','" + s8 + "')";
					String q2 = "update room set availability = 'Occupied' where room_number = " + s6;

					// Execute SQL queries
					c.s.executeUpdate(q1);
					c.s.executeUpdate(q2);

					// Display success message
					JOptionPane.showMessageDialog(null, "Data Inserted Successfully");

					// Redirect to Reception window
					new Reception().setVisible(true);
					setVisible(false);
				} catch (SQLException e1) {
					System.out.println(e1.getMessage());
				} catch (NumberFormatException s) {
					JOptionPane.showMessageDialog(null, "Please enter a valid Number");
				}
			}
		});
		btnNewButton.setBounds(100, 430, 120, 30);
		btnNewButton.setBackground(Color.BLACK);
		btnNewButton.setForeground(Color.WHITE);
		contentPane.add(btnNewButton);

// Add button to navigate back to Reception window
		JButton btnExit = new JButton("Back");
		btnExit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new Reception().setVisible(true);
				setVisible(false);
			}
		});
		btnExit.setBounds(260, 430, 120, 30);
		btnExit.setBackground(Color.BLACK);
		btnExit.setForeground(Color.WHITE);
		contentPane.add(btnExit);

		// Set background color
		getContentPane().setBackground(Color.WHITE);
	}
}














src/hotel/PickUp.java
package hotel;

import net.proteanit.sql.DbUtils;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.sql.*;

// Class for handling pick-up service
public class PickUp extends JFrame {
	// Database connection variables
	Connection conn = null;
	PreparedStatement pst = null;
	ResultSet rs = null;

	// GUI components
	private JPanel contentPane;
	private JTable table;
	private Choice c1;


	// Main method to run the application
	public static void main(String[] args) {
		// Running the application
		EventQueue.invokeLater(() -> {
			try {
				// Create a new instance of the PickUp frame
				PickUp frame = new PickUp();
				// Set the frame to be visible
				frame.setVisible(true);
			} catch (Exception e) {
				// Print stack trace in case of an exception
				e.printStackTrace();
			}
		});
	}


	// Method to close the frame
	public void close() {
		this.dispose();
	}


	// Constructor
	public PickUp() {
		// Initialize the frame
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(530, 200, 800, 600);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		// Center the frame on the screen
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int screenWidth = (int) screenSize.getWidth();
		int screenHeight = (int) screenSize.getHeight();
		int frameWidth = getWidth();
		int frameHeight = getHeight();
		int x = (screenWidth - frameWidth) / 2;
		int y = (screenHeight - frameHeight) / 2;
		setLocation(x, y);

		// Add labels and components to the frame
		JLabel lblPickUpService = new JLabel("Pick Up Service");
		lblPickUpService.setFont(new Font("Tahoma", Font.PLAIN, 20));
		lblPickUpService.setBounds(90, 11, 158, 25);
		contentPane.add(lblPickUpService);

		JLabel lblTypeOfCar = new JLabel("Type of Car");
		lblTypeOfCar.setBounds(32, 97, 89, 14);
		contentPane.add(lblTypeOfCar);

		c1 = new Choice();
		try {
			DBConnection c = new DBConnection();
			ResultSet rs = c.s.executeQuery("select * from driver");
			while (rs.next()) {
				c1.add(rs.getString("brand"));
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		c1.setBounds(123, 94, 150, 25);
		contentPane.add(c1);

		// Add a button to display information
		JButton btnRegister = new JButton("Display");
		btnRegister.addActionListener(e -> {
			String SQL = "select * from driver where brand = '" + c1.getSelectedItem() + "'";
			try {
				DBConnection c = new DBConnection();
				rs = c.s.executeQuery(SQL);
				table.setModel(DbUtils.resultSetToTableModel(rs));
			} catch (SQLException ss) {
				ss.printStackTrace();
			}
		});
		btnRegister.setBounds(200, 500, 120, 30);
		btnRegister.setBackground(Color.BLACK);
		btnRegister.setForeground(Color.WHITE);
		contentPane.add(btnRegister);

		// Add a button to go back to the previous screen
		JButton btnExit = new JButton("Back");
		btnExit.addActionListener(e -> {
			new Reception().setVisible(true);
			setVisible(false);
		});
		btnExit.setBounds(420, 500, 120, 30);
		btnExit.setBackground(Color.BLACK);
		btnExit.setForeground(Color.WHITE);
		contentPane.add(btnExit);

		// Add a table to display information
		table = new JTable();
		table.setBounds(0, 233, 800, 250);
		contentPane.add(table);

		// Add labels for table columns
		JLabel lblInfo = new JLabel("Name");
		lblInfo.setBounds(24, 208, 46, 14);
		contentPane.add(lblInfo);

		JLabel lblNewLabel = new JLabel("Age");
		lblNewLabel.setBounds(165, 208, 46, 14);
		contentPane.add(lblNewLabel);

		JLabel lblGender = new JLabel("Gender");
		lblGender.setBounds(264, 208, 46, 14);
		contentPane.add(lblGender);

		JLabel lblTypeOfDriver = new JLabel("Company");
		lblTypeOfDriver.setBounds(366, 208, 80, 14);
		contentPane.add(lblTypeOfDriver);

		JLabel lblDateOfThe = new JLabel("Brand");
		lblDateOfThe.setBounds(486, 208, 105, 14);
		contentPane.add(lblDateOfThe);

		JLabel lblAirport = new JLabel("Available");
		lblAirport.setBounds(600, 208, 86, 14);
		contentPane.add(lblAirport);

		JLabel lblAvailable = new JLabel("Location");
		lblAvailable.setBounds(700, 208, 73, 14);
		contentPane.add(lblAvailable);

		// Set the background color
		getContentPane().setBackground(Color.WHITE);
	}
}







package hotel;

import javax.swing.*;
import java.sql.*;
import java.awt.event.*;
import java.awt.*;

/**
 * The Reception class represents the main window for hotel reception management.
 */
public class Reception extends JFrame {

	// Panel to hold the components
	private final JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		new Reception();
	}

	/**
	 * Create the frame.
	 */
	public Reception() {

		// Set frame properties
		setBounds(530, 200, 850, 570);
		contentPane = new JPanel();
		setContentPane(contentPane);
		contentPane.setLayout(null);


		// Center the frame on the screen
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int screenWidth = (int) screenSize.getWidth();
		int screenHeight = (int) screenSize.getHeight();
		int frameWidth = getWidth();
		int frameHeight = getHeight();

		int x = (screenWidth - frameWidth) / 2;
		int y = (screenHeight - frameHeight) / 2;

		setLocation(x, y);



		// Load and set background image
		ImageIcon backgroundIcon = new ImageIcon(ClassLoader.getSystemResource("icons/fourth.jpg"));
		Image backgroundImg = backgroundIcon.getImage().getScaledInstance(500, 500, Image.SCALE_DEFAULT);
		ImageIcon backgroundImgIcon = new ImageIcon(backgroundImg);
		JLabel backgroundLabel = new JLabel(backgroundImgIcon);
		backgroundLabel.setBounds(250, 30, 500, 470);
		add(backgroundLabel);

		// Create buttons with specific text, Y-coordinate, and ActionListener
		createButton("New Customer Form", 10, 30, e -> {
			try {
				// Open the NewCustomer window and hide the current window
				NewCustomer custom = new NewCustomer();
				custom.setVisible(true);
				setVisible(false);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});

		createButton("Room", 10, 70, e -> {
			try {
				// Open the Room window and hide the current window
				Room room = new Room();
				room.setVisible(true);
				setVisible(false);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});

		createButton("All Employee Info", 10, 150, e -> {
			try {
				// Open the Employee window and hide the current window
				Employee em = new Employee();
				em.setVisible(true);
				setVisible(false);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});

		createButton("Customer Info", 10, 190, e -> {
			try {
				// Open the CustomerInfo window and hide the current window
				CustomerInfo customer = new CustomerInfo();
				customer.setVisible(true);
				setVisible(false);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});

		createButton("Manager Info", 10, 230, e -> {
			try {
				// Open the ManagerInfo window and hide the current window
				ManagerInfo mana = new ManagerInfo();
				mana.setVisible(true);
				setVisible(false);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});

		createButton("Check Out", 10, 270, e -> {
			try {
				// Open the CheckOut window and hide the current window
				CheckOut check = new CheckOut();
				check.setVisible(true);
				setVisible(false);
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
		});

		createButton("Update Check Status", 10, 310, e -> {
			try {
				// Open the UpdateCheck window and hide the current window
				UpdateCheck update = new UpdateCheck();
				update.setVisible(true);
				setVisible(false);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});

		createButton("Update Room Status", 10, 350, e -> {
			try {
				// Open the UpdateRoom window and hide the current window
				UpdateRoom room = new UpdateRoom();
				room.setVisible(true);
				setVisible(false);
			} catch (Exception s) {
				s.printStackTrace();
			}
		});

		createButton("Pick up Service", 10, 390, e -> {
			try {
				// Open the PickUp window and hide the current window
				PickUp pick = new PickUp();
				pick.setVisible(true);
				setVisible(false);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});

		createButton("Search Room", 10, 430, e -> {
			try {
				// Open the SearchRoom window and hide the current window
				SearchRoom search = new SearchRoom();
				search.setVisible(true);
				setVisible(false);
			} catch (Exception ss) {
				ss.printStackTrace();
			}
		});

		createButton("Log Out", 10, 470, e -> {
			try {
				// Open the Login window and hide the current window
				new Login().setVisible(true);
				setVisible(false);
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		});

		// Set the background color of the content pane
		getContentPane().setBackground(Color.WHITE);

		// Set frame visibility
		setVisible(true);
	}


	/**
	 * Helper method to create buttons with a specific text, Y-coordinate, and ActionListener.
	 *
	 * @param text      The text displayed on the button
	 * @param x         The X-coordinate of the button
	 * @param y         The Y-coordinate of the button
	 * @param listener  The ActionListener for the button
	 */
	private void createButton(String text, final int x, int y, ActionListener listener) {
		JButton button = new JButton(text);
		button.addActionListener(listener);
		button.setBounds(x, y, 200, 30);
		button.setBackground(Color.BLACK);
		button.setForeground(Color.WHITE);
		contentPane.add(button);
	}
}










src/hotel/Room.java
package hotel;

import net.proteanit.sql.DbUtils;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Room extends JFrame {
	private JTable table;
	private JLabel lblAvailability;
	private JLabel lblCleanStatus;
	private JLabel lblNewLabel;
	private JLabel lblNewLabel_1;
	private JLabel lblRoomNumber;
	private JLabel lblId;

	public Room() throws SQLException {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(450, 200, 1100, 600);
		JPanel contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);


		// Center the frame on the screen
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int screenWidth = (int) screenSize.getWidth();
		int screenHeight = (int) screenSize.getHeight();
		int frameWidth = getWidth();
		int frameHeight = getHeight();

		int x = (screenWidth - frameWidth) / 2;
		int y = (screenHeight - frameHeight) / 2;

		setLocation(x, y);



		// Load image
		ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/eight.jpg"));
		Image i3 = i1.getImage().getScaledInstance(600, 600, Image.SCALE_DEFAULT);
		ImageIcon i2 = new ImageIcon(i3);
		JLabel l1 = new JLabel(i2);
		l1.setBounds(500, 0, 600, 600);
		add(l1);

		// Create table
		table = new JTable();
		table.setBounds(0, 40, 500, 400);
		contentPane.add(table);

		// Load data button
		JButton btnLoadData = new JButton("Load Data");
		btnLoadData.addActionListener(e -> loadData());
		btnLoadData.setBounds(100, 470, 120, 30);
		btnLoadData.setBackground(Color.BLACK);
		btnLoadData.setForeground(Color.WHITE);
		contentPane.add(btnLoadData);

		// Back button
		JButton btnNewButton = new JButton("Back");
		btnNewButton.addActionListener(e -> {
			new Reception().setVisible(true);
			setVisible(false);
		});
		btnNewButton.setBounds(290, 470, 120, 30);
		btnNewButton.setBackground(Color.BLACK);
		btnNewButton.setForeground(Color.WHITE);
		contentPane.add(btnNewButton);

		// Labels
		lblAvailability = new JLabel("Availability");
		lblAvailability.setBounds(119, 15, 69, 14);
		contentPane.add(lblAvailability);

		lblCleanStatus = new JLabel("Clean Status");
		lblCleanStatus.setBounds(216, 15, 76, 14);
		contentPane.add(lblCleanStatus);

		lblNewLabel = new JLabel("Price");
		lblNewLabel.setBounds(330, 15, 46, 14);
		contentPane.add(lblNewLabel);

		lblNewLabel_1 = new JLabel("Bed Type");
		lblNewLabel_1.setBounds(417, 15, 76, 14);
		contentPane.add(lblNewLabel_1);

		lblId = new JLabel("Room Number");
		lblId.setBounds(12, 15, 90, 14);
		contentPane.add(lblId);

		getContentPane().setBackground(Color.WHITE);
	}

	// Method to load data into the table
	private void loadData() {
		try {
			DBConnection c = new DBConnection();
			String displayCustomersql = "select * from Room";
			ResultSet rs = c.s.executeQuery(displayCustomersql);
			table.setModel(DbUtils.resultSetToTableModel(rs));
		} catch (Exception e1) {
			e1.printStackTrace();
		}
	}

	public static void main(String[] args) {
		// Run the application
		EventQueue.invokeLater(() -> {
			try {
				Room frame = new Room();
				frame.setVisible(true);
			} catch (Exception e) {
				e.printStackTrace();
			}
		});
	}
}













src/hotel/SearchRoom.java
package hotel;

import net.proteanit.sql.DbUtils;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

// Class for searching for available rooms
public class SearchRoom extends JFrame {
	// Database connection variables
	Connection conn = null;
	PreparedStatement pst = null;
	ResultSet rs = null;

	// GUI components
	private JPanel contentPane;
	private JTextField txt_Type;
	private JTable table;
	private Choice c1;

	// Main method
	public static void main(String[] args) {
		EventQueue.invokeLater(() -> {
			try {
				SearchRoom frame = new SearchRoom();
				frame.setVisible(true);
			} catch (Exception e) {
				e.printStackTrace();
			}
		});
	}

	// Method to close the frame
	public void close() {
		this.dispose();
	}

	// Constructor
	public SearchRoom() throws SQLException {
		// Setting up the frame
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(530, 200, 700, 500);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		// Centering the frame on the screen
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int screenWidth = (int) screenSize.getWidth();
		int screenHeight = (int) screenSize.getHeight();
		int frameWidth = getWidth();
		int frameHeight = getHeight();
		int x = (screenWidth - frameWidth) / 2;
		int y = (screenHeight - frameHeight) / 2;
		setLocation(x, y);

		// Adding labels and components to the frame
		JLabel lblSearchForRoom = new JLabel("Search For Room");
		lblSearchForRoom.setFont(new Font("Tahoma", Font.PLAIN, 20));
		lblSearchForRoom.setBounds(250, 11, 186, 31);
		contentPane.add(lblSearchForRoom);

		JLabel lblRoomAvailable = new JLabel("Room Bed Type:");
		lblRoomAvailable.setBounds(50, 73, 96, 14);
		contentPane.add(lblRoomAvailable);

		JLabel lblRoomType = new JLabel("Room Number");
		lblRoomType.setBounds(23, 162, 96, 14);
		contentPane.add(lblRoomType);

		JLabel lblRoomAvailable_1 = new JLabel("Availability");
		lblRoomAvailable_1.setBounds(175, 162, 120, 14);
		contentPane.add(lblRoomAvailable_1);

		JLabel lblPrice_1 = new JLabel("Price");
		lblPrice_1.setBounds(458, 162, 46, 14);
		contentPane.add(lblPrice_1);

		JLabel l1 = new JLabel("Bed Type");
		l1.setBounds(580, 162, 96, 14);
		contentPane.add(l1);

		JCheckBox checkRoom = new JCheckBox("Only display Available");
		checkRoom.setBounds(400, 69, 205, 23);
		checkRoom.setBackground(Color.WHITE);
		contentPane.add(checkRoom);

		c1 = new Choice();
		c1.add("Single Bed");
		c1.add("Double Bed");
		c1.setBounds(153, 70, 120, 20);
		contentPane.add(c1);

		// Button to search for rooms
		JButton btnSearch = new JButton("Search");
		btnSearch.addActionListener(e -> {
			String SQL = "select * from Room where bed_type = '" + c1.getSelectedItem() + "'";
			String SQL2 = "select * from Room where availability = 'Available' AND bed_type = '" + c1.getSelectedItem() + "'";
			try {
				DBConnection c = new DBConnection();
				rs = c.s.executeQuery(SQL);
				table.setModel(DbUtils.resultSetToTableModel(rs));

				if (checkRoom.isSelected()) {
					rs = c.s.executeQuery(SQL2);
					table.setModel(DbUtils.resultSetToTableModel(rs));
				}
			} catch (SQLException ss) {
				ss.printStackTrace();
			}
		});
		btnSearch.setBounds(200, 400, 120, 30);
		btnSearch.setBackground(Color.BLACK);
		btnSearch.setForeground(Color.WHITE);
		contentPane.add(btnSearch);

		// Button to go back to reception
		JButton btnExit = new JButton("Back");
		btnExit.addActionListener(e -> {
			new Reception().setVisible(true);
			setVisible(false);
		});
		btnExit.setBounds(380, 400, 120, 30);
		btnExit.setBackground(Color.BLACK);
		btnExit.setForeground(Color.WHITE);
		contentPane.add(btnExit);

		table = new JTable();
		table.setBounds(0, 187, 700, 300);
		contentPane.add(table);

		JLabel lblCleanStatus = new JLabel("Clean Status");
		lblCleanStatus.setBounds(306, 162, 96, 14);
		contentPane.add(lblCleanStatus);

		// Setting background color
		getContentPane().setBackground(Color.WHITE);
	}
}















src/hotel/UpdateCheck.java
package hotel;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;

import javax.swing.*;
import javax.swing.border.EmptyBorder;

// Define UpdateCheck class as a subclass of JFrame
public class UpdateCheck extends JFrame {
	Connection conn = null;
	PreparedStatement pst = null;
	private JPanel contentPane;
	private JTextField txt_ID;
	private JTextField txt_Status;
	private JTextField txt_Date;
	private JTextField txt_Time;
	private JTextField txt_Payment;

	Choice c1, c2;

	// Main method to launch the application
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					UpdateCheck frame = new UpdateCheck();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	// Method to close the window
	public void close() {
		this.dispose();
	}

	// Constructor for UpdateCheck class
	public UpdateCheck() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(500, 200, 950, 500);

		// Create content pane
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		// Center the frame on the screen
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int screenWidth = (int) screenSize.getWidth();
		int screenHeight = (int) screenSize.getHeight();
		int frameWidth = getWidth();
		int frameHeight = getHeight();
		int x = (screenWidth - frameWidth) / 2;
		int y = (screenHeight - frameHeight) / 2;
		setLocation(x, y);

		// Load image icon for decoration
		ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/nine.jpg"));
		JLabel l1 = new JLabel(i1);
		l1.setBounds(450, 70, 476, 270);
		add(l1);

		// Label for Check-In Details title
		JLabel lblUpdateCheckStatus = new JLabel("Check-In Details");
		lblUpdateCheckStatus.setFont(new Font("Tahoma", Font.PLAIN, 20));
		lblUpdateCheckStatus.setBounds(124, 11, 222, 25);
		contentPane.add(lblUpdateCheckStatus);

		// Label and choice for selecting customer ID
		JLabel lblNewLabel = new JLabel("ID:");
		lblNewLabel.setBounds(25, 88, 46, 14);
		contentPane.add(lblNewLabel);

		c1 = new Choice();
		try {
			// Fetch customer IDs from the database
			DBConnection c = new DBConnection();
			ResultSet rs = c.s.executeQuery("select * from customer");
			while (rs.next()) {
				c1.add(rs.getString("number"));
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		c1.setBounds(248, 85, 140, 20);
		contentPane.add(c1);

		// Labels for various details
		JLabel lblNewLabel_1 = new JLabel("Room Number :");
		lblNewLabel_1.setBounds(25, 129, 107, 14);
		contentPane.add(lblNewLabel_1);

		JLabel lblNewLabel_2 = new JLabel("Name : ");
		lblNewLabel_2.setBounds(25, 174, 97, 14);
		contentPane.add(lblNewLabel_2);

		JLabel lblNewLabel_3 = new JLabel("Checked-in :");
		lblNewLabel_3.setBounds(25, 216, 107, 14);
		contentPane.add(lblNewLabel_3);

		JLabel lblNewLabel_4 = new JLabel("Amount Paid (Rs) : ");
		lblNewLabel_4.setBounds(25, 261, 107, 14);
		contentPane.add(lblNewLabel_4);

		JLabel lblNewLabel_5 = new JLabel("Pending Amount (Rs) : ");
		lblNewLabel_5.setBounds(25, 302, 150, 14);
		contentPane.add(lblNewLabel_5);

		// Text fields for user input
		txt_ID = new JTextField();
		txt_ID.setBounds(248, 126, 140, 20);
		contentPane.add(txt_ID);

		txt_Status = new JTextField();
		txt_Status.setBounds(248, 171, 140, 20);
		contentPane.add(txt_Status);
		txt_Status.setColumns(10);

		txt_Date = new JTextField();
		txt_Date.setBounds(248, 216, 140, 20);
		contentPane.add(txt_Date);
		txt_Date.setColumns(10);

		txt_Time = new JTextField();
		txt_Time.setBounds(248, 258, 140, 20);
		contentPane.add(txt_Time);
		txt_Time.setColumns(10);

		txt_Payment = new JTextField();
		txt_Payment.setBounds(248, 299, 140, 20);
		contentPane.add(txt_Payment);
		txt_Payment.setColumns(10);

		// Button to update customer details
		JButton btnUpdate = new JButton("Update");
		btnUpdate.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent ae) {
				try {
					// Update customer details in the database
					DBConnection c = new DBConnection();
					String s1 = c1.getSelectedItem();
					String s2 = txt_ID.getText(); // Room number
					String s3 = txt_Status.getText(); // Name
					String s4 = txt_Date.getText(); // Checked-in status
					String s5 = txt_Time.getText(); // Amount paid
					c.s.executeUpdate("update customer set room_number = '" + s2 + "', name = '" + s3 + "', status = '" + s4 + "', deposit = '" + s5 + "' where number = '" + s1 + "'");
					JOptionPane.showMessageDialog(null, "Data Updated Successfully");
					new Reception().setVisible(true);
					setVisible(false);
				} catch (Exception ee) {
					System.out.println(ee);
				}
			}
		});
		btnUpdate.setBounds(168, 378, 89, 23);
		btnUpdate.setBackground(Color.BLACK);
		btnUpdate.setForeground(Color.WHITE);
		contentPane.add(btnUpdate);

		// Button to navigate back to Reception window
		JButton btnExit = new JButton("Back");
		btnExit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new Reception().setVisible(true);
				setVisible(false);
			}
		});
		btnExit.setBounds(281, 378, 89, 23);
		btnExit.setBackground(Color.BLACK);
		btnExit.setForeground(Color.WHITE);
		contentPane.add(btnExit);


		// Button to retrieve customer details
		JButton btnAdd = new JButton("Check");
		btnAdd.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					String s1 = c1.getSelectedItem();
					DBConnection c = new DBConnection();
					ResultSet rs1 = c.s.executeQuery("select * from customer where number = " + s1);

					// Populate text fields with fetched details
					while (rs1.next()) {
						txt_ID.setText(rs1.getString("room_number"));
						txt_Status.setText(rs1.getString("name"));
						txt_Date.setText(rs1.getString("status"));
						txt_Time.setText(rs1.getString("deposit"));
					}

					// Calculate pending amount
					try {
						String total = "";
						ResultSet rs2 = c.s.executeQuery("select * from room where room_number = " + txt_ID.getText());
						while (rs2.next()) {
							total = rs2.getString("price");
						}
						String paid = txt_Time.getText();
						int pending = Integer.parseInt(total) - Integer.parseInt(paid);
						txt_Payment.setText(Integer.toString(pending));
					} catch (Exception ee) {
						throw new RuntimeException(ee);
					}
				} catch (Exception ee) {
					throw new RuntimeException(ee);
				}
			}
		});
		btnAdd.setBounds(56, 378, 89, 23);
		btnAdd.setBackground(Color.BLACK);
		btnAdd.setForeground(Color.WHITE);
		contentPane.add(btnAdd);

		// Set background color of content pane
		getContentPane().setBackground(Color.WHITE);
	}
}















src/hotel/UpdateRoom.java
package hotel;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.sql.ResultSet;

/**
 * This class provides functionality to update room status in the hotel management system.
 */
public class UpdateRoom extends JFrame {
	private JPanel contentPane;
	private JTextField txt_Ava;
	private JTextField txt_Status;
	private JTextField txt_Room;
	private Choice c1;

	/**
	 * Launches the UpdateRoom frame.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(() -> {
			try {
				UpdateRoom frame = new UpdateRoom();
				frame.setVisible(true);
			} catch (Exception e) {
				e.printStackTrace();
			}
		});
	}

	/**
	 * Closes the current frame.
	 */
	public void close() {
		this.dispose();
	}

	/**
	 * Creates the frame for updating room status.
	 */
	public UpdateRoom() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(530, 200, 1000, 450);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		// Center the frame on the screen
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int screenWidth = (int) screenSize.getWidth();
		int screenHeight = (int) screenSize.getHeight();
		int frameWidth = getWidth();
		int frameHeight = getHeight();
		int x = (screenWidth - frameWidth) / 2;
		int y = (screenHeight - frameHeight) / 2;
		setLocation(x, y);

		// Add background image
		ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/seventh.jpg"));
		Image i3 = i1.getImage().getScaledInstance(550, 250, Image.SCALE_DEFAULT);
		ImageIcon i2 = new ImageIcon(i3);
		JLabel l1 = new JLabel(i2);
		l1.setBounds(400, 80, 600, 250);
		add(l1);

		// Label for the title
		JLabel lblUpdateRoomStatus = new JLabel("Update Room Status");
		lblUpdateRoomStatus.setFont(new Font("Tahoma", Font.PLAIN, 20));
		lblUpdateRoomStatus.setBounds(85, 11, 206, 34);
		contentPane.add(lblUpdateRoomStatus);

		// Label and choice for selecting guest ID
		JLabel lblNewLabel = new JLabel("Guest ID:");
		lblNewLabel.setBounds(27, 87, 90, 14);
		contentPane.add(lblNewLabel);
		c1 = new Choice();
		try {
			DBConnection c = new DBConnection();
			ResultSet rs = c.s.executeQuery("select * from customer");
			while (rs.next()) {
				c1.add(rs.getString("number"));
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		c1.setBounds(160, 84, 140, 20);
		contentPane.add(c1);

		// Labels and text fields for displaying and updating room availability and clean status
		JLabel lblAvailability = new JLabel("Availability:");
		lblAvailability.setBounds(27, 187, 90, 14);
		contentPane.add(lblAvailability);
		JLabel lblCleanStatus = new JLabel("Clean Status:");
		lblCleanStatus.setBounds(27, 240, 90, 14);
		contentPane.add(lblCleanStatus);
		txt_Ava = new JTextField();
		txt_Ava.setBounds(160, 184, 140, 20);
		contentPane.add(txt_Ava);
		txt_Ava.setColumns(10);
		txt_Status = new JTextField();
		txt_Status.setBounds(160, 237, 140, 20);
		contentPane.add(txt_Status);
		txt_Status.setColumns(10);

		// Text field for displaying the room number
		txt_Room = new JTextField();
		txt_Room.setBounds(160, 130, 140, 20);
		contentPane.add(txt_Room);
		txt_Room.setColumns(10);



		// Button to check and display room details
		JButton b1 = new JButton("Check");
		b1.addActionListener(e -> {
			try {
				String s1 = c1.getSelectedItem();
				DBConnection c = new DBConnection();
				ResultSet rs1 = c.s.executeQuery("select * from customer where number = " + s1);
				while (rs1.next()) {
					txt_Room.setText(rs1.getString("room_number"));
				}
			} catch (Exception ee) {
				throw new RuntimeException(ee);
			}
			try {
				DBConnection c = new DBConnection();
				ResultSet rs2 = c.s.executeQuery("select * from room where room_number = " + txt_Room.getText());
				while (rs2.next()) {
					txt_Ava.setText(rs2.getString("availability"));
					txt_Status.setText(rs2.getString("clean_status"));
				}
			} catch (Exception ee) {
				throw new RuntimeException(ee);
			}
		});
		b1.setBounds(120, 315, 89, 23);
		b1.setBackground(Color.BLACK);
		b1.setForeground(Color.WHITE);
		contentPane.add(b1);



		// Button to update room clean status
		JButton btnUpdate = new JButton("Update");
		btnUpdate.addActionListener(e -> {
			try {
				// Establish database connection
				DBConnection c = new DBConnection();
				// Construct SQL query to update room clean status
				String str = "update room set clean_status = '" + txt_Status.getText() + "' where room_number = " + txt_Room.getText();
				// Execute the update query
				c.s.executeUpdate(str);
				// Show message for successful update
				JOptionPane.showMessageDialog(null, "Update Successful");
				// Navigate back to the reception screen
				new Reception().setVisible(true);
				// Close the current window
				setVisible(false);
			} catch (Exception ee) {
				// Print stack trace for any exceptions
				ee.printStackTrace();
			}
		});
		// Set bounds for the update button
		btnUpdate.setBounds(60, 355, 89, 23);
		// Set background color to black
		btnUpdate.setBackground(Color.BLACK);
		// Set foreground color to white
		btnUpdate.setForeground(Color.WHITE);
		// Add the update button to the content pane
		contentPane.add(btnUpdate);

		// Button to go back to the reception screen
		JButton btnExit = new JButton("Back");
		btnExit.addActionListener(e -> {
			// Show the reception screen
			new Reception().setVisible(true);
			// Close the current window
			setVisible(false);
		});
		// Set bounds for the exit button
		btnExit.setBounds(180, 355, 89, 23);
		// Set background color to black
		btnExit.setBackground(Color.BLACK);
		// Set foreground color to white
		btnExit.setForeground(Color.WHITE);
		// Add the exit button to the content pane
		contentPane.add(btnExit);

		// Label for the room number
		JLabel lblRoomId = new JLabel("Room Number:");
		// Set bounds for the room number label
		lblRoomId.setBounds(27, 133, 100, 14);
		// Add the room number label to the content pane
		contentPane.add(lblRoomId);

		// Set the background color of the content pane to white
		getContentPane().setBackground(Color.WHITE);
	}
}





HotelManagementSystem


<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="module-library" exported="">
      <library>
        <CLASSES>
          <root url="jar://C:/mysql-connector-java-8.0.27.jar!/" />
          <root url="jar://C:/rs2xml.jar!/" />
        </CLASSES>
        <JAVADOC />
        <SOURCES>
          <root url="jar://C:/rs2xml.jar!/src" />
        </SOURCES>
      </library>
    </orderEntry>
    <orderEntry type="library" name="mysql-connector-java-8.0.27" level="project" />
  </component>
</module>









можно ли не использовать xampp и все эти библиотеки а в качестве базы данных просто использовать mysql workbench