use of operation.ComboboxList in project Money-Manager by krHasan.
the class SettingsController method advancedBtnAdd.
@FXML
private void advancedBtnAdd(ActionEvent event) {
try {
if (new ComboboxList().getAdvancedSectorActiveArraySize() == 7) {
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Message");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("You can add maximum 7 sector to this list");
Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow();
confirmationMsg.setX(SettingsStage.getX() + 200);
confirmationMsg.setY(SettingsStage.getY() + 170);
tabAdvancedInitialize();
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(7), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.setResult(ButtonType.CANCEL);
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
} else {
advancedSector.addSectorToList(advancedCmboAdd.getValue());
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Message");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Successful");
Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow();
confirmationMsg.setX(SettingsStage.getX() + 200);
confirmationMsg.setY(SettingsStage.getY() + 28);
tabAdvancedInitialize();
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.setResult(ButtonType.CANCEL);
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
}
} catch (Exception e) {
}
}
use of operation.ComboboxList in project Money-Manager by krHasan.
the class ExpenseChart method getExpenseData.
public static Series<String, Number> getExpenseData(String monthName) {
XYChart.Series<String, Number> sector = new XYChart.Series<>();
String[] allSector = new ComboboxList().getSectorList();
// chart data for all other Sectors
for (String sectorName : allSector) {
String sectorShortName = getAbbreviateName(sectorName);
double amount = longToDouble(new Sector().getAmountBySectorFromExpense(monthName, sectorName));
sector.getData().add(new XYChart.Data<>(sectorShortName, amount));
}
// chart data for "Adjusted Balance" Sector
String srtName = getAbbreviateName("Adjusted Balance");
double amnt = longToDouble(new Sector().getAmountBySectorFromExpense(monthName, "Adjusted Balance"));
sector.getData().add(new XYChart.Data<>(srtName, amnt));
return sector;
}
use of operation.ComboboxList in project Money-Manager by krHasan.
the class DashboardModel method getAmountBySector.
public String getAmountBySector(String monthName, String sectorName) {
long totalAmountinLong = 0;
if (monthName.equals("Total")) {
if (sectorName.equals("All")) {
String allExpenseSql = "SELECT exAmount FROM Expense WHERE exSector <> \"Adjusted Balance\"";
try (Connection conn = connector();
Statement stmt = conn.createStatement();
ResultSet result = stmt.executeQuery(allExpenseSql)) {
while (result.next()) {
totalAmountinLong += UnitConverter.stringToLong(removeThousandSeparator(result.getString("exAmount")));
}
} catch (Exception e) {
e.printStackTrace();
}
long totalAdjustBal = 0;
String allAdjustBalSql = "SELECT exAmount FROM Expense WHERE exSector = \"Adjusted Balance\"";
try (Connection conn = connector();
Statement stmt = conn.createStatement();
ResultSet result = stmt.executeQuery(allAdjustBalSql)) {
while (result.next()) {
totalAdjustBal += UnitConverter.stringToLong(removeThousandSeparator(result.getString("exAmount").replaceAll("[^0-9.*]", "")));
}
} catch (Exception e) {
e.printStackTrace();
}
totalAmountinLong = totalAmountinLong - totalAdjustBal;
} else if (sectorName.equals("Adjusted Balance")) {
String sql = "SELECT exAmount FROM Expense WHERE exSector = \"Adjusted Balance\"";
try (Connection conn = connector();
Statement stmt = conn.createStatement();
ResultSet result = stmt.executeQuery(sql)) {
long totalAddedBal = 0;
while (result.next()) {
if (result.getString("exAmount").matches(".*\\badded\\b.*")) {
totalAddedBal += stringToLong(removeThousandSeparator(result.getString("exAmount").replaceAll("[^0-9.*]", "")));
} else {
totalAmountinLong += stringToLong(removeThousandSeparator(result.getString("exAmount")));
}
}
totalAmountinLong = totalAmountinLong - totalAddedBal;
} catch (Exception e) {
e.printStackTrace();
}
} else {
String bysectorSql = "SELECT exAmount FROM Expense WHERE exSector = ? ";
try (Connection conn = connector();
PreparedStatement pstmt = conn.prepareStatement(bysectorSql)) {
pstmt.setString(1, sectorName);
ResultSet result = pstmt.executeQuery();
while (result.next()) {
totalAmountinLong += UnitConverter.stringToLong(removeThousandSeparator(result.getString("exAmount")));
}
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
if (sectorName.equals("All")) {
totalAmountinLong += new Sector().getAmountBySectorFromExpense(monthName, "Adjusted Balance");
String[] sectorList = new ComboboxList().getSectorList();
for (String string : sectorList) {
totalAmountinLong += new Sector().getAmountBySectorFromExpense(monthName, string);
}
totalAmountinLong -= new Sector().addedAdjustBalance(monthName);
} else {
totalAmountinLong = new Sector().getAmountBySectorFromExpense(monthName, sectorName);
}
}
return addThousandSeparator(longToString(totalAmountinLong));
}
use of operation.ComboboxList in project Money-Manager by krHasan.
the class DashboardModel method getAmountBySource.
public String getAmountBySource(String monthName, String sourceName) {
long totalAmountinLong = 0;
if (monthName.equals("Total")) {
if (sourceName.equals("All")) {
String allGetMoneySql = "SELECT gmAmount FROM Get_Money";
try (Connection conn = connector();
Statement stmt = conn.createStatement();
ResultSet result = stmt.executeQuery(allGetMoneySql)) {
while (result.next()) {
totalAmountinLong += UnitConverter.stringToLong(removeThousandSeparator(result.getString("gmAmount")));
}
} catch (Exception e) {
e.printStackTrace();
}
} else if (sourceName.equals("Carried Over Amount")) {
totalAmountinLong = 0;
} else {
String sql = "SELECT gmAmount FROM Get_Money WHERE gmSource = ?";
try (Connection conn = connector();
PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, sourceName);
ResultSet result = pstmt.executeQuery();
while (result.next()) {
totalAmountinLong += UnitConverter.stringToLong(removeThousandSeparator(result.getString("gmAmount")));
}
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
if (sourceName.equals("All")) {
String[] sourceList = new ComboboxList().getSourceListForDashboard();
for (String string : sourceList) {
totalAmountinLong += new Source().getAmountBySourceFromGM(monthName, string);
}
totalAmountinLong += new CarriedOver().getCOAmount(monthName);
} else if (sourceName.equals("Carried Over Amount")) {
totalAmountinLong = new CarriedOver().getCOAmount(monthName);
} else {
totalAmountinLong = new Source().getAmountBySourceFromGM(monthName, sourceName);
}
}
return addThousandSeparator(longToString(totalAmountinLong));
}
use of operation.ComboboxList in project Money-Manager by krHasan.
the class MakeATransactionController method exSaveFunction.
// save user input values to database
private void exSaveFunction() {
try {
Map<String, String> expenseData = new HashMap<>();
expenseData.put("exTime", timeToSave());
expenseData.put("exDate", (new DateFormatManager()).toString(exdateDate.getValue()));
expenseData.put("exMonth", monthToSave(exdateDate.getValue()));
if (adjustBtnPressed) {
expenseData.put("exAmount", exAdjustAmount);
} else {
expenseData.put("exAmount", extxtAmount.getText());
}
if (adjustBtnPressed) {
if (exIsDescripionEmpty()) {
expenseData.put("exDescription", "You have adjusted your Wallet Balance");
} else {
expenseData.put("exDescription", extxtDescription.getText());
}
} else {
if (exIsDescripionEmpty()) {
expenseData.put("exDescription", "None");
} else {
expenseData.put("exDescription", extxtDescription.getText());
}
}
if (adjustBtnPressed) {
expenseData.put("exSector", "Adjusted Balance");
} else {
expenseData.put("exSector", excmboSector.getValue());
}
expenseData.put("exWalletBalanceBefore", getWalletBalance());
if (adjustBtnPressed) {
expenseData.put("exWalletBalanceAfter", exAdjustBalAfter);
setCurrentWalletBalance(exAdjustBalAfter);
} else {
expenseData.put("exWalletBalanceAfter", exWalletBalanceAfter(extxtAmount.getText()));
setCurrentWalletBalance(exWalletBalanceAfter(extxtAmount.getText()));
}
(new Expense()).saveExpenseData(expenseData);
(new ComboboxList()).setAllMonth(monthToSave(exdateDate.getValue()), yearToSave(exdateDate.getValue()));
(new ComboboxList()).setAllExMonth(monthToSave(exdateDate.getValue()), yearToSave(exdateDate.getValue()));
exInitialize();
extxtAmount.clear();
extxtDescription.clear();
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Successfull 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();
} 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) exbtnSave.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();
}
}
Aggregations