0% found this document useful (0 votes)
13 views31 pages

Amaan Capstonefinal

The document presents a project report on a Canteen Management System developed by Amaan Mohd Azam Shah and Ganesh Sante as part of their Master of Computer Application program at the University of Mumbai. The system, built using Java, aims to automate food ordering, billing, and customer tracking to enhance efficiency and improve user experience. It includes features such as an admin panel for menu management, real-time order tracking, and a user-friendly interface for customers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views31 pages

Amaan Capstonefinal

The document presents a project report on a Canteen Management System developed by Amaan Mohd Azam Shah and Ganesh Sante as part of their Master of Computer Application program at the University of Mumbai. The system, built using Java, aims to automate food ordering, billing, and customer tracking to enhance efficiency and improve user experience. It includes features such as an admin panel for menu management, real-time order tracking, and a user-friendly interface for customers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

UNIVERSITY OF MUMBAI

Master of Computer Application

In-Semester Capstone
Project Report on
Canteen Management System

Submitted by –

Amaan Mohd Azam Shah

-Ganesh Sante

Roll no –

Amaan Shah(164)

Ganesh Sante(160)

(Semester-I)
Year 2024-25

Under the Guidance of


In writing this project report, it has been our endeavour to present the
subject in simple and lucid manner to those who wish to refer it for
enhancement or improving the existing features. The knowledge that
we have gathered, study of Relevant literature for understanding our
project, planning of details and suitable software platform by itself
and acknowledgement to the industry zeal and technical competence
of those many individuals who have contributed to it with profound
gratitude, we wish to acknowledge them.
We sincerely thank Thakur Institute of Management Studies, Career
Development & Research for training us in the MCA course. We
express our deep gratitude to our honourable director Dr. Vinita
Gaikwad and we would also express our deep gratitude to our
internal guide Prof. MS. Alifiya Shaikh
Who supported us with their knowledge and understanding. Thank
you all for your unwavering support.
Table of Contents
1. Introduction 4
Introduction of Project 4
Project Purpose 4
Project Objective 5
Scope of Project 5
2. System Study 6
Requirement Analysis 8
Planning and Scheduling 9
3. Analysis and Design 13
Software Requirements 15
Actual Gantt Chart 16

UML Diagrams 17
Flow Chart 18
Data Flow Diagram 18
Entity Relationship Diagram 19
Description of Entities 20
4. Testing and Validation 21
Code Efficiency 22
Testing Approach 24
Unit Testing 25
Integration Testing 25

5.User Manual 26

User Documentation 27
Outputs 29
Code Snippets 30
6.Conclusion 31
Conclusion 31
Limitations 31
Future Scope 32
1. Introduction :

Introduction :

The Canteen Management System is a comprehensive and efficient solution developed using
Java to manage and streamline the operations of a canteen. This system is designed to automate
tasks such as food ordering, order and their bill details, and customer tracking, significantly
reducing the manual effort involved in managing these processes.

The core features of this Canteen Management System include:

● Customer Ordering: Allows customers to place orders from a menu and track their
orders.
● Billing System: Automatically calculates the total cost of orders.
● Admin Panel: Allows administrators to add or remove items from the menu, update
prices, and monitor daily sales.

By implementing this system, the canteen management can achieve better organization,
improved efficiency, and enhanced customer service, contributing to an overall better experience
for both staff and customers.

Purpose :

The primary purpose of the Canteen Management System is to automate and optimize the day-
to-day operations of a canteen, ensuring smooth management of food orders, billing.

This system aims to:

1. Enhance Efficiency: Automate routine tasks such as order taking, billing and order
tracking to reduce manual errors and improve the speed of service.
2. Simplify Management: Provide canteen administrators with an intuitive interface to
manage menus, pricing, inventory, and staff assignments in real-time.
3. Improve Customer Experience: Allow customers to place orders quickly, track the
status of their orders, and make payments efficiently, resulting in a better overall
experience.
4. Control Inventory: Provide a system to track stock levels, prevent shortages, and ensure
timely reordering of supplies, which can help maintain smooth operations.

Ultimately, this Canteen Management System aims to reduce operational complexities, increase
productivity, and foster better communication between customers, staff, and administrators,
leading to a more organized and profitable canteen.
Objective :

The primary objectives of the Canteen Management System project are to:

1. Automate the Order Process:


○ Enable customers to easily place orders from a digital menu, reducing the need for
manual order taking by staff.
○ Ensure quick order processing and avoid delays in order completion.
2. Improve Billing Processing:
○ Automate the generation of bills based on customer orders, ensuring accuracy and
saving time.
3. Streamline Administrative Tasks:
○ Provide administrators with tools to manage menu items, pricing, and inventory
effectively.
○ Allow easy generation of reports (sales, inventory usage) to aid in decision-
making and financial planning.
4. Increase Customer Satisfaction:
○ Provide a user-friendly interface for customers to place orders and check the
status of their food, enhancing the overall customer experience.
○ Reduce wait times for customers by automating repetitive tasks, such as billing
and order tracking.

These objectives set clear goals for what the Canteen Management System should achieve and
emphasize improving efficiency, user experience, and decision-making through automation and
data-driven insights. These objectives will also guide your development process and help
measure the success of the project.

Working of project

In our system, once a customer has added items to their cart and is ready to place an order, the
following process is followed:

Cart Overview: All selected items, including their names, quantities, and individual prices, are
displayed in the cart for review. The total cost is calculated based on the items added.

Order Placement: After reviewing the cart, the customer clicks the "Place Order" button to
initiate the ordering process.

Order Processing: Upon placing the order, the status of each item in the order is updated to
"Processing". This indicates that the order is being prepared and is not yet complete. The system
will continue to track the progress of the order during this phase.
Order Completion: Once the order is successfully processed and completed, it will be moved to
the Order History section, where the status of the order will be updated to "Completed". This
signifies that the order has been successfully delivered or fulfilled.

Order History: The Order History section keeps a record of all completed orders, where the
status of each order will show as "Completed", along with relevant details like items ordered,
quantities, and the total cost at the time of completion.

Advantages & disadvantages of project

Advantages:
● Simplified User Experience: No complex invoices; customers only see the order status
(processing/completed), making the process clear and easy.
● Real-Time Tracking: Customers can track the status of their order at any time.
● Reduced Administrative Overhead: No need to generate and manage invoices, which
simplifies the system and saves time.
● Scalable: The system is easier to scale since it focuses on order statuses instead of billing
details.
● Fewer Billing Errors: With no invoices, there’s less chance of billing mistakes.

Disadvantages:
● Lack of Detailed Documentation: No formal invoice could lead to confusion about pricing or
itemized costs.
● Limited Financial Tracking: Missing invoices might make it harder for customers and
businesses to track finances or generate reports.
● No Legal Documentation: Invoices are often required for returns, warranties, or proof of
purchase.
● Customer Confusion: Customers may not understand the breakdown of costs, like taxes and
shipping fees.
● Limited Integration with Accounting Systems: Without invoices, integrating with accounting
tools could be challenging.
2. System Study

Planning and Scheduling: -

Phase 1: Requirement Gathering and Analysis (1 Week)

Phase 2: Design UI/UX Design and Wireframing (2 Weeks)


Backend Architecture and Database Schema (1 Week)

Phase 3: Development Core Features Implementation (4 Weeks)


Admin Features and Property Management (2 Weeks)
User Dashboard and Profile (1 Week)

Phase 4: Testingo Unit and Integration Testing (2 Weeks)


Bug Fixes and Optimization (1 Week)

Phase 5: Deployment and Maintenance (1 Week)

Requirement Analysis: -

Functional Requirements:
● User login/signup with valid credentials.
● Admin panel for managing item listings.
● Items search from menu with prices..
● Detailed item view including images.

Non-Functional Requirements:
● Scalability: Handle a growing number of users and their choices.
● Performance: Ensure minimal latency during searches and updates.
● Security: Protect user data with authentication and encrypted storage.
● User Experience: Provide an intuitive and responsive interface.
3. Analysis and Design

Software Requirement

Java :

Java is the primary programming language used for


developing the backend logic and business processes of the
project. It handles tasks like processing orders, managing the
cart, updating order status, and interacting with the database.

Swing:

Swing is used for building the Graphical User Interface (GUI) of the application. It provides a set
of components to create windows, buttons, text fields, and other elements that users interact with.
Swing is particularly useful for building desktop applications, providing a responsive and user-
friendly interface.

MySQL:

MySQL is the relational database used to store user data,


orders, cart items, and order history. It manages the data
persistency for the project, ensuring that all order and
user- related information is stored and can be retrieved
efficiently.

Actual Gantt Chart


UML Diagrams :

Features Of The Activity UML Diagram Of Canteen Management System


• Admin User can search Food Item, view description of a selected Food Item, add Food Item,
update Food Item and delete Food Item.
• Its shows the activity flow of editing, adding and updating of Canteen
• User will be able to search and generate report of Bill Employee, Products, Orders
• All objects such as (Food Item, Canteen, Orders) are interlinked
• Its shows the full description and flow of Food Item, Products, Orders, Bill Employee, Canteen

4. Testing and Validation

1. Code Efficiency

Definition: Code efficiency refers to how well the code performs in terms of resource utilization
(e.g., CPU, memory, disk space) while achieving its intended purpose. Efficient code minimizes
resource consumption and performs optimally under varying conditions.

Key Aspects:
● Time Complexity: The amount of time a program takes to run in relation to the size of
the input (often expressed in Big-O notation, like O(n), O(log n)).
● Space Complexity: The amount of memory the program consumes relative to the input
size.
● Optimization: Refactoring code or algorithms to improve speed, reduce memory
consumption, or handle larger datasets efficiently.
● Profiling: Using tools to measure the program’s resource usage to pinpoint bottlenecks or
inefficiencies.

2. Testing Approach

Definition: The testing approach refers to the structured methodology adopted for verifying and
validating the software throughout its development lifecycle. It outlines how testing will be
executed to ensure the software meets its requirements and functions as expected.

Key Aspects:

● Test-Driven Development (TDD): A software development methodology where tests


are written before the code itself. This ensures that the code meets predefined
functionality as it is written.
● Continuous Integration (CI): A practice where code changes are automatically tested
and integrated into the codebase. This minimizes integration issues and ensures that tests
run regularly to catch bugs early.
● Test Automation: Automating the execution of tests to increase the speed and frequency
of testing while maintaining consistency.
● Risk-Based Testing: Prioritizing tests based on the risk they mitigate. High-risk areas
(e.g., complex logic, critical features) are tested more rigorously.

3. Unit Testing

Definition: Unit testing is the process of testing individual components or units of code (such as
functions or methods) in isolation from the rest of the system to ensure that each unit functions
correctly.

Key Aspects:

● Isolation: Ensuring that each unit is tested independently, often using techniques like
mocking or stubbing to simulate external dependencies (e.g., databases, APIs).
● Granularity: Unit tests are generally small, testing one specific behavior or piece of
functionality of the component.
● Edge Cases: These tests should not only cover typical use cases but also edge cases, such
as invalid inputs or boundary conditions.
● Automation: Unit tests should be automated and part of the CI pipeline so that they run
automatically whenever code changes.

4. Integration Testing

Definition: Integration testing involves testing the interaction between different modules,
services, or components in a system to ensure they work together as expected. Unlike unit tests,
which focus on isolated components, integration tests check how well parts of the application
interact with one another.

Key Aspects:

Component Interaction: It ensures that different components of the system (e.g., frontend-
backend, microservices, database interactions) function correctly when combined.

End-to-End Testing: A type of integration testing where the entire system or a significant part
of it is tested from start to finish, often simulating real-world user behavior.

Real Dependencies: Unlike unit tests where external systems might be mocked, integration tests
often involve using real systems or simulated production environments (like a test database or
API).

API Testing: Verifying the correct behavior of APIs by sending real requests and receiving real
responses, checking for correct status codes, data formats, and error handling.

5. User Manual
Code snippet :

RegistrationForm.java :

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

public class RegistrationForm extends JFrame {

private JTextField usernameField;


private JTextField sapIdField;
private JTextField phoneNoField;
private JPasswordField passwordField;

static final String DB_URL = "jdbc:mysql://localhost/java";


static final String USER = "root";
static final String PASS = "";

public RegistrationForm() {
setTitle("Registration Form");
setSize(500, 350);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(10, 10, 10, 10);

JLabel usernameLabel = new JLabel("Username:");


usernameField = new JTextField(20);

JLabel sapIdLabel = new JLabel("SAP ID:");


sapIdField = new JTextField(20);

JLabel phoneNoLabel = new JLabel("Phone No:");


phoneNoField = new JTextField(20);
JLabel passwordLabel = new JLabel("Password:");
passwordField = new JPasswordField(20);

JButton submitButton = new JButton("Register");


JButton loginButton = new JButton("Login");

submitButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String username = usernameField.getText();
String sapId = sapIdField.getText();
String phoneNo = phoneNoField.getText();
String password = new
String(passwordField.getPassword());

if (!validateInputs(username, sapId, phoneNo,


password)) {
return;
}

try {
registerUser(username, sapId, phoneNo,
password);
JOptionPane.showMessageDialog(null,
"Registration successful!");
new LoginPage();
dispose();
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "Error:
" + ex.getMessage());
}
}
});

loginButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new LoginPage();
dispose();
}
});

gbc.gridx = 0;
gbc.gridy = 0;

add(usernameLabel, gbc);
gbc.gridx = 1;
add(usernameField, gbc);

gbc.gridx = 0;
gbc.gridy = 1;

add(sapIdLabel, gbc);
gbc.gridx = 1;
add(sapIdField, gbc);

gbc.gridx = 0;
gbc.gridy = 2;

add(phoneNoLabel, gbc);
gbc.gridx = 1;
add(phoneNoField, gbc);

gbc.gridx = 0;
gbc.gridy = 3;

add(passwordLabel, gbc);
gbc.gridx = 1;
add(passwordField, gbc);

gbc.gridx = 0;
gbc.gridy = 4;

add(loginButton, gbc);
gbc.gridx = 1;
add(submitButton, gbc);

setVisible(true);
}

private boolean validateInputs(String username, String


sapId, String phoneNo, String password) {
// Username validate
if (!username.matches("^[a-zA-Z0-9]{3,15}$")) {
JOptionPane.showMessageDialog(null, "Username must
be 3-15 characters and alphanumeric.");
return false;
}

// SAP validate
if (!sapId.matches("^[a-zA-Z0-9]{11}$")) {
JOptionPane.showMessageDialog(null, "SAP ID must be
11 characters and alphanumeric.");
return false;
}

// Phone validate
if (!phoneNo.matches("^\\d{10}$")) {
JOptionPane.showMessageDialog(null, "Phone number
must be a valid 10-digit number.");
return false;
}

// Password validate
if (!password.matches("^(?=.*[0-9])(?=.*[A-Z])(?=.*[@#$
%^&+=!])(?=\\S+$).{8,}$")) {
JOptionPane.showMessageDialog(null, "Password must
be at least 8 characters long and contain at least one digit,
one uppercase letter, and one special character.");
return false;
}

return true;
}

private void registerUser(String username, String sapId,


String phoneNo, String password) throws SQLException {
Connection connection =
DriverManager.getConnection(DB_URL, USER, PASS);
String sql = "INSERT INTO Reg_Info (username, sap_id,
phone_no, password) VALUES (?, ?, ?, ?)";
try (PreparedStatement statement =
connection.prepareStatement(sql)) {
statement.setString(1, username);
statement.setString(2, sapId);
statement.setString(3, phoneNo);
statement.setString(4, password);
statement.executeUpdate();
} finally {
connection.close();
}
}

public static void main(String[]


args) {
SwingUtilities.invokeLater(() -> new
RegistrationForm());
}
}

LoginPage.java :
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.*;

public class LoginPage extends JFrame {

private JTextField usernameField;


private JPasswordField passwordField;

// Database connection details


static final String DB_URL = "jdbc:mysql://localhost/java";
static final String USER = "root";
static final String PASS = "";

public LoginPage() {
setTitle("Login Page");
setSize(400, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(10, 10, 10, 10);

JLabel usernameLabel = new JLabel("Username:");


usernameField = new JTextField(20);

JLabel passwordLabel = new JLabel("Password:");


passwordField = new JPasswordField(20);

JButton loginButton = new JButton("Login");


JButton registerButton = new JButton("Register");

registerButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new RegistrationForm();
dispose();
}
});

loginButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String username = usernameField.getText();
String password = new
String(passwordField.getPassword());

if (username.isEmpty() || password.isEmpty()) {
JOptionPane.showMessageDialog(null, "Please
fill in all fields.");
} else {
try {
if (checkCredentials(username,
password)) {
JOptionPane.showMessageDialog(null,
"Login successful!");
new CanteenManagementSystemUI();
dispose();
} else {
JOptionPane.showMessageDialog(null,
"Invalid username or password.");
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(null,
"Error: " + ex.getMessage());
}
}
}
});

gbc.gridx = 0;
gbc.gridy = 0;

add(usernameLabel, gbc);
gbc.gridx = 1;
add(usernameField, gbc);

gbc.gridx = 0;
gbc.gridy = 1;

add(passwordLabel, gbc);
gbc.gridx = 1;
add(passwordField, gbc);

gbc.gridx = 1;
gbc.gridy = 2;

gbc.gridwidth = 1;
add(loginButton, gbc);
gbc.gridx = 0;
gbc.gridy = 2;
gbc.gridwidth = 1;
add(registerButton, gbc);

setVisible(true);
}

private boolean checkCredentials(String username, String


password) throws Exception {
Connection connection =
DriverManager.getConnection(DB_URL, USER, PASS);
String sql = "SELECT * FROM Reg_Info WHERE BINARY
username = ? AND BINARY password = ?";
try (PreparedStatement statement =
connection.prepareStatement(sql)) {
statement.setString(1, username);
statement.setString(2, password);
ResultSet resultSet = statement.executeQuery();
return resultSet.next();
} finally {
connection.close();
}
}

public static void main(String[] args) {


SwingUtilities.invokeLater(() -> new LoginPage());
}
}

CanteenManagementSystemUI.java :

import java.awt.*;
import java.sql.*;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;
import javax.swing.*;

class MenuItem {

String name;
double price;
ImageIcon image;
MenuItem(String name, double price, ImageIcon image) {
this.name = name;
this.price = price;
this.image = image;
}

@Override
public String toString() {
return name + " - Rs. " + price;
}
}

class CartItem {

MenuItem menuItem;
int quantity;

CartItem(MenuItem menuItem, int quantity) {


this.menuItem = menuItem;
this.quantity = quantity;
}

public double getTotalPrice() {


return menuItem.price * quantity;
}

@Override
public String toString() {
return menuItem.name + " (x" + quantity + ") - Rs. " +
getTotalPrice();
}
}

class Order {

String item;
String status;

Order(String item) {
this.item = item;
this.status = "Processing";
}

@Override
public String toString() {
return item + " - Status: Completed";
}
}

public class CanteenManagementSystemUI extends JFrame {

private ArrayList<MenuItem> menuItems;


private Stack<Order> orderHistory;
private Queue<Order> currentOrders;

private DefaultListModel<String> cartListModel;


private DefaultListModel<String> orderListModel;
private ArrayList<CartItem> cartItems;
private JTextArea orderHistoryArea;

private JPanel cards;


private CardLayout cardLayout;

private Connection connection;

public CanteenManagementSystemUI() {
menuItems = new ArrayList<>();
orderHistory = new Stack<>();
currentOrders = new LinkedList<>();
cartItems = new ArrayList<>();

cartListModel = new DefaultListModel<>();


orderListModel = new DefaultListModel<>();

initializeDatabase();
initializeMenu();
loadCurrentOrders();

setTitle("Canteen Management System");


setSize(1000, 600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);

setLayout(new BorderLayout());

// Left side panel


JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(3, 1));

JButton menuButton = new JButton("Menu");


JButton processOrderButton = new JButton("Current Order
Processing");
JButton orderHistoryButton = new JButton("Order
History");

buttonPanel.add(menuButton);
buttonPanel.add(processOrderButton);
buttonPanel.add(orderHistoryButton);

add(buttonPanel, BorderLayout.WEST);

// Right side panel


cards = new JPanel();
cardLayout = new CardLayout();
cards.setLayout(cardLayout);

JPanel menuPanel = new JPanel(new BorderLayout());

// Left side for menu button


JPanel menuItemsPanel = new JPanel();
menuItemsPanel.setLayout(new GridLayout(0, 3, 10,
10)); // 3 items per row with gaps
JScrollPane menuScrollPane = new
JScrollPane(menuItemsPanel);

// Right side for menu button


JPanel cartPanel = new JPanel(new BorderLayout());
JList<String> cartList = new JList<>(cartListModel);

cartList.setSelectionMode(ListSelectionModel.SINGLE_SEL
ECTION); JScrollPane cartScrollPane = new
JScrollPane(cartList); cartPanel.add(new
JLabel("Cart"), BorderLayout.NORTH);
cartPanel.add(cartScrollPane, BorderLayout.CENTER);
JButton placeOrderButton = new JButton("Place Order");
cartPanel.add(placeOrderButton, BorderLayout.SOUTH);

menuPanel.add(menuScrollPane, BorderLayout.CENTER);
menuPanel.add(cartPanel, BorderLayout.EAST);
cards.add(menuPanel, "Menu");

JPanel processOrderPanel = new JPanel(new


BorderLayout());
JList<String> currentOrderList = new
JList<>(orderListModel);
JButton processNextButton = new JButton("Process Next
Order");

processNextButton.addActionListener(e ->
processNextOrder());

processOrderPanel.add(new JLabel("Processing Current


Orders"), BorderLayout.NORTH);
processOrderPanel.add(new JScrollPane(currentOrderList),
BorderLayout.CENTER);
processOrderPanel.add(processNextButton,
BorderLayout.SOUTH);
cards.add(processOrderPanel, "Processing Order");

JPanel historyPanel = new JPanel(new BorderLayout());


orderHistoryArea = new JTextArea();
orderHistoryArea.setEditable(false);
historyPanel.add(new JLabel("Order History"),
BorderLayout.NORTH);
historyPanel.add(new JScrollPane(orderHistoryArea),
BorderLayout.CENTER);
cards.add(historyPanel, "Order History");

add(cards, BorderLayout.CENTER);

for (MenuItem item : menuItems) {


JPanel itemPanel = new JPanel();
itemPanel.setLayout(new BorderLayout());

itemPanel.setBorder(BorderFactory.createLineBorder(Color.GRAY,
1));
itemPanel.setPreferredSize(new Dimension(170, 20));

JLabel itemImageLabel = new JLabel(item.image);

itemImageLabel.setHorizontalAlignment(JLabel.CENTER);

JLabel itemNameLabel = new JLabel(item.name);


itemNameLabel.setHorizontalAlignment(JLabel.CENTER);

JLabel itemPriceLabel = new JLabel("Rs. " +


item.price);

itemPriceLabel.setHorizontalAlignment(JLabel.CENTER);

JButton addItemButton = new JButton("Add to Cart");


addItemButton.addActionListener(e ->
addItemToCart(item));

JPanel detailsPanel = new JPanel();


detailsPanel.setLayout(new BoxLayout(detailsPanel,
BoxLayout.Y_AXIS));
detailsPanel.add(itemNameLabel);
detailsPanel.add(itemPriceLabel);
detailsPanel.add(addItemButton);

itemPanel.add(itemImageLabel, BorderLayout.NORTH);
itemPanel.add(detailsPanel, BorderLayout.CENTER);

menuItemsPanel.add(itemPanel);
}

menuButton.addActionListener(e -> cardLayout.show(cards,


"Menu"));
processOrderButton.addActionListener(e ->
cardLayout.show(cards, "Processing Order"));
orderHistoryButton.addActionListener(e -> {
displayOrderHistory();
cardLayout.show(cards, "Order History");
});

placeOrderButton.addActionListener(e -> placeOrder());

cartList.addListSelectionListener(e -> {
if (!e.getValueIsAdjusting()) {
int selectedIndex = cartList.getSelectedIndex();
if (selectedIndex >= 0) {
showUpdateCartDialog(selectedIndex);
}
}
});

setVisible(true);
}

private void initializeDatabase() {


try {
String url = "jdbc:mysql://localhost/java";
String user = "root";
String password = "";
connection = DriverManager.getConnection(url, user,
password);
} catch (SQLException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(this, "Failed to
connect to the database.");
System.exit(1);
}
}

private void initializeMenu() {


try {
String query = "SELECT * FROM menu";
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);

while (resultSet.next()) {
String name = resultSet.getString("item_name");
double price =
resultSet.getDouble("item_price");
String imagePath =
resultSet.getString("item_image");
ImageIcon icon = new ImageIcon(imagePath);
icon = resizeImage(icon, 50, 50);
menuItems.add(new MenuItem(name, price, icon));
}
} catch (SQLException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(this, "Error loading
menu items from the database.");
}
}

private void loadCurrentOrders() {


try {
String query = "SELECT * FROM
current_order_processing WHERE item_status='Processing'";
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);

orderListModel.clear();

while (resultSet.next()) {
String item = resultSet.getString("item_name");
orderListModel.addElement(item + " - Status:
Processing");
currentOrders.add(new Order(item));
}
} catch (SQLException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(this, "Error loading
current orders from the database.");
}
}

private ImageIcon resizeImage(ImageIcon icon, int width, int


height) {
Image image = icon.getImage();
Image newImage = image.getScaledInstance(width, height,
Image.SCALE_SMOOTH);
return new ImageIcon(newImage);
}

private void addItemToCart(MenuItem item) {


boolean itemExists = false;
for (CartItem cartItem : cartItems) {
if (cartItem.menuItem.name.equals(item.name)) {
cartItem.quantity++;
itemExists = true;
break;
}
}
if (!itemExists) {
cartItems.add(new CartItem(item, 1));
}
updateCartList();
}

private void updateCartList() {


cartListModel.clear();
for (CartItem cartItem : cartItems) {
cartListModel.addElement(cartItem.toString());
}
}

private void placeOrder() {


if (cartItems.isEmpty()) {
JOptionPane.showMessageDialog(this, "Your cart is
empty!");
return;
}

for (CartItem cartItem :


cartItems) { String item =
cartItem.menuItem.name;
currentOrders.add(new Order(item));
orderListModel.addElement(item);
}

cartItems.clear();
updateCartList();

JOptionPane.showMessageDialog(this, "Order placed


successfully!");
}

private void processNextOrder() {


if (currentOrders.isEmpty()) {
JOptionPane.showMessageDialog(this, "No orders to
process!");
return;
}
Order order = currentOrders.poll();
orderHistory.push(order);
orderListModel.removeElement(order.item);

addToOrderHistory(order);

JOptionPane.showMessageDialog(this, "Processed order: "


+ order.item);
}

private void addToOrderHistory(Order order) {


String query = "INSERT INTO order_history (item_name,
item_status) VALUES (?, ?)";
try (PreparedStatement preparedStatement =
connection.prepareStatement(query)) {
preparedStatement.setString(1, order.item);
preparedStatement.setString(2, "Completed");
preparedStatement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(this, "Error saving
order history.");
}
}

private void displayOrderHistory() {


StringBuilder history = new StringBuilder();
for (Order order : orderHistory) {
history.append(order.toString()).append("\n");
}
orderHistoryArea.setText(history.toString());
}

private void showUpdateCartDialog(int index) {


CartItem selectedCartItem = cartItems.get(index);
String quantityStr = JOptionPane.showInputDialog(this,
"Update quantity for " + selectedCartItem.menuItem.name + ":",
selectedCartItem.quantity);
if (quantityStr != null && !quantityStr.isEmpty()) {
int quantity = Integer.parseInt(quantityStr);
selectedCartItem.quantity = quantity;
updateCartList();
}
}
public static void main(String[] args) {
SwingUtilities.invokeLater(CanteenManagementSystemUI::new);
}
}

Outputs:
Registration form:

Login Page:
Menu:

Current order processing:


Order History:

6. Conclusion

In conclusion, the project successfully implemented an order management system using Java,
Swing, and MySQL. The main objectives were achieved, which included creating a functional
cart, processing orders, and tracking order statuses from "Processing" to "Completed." The
project provided a comprehensive approach to managing orders without generating invoices but
still allowing customers to track the progress of their orders through the interface. By leveraging
Java for backend processing, Swing for the user interface, and MySQL for data storage, the
system operates smoothly and efficiently, ensuring that all orders are recorded and updated in
real-time. The project also emphasized the importance of user experience by providing an
intuitive and clear interface for customers to interact with.

Limitations:
1. Lack of Detailed Documentation: No formal invoice could lead to confusion about
pricing or itemized costs.
2. Limited Financial Tracking: Missing invoices might make it harder for customers and
businesses to track finances or generate reports.
3. No Legal Documentation: Invoices are often required for returns, warranties, or proof of
purchase.
4. Customer Confusion: Customers may not understand the breakdown of costs, like taxes
and shipping fees.
5. Limited Integration with Accounting Systems: Without invoices, integrating with
accounting tools could be challenging.

Future Scope:
Overcoming all the limitations and adding QR code menu functionality by which user can scan
the qr code an place the order easily

You might also like