use of tab.Source 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 tab.Source in project Money-Manager by krHasan.
the class MakeATransactionController method gmCreateSourceBtn.
@FXML
private void gmCreateSourceBtn(ActionEvent event) {
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Create Income Source");
dialog.setHeaderText("Create Income Source, Where from you get Tk.");
dialog.setContentText("Please type a source name :");
Stage MakeATransactionStage = (Stage) gmbtnCreateSource.getScene().getWindow();
dialog.setX(MakeATransactionStage.getX() + 200);
dialog.setY(MakeATransactionStage.getY() + 170);
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
String typedName = result.get();
if (typedName.length() == 0) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Operation Falied");
alert.setHeaderText(null);
alert.setContentText("Write a Source Name Please");
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 (countWords(typedName) == 0) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Operation Falied");
alert.setHeaderText(null);
alert.setContentText("Write a Source Name Please");
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 {
new Source().createSource(typedName);
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Message");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Source " + typedName + " created successfully");
Stage SettingsStage = (Stage) MakeATransactionStage.getScene().getWindow();
confirmationMsg.setX(SettingsStage.getX() + 200);
confirmationMsg.setY(SettingsStage.getY() + 170);
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();
gmLoadSource();
gmcmboSource.getSelectionModel().selectLast();
}
}
}
use of tab.Source in project Money-Manager by krHasan.
the class GetMoneyChart method getSourceData.
public static Series<String, Number> getSourceData(String monthName) {
XYChart.Series<String, Number> source = new XYChart.Series<>();
String[] allSource = new ComboboxList().getSourceListForDashboard();
for (String sourceName : allSource) {
if (!sourceName.equals("All")) {
if (sourceName.equals("Carried Over Amount")) {
String sourceShortName = getAbbreviateName(sourceName);
double amount = longToDouble(new CarriedOver().getCOAmount(monthName));
source.getData().add(new XYChart.Data<>(sourceShortName, amount));
} else {
String sourceShortName = getAbbreviateName(sourceName);
double amount = longToDouble(new Source().getAmountBySourceFromGM(monthName, sourceName));
source.getData().add(new XYChart.Data<>(sourceShortName, amount));
}
}
}
return source;
}
Aggregations