diff --git a/src/main/java/com/pharmacy/Controllers/ProductController.java b/src/main/java/com/pharmacy/Controllers/ProductController.java
index 3f4ea68..ed09e59 100644
--- a/src/main/java/com/pharmacy/Controllers/ProductController.java
+++ b/src/main/java/com/pharmacy/Controllers/ProductController.java
@@ -103,7 +103,7 @@ public void addProduct(ProductModel productModel) {
}
}
- public void addPurchaseInfo(ProductModel productModel) {
+ public void addRestockInfo(ProductModel productModel) {
java.sql.Date date = new java.sql.Date(productModel.getDate().getTime());
try {
@@ -171,11 +171,12 @@ public void updateProduct(ProductModel productModel) {
/**
* Handling of stocks in Purchase page (-)
+ * when a restocking info is deleted
*
* @param code product code
* @param quantity quantity of product
*/
- public void updatePurchaseStock(String code, int quantity) {
+ public void reduceProductStock(String code, int quantity) {
try {
String query = "SELECT * FROM products WHERE product_code='" + code + "'";
resultSet = statement.executeQuery(query);
@@ -232,7 +233,7 @@ public void deleteProduct(int pid) {
}
}
- public void deletePurchaseInfo(int id) {
+ public void deleteRestockInfo(int id) {
try {
String query = "DELETE FROM purchaseinfo WHERE purchase_id=?";
preparedStatement = connection.prepareStatement(query);
@@ -297,8 +298,8 @@ public void sellProduct(ProductModel productModel, String username) {
public ResultSet getProducts() {
try {
String query = """
- SELECT pid, product_code, product_name, description, quantity, cost_price, sell_price, supplied_by, expiration_date, last_updated FROM products;
- """;
+ SELECT pid, product_code, product_name, description, quantity, cost_price, sell_price, supplied_by, expiration_date, last_updated FROM products;
+ """;
resultSet = statement.executeQuery(query);
} catch (SQLException throwables) {
@@ -309,7 +310,7 @@ public ResultSet getProducts() {
}
// Purchase table data set retrieval
- public ResultSet getPurchaseInfo() {
+ public ResultSet getRestockInfo() {
try {
String query = "SELECT purchase_id, purchaseinfo.product_code,product_name,purchaseinfo.quantity,total_cost "
+ "FROM purchaseinfo INNER JOIN products "
@@ -326,14 +327,14 @@ public ResultSet getPurchaseInfo() {
public ResultSet getSalesInfo() {
try {
String query = """
- SELECT sales_id, products.product_name AS products_code,
- customers.full_name AS customer_code, salesinfo.quantity, revenue,
- date, users.name AS sold_by
- FROM salesinfo
- INNER JOIN products ON salesinfo.product_code = products.product_code
- INNER JOIN customers ON salesinfo.customer_code = customers.customer_code
- INNER JOIN users ON salesinfo.sold_by = users.name;
- """;
+ SELECT sales_id, products.product_name AS products_code,
+ customers.full_name AS customer_code, salesinfo.quantity, revenue,
+ date, users.name AS sold_by
+ FROM salesinfo
+ INNER JOIN products ON salesinfo.product_code = products.product_code
+ INNER JOIN customers ON salesinfo.customer_code = customers.customer_code
+ INNER JOIN users ON salesinfo.sold_by = users.name;
+ """;
resultSet = statement.executeQuery(query);
} catch (SQLException throwables) {
@@ -347,7 +348,7 @@ public ResultSet getSalesInfo() {
public ResultSet getProductSearch(String text) {
try {
String query = "SELECT pid, product_code, product_name, description, quantity, cost_price, sell_price, supplied_by, expiration_date, last_updated FROM products "
- + "WHERE product_code LIKE '%" + text + "%' OR product_name LIKE '%" + text + "%' OR supplied_by LIKE '%" + text + "%'";
+ + "WHERE product_code LIKE '%" + text + "%' OR product_name LIKE '%" + text + "%' OR supplied_by LIKE '%" + text + "%'";
resultSet = statement.executeQuery(query);
} catch (SQLException e) {
e.printStackTrace();
@@ -373,18 +374,18 @@ public ResultSet getProdFromCode(String text) {
public ResultSet getSalesSearch(String text) {
try {
String query = """
- SELECT sales_id, products.product_name AS products_code,
- customers.full_name AS customer_code, salesinfo.quantity, revenue,
- date, users.name AS sold_by
- FROM salesinfo
- INNER JOIN products ON salesinfo.product_code = products.product_code
- INNER JOIN customers ON salesinfo.customer_code = customers.customer_code
- INNER JOIN users ON salesinfo.sold_by = users.name
- WHERE salesinfo.product_code LIKE '%""" + text + "%'"
- + "OR product_name LIKE '%" + text + "%' "
- + "OR users.name LIKE '%" + text + "%'"
- + "OR customers.full_name LIKE '%" + text + "%'"
- + "ORDER BY sales_id;";
+ SELECT sales_id, products.product_name AS products_code,
+ customers.full_name AS customer_code, salesinfo.quantity, revenue,
+ date, users.name AS sold_by
+ FROM salesinfo
+ INNER JOIN products ON salesinfo.product_code = products.product_code
+ INNER JOIN customers ON salesinfo.customer_code = customers.customer_code
+ INNER JOIN users ON salesinfo.sold_by = users.name
+ WHERE salesinfo.product_code LIKE '%""" + text + "%'"
+ + "OR product_name LIKE '%" + text + "%' "
+ + "OR users.name LIKE '%" + text + "%'"
+ + "OR customers.full_name LIKE '%" + text + "%'"
+ + "ORDER BY sales_id;";
resultSet = statement.executeQuery(query);
} catch (SQLException e) {
@@ -395,7 +396,7 @@ public ResultSet getSalesSearch(String text) {
}
// Search method for purchase logs
- public ResultSet getPurchaseSearch(String text) {
+ public ResultSet getRestockSearch(String text) {
try {
String query = "SELECT purchase_id,purchaseinfo.product_code,products.product_name,quantity,total_cost\n"
+ "FROM purchaseinfo INNER JOIN products ON purchaseinfo.product_code=products.product_code\n"
diff --git a/src/main/java/com/pharmacy/Views/Dashboard.form b/src/main/java/com/pharmacy/Views/Dashboard.form
index 4cf16c6..abe5d67 100644
--- a/src/main/java/com/pharmacy/Views/Dashboard.form
+++ b/src/main/java/com/pharmacy/Views/Dashboard.form
@@ -221,7 +221,7 @@
-
+
diff --git a/src/main/java/com/pharmacy/Views/Dashboard.java b/src/main/java/com/pharmacy/Views/Dashboard.java
index 541a24c..6034f03 100644
--- a/src/main/java/com/pharmacy/Views/Dashboard.java
+++ b/src/main/java/com/pharmacy/Views/Dashboard.java
@@ -43,7 +43,7 @@ public Dashboard(String username, String userType, UserModel userModel) {
displayPanel.add("Products", new ProductPage(this));
displayPanel.add("Suppliers", new SupplierPage());
displayPanel.add("Sales", new SalesPage(username, this));
- displayPanel.add("Purchase", new PurchasePage(this));
+ displayPanel.add("Restock", new RestockPage(this));
displayPanel.add("Logs", new UserLogsPage());
this.addWindowListener(new WindowAdapter() {
@@ -97,8 +97,8 @@ public void addSalesPage() {
layout.show(displayPanel, "Sales");
}
- public void addPurchasePage() {
- layout.show(displayPanel, "Purchase");
+ public void addRestockPage() {
+ layout.show(displayPanel, "Restock");
}
public void addLogsPage() {
@@ -190,7 +190,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
});
purchaseButton.setFont(new java.awt.Font("Liberation Sans", 1, 15)); // NOI18N
- purchaseButton.setText("Purchase");
+ purchaseButton.setText("Restock");
purchaseButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
purchaseButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -354,7 +354,7 @@ private void homeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
}//GEN-LAST:event_homeButtonActionPerformed
private void purchaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_purchaseButtonActionPerformed
- addPurchasePage();
+ addRestockPage();
}//GEN-LAST:event_purchaseButtonActionPerformed
private void logsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logsButtonActionPerformed
diff --git a/src/main/java/com/pharmacy/Views/PurchasePage.form b/src/main/java/com/pharmacy/Views/RestockPage.form
similarity index 99%
rename from src/main/java/com/pharmacy/Views/PurchasePage.form
rename to src/main/java/com/pharmacy/Views/RestockPage.form
index 96f5816..fb2718a 100644
--- a/src/main/java/com/pharmacy/Views/PurchasePage.form
+++ b/src/main/java/com/pharmacy/Views/RestockPage.form
@@ -67,7 +67,7 @@
-
+
@@ -76,7 +76,7 @@
-
+
diff --git a/src/main/java/com/pharmacy/Views/PurchasePage.java b/src/main/java/com/pharmacy/Views/RestockPage.java
similarity index 97%
rename from src/main/java/com/pharmacy/Views/PurchasePage.java
rename to src/main/java/com/pharmacy/Views/RestockPage.java
index fe96f5c..bb22e0d 100644
--- a/src/main/java/com/pharmacy/Views/PurchasePage.java
+++ b/src/main/java/com/pharmacy/Views/RestockPage.java
@@ -13,7 +13,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
-public class PurchasePage extends javax.swing.JPanel {
+public class RestockPage extends javax.swing.JPanel {
ProductModel productModel;
Dashboard dashboard;
@@ -21,7 +21,7 @@ public class PurchasePage extends javax.swing.JPanel {
int quantity;
String prodCode = null;
- public PurchasePage(Dashboard dashboard) {
+ public RestockPage(Dashboard dashboard) {
this.dashboard = dashboard;
initComponents();
@@ -63,9 +63,9 @@ private void initComponents() {
jLabel10 = new javax.swing.JLabel();
jLabel1.setFont(new java.awt.Font("Impact", 1, 24)); // NOI18N
- jLabel1.setText("PURCHASE");
+ jLabel1.setText("RESTOCK");
- jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Purchase Product"));
+ jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Restock Product"));
jLabel2.setText("Supplier:");
@@ -342,7 +342,7 @@ private void purchaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GE
productModel.setTotalCost(totalCost);
EventQueue.invokeLater(() -> {
- new ProductController().addPurchaseInfo(productModel);
+ new ProductController().addRestockInfo(productModel);
loadDataSet();
});
} else {
@@ -368,8 +368,8 @@ private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
JOptionPane.YES_NO_OPTION);
if (opt == JOptionPane.YES_OPTION) {
EventQueue.invokeLater(() -> {
- new ProductController().deletePurchaseInfo((int) purchaseTable.getValueAt(purchaseTable.getSelectedRow(), 0));
- new ProductController().updatePurchaseStock(prodCode, quantity);
+ new ProductController().deleteRestockInfo((int) purchaseTable.getValueAt(purchaseTable.getSelectedRow(), 0));
+ new ProductController().reduceProductStock(prodCode, quantity);
loadDataSet();
});
}
@@ -446,7 +446,7 @@ public void loadDataSet() {
EventQueue.invokeLater(() -> {
try {
ProductController productController = new ProductController();
- purchaseTable.setModel(new DataTableModel().buildTableModel(productController.getPurchaseInfo()));
+ purchaseTable.setModel(new DataTableModel().buildTableModel(productController.getRestockInfo()));
} catch (SQLException throwables) {
throwables.printStackTrace();
}
@@ -458,7 +458,7 @@ public void loadSearchData(String text) {
EventQueue.invokeLater(() -> {
try {
ProductController productController = new ProductController();
- purchaseTable.setModel(new DataTableModel().buildTableModel(productController.getPurchaseSearch(text)));
+ purchaseTable.setModel(new DataTableModel().buildTableModel(productController.getRestockSearch(text)));
} catch (SQLException e) {
e.printStackTrace();
}