0% found this document useful (0 votes)
6 views

PremJavaReport

The document outlines a micro project titled 'E-Shop Management System' developed by Prem Yede under the guidance of Ms. K. S. Jadhav as part of a Diploma in Information Technology course. The project is a Java-based application designed for e-commerce management, featuring functionalities for product cataloging, inventory control, and user authentication, supported by a MySQL database. It aims to enhance programming skills through practical application of GUI frameworks, event handling, and database management.

Uploaded by

sujal patade
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

PremJavaReport

The document outlines a micro project titled 'E-Shop Management System' developed by Prem Yede under the guidance of Ms. K. S. Jadhav as part of a Diploma in Information Technology course. The project is a Java-based application designed for e-commerce management, featuring functionalities for product cataloging, inventory control, and user authentication, supported by a MySQL database. It aims to enhance programming skills through practical application of GUI frameworks, event handling, and database management.

Uploaded by

sujal patade
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

A

Micro Project On

“E-Shop Management System”

Submitted by
18.Prem Yede

Under Guidance of
Ms. K. S. Jadhav

Diploma Course in Information Technology


(As per directives of I Scheme, MSBTE)

Sinhgad Institutes
Sinhgad Technical Education Society’s
SOU. VENUTAI CHAVAN POLYTECHNIC, PUNE - 411041
ACADEMIC YEAR 2024– 2025
Maharashtra State Board of technical
Education Certificate
This is to certify that, Mast. Prem Yede with Roll No. 18 of Third
Semester of Diploma in Information Technology of Institute Sou.
Venutai Chavan Polytechnic (Code:0040) has successfully
completed the Micro-Project in Advanced Java Programming
(22517) for the academic year 2024-2025.

Place: SVCP, Pune Enrollment No: 2200400406

Date: Exam Seat No:

Ms. K. S. Jadhav Mr. U. S. Shirshetti Dr. M. S. Jadhav


Course Teacher Head of Department Principal
Annexure – I
Part A-Micro project proposal

A. BRIEF INTRODUCTION:

E-Shop Management System is a Java-based project where crabs descend from random positions at
the top of the screen, and the player controls a paddle at the bottom. The objective is to shoot the crabs
using bullets fired from the paddle. When the crabs are hit, they disappear, and the game continues as
more crabs appear. This game challenges players to react quickly and improve their aim, combining
elements of randomness with fast-paced shooting mechanics. It also incorporates object-oriented
design principles and showcases your skills in game development using Java.

B. AIM OF THE PROJECT:

The aim of the E-Shop Management System project is to develop an engaging and interactive arcade-
style game where players control a paddle to shoot crabs descending from the top of the screen. The
project focuses on enhancing logical thinking and programming skills by implementing core game
mechanics, such as random object generation, collision detection, and player interaction, using Java.
It also aims to provide a fun and challenging experience for players while showcasing the developer’s
understanding of object-oriented programming, game physics, and graphical user interface design in
Java.

C. INTENTED COURSE OUTCOME:

a) Develop programs using GUI Framework (AWT and Swing).


b) Handle events of AWT and Swings components.
c) Develop programs to handle events in Java Programming.
d) Develop Java programs using networking concepts.
e) Develop programs using database.
f) Develop programs using Servlets.
D. RESOURCES REQUIRED:

Name of Resource
Sr. No. Specification
Required
1. Laptop Dell – i5 ,16 GB RAM
2. Operating system Windows 11
3. Software Google chrome

E. ACTION PLAN:

Sr. No Details of Activity Week

1 Discussion and finalization of topic

Discussion and
2 finalization of topic
3 Literature Review
4 Collection of Data
5 Discussion and outline of Content
6 Editing and proof Reading of Content

Completion of Report
7 and Presentation

8 Final submission of Micro Project

GROUP MEMBERS:

Roll. No. Name of group members


18 Prem Yede
Annexure II
Part B- Micro-Project
1. Rational

Java technology is widely used for web applications development. Based on the object-oriented
concepts and core Java concepts, this course will equip the students with the required
knowledge and skill of object-oriented programming approach needed for the development of
robust, powerful web applications. Through this course students will get hands-on experience
on GUI Technologies viz. AWT and Swings, event handling mechanisms and network
programming. The course also gives coverage to various web applications aspects like

2. Course Outcome Addressed


a) Develop programs using GUI Framework (AWT and Swing).
b) Handle events of AWT and Swings components.
c) Develop programs to handle events in Java Programming.
f) Develop programs using Servlets.
e) Develop programs using database.

3. Actual Method Followed

The process for this micro project is to make a "E-Shop Management System"
We collect information and organize by following points:
1. Collect the information on Notepad.
2. Show the information to faculty.
3. Learn about layers of atmospheres.
4. First make a raw report and then correct it.
5. After all the corrections make a proposal.
6. Prepare a project on “E-Shop Management System”
7. Make pdf of report and print it.
Annexure III
Evaluation Sheet for the Micro Project
Academic Year: 2024-2025 Name of the Faculty: Ms. K. S. Jadhav
Course: Advanced Java Programming (22517) Semester: Fifth
Title of the project: " E-Shop Management System."

COs addressed by Micro Project:


S. No Course Outcomes
a) Develop programs using GUI Framework (AWT and Swing).
b) Handle events of AWT and Swings components
c) Develop programs to handle events in Java Programming
e) Develop programs using database

Major learning outcomes achieved by students by doing the project


(A)Practical outcomes (PrO’s):
1. Write a program to demonstrate the use of components like Label,
TextField, TextArea, Button, Checkbox, RadioButton (CheckboxGroup) [1].
2. Write a program to accept keyboard input to show the pressed/released
status of each key on Applet Window [12].
3. Write a program to demonstrate use of Adapter class [20].
4. Write a program to establish successful connection of database
(B) Unit outcomes in Cognitive domain
1. Develop Graphical user interface (GUI) programs using AWT components for the given
problem [1a].
2. Create Frame window with the specified AWT components [1b].
3. Develop Graphical user interface (GUI) programs using swing components for the given
problem[2b].
4. Use delegation event model to develop event driven program for the given problem [3a].
5.Use Adapter classes in Java program to solve the given problem [3c].
6. Explain function of the given tier of JDBC architecture for two tier/three tier models [5b].

Comments/suggestions about team work /leadership/inter-personal communication (if any)


…………………………………………………………………………

Marks out of 6 Marks out of 4


Roll for performance for performance
No Name of the Student in group activity in oral/ Total Marks
(D5 Col.8) presentation out of 10
(D5 Col.9)

18 Prem Yede

(Name & Signature)


Introduction

E-Shop Management System

The E-Shop Management System is a Java Swing application designed to streamline e-commerce
management by providing a user-friendly platform for product cataloging, inventory control, and
secure user authentication. This system allows customers to log in, view product details with images,
check stock availability, and place orders, while administrators can manage products, update
inventory, and oversee customer data. With a MySQL database integration, the system efficiently
handles data storage for users and products, ensuring secure and smooth transactions. This project
aims to simplify and automate e-commerce management, offering an intuitive interface for customers
and robust tools for administrators.
Code:-

• App.java

import javax.swing.*;
import java.util.ArrayList;
import java.util.List;

public class App {


public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
// Launch the Account Creation page first
AccountCreation accountCreation = new AccountCreation();
accountCreation.setVisible(true);
});
}
}

• AccountCreation.java

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

public class AccountCreation extends JFrame {


private JTextField usernameField;
private JPasswordField passwordField;
private JTextField emailField;
private JTextField phoneField;
Database db = new Database();
public AccountCreation() {
setTitle("Create Account");
setSize(400, 350);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);

// Create components
JLabel usernameLabel = new JLabel("Username:");
usernameField = new JTextField(20);

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


passwordField = new JPasswordField(20);

JLabel emailLabel = new JLabel("Email:");


emailField = new JTextField(20);

JLabel phoneLabel = new JLabel("Phone:");


phoneField = new JTextField(15);
JButton createAccountButton = new JButton("Create Account");
createAccountButton.addActionListener(new CreateAccountAction());

JButton adminButton = new JButton("Admin");


adminButton.addActionListener(new AdminAction());

JButton loginButton = new JButton("Login");


loginButton.addActionListener(new LoginAction());

// Create panel and set layout


JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 5, 5, 5); // Add some padding

// Add components to the panel with constraints


gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 0.5;
panel.add(usernameLabel, gbc);

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


panel.add(usernameField, gbc);

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


panel.add(passwordLabel, gbc);

gbc.gridx = 1; gbc.gridy = 1; gbc.weightx = 1.0;


panel.add(passwordField, gbc);

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


panel.add(emailLabel, gbc);

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


panel.add(emailField, gbc);

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


panel.add(phoneLabel, gbc);

gbc.gridx = 1; gbc.gridy = 3; gbc.weightx = 1.0;


panel.add(phoneField, gbc);

gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 2; // Span across two columns


gbc.fill = GridBagConstraints.CENTER;
panel.add(createAccountButton, gbc);

gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 1; // Reset to single column


gbc.fill = GridBagConstraints.HORIZONTAL;
panel.add(adminButton, gbc);

gbc.gridx = 1; gbc.gridy = 5; // Place login button next to admin button


panel.add(loginButton, gbc);
// Add panel to frame
add(panel);
}

// Inside the CreateAccountAction class in AccountCreation


private class CreateAccountAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
String username = usernameField.getText();
String password = new String(passwordField.getPassword());
String email = emailField.getText();
String phone = phoneField.getText();

if (username.isEmpty() || password.isEmpty() || email.isEmpty() || phone.isEmpty()) {


JOptionPane.showMessageDialog(null, "Please fill in all fields!");
} else {
JOptionPane.showMessageDialog(null, "Account created successfully!");
db.storeUserDetails(username, password, email, Integer.parseInt(phone));

usernameField.setText("");
passwordField.setText("");
emailField.setText("");
phoneField.setText("");

// Open the ProductDisplay window with the product list


ProductDisplay productDisplay = new ProductDisplay(ProductUtil.getSampleProducts());
productDisplay.setVisible(true);
dispose();
}
}
}

private class AdminAction implements ActionListener {


@Override
public void actionPerformed(ActionEvent e) {
JFrame admin = new AdminLoginPage();
admin.setVisible(true);
}
}

private class LoginAction implements ActionListener {


@Override
public void actionPerformed(ActionEvent e) {
JFrame login = new LoginPage();
login.setVisible(true);
}
}
}
• AdminDashboard.java

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

public class AdminDashboard extends JFrame {


private JTextField idField, nameField, priceField, quantityField;
private JTextField imagePathField;
private JButton addButton, browseButton;
private JLabel imageLabel;

public AdminDashboard() {
setTitle("Admin Dashboard - Add New Products");
setSize(500, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(7, 2, 10, 10));

// Create and add components


add(new JLabel("Product ID:"));
idField = new JTextField();
add(idField);

add(new JLabel("Product Name:"));


nameField = new JTextField();
add(nameField);

add(new JLabel("Price:"));
priceField = new JTextField();
add(priceField);

add(new JLabel("Quantity:"));
quantityField = new JTextField();
add(quantityField);

add(new JLabel("Image Path:"));


imagePathField = new JTextField();
imagePathField.setEditable(false);
add(imagePathField);

browseButton = new JButton("Browse Image");


add(browseButton);

// Label to display the selected image


imageLabel = new JLabel();
imageLabel.setHorizontalAlignment(SwingConstants.CENTER);
add(imageLabel);

addButton = new JButton("Add Product");


add(addButton);
// Action listener for the browse button
browseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int result = fileChooser.showOpenDialog(null);
if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
imagePathField.setText(selectedFile.getAbsolutePath());

// Display the selected image


ImageIcon imageIcon = new ImageIcon(selectedFile.getAbsolutePath());
Image image = imageIcon.getImage().getScaledInstance(100, 100,
Image.SCALE_SMOOTH);
imageLabel.setIcon(new ImageIcon(image));
}
}
});

// Add product button action listener


addButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
int id = Integer.parseInt(idField.getText());
String name = nameField.getText();
double price = Double.parseDouble(priceField.getText());
int quantity = Integer.parseInt(quantityField.getText());
String imagePath = imagePathField.getText();

// Call the database method to store product details


Database productDb = new Database();
productDb.storeProductDetails(id, name, price, quantity, imagePath);
productDb.closeConnection();

// Show confirmation message


JOptionPane.showMessageDialog(null, "Product added successfully!");

// Clear the input fields


idField.setText("");
nameField.setText("");
priceField.setText("");
quantityField.setText("");
imagePathField.setText("");
imageLabel.setIcon(null);

} catch (NumberFormatException ex) {


JOptionPane.showMessageDialog(null, "Please enter valid data!");
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Error adding product: " + ex.getMessage());
}
}
});

setVisible(true);
}

• AdminLoginPage.java

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

public class AdminLoginPage extends JFrame {


private JTextField usernameField;
private JPasswordField passwordField;

public AdminLoginPage() {
setTitle("Admin Login");
setSize(350, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);

// Create components
JLabel usernameLabel = new JLabel("Username:");
usernameField = new JTextField(15);

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


passwordField = new JPasswordField(15);

JButton loginButton = new JButton("Login");


loginButton.addActionListener(new LoginAction());

// Create panel and set layout


JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(5, 5, 5, 5); // Add padding

// Add components to the panel


gbc.gridx = 0; gbc.gridy = 0;
panel.add(usernameLabel, gbc);

gbc.gridx = 1; gbc.gridy = 0;
panel.add(usernameField, gbc);

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

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


panel.add(loginButton, gbc);

// Add panel to frame


add(panel);
}

private class LoginAction implements ActionListener {


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

// Check admin credentials


if ("admin".equals(username) && "prem123".equals(password)) {
JOptionPane.showMessageDialog(null, "Admin login successful!");

JFrame frame = new AdminDashboard();


frame.setVisible(true);
dispose(); // Close the login window
} else {
JOptionPane.showMessageDialog(null, "Invalid admin username or password.");
}
}
}

}
• ScoreDb.java

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Database {


private static final String URL = "jdbc:mysql://localhost:3306/EShopManagement"; // Replace
`eshop_db` with your database name
private static final String USER = "root";
private static final String PASSWORD = "Sujal@2006";

private Connection connection;

// Constructor to initialize the connection


public Database() {
try {
connection = DriverManager.getConnection(URL, USER, PASSWORD);
System.out.println("Connected to the database successfully!");
} catch (SQLException e) {
System.err.println("Failed to connect to the database.");
e.printStackTrace();
}
}

// Function to store user details in the database


public void storeUserDetails(String username, String password, String email,int phone) {
String query = "INSERT INTO userAccount (username, password, email,phone) VALUES
(?, ?, ?,?)";

try (PreparedStatement preparedStatement = connection.prepareStatement(query)) {


preparedStatement.setString(1, username);
preparedStatement.setString(2, password);
preparedStatement.setString(3, email);
preparedStatement.setInt(4, phone);

int rowsInserted = preparedStatement.executeUpdate();


if (rowsInserted > 0) {
System.out.println("User details stored successfully!");
} else {
System.out.println("Failed to store user details.");
}
} catch (SQLException e) {
System.err.println("Error storing user details.");
e.printStackTrace();
}
}
public boolean checkLogin(String username, String password) {
String query = "SELECT * FROM userAccount WHERE username = ? AND password = ?";

try (PreparedStatement preparedStatement = connection.prepareStatement(query)) {


preparedStatement.setString(1, username);
preparedStatement.setString(2, password);

try (ResultSet resultSet = preparedStatement.executeQuery()) {


if (resultSet.next()) {
System.out.println("user found");
return true; // User found
}
}
} catch (SQLException e) {
System.err.println("Error checking login credentials.");
e.printStackTrace();
}

return false; // User not found


}
public void storeProductDetails(int id, String name, double price, int quantity, String
imagePath) throws IOException {
String query = "INSERT INTO products (id, name, price, quantity, image) VALUES (?, ?, ?,
?, ?)";

try (PreparedStatement preparedStatement = connection.prepareStatement(query);


FileInputStream imageInputStream = new FileInputStream(imagePath)) {
preparedStatement.setInt(1, id);
preparedStatement.setString(2, name);
preparedStatement.setDouble(3, price);
preparedStatement.setInt(4, quantity);
preparedStatement.setBinaryStream(5, imageInputStream);

int rowsInserted = preparedStatement.executeUpdate();


if (rowsInserted > 0) {
System.out.println("Product details stored successfully!");
} else {
System.out.println("Failed to store product details.");
}
} catch (SQLException e) {
System.err.println("Error storing product details.");
e.printStackTrace();
} catch (FileNotFoundException e) {
System.err.println("Image file not found.");
e.printStackTrace();
}
}
public void closeConnection() {
try {
if (connection != null && !connection.isClosed()) {
connection.close();
System.out.println("Connection closed.");
}
} catch (SQLException e) {
System.err.println("Failed to close the connection.");
e.printStackTrace();
}
}

• LoginPage.java

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

public class LoginPage extends JFrame {


private JTextField usernameField;
private JPasswordField passwordField;
Database db = new Database();
public LoginPage() {
setTitle("Login");
setSize(350, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);

// Create components
JLabel usernameLabel = new JLabel("Username:");
usernameField = new JTextField(15);

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


passwordField = new JPasswordField(15);

JButton loginButton = new JButton("Login");


loginButton.addActionListener(new LoginAction());

// Create panel and set layout


JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(5, 5, 5, 5); // Add padding

// Add components to the panel


gbc.gridx = 0; gbc.gridy = 0;
panel.add(usernameLabel, gbc);

gbc.gridx = 1; gbc.gridy = 0;
panel.add(usernameField, gbc);
gbc.gridx = 0; gbc.gridy = 1;
panel.add(passwordLabel, gbc);

gbc.gridx = 1; gbc.gridy = 1;
panel.add(passwordField, gbc);

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


panel.add(loginButton, gbc);

// Add panel to frame


add(panel);
}

// Inside the LoginAction class in LoginPage


private class LoginAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
String username = usernameField.getText();
String password = new String(passwordField.getPassword());
boolean loginStatus = db.checkLogin(username, password);

if (loginStatus) {
JOptionPane.showMessageDialog(null, "Login successful!");

// Open the ProductDisplay window with the product list


ProductDisplay productDisplay = new ProductDisplay(ProductUtil.getSampleProducts());
productDisplay.setVisible(true);
dispose();
} else {
JOptionPane.showMessageDialog(null, "Invalid username or password.");
}
}
}

• Product.java
public class Product {
private int id;
private String name;
private double price;
private int quantity;
private String imagePath;

public Product(int id, String name, double price, int quantity, String imagePath) {
this.id = id;
this.name = name;
this.price = price;
this.quantity = quantity;
this.imagePath = imagePath;
}
public int getId() {
return id;
}

public String getName() {


return name;
}

public double getPrice() {


return price;
}

public int getQuantity() {


return quantity;
}

public String getImagePath() {


return imagePath;
}

public void setQuantity(int quantity) {


this.quantity = quantity;
}
}
Algorithm
Output
Reference

https://docs.oracle.com/javase/tutorial/extra/fullscreen/index.html
https://docs.oracle.com/javase/tutorial/uiswing/
https://www.geeksforgeeks.org/introduction-to-java-swing/
https://www.tutorialspoint.com/swing/index.html
https://stackoverflow.com/questions/66906630/switch-scenes-in-java-swing
Conclusion

This project effectively demonstrates the implementation of a user-friendly e-shop management system using Java
Swing. The application provides a smooth experience for both general users and admin users by allowing account
creation, user authentication, and product display functionalities. Through the account creation feature, users can
register their details, which are securely stored in a MySQL database. The login feature validates user credentials
to ensure secure access, with specific screens tailored for regular and admin users. Additionally, the product display
page showcases products in a format similar to an e-commerce platform, enhancing the user experience and
simulating a real-world shopping environment.

You might also like