Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sadegh-majidi committed Jun 22, 2020
2 parents 40a1649 + 3886556 commit 5a365eb
Show file tree
Hide file tree
Showing 55 changed files with 262 additions and 71 deletions.
1 change: 0 additions & 1 deletion Resources/Categories/book.json

This file was deleted.

2 changes: 1 addition & 1 deletion Resources/Discounts/dis_fuckMavenCode.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"id":1,"code":"fuckMavenCode","startDate":{"year":2020,"month":6,"day":13},"endDate":{"year":2020,"month":6,"day":26},"maxDiscountAmount":60000,"discountPercent":40,"includedCustomers":{"sadeegh":9,"kure":8}}
{"id":1,"code":"fuckMavenCode","startDate":{"year":2020,"month":6,"day":13},"endDate":{"year":2020,"month":6,"day":26},"maxDiscountAmount":60000,"discountPercent":30,"includedCustomers":{"sadeegh":9,"kure":8}}
1 change: 1 addition & 0 deletions Resources/GoodsInCarts/goodCart_40.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"goodInCartId":40,"goodId":6,"seller":"jafar","number":1}
1 change: 1 addition & 0 deletions Resources/GoodsInCarts/goodCart_46.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"goodInCartId":46,"goodId":6,"seller":"jafar","number":1}
1 change: 1 addition & 0 deletions Resources/GoodsInCarts/goodCart_52.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"goodInCartId":52,"goodId":6,"seller":"jafar","number":1}
1 change: 1 addition & 0 deletions Resources/GoodsInCarts/goodCart_58.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"goodInCartId":58,"goodId":6,"seller":"jafar","number":1}
1 change: 1 addition & 0 deletions Resources/GoodsInCarts/goodCart_64.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"goodInCartId":64,"goodId":1,"seller":"yasaman","number":2}
1 change: 1 addition & 0 deletions Resources/Orders/OrderForCustomers/order_24.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"goodsDetails":[40],"discountAmount":0,"address":"shiraz","phoneNumber":"09876543214","postCode":"65748493","name":"yasaman","orderId":24,"date":{"year":2020,"month":6,"day":22},"price":50000,"orderStatus":"RECEIVED"}
1 change: 1 addition & 0 deletions Resources/Orders/OrderForCustomers/order_26.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"goodsDetails":[46],"discountAmount":0,"address":"tehran","phoneNumber":"09876547321","postCode":"768594","name":"ghazal","orderId":26,"date":{"year":2020,"month":6,"day":22},"price":50000,"orderStatus":"RECEIVED"}
1 change: 1 addition & 0 deletions Resources/Orders/OrderForCustomers/order_28.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"goodsDetails":[52],"discountAmount":0,"address":"Iran","phoneNumber":"09876543210","postCode":"980796","name":"sadri","orderId":28,"date":{"year":2020,"month":6,"day":22},"price":50000,"orderStatus":"RECEIVED"}
1 change: 1 addition & 0 deletions Resources/Orders/OrderForCustomers/order_30.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"goodsDetails":[58],"discountAmount":0,"address":"Iran","phoneNumber":"09876543214","postCode":"768594","name":"hi","orderId":30,"date":{"year":2020,"month":6,"day":22},"price":50000,"orderStatus":"RECEIVED"}
1 change: 1 addition & 0 deletions Resources/Orders/OrderForCustomers/order_32.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"goodsDetails":[64],"discountAmount":0,"address":"Iran","phoneNumber":"09876543214","postCode":"987654","name":"kabir","orderId":32,"date":{"year":2020,"month":6,"day":22},"price":600000,"orderStatus":"RECEIVED"}
1 change: 1 addition & 0 deletions Resources/Orders/OrderForSellers/order_25.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"seller":"jafar","customerName":"kure","offDeduct":0,"numberPerGood":{"6":1},"orderId":25,"date":{"year":2020,"month":6,"day":22},"price":50000,"orderStatus":"SENT"}
1 change: 1 addition & 0 deletions Resources/Orders/OrderForSellers/order_27.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"seller":"jafar","customerName":"kure","offDeduct":0,"numberPerGood":{"6":1},"orderId":27,"date":{"year":2020,"month":6,"day":22},"price":50000,"orderStatus":"SENT"}
1 change: 1 addition & 0 deletions Resources/Orders/OrderForSellers/order_29.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"seller":"jafar","customerName":"kure","offDeduct":0,"numberPerGood":{"6":1},"orderId":29,"date":{"year":2020,"month":6,"day":22},"price":50000,"orderStatus":"SENT"}
1 change: 1 addition & 0 deletions Resources/Orders/OrderForSellers/order_31.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"seller":"jafar","customerName":"kure","offDeduct":0,"numberPerGood":{"6":1},"orderId":31,"date":{"year":2020,"month":6,"day":22},"price":50000,"orderStatus":"SENT"}
1 change: 1 addition & 0 deletions Resources/Orders/OrderForSellers/order_33.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"seller":"yasaman","customerName":"kure","offDeduct":400000,"numberPerGood":{"1":2},"orderId":33,"date":{"year":2020,"month":6,"day":22},"price":600000,"orderStatus":"SENT"}
2 changes: 1 addition & 1 deletion Resources/Products/product_1.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"goodId":1,"goodStatus":"CONFIRMED","name":"thinkpad E580","brand":"lenovo","averageRate":6.0,"subCategory":"laptop","sellerRelatedInfoAboutGoods":[1],"details":"nice laptop","comments":[1,2,4],"seenNumber":18,"modificationDate":{"year":2020,"month":5,"day":18},"categoryProperties":{"battery life":"18","cpu":"core i7","weight":"0.3","graphic":"2 GB","ram":"8 GB"}}
{"goodId":1,"goodStatus":"NOTAVAILABLE","name":"thinkpad E580","brand":"lenovo","averageRate":6.0,"subCategory":"laptop","sellerRelatedInfoAboutGoods":[1],"details":"nice laptop","comments":[1,2,4],"seenNumber":18,"modificationDate":{"year":2020,"month":5,"day":18},"categoryProperties":{"battery life":"18","cpu":"core i7","weight":"0.3","graphic":"2 GB","ram":"8 GB"}}
2 changes: 1 addition & 1 deletion Resources/Products/product_6.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"goodId":6,"goodStatus":"CONFIRMED","name":"redmi note 8pro","brand":"xiaomi","averageRate":7.0,"subCategory":"mobile","sellerRelatedInfoAboutGoods":[6],"details":"a phone","comments":[3],"seenNumber":15,"modificationDate":{"year":2020,"month":5,"day":18},"categoryProperties":{"battery life":"15","size":"7","weight":"0.4","resolution":"1280"}}
{"goodId":6,"goodStatus":"NOTAVAILABLE","name":"redmi note 8pro","brand":"xiaomi","averageRate":7.0,"subCategory":"mobile","sellerRelatedInfoAboutGoods":[6],"details":"a phone","comments":[3],"seenNumber":15,"modificationDate":{"year":2020,"month":5,"day":18},"categoryProperties":{"battery life":"15","size":"7","weight":"0.4","resolution":"1280"}}
2 changes: 1 addition & 1 deletion Resources/ProductsInfo/productInfo_1_yasaman.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"sellerRelatedInfoAboutGoodId":1,"seller":"yasaman","price":500000,"availableNumber":12}
{"sellerRelatedInfoAboutGoodId":1,"seller":"yasaman","price":500000,"availableNumber":0}
2 changes: 1 addition & 1 deletion Resources/ProductsInfo/productInfo_6_jafar.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"sellerRelatedInfoAboutGoodId":6,"seller":"jafar","price":50000,"availableNumber":1}
{"sellerRelatedInfoAboutGoodId":6,"seller":"jafar","price":50000,"availableNumber":0}
2 changes: 1 addition & 1 deletion Resources/Users/Customers/kure.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"discountCodesIds":[1,2],"previousOrders":[1,7,9,11,13,15,17,20,22],"credit":107510000,"username":"kure","firstName":"ghahreman","lastName":"kure","email":"[email protected]","phoneNumber":"09980000000","password":"Kure1"}
{"discountCodesIds":[1,2,3],"previousOrders":[1,7,9,11,13,15,17,20,22,24,26,28,30,32],"credit":106710000,"username":"kure","firstName":"ghahreman","lastName":"kure","email":"[email protected]","phoneNumber":"09980000000","password":"Kure1"}
1 change: 1 addition & 0 deletions Resources/Users/Managers/yas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"username":"yas","firstName":"yasi","lastName":"zolfi","email":"[email protected]","phoneNumber":"09876543241","password":"Yas1"}
2 changes: 1 addition & 1 deletion Resources/Users/Sellers/jafar.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"company":2,"previousSellsIds":[4,6,8],"activeGoodsIds":[2,6,16,32],"activeOffsIds":[],"username":"jafar","firstName":"mehdi","lastName":"jafar","email":"[email protected]","phoneNumber":"09360000000","password":"Jafar1"}
{"company":2,"previousSellsIds":[4,6,8,25,27,29,31],"activeGoodsIds":[2,6,16,32],"activeOffsIds":[],"username":"jafar","firstName":"mehdi","lastName":"jafar","email":"[email protected]","phoneNumber":"09360000000","password":"Jafar1"}
2 changes: 1 addition & 1 deletion Resources/Users/Sellers/yasaman.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"company":1,"previousSellsIds":[2,10,12,14,16,18,21,23],"activeGoodsIds":[1,2,7,24],"activeOffsIds":[2,3,4],"username":"yasaman","firstName":"yasaman","lastName":"zolfi","email":"[email protected]","phoneNumber":"09120000000","password":"Yasaman1"}
{"company":1,"previousSellsIds":[2,10,12,14,16,18,21,23,33],"activeGoodsIds":[1,2,7,24],"activeOffsIds":[2,3,4],"username":"yasaman","firstName":"yasaman","lastName":"zolfi","email":"[email protected]","phoneNumber":"09120000000","password":"Yasaman1"}
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@
<classifier>win</classifier>
</dependency>

<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-media -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>11</version>
</dependency>



</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void initialize(URL location, ResourceBundle resources) {
}

public static void showPage(String errorTitle, String errorContent) {
playErrorMusic();
ErrorPageFxController.errorTitle = errorTitle;
ErrorPageFxController.errorContent = errorContent;
window = new Stage();
Expand Down
81 changes: 80 additions & 1 deletion src/main/java/ApProject_OnlineShop/GUI/FxmlController.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
package ApProject_OnlineShop.GUI;

import ApProject_OnlineShop.Main;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.stage.Stage;
import javafx.scene.media.AudioClip;

import java.io.IOException;
import java.net.URL;
import java.nio.file.Paths;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

import static javafx.scene.media.AudioClip.INDEFINITE;

public class FxmlController {
private static boolean isMainLayoutPlay;
private static boolean isAccountAreaPlay;
private static boolean isAllProductPlay;

public void setScene(String address, String title) {
playButtonMusic();
Stage stage = StageController.getStage();
Parent rootParent = null;
try {
Expand All @@ -35,4 +44,74 @@ public Optional<ButtonType> showAlert(Alert.AlertType alertType, String title, S
return alert.showAndWait();
}

public static void playButtonMusic() {
String resource2 = Paths.get("src/main/resources/musics/buttonsEffects/Keyboard_Button_1-fesliyanstudios.com.mp3").toUri().toString();
realPlay(resource2);
}

public static void playErrorMusic() {
String resource2 = Paths.get("src/main/resources/musics/buttonsEffects/Error-sound.mp3").toUri().toString();
realPlay(resource2);
}

public static void playSuccessMusic() {
String resource2 = Paths.get("src/main/resources/musics/buttonsEffects/Success-sound-effect (mp3cut.net).mp3").toUri().toString();
realPlay(resource2);
}

private static void realPlay(String url) {
AudioClip audioClip = new AudioClip(url);
audioClip.setVolume(0.2);
audioClip.play();
try {
TimeUnit.MILLISECONDS.sleep(150);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

private static void playMusicForMainLayout(boolean show) {
AudioClip audioClip = new AudioClip(Paths.get("src/main/resources/musics/mainLayout.mp3").toUri().toString());
audioClip.setVolume(0.05);
audioClip.setCycleCount(INDEFINITE);
if (show) {
audioClip.play();
} else {
audioClip.stop();
}
}

private static void playMusicForAllProducts(boolean show) {
AudioClip audioClip = new AudioClip(Paths.get("src/main/resources/musics/allProducts.mp3").toUri().toString());
audioClip.setVolume(0.05);
audioClip.setCycleCount(INDEFINITE);
if (show) {
audioClip.play();
} else {
audioClip.stop();
}
}

private static void playMusicForAccountArea(boolean show) {
AudioClip audioClip = new AudioClip(Paths.get("src/main/resources/musics/accountArea.mp3").toUri().toString());
audioClip.setVolume(0.05);
audioClip.setCycleCount(INDEFINITE);
if (show) {
audioClip.play();
} else {
audioClip.stop();
}
}

public static void playMusicBackGround(boolean mainLayout, boolean allProducts, boolean accountArea) {
if (mainLayout == isMainLayoutPlay && allProducts == isAllProductPlay && accountArea == isAccountAreaPlay)
return;
playMusicForMainLayout(mainLayout);
playMusicForAccountArea(accountArea);
playMusicForAllProducts(allProducts);
isMainLayoutPlay = mainLayout;
isAccountAreaPlay = accountArea;
isAllProductPlay = allProducts;
}

}
2 changes: 0 additions & 2 deletions src/main/java/ApProject_OnlineShop/GUI/StageController.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public StageController() {
Parent root = null;
try {
root = FXMLLoader.load(Objects.requireNonNull(getClass().getClassLoader().getResource("mainMenuLayout.fxml")));
// ProductPage.setProductId(6);
// root = FXMLLoader.load(Objects.requireNonNull(getClass().getClassLoader().getResource("productPage.fxml")));
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void initialize(URL location, ResourceBundle resources) {
}

public static void showPage(String successTitle, String successContent) {
playSuccessMusic();
SuccessPageFxController.successTitle = successTitle;
SuccessPageFxController.successContent = successContent;
window = new Stage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class AccountAreaForCustomerController extends FxmlController implements

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
playMusicBackGround(false, false, true);
ArrayList<String> personalInfo = MainController.getInstance().getAccountAreaForCustomerController().getUserPersonalInfo();
userName.setText(personalInfo.get(0));
name.setText(personalInfo.get(1));
Expand All @@ -49,6 +50,7 @@ public void viewDiscountCode() {
}

public void viewSortedDiscountCode(int sort) {
playButtonMusic();
GridPane root = style.makeGridPane();
Label topic = new Label("Discount codes");
topic.setFont(Font.font("Times New Roman", 26));
Expand Down Expand Up @@ -103,6 +105,7 @@ public void viewSortedDiscountCode(int sort) {
}

public void viewSingleDiscountCode(String summeryOfDiscountCode) {
playButtonMusic();
int index = summeryOfDiscountCode.indexOf(" ");
String code = summeryOfDiscountCode.substring("discount code:".length(), index);
List<String> discountCodeDetails = Shop.getInstance().findDiscountCode(code).getAllDetails();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ public void initialize(URL location, ResourceBundle resources) {
List<Long> productIds = MainController.getInstance().getAccountAreaForCustomerController().getBoughtProducts();
int num = 0;
int row = 0;
if (productIds.size() % 3 == 0) {
if (((productIds.size() / 3) + 0) * 250 > 577) {
root.setPrefHeight(((productIds.size() / 3) + 0) * 250);
}
} else {
if (((productIds.size() / 3) + 1) * 250 > 577) {
root.setPrefHeight(((productIds.size() / 3) + 1) * 250);
}
}
for (Long productId : productIds) {
VBox vbox;
if (MainController.getInstance().getAccountAreaForSellerController().isInOff(productId)) {
Expand All @@ -56,9 +65,6 @@ public void initialize(URL location, ResourceBundle resources) {
if (num % 3 == 0)
row++;
}
if (productIds.size()/3 * 250 > 577) {
root.setPrefHeight(productIds.size() * 250);
}
}

private void rateProduct(long productId2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public ViewOrders(AccountAreaForCustomerController controller) {
}

public void viewSortedOrders(int sort) {
playButtonMusic();
GridPane root = style.makeGridPane();
Label topic = new Label("All Orders");
topic.setFont(Font.font("Times New Roman", 26));
Expand Down Expand Up @@ -80,6 +81,7 @@ public void viewSortedOrders(int sort) {
}

public void viewSingleOrder(String orderString) {
playButtonMusic();
int index = orderString.indexOf(" ");
String code = orderString.substring("order ID: ".length(), index);
long orderId = Long.parseLong(code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public void onCreateNewDiscountPressed() {

@Override
public void initialize(URL location, ResourceBundle resources) {
playMusicBackGround(false, false, true);
ArrayList<String> personalInfo = MainController.getInstance().getAccountAreaForManagerController().getUserPersonalInfo();
userName.setText(personalInfo.get(0));
name.setText(personalInfo.get(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ private void updatePage() {
List<Long> productIds = Shop.getInstance().getAllGoods().stream().map(Good::getGoodId).collect(Collectors.toList());
int num = 0;
int row = 0;
int size1 = productIds.size() * 250 / 3;
int size1 ;
if (productIds.size() % 3 == 0) {
size1 = productIds.size() * 250 / 3;
} else {
size1 = ((productIds.size() / 3) + 1) * 250;
}
if (size1 > 577) {
root.setPrefHeight(size1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class AccountAreaForSellerController extends FxmlController implements In

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
playMusicBackGround(false, false, true);
ArrayList<String> personalInfo = MainController.getInstance().getAccountAreaForSellerController().getUserPersonalInfo();
userName.setText(personalInfo.get(0));
name.setText(personalInfo.get(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ public void initialize(URL location, ResourceBundle resources) {
List<Long> productIds = MainController.getInstance().getAccountAreaForSellerController().viewProducts(sortSelected);
int num = 0;
int row = 0;
int size1;
if (productIds.size() % 3 == 0) {
size1 = productIds.size() * 250 / 3;
} else {
size1 = ((productIds.size() / 3) + 1) * 250;
}
if (size1 > 577) {
root.setPrefHeight(size1);
}
for (Long productId : productIds) {
if (MainController.getInstance().getAccountAreaForSellerController().isInOff(productId)) {
VBox vbox = new ProductBriefSummery().offProductBriefSummery(productId);
Expand All @@ -47,10 +56,6 @@ public void initialize(URL location, ResourceBundle resources) {
if (num % 3 == 0)
row++;
}
int size1 = productIds.size() * 250 / 3;
if (size1 > 577) {
root.setPrefHeight(size1);
}
}

private void showProduct(Long productId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class ViewOrdersForSeller extends FxmlController {
private Styles style = new Styles();

public void viewSortedOrders(int sort) {
playButtonMusic();
GridPane root = style.makeGridPane();
Label topic = new Label("Sales History");
topic.setFont(Font.font("Times New Roman", 26));
Expand Down Expand Up @@ -65,6 +66,7 @@ public void viewSortedOrders(int sort) {
}

public void viewSingleOrder(String orderString) {
playButtonMusic();
int index = orderString.indexOf(" ");
String code = orderString.substring("order ID: ".length(), index);
long orderId = Long.parseLong(code);
Expand Down
Loading

0 comments on commit 5a365eb

Please sign in to comment.