Search in sources :

Example 76 with ActionEvent

use of javafx.event.ActionEvent in project Money-Manager by krHasan.

the class MakeATransactionController method exbtnAdvancedSaveAndAdd.

@FXML
private void exbtnAdvancedSaveAndAdd(ActionEvent event) {
    if (total == 0) {
        exlblAdvWarningMsg.setText("Empty or Zero is not approved.");
    } else {
        TextField[] AdvancedExtxt = { extxtAdvSector1, extxtAdvSector2, extxtAdvSector3, extxtAdvSector4, extxtAdvSector5, extxtAdvSector6, extxtAdvSector7 };
        Label[] AdvancedExlbl = { exlblAdvSector1, exlblAdvSector2, exlblAdvSector3, exlblAdvSector4, exlblAdvSector5, exlblAdvSector6, exlblAdvSector7 };
        int index = 0;
        for (TextField textField : AdvancedExtxt) {
            if ((!textField.getText().isEmpty()) && (!textField.getText().equals("0"))) {
                exAdvSaveFunction(textField.getText(), AdvancedExlbl[index].getText());
            }
            ++index;
        }
        exInitialize();
        extxtAdvancedDescription.clear();
        Alert confirmationMsg = new Alert(AlertType.INFORMATION);
        confirmationMsg.setTitle("Successfull Transaction");
        confirmationMsg.setHeaderText(null);
        confirmationMsg.setContentText("Your transaction completed successfully.");
        Stage MakeATransactionStage = (Stage) exbtnSave.getScene().getWindow();
        confirmationMsg.setX(MakeATransactionStage.getX() + 200);
        confirmationMsg.setY(MakeATransactionStage.getY() + 29);
        Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                confirmationMsg.hide();
            }
        }));
        idlestage.setCycleCount(1);
        idlestage.play();
        confirmationMsg.showAndWait();
    }
}
Also used : Timeline(javafx.animation.Timeline) ActionEvent(javafx.event.ActionEvent) Label(javafx.scene.control.Label) TextField(javafx.scene.control.TextField) Stage(javafx.stage.Stage) KeyFrame(javafx.animation.KeyFrame) EventHandler(javafx.event.EventHandler) Alert(javafx.scene.control.Alert) FXML(javafx.fxml.FXML)

Example 77 with ActionEvent

use of javafx.event.ActionEvent in project Money-Manager by krHasan.

the class MakeATransactionController method bnkSaveBtn.

@FXML
private void bnkSaveBtn(ActionEvent event) {
    if (bnkSelectedTabName.equals("bKash")) {
        if (amountIsZero(bktxtAmount.getText())) {
            Alert alert = new Alert(AlertType.WARNING);
            alert.setTitle("Transaction Failed");
            alert.setHeaderText(null);
            alert.setContentText("Zero or Empty is not allowed");
            Stage MakeATransactionStage = (Stage) btnSignOut.getScene().getWindow();
            alert.setX(MakeATransactionStage.getX() + 200);
            alert.setY(MakeATransactionStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    alert.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            alert.showAndWait();
        } else {
            bnkSaveFunction();
        }
    } else if (bnkSelectedTabName.equals("Rocket")) {
        if (amountIsZero(roctxtAmount.getText())) {
            Alert alert = new Alert(AlertType.WARNING);
            alert.setTitle("Transaction Failed");
            alert.setHeaderText(null);
            alert.setContentText("Zero or Empty is not allowed");
            Stage MakeATransactionStage = (Stage) btnSignOut.getScene().getWindow();
            alert.setX(MakeATransactionStage.getX() + 200);
            alert.setY(MakeATransactionStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    alert.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            alert.showAndWait();
        } else {
            bnkSaveFunction();
        }
    } else {
        if (amountIsZero(pertxtAmount.getText())) {
            Alert alert = new Alert(AlertType.WARNING);
            alert.setTitle("Transaction Failed");
            alert.setHeaderText(null);
            alert.setContentText("Zero or Empty is not allowed");
            Stage MakeATransactionStage = (Stage) btnSignOut.getScene().getWindow();
            alert.setX(MakeATransactionStage.getX() + 200);
            alert.setY(MakeATransactionStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    alert.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            alert.showAndWait();
        } else {
            bnkSaveFunction();
        }
    }
}
Also used : Timeline(javafx.animation.Timeline) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) KeyFrame(javafx.animation.KeyFrame) EventHandler(javafx.event.EventHandler) Alert(javafx.scene.control.Alert) FXML(javafx.fxml.FXML)

Example 78 with ActionEvent

use of javafx.event.ActionEvent in project Money-Manager by krHasan.

the class MakeATransactionController method exbtnAdvancedAdjustBalance.

@FXML
private void exbtnAdvancedAdjustBalance(ActionEvent event) {
    TextInputDialog dialog = new TextInputDialog();
    dialog.setTitle("Adjust Wallet Balance");
    dialog.setHeaderText("Provide Balance Status at Your Hand Now.");
    dialog.setContentText("Please enter the amount:");
    Stage MakeATransactionStage = (Stage) exbtnAdjustBalance.getScene().getWindow();
    dialog.setX(MakeATransactionStage.getX() + 200);
    dialog.setY(MakeATransactionStage.getY() + 170);
    Optional<String> result = dialog.showAndWait();
    if (result.isPresent()) {
        String typedAmount = result.get();
        if (!validAmount(typedAmount)) {
            Alert alert = new Alert(AlertType.WARNING);
            alert.setTitle("Transaction Failed");
            alert.setHeaderText(null);
            alert.setContentText(InvalidInput);
            alert.setX(MakeATransactionStage.getX() + 200);
            alert.setY(MakeATransactionStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    alert.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            alert.showAndWait();
        } else if (amountIsZero(typedAmount)) {
            Alert alert = new Alert(AlertType.WARNING);
            alert.setTitle("Transaction Failed");
            alert.setHeaderText(null);
            alert.setContentText("Zero is not approved.");
            alert.setX(MakeATransactionStage.getX() + 200);
            alert.setY(MakeATransactionStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    alert.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            alert.showAndWait();
        } else {
            long dbWalletBalance = currentWalletBalance();
            long typedBalance = stringToLong(typedAmount);
            String exAdvAdjustBalAfter = typedAmount;
            String exAdvAdjustAmount;
            if (dbWalletBalance < typedBalance) {
                exAdvAdjustAmount = "added " + longToString(typedBalance - dbWalletBalance) + " to Wallet";
            } else if (dbWalletBalance > typedBalance) {
                exAdvAdjustAmount = exWalletBalanceAfter(typedAmount);
            } else {
                exAdvAdjustAmount = "0.0";
            }
            try {
                Map<String, String> expenseData = new HashMap<>();
                expenseData.put("exTime", timeToSave());
                expenseData.put("exDate", (new DateFormatManager()).toString(exdateAdvancedDate.getValue()));
                expenseData.put("exMonth", monthToSave(exdateAdvancedDate.getValue()));
                expenseData.put("exAmount", exAdvAdjustAmount);
                if (exIsAdvDescripionEmpty()) {
                    expenseData.put("exDescription", "You have adjusted your Wallet Balance");
                } else {
                    expenseData.put("exDescription", extxtAdvancedDescription.getText());
                }
                expenseData.put("exSector", "Adjusted Balance");
                expenseData.put("exWalletBalanceBefore", getWalletBalance());
                expenseData.put("exWalletBalanceAfter", exAdvAdjustBalAfter);
                setCurrentWalletBalance(exAdvAdjustBalAfter);
                (new Expense()).saveExpenseData(expenseData);
                (new ComboboxList()).setAllMonth(monthToSave(exdateAdvancedDate.getValue()), yearToSave(exdateAdvancedDate.getValue()));
                (new ComboboxList()).setAllExMonth(monthToSave(exdateAdvancedDate.getValue()), yearToSave(exdateAdvancedDate.getValue()));
                exInitialize();
                extxtAdvancedDescription.clear();
                Alert confirmationMsg = new Alert(AlertType.INFORMATION);
                confirmationMsg.setTitle("Successfull Transaction");
                confirmationMsg.setHeaderText(null);
                confirmationMsg.setContentText("Successful");
                confirmationMsg.setX(MakeATransactionStage.getX() + 200);
                confirmationMsg.setY(MakeATransactionStage.getY() + 29);
                Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

                    @Override
                    public void handle(ActionEvent event) {
                        confirmationMsg.hide();
                    }
                }));
                idlestage.setCycleCount(1);
                idlestage.play();
                confirmationMsg.showAndWait();
            } catch (Exception e) {
                Alert alert = new Alert(AlertType.WARNING);
                alert.setTitle("Transaction Failed");
                alert.setHeaderText(null);
                alert.setContentText("There something is wrong.");
                alert.setX(MakeATransactionStage.getX() + 200);
                alert.setY(MakeATransactionStage.getY() + 170);
                Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {

                    @Override
                    public void handle(ActionEvent event) {
                        alert.hide();
                    }
                }));
                idlestage.setCycleCount(1);
                idlestage.play();
                alert.showAndWait();
            }
        }
    }
}
Also used : ActionEvent(javafx.event.ActionEvent) DateFormatManager(system.DateFormatManager) EventHandler(javafx.event.EventHandler) Timeline(javafx.animation.Timeline) Expense(tab.Expense) ComboboxList(operation.ComboboxList) Stage(javafx.stage.Stage) KeyFrame(javafx.animation.KeyFrame) Alert(javafx.scene.control.Alert) Map(java.util.Map) HashMap(java.util.HashMap) TextInputDialog(javafx.scene.control.TextInputDialog) FXML(javafx.fxml.FXML)

Example 79 with ActionEvent

use of javafx.event.ActionEvent in project Money-Manager by krHasan.

the class MakeATransactionController method gmbtnSaveAdd.

@FXML
private void gmbtnSaveAdd(ActionEvent event) {
    if (amountIsZero(gmtxtAmount.getText())) {
        gmlblWarningMsg.setText("Empty or Zero is not approved.");
    } else {
        try {
            Map<String, String> stringData = new HashMap<>();
            stringData.put("gmTime", timeToSave());
            stringData.put("gmDate", (new DateFormatManager()).toString(gmdateDate.getValue()));
            stringData.put("gmMonth", monthToSave(gmdateDate.getValue()));
            stringData.put("gmAmount", gmtxtAmount.getText());
            if ((gmcmboMethod.getValue()).equals("bKash")) {
                stringData.put("gmBankCharge", bkashBnkCharge(gmtxtAmount.getText(), "Cash In"));
            } else if ((gmcmboMethod.getValue()).equals("Rocket")) {
                stringData.put("gmBankCharge", rocketBnkCharge(gmtxtAmount.getText(), "Cash In", gmGetSelectedrbtnName()));
            } else {
                stringData.put("gmBankCharge", "0.00");
            }
            if ((gmcmboMethod.getValue()).equals("bKash")) {
                stringData.put("gmAmountNature", "Cash In from Agent");
            } else if ((gmcmboMethod.getValue()).equals("Rocket")) {
                stringData.put("gmAmountNature", gmGetSelectedrbtnName());
            } else {
                stringData.put("gmAmountNature", "None");
            }
            if ((gmcmboMethod.getValue()).equals("bKash")) {
                stringData.put("bkBalanceAfter", updatedbKashBalance(gmtxtAmount.getText(), "Cash In"));
                (new Bkash()).saveGmBkashData(stringData);
            } else if ((gmcmboMethod.getValue()).equals("Rocket")) {
                stringData.put("rocBalanceAfter", updatedRocketBalance(gmtxtAmount.getText(), "Cash In", gmGetSelectedrbtnName()));
                (new Rocket()).saveGmRocketData(stringData);
            }
            stringData.put("gmSource", gmcmboSource.getValue());
            if (gmIsDescripionEmpty()) {
                stringData.put("gmDescription", "None");
            } else {
                stringData.put("gmDescription", gmtxtDescription.getText());
            }
            stringData.put("gmMethod", gmcmboMethod.getValue());
            stringData.put("gmWalletBalanceBefore", getWalletBalance());
            if ((gmcmboMethod.getValue()).equals("Hand to Hand")) {
                stringData.put("gmWalletBalanceAfter", gmWalletBalanceAfter(gmtxtAmount.getText()));
                setCurrentWalletBalance(gmWalletBalanceAfter(gmtxtAmount.getText()));
            } else {
                stringData.put("gmWalletBalanceAfter", getWalletBalance());
            }
            (new GetMoney()).saveGetMoneyData(stringData);
            (new ComboboxList()).setAllMonth(monthToSave(gmdateDate.getValue()), yearToSave(gmdateDate.getValue()));
            (new ComboboxList()).setAllGmMonth(monthToSave(gmdateDate.getValue()), yearToSave(gmdateDate.getValue()));
            gmInitialize();
            gmtxtAmount.clear();
            gmtxtDescription.clear();
            Alert confirmationMsg = new Alert(AlertType.INFORMATION);
            confirmationMsg.setTitle("Successfull Transaction");
            confirmationMsg.setHeaderText(null);
            confirmationMsg.setContentText("Successful");
            Stage MakeATransactionStage = (Stage) gmbtnSave.getScene().getWindow();
            confirmationMsg.setX(MakeATransactionStage.getX() + 200);
            confirmationMsg.setY(MakeATransactionStage.getY() + 29);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    confirmationMsg.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            confirmationMsg.showAndWait();
        } catch (Exception e) {
            Alert alert = new Alert(AlertType.WARNING);
            alert.setTitle("Transaction Failed");
            alert.setHeaderText(null);
            alert.setContentText("There something is wrong.");
            Stage MakeATransactionStage = (Stage) gmbtnSave.getScene().getWindow();
            alert.setX(MakeATransactionStage.getX() + 200);
            alert.setY(MakeATransactionStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    alert.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            alert.showAndWait();
        }
    }
    cancelbtnPressed = true;
}
Also used : HashMap(java.util.HashMap) GetMoney(tab.GetMoney) ActionEvent(javafx.event.ActionEvent) DateFormatManager(system.DateFormatManager) EventHandler(javafx.event.EventHandler) Rocket(tab.Rocket) Timeline(javafx.animation.Timeline) ComboboxList(operation.ComboboxList) Bkash(tab.Bkash) Stage(javafx.stage.Stage) KeyFrame(javafx.animation.KeyFrame) Alert(javafx.scene.control.Alert) FXML(javafx.fxml.FXML)

Example 80 with ActionEvent

use of javafx.event.ActionEvent in project Money-Manager by krHasan.

the class MakeATransactionController method exbtnAdvancedSave.

@FXML
private void exbtnAdvancedSave(ActionEvent event) {
    if (total == 0) {
        exlblAdvWarningMsg.setText("Empty or Zero is not approved.");
    } else {
        TextField[] AdvancedExtxt = { extxtAdvSector1, extxtAdvSector2, extxtAdvSector3, extxtAdvSector4, extxtAdvSector5, extxtAdvSector6, extxtAdvSector7 };
        Label[] AdvancedExlbl = { exlblAdvSector1, exlblAdvSector2, exlblAdvSector3, exlblAdvSector4, exlblAdvSector5, exlblAdvSector6, exlblAdvSector7 };
        int index = 0;
        for (TextField textField : AdvancedExtxt) {
            if ((!textField.getText().isEmpty()) && (!textField.getText().equals("0"))) {
                exAdvSaveFunction(textField.getText(), AdvancedExlbl[index].getText());
            }
            ++index;
        }
        exInitialize();
        extxtAdvancedDescription.clear();
        Alert confirmationMsg = new Alert(AlertType.INFORMATION);
        confirmationMsg.setTitle("Successful Transaction");
        confirmationMsg.setHeaderText(null);
        confirmationMsg.setContentText("Successful");
        Stage MakeATransactionStage = (Stage) exbtnSave.getScene().getWindow();
        confirmationMsg.setX(MakeATransactionStage.getX() + 200);
        confirmationMsg.setY(MakeATransactionStage.getY() + 29);
        Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                confirmationMsg.hide();
            }
        }));
        idlestage.setCycleCount(1);
        idlestage.play();
        confirmationMsg.showAndWait();
        (new GoToOperation()).goToDashboard(MakeATransactionStage);
    }
}
Also used : Timeline(javafx.animation.Timeline) ActionEvent(javafx.event.ActionEvent) Label(javafx.scene.control.Label) TextField(javafx.scene.control.TextField) Stage(javafx.stage.Stage) KeyFrame(javafx.animation.KeyFrame) EventHandler(javafx.event.EventHandler) GoToOperation(operation.GoToOperation) Alert(javafx.scene.control.Alert) FXML(javafx.fxml.FXML)

Aggregations

ActionEvent (javafx.event.ActionEvent)171 EventHandler (javafx.event.EventHandler)61 Stage (javafx.stage.Stage)52 KeyFrame (javafx.animation.KeyFrame)47 Timeline (javafx.animation.Timeline)47 FXML (javafx.fxml.FXML)44 Alert (javafx.scene.control.Alert)36 Button (javafx.scene.control.Button)35 Label (javafx.scene.control.Label)35 MenuItem (javafx.scene.control.MenuItem)33 ContextMenu (javafx.scene.control.ContextMenu)25 File (java.io.File)24 Insets (javafx.geometry.Insets)24 Scene (javafx.scene.Scene)24 List (java.util.List)21 ObservableList (javafx.collections.ObservableList)21 Node (javafx.scene.Node)20 TextField (javafx.scene.control.TextField)20 Optional (java.util.Optional)18 FXCollections (javafx.collections.FXCollections)18