-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from ahmedsiam0/orders-history4customer-and-admin
Add orders history scenes
- Loading branch information
Showing
6 changed files
with
252 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.asu.librarysystem; | ||
|
||
public class OrderRow { | ||
private Order order; | ||
private String owner; | ||
|
||
public OrderRow(Order order, String owner) { | ||
this.order = order; | ||
this.owner = owner; | ||
} | ||
|
||
public String getOwner() { | ||
return owner; | ||
} | ||
|
||
public String getBook() { | ||
return order.getBook(); | ||
} | ||
|
||
public int getQuantity() { | ||
return order.getQuantity(); | ||
} | ||
|
||
public double getPrice() { | ||
return order.getPrice(); | ||
} | ||
|
||
public String getDiscountCode() { | ||
return order.getDiscountCode(); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/main/java/com/asu/librarysystem/OrdersForAdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.asu.librarysystem; | ||
|
||
import java.net.URL; | ||
import java.util.ArrayList; | ||
import java.util.ResourceBundle; | ||
|
||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
import javafx.event.ActionEvent; | ||
import javafx.fxml.FXML; | ||
import javafx.fxml.Initializable; | ||
import javafx.scene.Node; | ||
import javafx.scene.control.TableColumn; | ||
import javafx.scene.control.TableView; | ||
import javafx.scene.control.cell.PropertyValueFactory; | ||
import javafx.stage.Stage; | ||
|
||
public class OrdersForAdminController implements Initializable { | ||
|
||
@FXML | ||
private TableView<OrderRow> mainTable; | ||
|
||
@FXML | ||
private TableColumn<OrderRow, String> ownerColumn; | ||
|
||
@FXML | ||
private TableColumn<OrderRow, String> bookColumn; | ||
|
||
@FXML | ||
private TableColumn<OrderRow, String> discountColumn; | ||
|
||
@FXML | ||
private TableColumn<OrderRow, Double> priceColumn; | ||
|
||
@FXML | ||
private TableColumn<OrderRow, Integer> quantityColumn; | ||
|
||
private ObservableList<OrderRow> tableData = FXCollections.observableArrayList(); | ||
|
||
@FXML | ||
void back(ActionEvent event) { | ||
Stage stage = (Stage)((Node)event.getSource()).getScene().getWindow(); | ||
stage.close(); | ||
} | ||
|
||
@Override | ||
public void initialize(URL location, ResourceBundle resources) { | ||
ownerColumn.setCellValueFactory(new PropertyValueFactory<OrderRow, String>("owner")); | ||
bookColumn.setCellValueFactory(new PropertyValueFactory<OrderRow, String>("book")); | ||
quantityColumn.setCellValueFactory(new PropertyValueFactory<OrderRow, Integer>("quantity")); | ||
priceColumn.setCellValueFactory(new PropertyValueFactory<OrderRow, Double>("price")); | ||
discountColumn.setCellValueFactory(new PropertyValueFactory<OrderRow, String>("discountCode")); | ||
|
||
Customer activeAccount = (Customer)Library.getActiveAccount(); | ||
|
||
ArrayList<Order> orders = activeAccount.getOrders(); | ||
|
||
for (var order : orders) { | ||
tableData.add(new OrderRow(order, activeAccount.getUserName())); | ||
} | ||
|
||
mainTable.setItems(tableData); | ||
} | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/com/asu/librarysystem/OrdersForCustomerController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.asu.librarysystem; | ||
|
||
import java.net.URL; | ||
import java.util.ArrayList; | ||
import java.util.ResourceBundle; | ||
|
||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
import javafx.event.ActionEvent; | ||
import javafx.fxml.FXML; | ||
import javafx.fxml.Initializable; | ||
import javafx.scene.Node; | ||
import javafx.scene.control.TableColumn; | ||
import javafx.scene.control.TableView; | ||
import javafx.scene.control.cell.PropertyValueFactory; | ||
import javafx.stage.Stage; | ||
|
||
public class OrdersForCustomerController implements Initializable { | ||
|
||
@FXML | ||
private TableView<Order> mainTable; | ||
|
||
@FXML | ||
private TableColumn<Order, String> bookColumn; | ||
|
||
@FXML | ||
private TableColumn<Order, String> discountColumn; | ||
|
||
@FXML | ||
private TableColumn<Order, Double> priceColumn; | ||
|
||
@FXML | ||
private TableColumn<Order, Integer> quantityColumn; | ||
|
||
private ObservableList<Order> tableData = FXCollections.observableArrayList(); | ||
|
||
@FXML | ||
void back(ActionEvent event) { | ||
Stage stage = (Stage)((Node)event.getSource()).getScene().getWindow(); | ||
stage.close(); | ||
} | ||
|
||
@Override | ||
public void initialize(URL location, ResourceBundle resources) { | ||
bookColumn.setCellValueFactory(new PropertyValueFactory<Order, String>("book")); | ||
quantityColumn.setCellValueFactory(new PropertyValueFactory<Order, Integer>("quantity")); | ||
priceColumn.setCellValueFactory(new PropertyValueFactory<Order, Double>("price")); | ||
discountColumn.setCellValueFactory(new PropertyValueFactory<Order, String>("discountCode")); | ||
|
||
ArrayList<Order> orders = ((Customer)Library.getActiveAccount()).getOrders(); | ||
|
||
for (var order : orders) { | ||
tableData.add(order); | ||
} | ||
|
||
mainTable.setItems(tableData); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
src/main/resources/com/asu/librarysystem/orders-for-admin-view.fxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.geometry.Insets?> | ||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.TableColumn?> | ||
<?import javafx.scene.control.TableView?> | ||
<?import javafx.scene.layout.ColumnConstraints?> | ||
<?import javafx.scene.layout.GridPane?> | ||
<?import javafx.scene.layout.RowConstraints?> | ||
<?import javafx.scene.text.Font?> | ||
|
||
<GridPane prefHeight="720.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.asu.librarysystem.OrdersForAdminController"> | ||
<columnConstraints> | ||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1168.800048828125" minWidth="10.0" prefWidth="640.8001098632812" /> | ||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="762.3998413085938" minWidth="10.0" prefWidth="639.1998901367188" /> | ||
</columnConstraints> | ||
<rowConstraints> | ||
<RowConstraints maxHeight="135.00000610351563" minHeight="10.0" prefHeight="65.6000015258789" vgrow="SOMETIMES" /> | ||
<RowConstraints maxHeight="210.3999801635742" minHeight="10.0" prefHeight="183.1999984741211" vgrow="SOMETIMES" /> | ||
<RowConstraints maxHeight="231.1999694824218" minHeight="10.0" prefHeight="176.7999450683593" vgrow="SOMETIMES" /> | ||
<RowConstraints maxHeight="150.99997558593753" minHeight="10.0" prefHeight="125.60005493164067" vgrow="SOMETIMES" /> | ||
</rowConstraints> | ||
<children> | ||
<Button maxHeight="1.7976931348623157E308" mnemonicParsing="false" onAction="#back" prefHeight="135.0" prefWidth="261.0" text="Back" GridPane.hgrow="ALWAYS"> | ||
<font> | ||
<Font name="Monospaced Regular" size="30.0" /> | ||
</font> | ||
</Button> | ||
<Label text="Orders History" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.valignment="CENTER"> | ||
<font> | ||
<Font name="Monospaced Regular" size="30.0" /> | ||
</font> | ||
</Label> | ||
<TableView fx:id="mainTable" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1" GridPane.rowSpan="3" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS"> | ||
<columns> | ||
<TableColumn fx:id="ownerColumn" prefWidth="264.80023193359375" text="Owner" /> | ||
<TableColumn fx:id="bookColumn" prefWidth="490.39995497465134" text="Book" /> | ||
<TableColumn fx:id="quantityColumn" minWidth="0.0" prefWidth="96.79998397827148" text="Quantity" /> | ||
<TableColumn fx:id="priceColumn" prefWidth="148.0" text="Price" /> | ||
<TableColumn fx:id="discountColumn" prefWidth="140.0" text="Discount" /> | ||
</columns> | ||
<GridPane.margin> | ||
<Insets top="30.0" /> | ||
</GridPane.margin> | ||
</TableView> | ||
</children> | ||
</GridPane> |
47 changes: 47 additions & 0 deletions
47
src/main/resources/com/asu/librarysystem/orders-for-customer-view.fxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.geometry.Insets?> | ||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.TableColumn?> | ||
<?import javafx.scene.control.TableView?> | ||
<?import javafx.scene.layout.ColumnConstraints?> | ||
<?import javafx.scene.layout.GridPane?> | ||
<?import javafx.scene.layout.RowConstraints?> | ||
<?import javafx.scene.text.Font?> | ||
|
||
<GridPane prefHeight="720.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.asu.librarysystem.OrdersForCustomerController"> | ||
<columnConstraints> | ||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1168.800048828125" minWidth="10.0" prefWidth="640.8001098632812" /> | ||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="762.3998413085938" minWidth="10.0" prefWidth="639.1998901367188" /> | ||
</columnConstraints> | ||
<rowConstraints> | ||
<RowConstraints maxHeight="135.00000610351563" minHeight="10.0" prefHeight="65.6000015258789" vgrow="SOMETIMES" /> | ||
<RowConstraints maxHeight="210.3999801635742" minHeight="10.0" prefHeight="183.1999984741211" vgrow="SOMETIMES" /> | ||
<RowConstraints maxHeight="231.1999694824218" minHeight="10.0" prefHeight="176.7999450683593" vgrow="SOMETIMES" /> | ||
<RowConstraints maxHeight="150.99997558593753" minHeight="10.0" prefHeight="125.60005493164067" vgrow="SOMETIMES" /> | ||
</rowConstraints> | ||
<children> | ||
<Button maxHeight="1.7976931348623157E308" mnemonicParsing="false" onAction="#back" prefHeight="135.0" prefWidth="261.0" text="Back" GridPane.hgrow="ALWAYS"> | ||
<font> | ||
<Font name="Monospaced Regular" size="30.0" /> | ||
</font> | ||
</Button> | ||
<Label text="Orders History" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.valignment="CENTER"> | ||
<font> | ||
<Font name="Monospaced Regular" size="30.0" /> | ||
</font> | ||
</Label> | ||
<TableView fx:id="mainTable" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1" GridPane.rowSpan="3" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS"> | ||
<columns> | ||
<TableColumn fx:id="bookColumn" prefWidth="490.39995497465134" text="Book" /> | ||
<TableColumn fx:id="quantityColumn" minWidth="0.0" prefWidth="96.79998397827148" text="Quantity" /> | ||
<TableColumn fx:id="priceColumn" prefWidth="148.0" text="Price" /> | ||
<TableColumn fx:id="discountColumn" prefWidth="140.0" text="Discount" /> | ||
</columns> | ||
<GridPane.margin> | ||
<Insets top="30.0" /> | ||
</GridPane.margin> | ||
</TableView> | ||
</children> | ||
</GridPane> |