Group3 Puso
Group3 Puso
Quezon City
College of Information Technology Education
TITLE OF PROJECT
Project Documentation
Tulagan, Robert
Sayo, Keith
Omana,Luis
Salta, Myke
Second Semester SY 2020-2021
Submitted to
Table of Contents
Page No.
I. Course Objectives
………………………….
- See syllabus
II. Course Outcomes
…………………………..
- See syllabus
III. Project
Rationale……………………………
IV. Project Objectives …………………………
V. Conceptual Framework (With
Description)……
VI. Screenshots (With Descriptions of each
frame/applet/window)…....
VII. Source
Code………………………………….
- with class name as heading and
description of function of the class in the
form of a Java comment in the code
(before the import package line)
VIII. Screenshot of Project Explorer in Eclipse
Editor ………………………………….
- with description of each package and
each class in the Java project.
IX. Installation Guide
- instructions if there are files that are
necessary to be copied or transferred to a
folder before system execution.
X. Members Information …………………..
- Name of Leader –
- Email Address and Contact Number
- Name of Member 1
- Email Address and Contact Number
- Name of Member 2
- Email Address and Contact Number
Course Objectives
The course aims to provide students with the knowledge and skills in data structures
and algorithms and their implementations in Java programming. It also aims to develop
the affective domain learning abilities of students such as receiving, responding,
valuing, organizing, and characterizing as they perform the course learning activities
and assessment tasks.
Course Outcomes
By the end of the course, the students will be able to:
The development of the Inventory Management System (IMS) by 2nd-year IT students in Java
is driven by the necessity to address the limitations and inefficiencies inherent in manual
inventory management processes. Traditional methods are error-prone, time-consuming, and
lack the scalability required to meet the demands of modern businesses. The IMS aims to
automate and streamline inventory-related tasks, providing a robust and user-friendly solution
for businesses to manage their inventory efficiently.
The key problems the IMS seeks to solve include discrepancies in inventory levels, delayed
order processing, and the absence of real-time tracking. By automating these processes, the
system aims to enhance accuracy, reduce lead times, and enable businesses to make informed
decisions based on up-to-date inventory data. The scope of the project encompasses inventory
tracking and control, order processing, reporting, and analytics, with a focus on delivering a
user-friendly interface for all stakeholders.
Project Objectives
(These are the objectives that you want the project to accomplish.)
Screenshots
Procurement
SupplierSide
ClientInterface
Logistics
AdminSide_Client
AdminSide
Source Code
AdminSide_Client
/*
AdminSide_Client - Represents a GUI application for managing inventory information.
This class sets up a graphical user interface (GUI) for handling inventory
management tasks. It includes functionality for displaying, updating,
deleting, and fetching inventory data stored in a MySQL database. The GUI includes
various components such as text fields, buttons, and a table
to interact with the database and perform CRUD (Create, Read, Update, Delete)
operations on inventory information.
*/
package logistics;
public AdminSide_Client() {
getContentPane().setBackground(Color.WHITE);
setTitle("Database Table Example");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(971, 494);
btnDelete.setForeground(Color.WHITE);
btnDelete.setFont(new Font("Dialog", Font.BOLD, 14));
btnDelete.setBorder(null);
btnDelete.setBackground(Color.BLACK);
btnDelete.setBounds(810, 392, 95, 36);
getContentPane().add(btnDelete);
btnFetch.setForeground(Color.WHITE);
btnFetch.setFont(new Font("Dialog", Font.BOLD, 14));
btnFetch.setBorder(null);
btnFetch.setBackground(Color.BLACK);
btnFetch.setBounds(690, 345, 95, 36);
getContentPane().add(btnFetch);
productOrder = new JTextField();
productOrder.setForeground(Color.BLACK);
productOrder.setFont(new Font("Dialog", Font.PLAIN, 14));
productOrder.setColumns(10);
productOrder.setBorder(new TitledBorder(new
BevelBorder(BevelBorder.LOWERED, new Color(0, 0, 0), null, new Color(0, 0, 0), new
Color(0, 0, 0)), "Product to Order", TitledBorder.LEADING, TitledBorder.TOP, null, new
Color(0, 0, 0)));
productOrder.setBounds(468, 281, 190, 36);
getContentPane().add(productOrder);
btnDisplay.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
btnUpdate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/database1","root",
"password");
PreparedStatement pstmt =
conn.prepareStatement("UPDATE customer_crud SET `ordernumber`=?, `customerid`
= ?, customername = ?, customeraddress = ?, productorder=?, quantity=? WHERE
`ordernumber`=" + ordernumber.getText()+"");
pstmt.setInt(1,
Integer.parseInt(ordernumber.getText()));
pstmt.setInt(2,
Integer.parseInt(customerID.getText()));
pstmt.setString(3, customerName.getText());
pstmt.setString(4, customerAddress.getText());
pstmt.setString(5, productOrder.getText());
pstmt.setInt(6, (int) spinner.getValue());
pstmt.executeUpdate();
JOptionPane.showMessageDialog(null,
"Records have been updated");
}catch(Exception e1) {
System.out.println(e1);
}
}
});
btnFetch.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/database1","root",
"password");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT
`ordernumber` ,`customerid`,customername, customeraddress, productorder, `quantity`
FROM customer_crud WHERE `ordernumber`=" + ordernumber.getText()+"");
while (rs.next()) {
ordernumber.setText(Integer.toString(rs.getInt("ordernumber")));
customerID.setText(Integer.toString(rs.getInt("customerid")));
customerName.setText(rs.getString("customername"));
customerAddress.setText(rs.getString("customeraddress"));
productOrder.setText(rs.getString("productorder"));
spinner.setValue(rs.getInt("quantity"));
}
}catch(Exception e9) {
System.out.println(e9);
}
}
});
btnDelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/database1","root",
"password");
Statement st = conn.createStatement();
st.executeUpdate("Delete FROM customer_crud
WHERE `ordernumber`=" + ordernumber.getText()+"");
JOptionPane.showMessageDialog(null, "Record
Successfully deleted");
setLocationRelativeTo(null);
setVisible(true);
}
AdminSide
/*
AdminSide - Manages inventory information through a graphical user interface.
This class creates a graphical user interface (GUI) for managing inventory
information. It includes functionalities such as displaying, updating,
deleting, and fetching data related to items stored in a MySQL database. The GUI
contains various components like text fields, buttons, tables,
and log displays to facilitate CRUD (Create, Read, Update, Delete) operations on
item data.
*/
package logistics;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.sql.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Vector;
import javax.swing.border.TitledBorder;
import javax.swing.border.BevelBorder;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.List;
public AdminSide() {
getContentPane().setBackground(Color.WHITE);
setTitle("Database Table Example");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(971, 637);
btnRestock.setForeground(Color.WHITE);
btnRestock.setFont(new Font("Dialog", Font.BOLD, 14));
btnRestock.setBorder(null);
btnRestock.setBackground(Color.BLACK);
btnRestock.setBounds(466, 312, 95, 36);
getContentPane().add(btnRestock);
btnUpdate.setForeground(Color.WHITE);
btnUpdate.setFont(new Font("Dialog", Font.BOLD, 14));
btnUpdate.setBorder(null);
btnUpdate.setBackground(Color.BLACK);
btnUpdate.setBounds(810, 312, 95, 36);
getContentPane().add(btnUpdate);
while (resultSet.next()) {
Vector<Object> rowData = new Vector<>();
for (int i = 1; i <= columnCount; i++) {
rowData.add(resultSet.getObject(i));
}
tableModel.addRow(rowData);
}
}
});
btnDisplay.setForeground(Color.WHITE);
btnDisplay.setFont(new Font("Dialog", Font.BOLD, 14));
btnDisplay.setBorder(null);
btnDisplay.setBackground(Color.BLACK);
btnDisplay.setBounds(581, 312, 95, 36);
getContentPane().add(btnDisplay);
btnDelete.setForeground(Color.WHITE);
btnDelete.setFont(new Font("Dialog", Font.BOLD, 14));
btnDelete.setBorder(null);
btnDelete.setBackground(Color.BLACK);
btnDelete.setBounds(810, 367, 95, 36);
getContentPane().add(btnDelete);
btnFetch.setForeground(Color.WHITE);
btnFetch.setFont(new Font("Dialog", Font.BOLD, 14));
btnFetch.setBorder(null);
btnFetch.setBackground(Color.BLACK);
btnFetch.setBounds(694, 312, 95, 36);
getContentPane().add(btnFetch);
btnSort.setForeground(Color.WHITE);
btnSort.setFont(new Font("Dialog", Font.BOLD, 14));
btnSort.setBorder(null);
btnSort.setBackground(Color.BLACK);
btnSort.setBounds(694, 367, 95, 36);
getContentPane().add(btnSort);
btnRestock.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/sys","root", "1234567");
String query= "INSERT INTO admin_crud (itemCode,
itemName, itemPrice, productQuantity) VALUES (?, ?, ?, ?)";
PreparedStatement ps=con.prepareStatement(query);
ps.setInt(1, Integer.parseInt(itemCode.getText()));
ps.setString(2, itemName.getText());
ps.setInt(3, Integer.parseInt(itemPrice.getText()));
ps.setInt(4, (int)spinner.getValue());
ps.executeUpdate();
String[] logData = {
itemCode.getText(),
itemName.getText(),
itemPrice.getText(),
String.valueOf(spinner.getValue())
};
logList.add(logData);
}
});
btnDelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/sys","root", "1234567");
Statement st = conn.createStatement();
st.executeUpdate("Delete FROM admin_crud
WHERE `itemCode`=" + itemCode.getText()+"");
}
});
btnFetch.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/sys","root", "1234567");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT `itemCode`,
itemName, `itemPrice`, `productQuantity` FROM admin_crud WHERE `itemCode`=" +
itemCode.getText()+"");
while (rs.next()) {
itemCode.setText(Integer.toString(rs.getInt("itemCode")));
itemName.setText(rs.getString("itemName"));
itemPrice.setText(Integer.toString(rs.getInt("itemPrice")));
spinner.setValue(rs.getInt("productQuantity"));
}
btnUpdate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/sys","root", "1234567");
PreparedStatement pstmt =
conn.prepareStatement("UPDATE admin_crud SET `itemCode` = ?, itemName = ?,
`itemPrice` = ?, `productQuantity`=? WHERE `itemCode`=" + itemCode.getText()+"");
pstmt.setInt(1,
Integer.parseInt(itemCode.getText()));
pstmt.setString(2, itemName.getText());
pstmt.setInt(3,
Integer.parseInt(itemPrice.getText()));
pstmt.setInt(4, (int)spinner.getValue());
pstmt.executeUpdate();
logTableModel.addRow(new Object[]{"Updated
row for item code:" + itemCode.getText() + " [" + itemCode.getText() + "," +
itemName.getText() + "," + itemPrice.getText() + "," + spinner.getValue() + "]" });
}catch(Exception e1) {
System.out.println(e1);
}
}
});
btnSort.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
fetchDataAndSort();
}
});
setLocationRelativeTo(null);
setVisible(true);
}
// Sort the data based on item price in descending order using quicksort
quickSort(dataList, 0, dataList.size() - 1, 2); // Assuming item price is at index
2
// Update the JTable with the sorted data
DefaultTableModel tableModel = new DefaultTableModel(new Object[]{"Item
Code", "Item Name", "Item Price", "Product Quantity"}, 0);
for (String[] rowData : dataList) {
tableModel.addRow(rowData);
}
dataTable.setModel(tableModel);
private void quickSort(List<String[]> data, int low, int high, int sortIndex) {
if (low < high) {
int partitionIndex = partition(data, low, high, sortIndex);
private int partition(List<String[]> data, int low, int high, int sortIndex) {
String[] pivot = data.get(high);
int i = low - 1;
insertStatement.executeUpdate();
}
}
} catch (SQLException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Error updating data in the database");
}
}
}
ClientInterface
// Class: ClientInterface
// Description: Manages the inventory system and customer orders through a Swing-
based interface.
package logistics;
import java.sql.*;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Toolkit;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.JRadioButton;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.awt.event.ActionEvent;
import javax.swing.ButtonGroup;
import javax.swing.SwingConstants;
import java.awt.SystemColor;
import javax.swing.UIManager;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import javax.swing.border.BevelBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.JToggleButton;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.JSpinner;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;
/**
* Launch the application.
* @return
*/
// You may need to adjust the positions and sizes based on your layout
preferences
/**
* Create the frame.
*/
public ClientInterface() {
setBackground(UIManager.getColor("Button.shadow"));
setIconImage(Toolkit.getDefaultToolkit().getImage("C:\\Users\\tipqc\\Downloads\\i
con.jpg"));
setTitle("Registration form");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 647, 512);
contentPane = new JPanel();
contentPane.setBackground(SystemColor.controlHighlight);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
btnReset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
customerID.setText("");
customerName.setText("");
customerAddress.setText("");
productOrder.setText("");
productOrder.setText("");
buttonGroup.clearSelection();
spinner.setValue(0);
main(null);
}
});
btnReset.setFont(new Font("Dialog", Font.BOLD, 14));
btnOrder.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection(url, userid, password);
orderList.clear();
});
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(819, 526);
setLocationRelativeTo(null);
setVisible(true);
btnAddAnotherProduct.setForeground(Color.WHITE);
btnAddAnotherProduct.setFont(new Font("Dialog", Font.BOLD, 14));
btnAddAnotherProduct.setBorder(null);
btnAddAnotherProduct.setBackground(Color.BLACK);
btnAddAnotherProduct.setBounds(403, 242, 111, 36);
panel_1.add(btnAddAnotherProduct);
btnLockOrder.setForeground(Color.WHITE);
btnLockOrder.setFont(new Font("Dialog", Font.BOLD, 14));
btnLockOrder.setBorder(null);
btnLockOrder.setBackground(Color.BLACK);
btnLockOrder.setBounds(524, 242, 111, 36);
panel_1.add(btnLockOrder);
btnPay.setForeground(Color.WHITE);
btnPay.setFont(new Font("Dialog", Font.BOLD, 14));
btnPay.setBorder(null);
btnPay.setBackground(Color.BLACK);
btnPay.setBounds(525, 290, 111, 36);
panel_1.add(btnPay);
}
});
btnInventory.setForeground(Color.WHITE);
btnInventory.setFont(new Font("Dialog", Font.BOLD, 14));
btnInventory.setEnabled(true);
btnInventory.setBorder(null);
btnInventory.setBackground(Color.BLACK);
btnInventory.setBounds(403, 290, 111, 36);
panel_1.add(btnInventory);
btnPay.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFrame frame;
if(rdbtnPaymaya.isSelected()) {
frame = new JFrame();
frame.getContentPane().setBackground(Color.WHITE);
frame.setBounds(100, 100, 450, 293);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JOptionPane.showMessageDialog(null,
"Payment Succesful!");
btnOrder.setEnabled(true);
frame.dispose();
}
});
pay.setBackground(new Color(0, 0, 0));
pay.setBounds(323, 210, 89, 33);
frame.getContentPane().add(pay);
JLabel lblNewLabel_2 = new JLabel("Make sure you
have the Maya app installed and the notification is not muted . ");
lblNewLabel_2.setFont(new Font("Dialog",
Font.PLAIN, 10));
lblNewLabel_2.setBounds(21, 139, 668, 14);
frame.getContentPane().add(lblNewLabel_2);
frame.setVisible(true);
}else if(rdbtnGcash.isSelected()) {
frame = new JFrame();
frame.getContentPane().setBackground(Color.WHITE);
frame.setBounds(100, 100, 450, 293);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
lblPaymayaIsPending.setText("Payment Succesful!");
JOptionPane.showMessageDialog(null, "Payment
Succesful!");
btnOrder.setEnabled(true);
frame.dispose();
}
});
pay.setBackground(new Color(0, 0, 0));
pay.setBounds(323, 210, 89, 33);
frame.getContentPane().add(pay);
frame.setVisible(true);
}
}
});
btnAddAnotherProduct.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (add < 1) {
revalidate();
repaint();
add = 2;
} else if (add == 2) {
revalidate();
repaint();
add = 3;
} else if (add == 3) {
add = 4;
revalidate();
repaint();
btnAddAnotherProduct.setEnabled(false);
}
}
});
btnLockOrder.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
List<String> productOrders = new LinkedList<>();
List<Integer> spinners = new LinkedList<>();
btnPay.setEnabled(true);
if (add > 1) {
productOrders.add(productOrder1.getText()); // Second
product order
spinners.add((int) spinner_1.getValue()); // Second
spinner value
}
if (add > 2) {
productOrders.add(productOrder_2.getText()); // Third
product order
spinners.add((int) spinner_2.getValue()); // Third spinner
value
}
if (add > 3) {
productOrders.add(productOrder_3.getText()); // Fourth
product order
spinners.add((int) spinner_3.getValue()); // Fourth
spinner value
}
}
});
}
}
GCASH
// Class: Gcash
// Description: Manages a payment interface using GCash for authorization and
transaction processing.
import java.awt.EventQueue;
package logistics;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
/**
* Launch the application.
* Initializes and displays the GCash payment interface.
*/
/**
* Create the application.
*/
public Gcash() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.getContentPane().setBackground(Color.WHITE);
frame.setBounds(100, 100, 450, 293);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
lblPaymayaIsPending.setText("Payment Succesful!");
}
});
pay.setBackground(new Color(0, 0, 0));
pay.setBounds(323, 210, 89, 33);
frame.getContentPane().add(pay);
JLabel lblNewLabel_2 = new JLabel("Make sure you have the GCash app
installed and the notification is not muted . ");
lblNewLabel_2.setFont(new Font("Dialog", Font.PLAIN, 10));
lblNewLabel_2.setBounds(21, 139, 668, 14);
frame.getContentPane().add(lblNewLabel_2);
}
}
InventoryDisplay
// Class: InventoryDisplay
// Description: Displays an inventory from a database using Swing components.
package logistics;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.sql.*;
public InventoryDisplay() {
panel = new JPanel(new BorderLayout());
table = new JTable();
add(panel);
setTitle("Database Panel");
setSize(400, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setVisible(true);
connection.close();
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
}
/**
* Converts a ResultSet to a TableModel for display in the JTable.
* @param resultSet The ResultSet obtained from the database query.
* @return TableModel containing the data retrieved from the database.
* @throws SQLException If an SQL exception occurs during ResultSet processing.
*/
// Get data
Object[][] data = new Object[100][columnCount]; // Adjust the array size based on
your needs
int rowCount = 0;
while (resultSet.next()) {
for (int i = 1; i <= columnCount; i++) {
data[rowCount][i - 1] = resultSet.getObject(i);
}
rowCount++;
}
/**
* Entry point to start the InventoryDisplay GUI.
* @param args Command-line arguments.
*/
package logistics;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import com.mysql.cj.jdbc.result.ResultSetMetaData;
import javax.swing.border.BevelBorder;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;
import java.awt.event.ActionEvent;
import javax.swing.JComboBox;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import java.awt.Component;
import java.awt.Dimension;
/**
* Converts a ResultSet to a TableModel for display in the JTable.
* @param rs The ResultSet obtained from the database query.
* @return TableModel containing the data retrieved from the database.
* @throws SQLException If an SQL exception occurs during ResultSet processing.
*/
/**
* Launches the Logistics application.
* @param args Command-line arguments.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Logistics window = new Logistics();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public Logistics() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.getContentPane().setBackground(new Color(255, 255, 255));
frame.setBounds(100, 100, 927, 453);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
if (inputCustomerID.isEmpty() || !inputCustomerID.matches("\\d+")) {
JOptionPane.showMessageDialog(frame, "Please enter a valid customer
ID.", "Invalid Input", JOptionPane.ERROR_MESSAGE);
return;
}
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/sys","root", "1234567");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT `ordernumber`, `customerid`,
customername, customeraddress, productorder, `quantity`, deliveryStatus FROM
customer_crud WHERE `customerid` = " + customerId);
if (!rs.next()) {
JOptionPane.showMessageDialog(frame, "ID not found.", "ID Not
Found", JOptionPane.ERROR_MESSAGE);
return;
}
do {
customerID.setText(String.valueOf(rs.getInt("customerid")));
customerName.setText(rs.getString("customername"));
itemName.setText(rs.getString("productorder"));
customerAddress.setText(rs.getString("customeraddress"));
String deliveryStatus = rs.getString("deliveryStatus");
if (deliveryStatus != null) {
statusLabel.setText(deliveryStatus);
switch (deliveryStatus) {
case "Pending":
statusLabel.setForeground(Color.RED);
break;
case "Picked Up":
statusLabel.setForeground(Color.ORANGE);
break;
case "In-Transit":
statusLabel.setForeground(Color.YELLOW);
break;
case "Delivered":
statusLabel.setForeground(Color.GREEN);
break;
default:
statusLabel.setForeground(Color.BLACK);
break;
}
} else {
statusLabel.setText("Pending");
statusLabel.setForeground(Color.RED); // Default to red for pending
status
}
} while (rs.next());
frame.repaint();
frame.revalidate();
}
});
btnRestock.setForeground(Color.WHITE);
btnRestock.setFont(new Font("Dialog", Font.BOLD, 14));
btnRestock.setBorder(null);
btnRestock.setBackground(Color.BLACK);
btnRestock.setBounds(172, 108, 95, 36);
frame.getContentPane().add(btnRestock);
if (inputCustomerID.isEmpty() || !inputCustomerID.matches("\\d+")) {
JOptionPane.showMessageDialog(frame, "Please enter a valid customer
ID.", "Invalid Input", JOptionPane.ERROR_MESSAGE);
return;
}
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/sys","root", "1234567");
Statement st = conn.createStatement();
btnUpdate.setForeground(Color.WHITE);
btnUpdate.setFont(new Font("Dialog", Font.BOLD, 14));
btnUpdate.setBorder(null);
btnUpdate.setBackground(Color.BLACK);
btnUpdate.setBounds(377, 107, 95, 37);
frame.getContentPane().add(btnUpdate);
} catch(Exception ex) {
System.out.println(ex);
}
}
});
btnDisplay.setForeground(Color.WHITE);
btnDisplay.setFont(new Font("Dialog", Font.BOLD, 14));
btnDisplay.setBorder(null);
btnDisplay.setBackground(Color.BLACK);
btnDisplay.setBounds(272, 108, 95, 36);
frame.getContentPane().add(btnDisplay);
}
}
Paymaya
// Class: Paymaya
// Description: Manages PayMaya transactions and provides functionality for
authorization via the app.
package logistics;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Paymaya window = new Paymaya();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public Paymaya() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.getContentPane().setBackground(Color.WHITE);
frame.setBounds(100, 100, 450, 293);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
lblPaymayaIsPending.setText("Payment Succesful!");
}
});
pay.setBackground(new Color(43, 174, 132));
pay.setBounds(216, 216, 89, 23);
frame.getContentPane().add(pay);
JLabel lblNewLabel_2 = new JLabel("Make sure you have the Maya app
installed and the notification is not muted . ");
lblNewLabel_2.setFont(new Font("Dialog", Font.PLAIN, 10));
lblNewLabel_2.setBounds(21, 123, 668, 14);
frame.getContentPane().add(lblNewLabel_2);
}
}
Procurement
// Description: This class handles procurement-related functionalities such as fetching
details, settling payments, and completing transactions.
package logistics;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
import javax.swing.border.BevelBorder;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
public Procurement() {
initialize();
}
comboBox_1_1.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
String selectedItem = (String) comboBox_1_1.getSelectedItem();
if(comboBox.getSelectedItem()=="Nike") {
fetchDetailsFromDatabase(selectedItem, "nike");
}
else if(comboBox.getSelectedItem()=="Adidas") {
fetchDetailsFromDatabase(selectedItem, "adidas");
}
}
});
if (rowsAffected > 0) {
JOptionPane.showMessageDialog(null, "Transaction Succesful");
} else {
System.out.println("Failed to insert data.");
}
}
}
});
btnBuy.setEnabled(false);
btnBuy.setForeground(Color.WHITE);
btnBuy.setFont(new Font("Dialog", Font.BOLD, 14));
btnBuy.setBorder(null);
btnBuy.setBackground(Color.BLACK);
btnBuy.setBounds(592, 331, 95, 36);
frame.getContentPane().add(btnBuy);
btnSettlePayment.setForeground(Color.WHITE);
btnSettlePayment.setFont(new Font("Dialog", Font.BOLD, 14));
btnSettlePayment.setBorder(null);
btnSettlePayment.setBackground(Color.BLACK);
btnSettlePayment.setBounds(436, 331, 135, 36);
frame.getContentPane().add(btnSettlePayment);
btnSettlePayment.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
price = Integer.parseInt(textField_7.getText());
if(rdbtnPaymaya.isSelected()) {
frame = new JFrame();
frame.getContentPane().setBackground(Color.WHITE);
frame.setBounds(100, 100, 450, 293);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JOptionPane.showMessageDialog(null,
"Payment Succesful!");
btnBuy.setEnabled(true);
frame.dispose();
}
});
pay.setBackground(new Color(0, 0, 0));
pay.setBounds(323, 210, 89, 33);
frame.getContentPane().add(pay);
frame.setVisible(true);
}else if(rdbtnGcash.isSelected()) {
frame = new JFrame();
frame.getContentPane().setBackground(Color.WHITE);
frame.setBounds(100, 100, 450, 293);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/sys","root", "1234567");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT `balance`
FROM gcash_users_list WHERE `number`= " + number +"");
while (rs.next()) {
balance = rs.getDouble("balance");
}
if(balance>=5000) {
JOptionPane.showMessageDialog(null,
"Payment Succesful");
JOptionPane.showMessageDialog(null,
balance);
}else {
JOptionPane.showMessageDialog(null,
"Insufficient Balance");
}
}catch(Exception e9) {
e9.printStackTrace();
}
}
});
frame.setVisible(true);
}
}
});
comboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if(comboBox.getSelectedItem()=="Nike") {
populateComboBox("nike");
}else if(comboBox.getSelectedItem()=="Adidas") {
populateComboBox("adidas");
}
}
});
}
// Create a PreparedStatement
PreparedStatement statement = connection.prepareStatement(query);
// Query to fetch details from the "nike" table based on the selected item_code
String query = "SELECT * FROM " + ""+ table + "" +" WHERE `item_code` = ?";
// Create a PreparedStatement
PreparedStatement statement = connection.prepareStatement(query);
}catch(Exception e1) {
e1.printStackTrace();
}
}
}
SupplierSide
try { Class.forName("com.mysql.cj.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/sys","root", "1234567");
String query= "INSERT INTO "+ table +" (item_code, item_name,
product_line, supplier, manufacturing_date, quantity, manufacturing_country,
item_price) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
PreparedStatement ps=con.prepareStatement(query);
ps.setInt(1, Integer.parseInt(item_code.getText()));
ps.setString(2, item_name.getText());
ps.setString(3, product_line.getText());
ps.setString(4, supplier.getText());
ps.setString(5, manufacturing_date.getText());
ps.setInt(6, Integer.parseInt(quantity.getText()));
ps.setString(7, manufacturing_country.getText());
ps.setInt(8, Integer.parseInt(item_price.getText()));
ps.executeUpdate();
String[] logData = {
item_code.getText(),
item_name.getText(),
supplier.getText(),
manufacturing_date.getText(),
quantity.getText(),
manufacturing_country.getText(),
};
logList.add(logData);
public SupplierSide() {
getContentPane().setBackground(Color.WHITE);
setTitle("Database Table Example");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
logList = new ArrayList<>();
logTableModel = new DefaultTableModel();
setSize(835, 423);
getContentPane().setLayout(null);
apply(sup);
}else if(sup.equals("Adidas")) {
apply(sup);
}
});
btnDisplay.setForeground(Color.WHITE);
btnDisplay.setFont(new Font("Dialog", Font.BOLD, 14));
btnDisplay.setBorder(null);
btnDisplay.setBackground(Color.BLACK);
btnDisplay.setBounds(577, 315, 95, 36);
getContentPane().add(btnDisplay);
setLocationRelativeTo(null);
setVisible(true);
}
--
-- Table structure for table `adidas`
--
--
-- Dumping data for table `adidas`
--
--
-- Table structure for table `admin_crud`
--
--
-- Dumping data for table `admin_crud`
--
--
-- Table structure for table `customer_crud`
--
--
-- Dumping data for table `customer_crud`
--
--
-- Table structure for table `gcash_users_list`
--
--
-- Dumping data for table `gcash_users_list`
--
--
-- Table structure for table `login`
--
--
-- Dumping data for table `login`
--
--
-- Table structure for table `nike`
--
--
-- Dumping data for table `nike`
--
--
-- Table structure for table `paymaya_users_list`
--
--
-- Dumping data for table `paymaya_users_list`
--
● AdminSide_Client- Lets us see the clients information and will help us perform updates
● AdminSide- Is the full Admin side section that shows the logs and applies the full CRUD
method
● ClientInterface- Its where the customer orders their products, having to choose between
the two payment methods
● Gcash- Where it verifies the Gcash section of the payment
● InventoryDisplay- A class that shows the possible products from our inventory
● Login- Where the user of the application access their account
● Logistics- Shows the Tracking order and lets the admin update its status
● Paymaya-Where it verifies the PayMaya section of the payment
● Procurement-Settles the payment section of our two suppliers
● SupplierSide- The class where the supplier enters their section of the products
Members Information
Name (SN, FN, Picture (1x1 Detailed Email Address Phone Number
MI.) Uniform Contributions/A
picture) ssigned Tasks:
Member 3: Luis Built the java for qleomana@tip.e 0997 223 9616
Ezekeil Omana Sale du.ph
Management
and contributed
in Database.