Search in sources :

Example 1 with Personal

use of tab.Personal in project Money-Manager by krHasan.

the class MakeATransactionController method bnkSaveFunction.

private void bnkSaveFunction() {
    Map<String, String> bnkData = new HashMap<>();
    if (bnkSelectedTabName.equals("bKash")) {
        try {
            bnkData.put("bkTime", timeToSave());
            bnkData.put("bkDate", (new DateFormatManager()).toString(bnkdateDate.getValue()));
            bnkData.put("bkMonth", monthToSave(bnkdateDate.getValue()));
            bnkData.put("bkBalanceBefore", getbkAccountBalance());
            if (bnkAdjustBtnPressed) {
                bnkData.put("bkType", "Adjusted Balance");
                bnkData.put("bkNature", "Adjusted Balance");
                bnkData.put("bkAmount", bnkAdjustAmount);
                bnkData.put("bkBnkCharge", "None");
                bnkData.put("bkBalanceAfter", bnkAdjustBalAfter);
                (new Bkash()).saveBnkBkashData(bnkData);
                setCurrentbKashBalance(bnkAdjustBalAfter);
            } else {
                bnkData.put("bkType", bkcmboTransactionType.getValue());
                if (bkcmboAmountNature.getValue().equals("Credit")) {
                    bnkData.put("bkNature", "Credited by " + bkGetSelectedRbtn());
                } else {
                    bnkData.put("bkNature", "Debited by " + bkGetSelectedRbtn());
                }
                bnkData.put("bkAmount", bktxtAmount.getText());
                bnkData.put("bkBnkCharge", bkBankChargeShow());
                bnkData.put("bkBalanceAfter", updatedbKashBalance(bktxtAmount.getText(), bkGetSelectedRbtn()));
                if (bkcmboAmountNature.getValue().equals("Debit")) {
                    if (bkcmboTransactionType.getValue().equals("Personal")) {
                        bnkData.put("gmWalletBalanceBefore", longToString(currentWalletBalance()));
                        bnkData.put("gmWalletBalanceAfter", gmWalletBalanceAfter(bktxtAmount.getText()));
                        setCurrentWalletBalance(gmWalletBalanceAfter(bktxtAmount.getText()));
                    } else if (bkcmboTransactionType.getValue().equals("Get Money")) {
                        bnkData.put("gmWalletBalanceBefore", longToString(currentWalletBalance()));
                        bnkData.put("gmWalletBalanceAfter", gmWalletBalanceAfter(bktxtAmount.getText()));
                        (new GetMoney()).saveBnkBkashData(bnkData);
                        setCurrentWalletBalance(gmWalletBalanceAfter(bktxtAmount.getText()));
                    }
                }
                (new Bkash()).saveBnkBkashData(bnkData);
                setCurrentbKashBalance(updatedbKashBalance(bktxtAmount.getText(), bkGetSelectedRbtn()));
            }
            (new ComboboxList()).setAllMonth(monthToSave(bnkdateDate.getValue()), yearToSave(bnkdateDate.getValue()));
            bkInitialize();
            Alert confirmationMsg = new Alert(AlertType.INFORMATION);
            confirmationMsg.setTitle("Successful Transaction");
            confirmationMsg.setHeaderText(null);
            confirmationMsg.setContentText("Successful");
            Stage MakeATransactionStage = (Stage) btnSignOut.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) 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 if (bnkSelectedTabName.equals("Rocket")) {
        try {
            bnkData.put("rocTime", timeToSave());
            bnkData.put("rocDate", (new DateFormatManager()).toString(bnkdateDate.getValue()));
            bnkData.put("rocMonth", monthToSave(bnkdateDate.getValue()));
            bnkData.put("rocBalanceBefore", getRocAccountBalance());
            if (bnkAdjustBtnPressed) {
                bnkData.put("rocType", "Adjusted Balance");
                bnkData.put("rocNature", "Adjusted Balance");
                bnkData.put("rocAmount", bnkAdjustAmount);
                bnkData.put("rocBnkCharge", "None");
                bnkData.put("rocBalanceAfter", bnkAdjustBalAfter);
                (new Rocket()).saveBnkRocketData(bnkData);
                setCurrentRocketBalance(bnkAdjustBalAfter);
            } else {
                bnkData.put("rocType", roccmboTransactionType.getValue());
                if (roccmboAmountNature.getValue().equals("Credit")) {
                    bnkData.put("rocNature", "Credited by " + rocGetSelectedRbtn());
                } else {
                    bnkData.put("rocNature", "Debited by " + rocGetSelectedRbtn());
                }
                bnkData.put("rocAmount", roctxtAmount.getText());
                bnkData.put("rocBnkCharge", rocBankChargeShow());
                if (roccmboAmountNature.getValue().equals("Credit")) {
                    bnkData.put("rocBalanceAfter", updatedRocketBalance(roctxtAmount.getText(), "Cash In", rocGetSelectedRbtn()));
                    setCurrentRocketBalance(updatedRocketBalance(roctxtAmount.getText(), "Cash In", rocGetSelectedRbtn()));
                } else {
                    bnkData.put("rocBalanceAfter", updatedRocketBalance(roctxtAmount.getText(), "Cash Out", rocGetSelectedRbtn()));
                    setCurrentRocketBalance(updatedRocketBalance(roctxtAmount.getText(), "Cash Out", rocGetSelectedRbtn()));
                    if (roccmboTransactionType.getValue().equals("Personal")) {
                        bnkData.put("gmWalletBalanceBefore", longToString(currentWalletBalance()));
                        bnkData.put("gmWalletBalanceAfter", gmWalletBalanceAfter(roctxtAmount.getText()));
                        setCurrentWalletBalance(gmWalletBalanceAfter(roctxtAmount.getText()));
                    } else if (roccmboTransactionType.getValue().equals("Get Money")) {
                        bnkData.put("gmWalletBalanceBefore", longToString(currentWalletBalance()));
                        bnkData.put("gmWalletBalanceAfter", gmWalletBalanceAfter(roctxtAmount.getText()));
                        (new GetMoney()).saveBnkRocketData(bnkData);
                        setCurrentWalletBalance(gmWalletBalanceAfter(roctxtAmount.getText()));
                    }
                }
                (new Rocket()).saveBnkRocketData(bnkData);
            }
            (new ComboboxList()).setAllMonth(monthToSave(bnkdateDate.getValue()), yearToSave(bnkdateDate.getValue()));
            rocInitialize();
            Alert confirmationMsg = new Alert(AlertType.INFORMATION);
            confirmationMsg.setTitle("Successfull Transaction");
            confirmationMsg.setHeaderText(null);
            confirmationMsg.setContentText("Successful");
            Stage MakeATransactionStage = (Stage) btnSignOut.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) 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 {
        try {
            bnkData.put("perTime", timeToSave());
            bnkData.put("perDate", (new DateFormatManager()).toString(bnkdateDate.getValue()));
            bnkData.put("perMonth", monthToSave(bnkdateDate.getValue()));
            bnkData.put("perNature", percmboAmountNature.getValue());
            bnkData.put("perAmount", pertxtAmount.getText());
            bnkData.put("perBalanceBefore", getPerAccountBalance());
            if (percmboAmountNature.getValue().equals("Credit")) {
                bnkData.put("perBalanceAfter", updatedPersonalBalance(pertxtAmount.getText(), "Credit"));
                bnkData.put("gmWalletBalanceBefore", longToString(currentWalletBalance()));
                bnkData.put("gmWalletBalanceAfter", exWalletBalanceAfter(pertxtAmount.getText()));
                setCurrentWalletBalance(exWalletBalanceAfter(pertxtAmount.getText()));
                setCurrentPersonalBalance(updatedPersonalBalance(pertxtAmount.getText(), "Credit"));
            } else {
                bnkData.put("perBalanceAfter", updatedPersonalBalance(pertxtAmount.getText(), "Debit"));
                bnkData.put("gmWalletBalanceBefore", longToString(currentWalletBalance()));
                bnkData.put("gmWalletBalanceAfter", gmWalletBalanceAfter(pertxtAmount.getText()));
                setCurrentWalletBalance(gmWalletBalanceAfter(pertxtAmount.getText()));
                setCurrentPersonalBalance(updatedPersonalBalance(pertxtAmount.getText(), "Debit"));
            }
            (new Personal()).saveBnkPersonalData(bnkData);
            (new ComboboxList()).setAllMonth(monthToSave(bnkdateDate.getValue()), yearToSave(bnkdateDate.getValue()));
            perInitialize();
            Alert confirmationMsg = new Alert(AlertType.INFORMATION);
            confirmationMsg.setTitle("Successfull Transaction");
            confirmationMsg.setHeaderText(null);
            confirmationMsg.setContentText("Successful");
            Stage MakeATransactionStage = (Stage) btnSignOut.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) 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();
        }
    }
}
Also used : Personal(tab.Personal) 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)

Aggregations

HashMap (java.util.HashMap)1 KeyFrame (javafx.animation.KeyFrame)1 Timeline (javafx.animation.Timeline)1 ActionEvent (javafx.event.ActionEvent)1 EventHandler (javafx.event.EventHandler)1 Alert (javafx.scene.control.Alert)1 Stage (javafx.stage.Stage)1 ComboboxList (operation.ComboboxList)1 DateFormatManager (system.DateFormatManager)1 Bkash (tab.Bkash)1 GetMoney (tab.GetMoney)1 Personal (tab.Personal)1 Rocket (tab.Rocket)1