PurchaseOrder Update
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package org.example.petshopdesktop.DTOs;
|
||||
|
||||
public class PurchaseOrderDTO {
|
||||
|
||||
private int purchaseOrderId;
|
||||
private String supplierName;
|
||||
private String productName;
|
||||
private int quantity;
|
||||
private double unitCost;
|
||||
private String orderDate;
|
||||
private String status;
|
||||
|
||||
public PurchaseOrderDTO(int purchaseOrderId,
|
||||
String supplierName,
|
||||
String productName,
|
||||
int quantity,
|
||||
double unitCost,
|
||||
String orderDate,
|
||||
String status) {
|
||||
|
||||
this.purchaseOrderId = purchaseOrderId;
|
||||
this.supplierName = supplierName;
|
||||
this.productName = productName;
|
||||
this.quantity = quantity;
|
||||
this.unitCost = unitCost;
|
||||
this.orderDate = orderDate;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getPurchaseOrderId() {
|
||||
return purchaseOrderId;
|
||||
}
|
||||
|
||||
public String getSupplierName() {
|
||||
return supplierName;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public int getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public double getUnitCost() {
|
||||
return unitCost;
|
||||
}
|
||||
|
||||
public String getOrderDate() {
|
||||
return orderDate;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,52 @@
|
||||
package org.example.petshopdesktop.database;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import org.example.petshopdesktop.DTOs.PurchaseOrderDTO;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
public class PurchaseOrderDB {
|
||||
}
|
||||
|
||||
public static ObservableList<PurchaseOrderDTO> getPurchaseOrders()
|
||||
throws SQLException {
|
||||
|
||||
ObservableList<PurchaseOrderDTO> list =
|
||||
FXCollections.observableArrayList();
|
||||
|
||||
Connection conn = ConnectionDB.getConnection();
|
||||
|
||||
String sql = """
|
||||
SELECT po.purchaseOrderId,
|
||||
s.supCompany AS supplierName,
|
||||
p.prodName AS productName,
|
||||
poi.quantity,
|
||||
poi.unitCost,
|
||||
po.orderDate,
|
||||
po.status
|
||||
FROM purchaseOrder po
|
||||
JOIN supplier s ON po.supId = s.supId
|
||||
JOIN purchaseOrderItem poi ON po.purchaseOrderId = poi.purchaseOrderId
|
||||
JOIN product p ON poi.prodId = p.prodId
|
||||
""";
|
||||
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(sql);
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
list.add(new PurchaseOrderDTO(
|
||||
rs.getInt("purchaseOrderId"),
|
||||
rs.getString("supplierName"),
|
||||
rs.getString("productName"),
|
||||
rs.getInt("quantity"),
|
||||
rs.getDouble("unitCost"),
|
||||
rs.getString("orderDate"),
|
||||
rs.getString("status")
|
||||
));
|
||||
}
|
||||
|
||||
conn.close();
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +1,35 @@
|
||||
package org.example.petshopdesktop.models;
|
||||
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
public class PurchaseOrder {
|
||||
|
||||
private SimpleIntegerProperty orderId;
|
||||
private SimpleStringProperty supplierName;
|
||||
private SimpleStringProperty orderDate;
|
||||
private SimpleStringProperty status;
|
||||
private int purchaseOrderId;
|
||||
private int supId;
|
||||
private String orderDate;
|
||||
private String status;
|
||||
|
||||
public PurchaseOrder(int orderId,
|
||||
String supplierName,
|
||||
public PurchaseOrder(int purchaseOrderId,
|
||||
int supId,
|
||||
String orderDate,
|
||||
String status) {
|
||||
|
||||
this.orderId = new SimpleIntegerProperty(orderId);
|
||||
this.supplierName = new SimpleStringProperty(supplierName);
|
||||
this.orderDate = new SimpleStringProperty(orderDate);
|
||||
this.status = new SimpleStringProperty(status);
|
||||
this.purchaseOrderId = purchaseOrderId;
|
||||
this.supId = supId;
|
||||
this.orderDate = orderDate;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getOrderId() {
|
||||
return orderId.get();
|
||||
public int getPurchaseOrderId() {
|
||||
return purchaseOrderId;
|
||||
}
|
||||
|
||||
public String getSupplierName() {
|
||||
return supplierName.get();
|
||||
public int getSupId() {
|
||||
return supId;
|
||||
}
|
||||
|
||||
public String getOrderDate() {
|
||||
return orderDate.get();
|
||||
return orderDate;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status.get();
|
||||
return status;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user