Search in sources :

Example 6 with SMException

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");
}
Also used : ICustomer(CustomerContracts.ICustomer) SMException(SMExceptions.SMException) SMException(SMExceptions.SMException) FXML(javafx.fxml.FXML)

Example 7 with SMException

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);
        }
    });
}
Also used : CartProduct(BasicCommonClasses.CartProduct) SMException(SMExceptions.SMException)

Example 8 with SMException

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();
    }
}
Also used : SmartCode(BasicCommonClasses.SmartCode) CatalogProduct(BasicCommonClasses.CatalogProduct) SMException(SMExceptions.SMException) HashSet(java.util.HashSet) FXML(javafx.fxml.FXML)

Example 9 with SMException

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======================================");
}
Also used : SmartCode(BasicCommonClasses.SmartCode) ProductPackage(BasicCommonClasses.ProductPackage) SmartcodePrint(SmartcodeParser.SmartcodePrint) SMException(SMExceptions.SMException) SmartcodePrint(SmartcodeParser.SmartcodePrint) Location(BasicCommonClasses.Location) FXML(javafx.fxml.FXML)

Example 10 with SMException

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));
    }
}
Also used : BarcodeEventHandler(UtilsImplementations.BarcodeEventHandler) EmployeeDiConfigurator(EmployeeDI.EmployeeDiConfigurator) CommonDiConfigurator(CommonDI.CommonDiConfigurator) IEmployeeScreensParameterService(EmployeeCommon.IEmployeeScreensParameterService) IWorker(EmployeeContracts.IWorker) SMException(SMExceptions.SMException) SMException(SMExceptions.SMException)

Aggregations

SMException (SMExceptions.SMException)12 FXML (javafx.fxml.FXML)7 ICustomer (CustomerContracts.ICustomer)5 SmartCode (BasicCommonClasses.SmartCode)3 BarcodeEventHandler (UtilsImplementations.BarcodeEventHandler)2 CartProduct (BasicCommonClasses.CartProduct)1 CatalogProduct (BasicCommonClasses.CatalogProduct)1 CustomerProfile (BasicCommonClasses.CustomerProfile)1 ForgotPasswordData (BasicCommonClasses.ForgotPasswordData)1 ICustomerProfile (BasicCommonClasses.ICustomerProfile)1 Ingredient (BasicCommonClasses.Ingredient)1 Location (BasicCommonClasses.Location)1 ProductPackage (BasicCommonClasses.ProductPackage)1 CommonDiConfigurator (CommonDI.CommonDiConfigurator)1 CLIENT_TYPE (CommonDefs.CLIENT_TYPE)1 CustomerDiConfigurator (CustomerDI.CustomerDiConfigurator)1 EmployeeScreensParameterService (EmployeeCommon.EmployeeScreensParameterService)1 IEmployeeScreensParameterService (EmployeeCommon.IEmployeeScreensParameterService)1 IManager (EmployeeContracts.IManager)1 IWorker (EmployeeContracts.IWorker)1