use of SMExceptions.SMException in project SmartCity-Market by TechnionYP5777.
the class CustomerLoginScreen method loginButtonPressed.
@FXML
private void loginButtonPressed(ActionEvent __) {
ICustomer customer = InjectionFactory.getInstance(Customer.class);
try {
if (username.equals(guestLogin.getUserName())) {
DialogMessagesService.showErrorDialog(String.format("The user: \"{0}\" can access only as a guest user.", username), null, "");
return;
}
customer.login(username, password, true);
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
return;
} catch (Exception e) {
DialogMessagesService.showErrorDialog(e + "", null, "");
return;
}
TempCustomerPassingData.customer = customer;
AbstractApplicationScreen.setScene("/CustomerMainScreen/CustomerMainScreen.fxml");
}
use of SMExceptions.SMException in project SmartCity-Market by TechnionYP5777.
the class CustomerMainScreen method smartcodeScannedHandler.
private void smartcodeScannedHandler() {
Integer amount;
CartProduct cartPtoduct = customer.getCartProduct(scannedSmartCode);
if (cartPtoduct != null) {
catalogProduct = cartPtoduct.getCatalogProduct();
amount = cartPtoduct.getTotalAmount();
} else {
try {
catalogProduct = customer.viewCatalogProduct(scannedSmartCode);
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
return;
}
amount = 0;
}
Platform.runLater(new Runnable() {
@Override
public void run() {
addOrRemoveScannedProduct(catalogProduct, amount);
}
});
}
use of SMExceptions.SMException in project SmartCity-Market by TechnionYP5777.
the class ManageCatalogProductTab method runTheOperationButtonPressed.
@FXML
void runTheOperationButtonPressed(ActionEvent __) {
try {
if (addCatalogProductRadioButton.isSelected()) {
manager.addProductToCatalog(new CatalogProduct(Long.parseLong(barcodeTextField.getText()), productNameTextField.getText(), new HashSet<Ingredient>(), getManufacturer(), productDescriptionTextField.getText().isEmpty() ? "N/A" : productDescriptionTextField.getText(), Double.parseDouble(productPriceTextField.getText()), "", new HashSet<Location>()));
printToSuccessLog("Added new product '" + productNameTextField.getText() + "' to catalog");
} else if (removeCatalogProductRadioButton.isSelected()) {
manager.removeProductFromCatalog(new SmartCode(Long.parseLong(barcodeTextField.getText()), null));
printToSuccessLog("Remove product '" + productNameTextField.getText() + "' from catalog");
}
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
}
}
use of SMExceptions.SMException in project SmartCity-Market by TechnionYP5777.
the class ManagePackagesTab method runTheOperationButtonPressed.
@FXML
private void runTheOperationButtonPressed(ActionEvent __) {
SmartCode smartcode = new SmartCode(Long.parseLong(barcodeTextField.getText()), datePicker.getValue());
int amountVal = editPackagesAmountSpinner.getValue();
log.info("===============================runTheOperationButtonPressed======================================");
log.info("amount in spinner: " + amountVal);
try {
if (barcodeOperationsPane.isVisible()) {
log.info("barcode pane is visible");
if (addPakageToWarhouseRadioButton.isSelected()) {
log.info("addPakageToWarhouseRadioButton");
// init
Location loc = new Location(0, 0, PlaceInMarket.WAREHOUSE);
ProductPackage pp = new ProductPackage(smartcode, amountVal, loc);
// exec
worker.addProductToWarehouse(pp);
printToSuccessLog("Added (" + amountVal + ") " + "product packages (" + pp + ") to warehouse");
this.expirationDate = datePicker.getValue();
searchCodeButtonPressed(null);
}
} else if (addPackageToStoreRadioButton.isSelected()) {
log.info("addPackageToStoreRadioButton");
Location loc = new Location(0, 0, PlaceInMarket.STORE);
ProductPackage pp = new ProductPackage(smartcode, amountVal, loc);
worker.placeProductPackageOnShelves(pp);
printToSuccessLog("Added (" + amountVal + ") " + "product packages (" + pp + ") to store");
searchCodeButtonPressed(null);
} else if (removePackageFromStoreRadioButton.isSelected()) {
log.info("removePackageFromStoreRadioButton");
Location loc = new Location(0, 0, PlaceInMarket.STORE);
ProductPackage pp = new ProductPackage(smartcode, amountVal, loc);
worker.removeProductPackageFromStore(pp);
printToSuccessLog("Removed (" + amountVal + ") " + "product packages (" + pp + ") from store");
searchCodeButtonPressed(null);
} else if (!removePackageFromWarhouseRadioButton.isSelected()) {
if (printSmartCodeRadioButton.isSelected())
new SmartcodePrint(smartcode, amountVal).print();
} else {
log.info("removePackageFromWarhouseRadioButton");
Location loc = new Location(0, 0, PlaceInMarket.WAREHOUSE);
ProductPackage pp = new ProductPackage(smartcode, amountVal, loc);
worker.removeProductPackageFromStore(pp);
printToSuccessLog("Removed (" + amountVal + ") " + "product packages (" + pp + ") from warehouse");
searchCodeButtonPressed(null);
}
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
}
log.info("===============================runTheOperationButtonPressed======================================");
}
use of SMExceptions.SMException in project SmartCity-Market by TechnionYP5777.
the class EmployeeApplicationScreen method start.
@Override
public void start(Stage primaryStage) {
try {
stage = primaryStage;
InjectionFactory.createInjector(new EmployeeDiConfigurator(), new CommonDiConfigurator());
IEmployeeScreensParameterService employeeScreensParameterService = InjectionFactory.getInstance(EmployeeScreensParameterService.class);
employeeScreensParameterService.setNotShowMainScreenVideo(show);
barcodeEventHandler = InjectionFactory.getInstance(BarcodeEventHandler.class);
barcodeEventHandler.initializeHandler();
barcodeEventHandler.startListening();
setScene("/EmployeeMainScreen/EmployeeMainScreen.fxml");
stage.setTitle("Smart Market Beta");
stage.setMaximized(true);
stage.setOnCloseRequest(event -> {
try {
IWorker worker = InjectionFactory.getInstance(Worker.class);
if (worker.isLoggedIn())
worker.logout();
event.consume();
Platform.exit();
System.exit(0);
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
Platform.exit();
System.exit(0);
}
});
stage.show();
} catch (Exception e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
}
}
Aggregations