Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Kostentragerrechnung/database.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,22 @@ public void handleImport() throws SQLException {
}
}

@FXML private void handleReset() {
Auftrag.resetAll();
Teil.resetAll();
Material.resetAll();
Maschine.resetAll();
Arbeitsplan.resetAll();
Report.resetAll();

refreshTables();
}

@FXML
public void handleReturn() {
Application.switchScene("start-page.fxml");
}

@FXML
public void handleHelp() {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
Expand All @@ -242,29 +258,24 @@ public void handleHelp() {

String helpText = """
Diese Anwendung unterstützt die Erfassung und Auswertung von Daten zur Kostenrechnung.

──────────────
▶ Funktionen:
- "Import Excel": Lädt Daten zu Auftrag, Teil, Material, Maschine, Arbeitsplan.
- "Calculate": Führt alle Kostenberechnungen durch.
- "Export Excel/SQL": Exportiert die berechneten Daten.

──────────────
▶ Datenstruktur:
- Auftrag: Trägt zugehörige Teile, enthält keine Kosten direkt.
- Teil: Enthält Material, Arbeitsplan, und ggf. Unterteile.
- Material: Hat Stückkosten.
- Maschine: Hat Kostensatz pro Stunde.
- Arbeitsplan: Verknüpft Teil mit Maschine und Bearbeitungszeit.

──────────────
▶ Kostenarten:
- Materialkosten + 10% Materialgemeinkosten
- Fertigungskosten + 10% Fertigungsgemeinkosten
- Herstellkosten = Summe aller Komponenten

Alle Kosten gelten pro Stück in Euro (€).

──────────────
▶ Zusatzfunktionen:
- Diagramme zeigen Maschinenbelastung.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,14 @@ public void handleSave(ActionEvent actionEvent) {
// 📑 Auftrag (optional)
Auftrag auftrag = null;
if (auftragCheckBox.isSelected()) {
String selectedAuftragNr = auftragCombo.getValue();
auftrag = Auftrag.auftrags.stream()
.filter(a -> a.getAuftragNummer().equals(selectedAuftragNr))
.findFirst()
.orElse(null);
String selectedAuftragText = auftragCombo.getValue();
if (selectedAuftragText != null && selectedAuftragText.contains(" - ")) {
String selectedAuftragNr = selectedAuftragText.split(" - ")[1].trim();
auftrag = Auftrag.auftrags.stream()
.filter(a -> a.getAuftragNummer().equals(selectedAuftragNr))
.findFirst()
.orElse(null);
}
}

// ✅ Construct Teil
Expand All @@ -133,9 +136,10 @@ public void handleSave(ActionEvent actionEvent) {
}

if (auftrag != null) {
auftrag.addTeil(teil);
teil.setAuftrag(auftrag);
auftrag.addTeil(teil);
}

saved = true;
dialogStage.close();

Expand All @@ -144,8 +148,6 @@ public void handleSave(ActionEvent actionEvent) {
}
}



private void showAlert(String title, String content) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle(title);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public Arbeitsplan(){
arbeitsplans.add(this);
}

public static void resetAll() {
arbeitsplans.clear();
nextId = 0;
}

public int getArbeitsplanId() {
return arbeitsplanId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ public void addTeil(Teil teil) {
this.teil = new ArrayList<>();
}
this.teil.add(teil);

teil.setAuftrag(this);
}


public void berechneKosten() {
this.materialkosten = 0;
this.fertigungskosten = 0;
Expand All @@ -85,18 +88,23 @@ public void berechneKosten() {
this.fertigungskosten = Math.round(this.fertigungskosten * 100.0) / 100.0;
}


public static void berechneAlleKosten() {
for (Auftrag a : auftrags) {
a.berechneKosten();
a.printKosten();
}
}

public void printKosten() {
System.out.printf("Auftrag %s:\n K_mat=%.2f €\n K_fert=%.2f €\n Gesamt=%.2f €\n",
auftragNummer, materialkosten, fertigungskosten, materialkosten + fertigungskosten);
}

public static void resetAll() {
auftrags.clear();
nextId = 0;
}

public int getAuftragId() {
return auftragId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public Maschine(){
maschines.add(this);
}

public static void resetAll() {
Maschine.maschines.clear();
nextId = 0;
}

public int getMaschineId() {
return maschineId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public Material(){
materials.add(this);
}

public static void resetAll() {
Material.materials.clear();
nextId = 0;
}


public int getMaterialId() {
return materialId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public Report createReport(Teil teil, boolean recursive) {
return r;
}

public static void resetAll() {
report = new Report();
}

public String getAuftragNummer() {
return auftragNummer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ public void berechneKosten() {
) / 100.0;
}


public static void resetAll() {
teils.clear();
nextId = 0;
}

public int getTeilId() {
return teilId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public class CalculationService {
private final Map<String, Integer> maschinenDauerMap = new HashMap<>();

public void calculateCosts() {
// 1. Запускаем расчет для всех Aufträge
Auftrag.berechneAlleKosten();

// 2. Печатаем результаты по каждому Auftrag и Teil
for (Auftrag auftrag : Auftrag.auftrags) {
Expand All @@ -39,6 +37,9 @@ public void calculateCosts() {
System.out.println();
}
}

// 1. Запускаем расчет для всех Aufträge
Auftrag.berechneAlleKosten();
}

public void calculateCostsAndPrintReports() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.cell.PropertyValueFactory?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>

<AnchorPane maxHeight="720.0" maxWidth="1045.0" prefHeight="720.0" prefWidth="1045.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.prog.kostentragerrechnung.controller.InputPageController">
<children>
Expand Down Expand Up @@ -137,15 +135,12 @@
</Tab>
</tabs>
</TabPane>
<Text layoutX="20.0" layoutY="50.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Herstellkosten: Kostenträgerrechnung">
<font>
<Font size="24.0" />
</font>
</Text>
<Button fx:id="calculateButton" layoutX="880.0" layoutY="28.0" mnemonicParsing="false" onAction="#handleCalculate" prefHeight="29.0" prefWidth="182.0" text="Calculate" />
<Button fx:id="importExcelButton" layoutX="691.0" layoutY="28.0" mnemonicParsing="false" onAction="#handleImport" prefHeight="29.0" prefWidth="161.0" text="Import Excel" />
<Label fx:id="fileLabel" layoutX="691.0" layoutY="62.0" text="Kein Datei ausgewählt" />
<Button fx:id="calculateButton" layoutX="880.0" layoutY="28.0" mnemonicParsing="false" onAction="#handleCalculate" prefHeight="29.0" prefWidth="182.0" text="Berechnen" />
<Button fx:id="importExcelButton" layoutX="731.0" layoutY="28.0" mnemonicParsing="false" onAction="#handleImport" prefHeight="29.0" prefWidth="141.0" text="Excel importieren" />
<Label fx:id="fileLabel" layoutX="731.0" layoutY="66.0" text="Kein Datei ausgewählt" />

<Button fx:id="helpButton" layoutX="501.0" layoutY="28.0" mnemonicParsing="false" onAction="#handleHelp" prefHeight="29.0" prefWidth="161.0" text="Help" />
<Button fx:id="helpButton" layoutX="395.0" layoutY="28.0" mnemonicParsing="false" onAction="#handleHelp" prefHeight="29.0" prefWidth="121.0" text="Hilfe" />
<Button layoutX="535.0" layoutY="28.0" mnemonicParsing="false" onAction="#handleReset" prefHeight="29.0" prefWidth="182.0" text="Tabellen zurücksetzen" />
<Button layoutX="20.0" layoutY="28.0" mnemonicParsing="false" onAction="#handleReturn" prefHeight="29.0" prefWidth="132.0" text="Zurück" />
</children>
</AnchorPane>
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.chart.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.chart.BarChart?>
<?import javafx.scene.chart.CategoryAxis?>
<?import javafx.scene.chart.NumberAxis?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TreeView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>

<AnchorPane maxHeight="720.0" maxWidth="1045.0" prefHeight="720.0" prefWidth="1045.0" xmlns="http://javafx.com/javafx/17.0.12" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.prog.kostentragerrechnung.controller.ResultPageController">
<AnchorPane maxHeight="720.0" maxWidth="1045.0" prefHeight="720.0" prefWidth="1045.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.prog.kostentragerrechnung.controller.ResultPageController">
<children>
<TabPane layoutY="93.0" prefHeight="627.0" prefWidth="1077.0" tabClosingPolicy="UNAVAILABLE">
<tabs>
Expand Down Expand Up @@ -56,43 +65,49 @@
</AnchorPane>
</content>
</Tab>
<Tab text="Diagrams">
<Tab text="Ergebnis">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>

<TreeView fx:id="reportTreeView" layoutX="490.0" layoutY="372.0" prefHeight="175.0" prefWidth="552.0" />
<TreeView fx:id="entityTreeView" layoutX="14.0" layoutY="93.0" prefHeight="454.0" prefWidth="1033.0" />
<Label layoutX="14.0" layoutY="14.0" text="Auftragsstruktur &amp; Teilkosten:" />
<Label layoutX="14.0" layoutY="43.0" prefHeight="38.0" prefWidth="451.0" text="Hier werden alle Aufträge, enthaltene Teile sowie die zugehörigen Kostenarten angezeigt:" wrapText="true" />

<BarChart fx:id="reportBarChart" layoutX="493.0" layoutY="60.0" prefHeight="216.0" prefWidth="547.0">
</children>
</AnchorPane>
</content>
</Tab>
<Tab text="Maschine">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<TreeView fx:id="reportTreeView" layoutX="14.0" layoutY="372.0" prefHeight="175.0" prefWidth="1015.0" />
<BarChart fx:id="reportBarChart" layoutX="17.0" layoutY="60.0" prefHeight="216.0" prefWidth="1019.0">
<xAxis>
<CategoryAxis label="Maschine" />
</xAxis>
<yAxis>
<NumberAxis label="Minuten" />
</yAxis>
</BarChart>

<TreeView fx:id="entityTreeView" layoutX="14.0" layoutY="93.0" prefHeight="454.0" prefWidth="458.0" />
<Label layoutX="14.0" layoutY="14.0" text="Auftragsstruktur &amp; Teilkosten:" />
<Label layoutX="14.0" layoutY="43.0" prefHeight="38.0" prefWidth="451.0" text="Hier werden alle Aufträge, enthaltene Teile sowie die zugehörigen Kostenarten angezeigt:" wrapText="true" />
<Label layoutX="500.0" layoutY="285.0" text="Maschinenlast &amp; Einsatzdauer:" />
<Label layoutX="555.0" layoutY="23.0" text="Maschinenauslastung pro Woche (in Minuten)" />
<Label layoutX="556.0" layoutY="43.0" text="Maschinen-Zeiten (max. 2400 min/Woche)" />
<Label layoutX="500.0" layoutY="311.0" prefHeight="57.0" prefWidth="543.0" text="Darstellung aller Maschinen mit zugewiesenen Teilen, Bearbeitungszeit und Überlastungsprüfung:" wrapText="true" />

<Label layoutX="24.0" layoutY="285.0" text="Maschinenlast &amp; Einsatzdauer:" />
<Label layoutX="79.0" layoutY="23.0" text="Maschinenauslastung pro Woche (in Minuten)" />
<Label layoutX="80.0" layoutY="43.0" text="Maschinen-Zeiten (max. 2400 min/Woche)" />
<Label layoutX="24.0" layoutY="311.0" prefHeight="57.0" prefWidth="543.0" text="Darstellung aller Maschinen mit zugewiesenen Teilen, Bearbeitungszeit und Überlastungsprüfung:" wrapText="true" />
</children>
</AnchorPane>
</content>
</content>
</Tab>
</tabs>
</TabPane>
<Text layoutX="14.0" layoutY="51.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Result:" wrappingWidth="72.8203125">
<Text layoutX="14.0" layoutY="51.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Ergebnis:" wrappingWidth="161.33333333333326">
<font>
<Font size="24.0" />
</font>
</Text>
<Button fx:id="exportSQLButton" layoutX="484.0" layoutY="28.0" mnemonicParsing="false" onAction="#handleExportSQL" prefHeight="29.0" prefWidth="182.0" text="Export SQL" visible="false" />
<Button fx:id="exportExcelButton" layoutX="691.0" layoutY="28.0" mnemonicParsing="false" onAction="#handleExportExcel" prefHeight="29.0" prefWidth="161.0" text="Export Excel" />
<Button fx:id="returnButton" layoutX="881.0" layoutY="28.0" mnemonicParsing="false" onAction="#handleReturn" prefHeight="29.0" prefWidth="182.0" text="Return" />
<Button fx:id="exportExcelButton" layoutX="691.0" layoutY="28.0" mnemonicParsing="false" onAction="#handleExportExcel" prefHeight="29.0" prefWidth="161.0" text="Excel-Exportieren" />
<Button fx:id="returnButton" layoutX="881.0" layoutY="28.0" mnemonicParsing="false" onAction="#handleReturn" prefHeight="29.0" prefWidth="182.0" text="Zurück" />
</children>
</AnchorPane>
Loading