Completed jobs TreeTable and Stats

This commit is contained in:
Hendrik Schutter 2018-10-07 00:50:59 +02:00
parent 2a59156b0b
commit 8650177d86
6 changed files with 479 additions and 75 deletions

View File

@ -401,20 +401,180 @@ class DBController
// e.printStackTrace(); // e.printStackTrace();
} }
System.out.println("XXXXXXXXXXX 0 XXXXXXXXXXX");
return 0; return 0;
} }
public void fillJobs_Jobs(int pID, String pTime, String pPositionen_quantity, String pPositionen_name, public String getTime_Job(int pID)
String pPositionen_value, String pPositionen_cat, String pState, { // Gibt den Nutzernamen zurück
String pJobvalue) try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(
"SELECT jobid, time FROM jobs WHERE jobid = " + pID + ";");
return rs.getString("time");
} catch (SQLException e) {
System.err.println("Couldn't handle DB-Query");
e.printStackTrace();
return "404";
}
}
public String getQuantity_Job(int pID)
{ // Gibt den Nutzernamen zurück
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(
"SELECT jobid, positionen_quantity FROM jobs WHERE jobid = "
+ pID + ";");
return rs.getString("positionen_quantity");
} catch (SQLException e) {
System.err.println("Couldn't handle DB-Query");
e.printStackTrace();
return "404";
}
}
public String getName_Job(int pID)
{ // Gibt den Nutzernamen zurück
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(
"SELECT jobid, positionen_name FROM jobs WHERE jobid = " + pID
+ ";");
return rs.getString("positionen_name");
} catch (SQLException e) {
System.err.println("Couldn't handle DB-Query");
e.printStackTrace();
return "404";
}
}
public String getValue_Job(int pID)
{ // Gibt den Nutzernamen zurück
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(
"SELECT jobid, positionen_value FROM jobs WHERE jobid = " + pID
+ ";");
return rs.getString("positionen_value");
} catch (SQLException e) {
System.err.println("Couldn't handle DB-Query");
e.printStackTrace();
return "404";
}
}
public String getCategory_Job(int pID)
{ // Gibt den Nutzernamen zurück
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(
"SELECT jobid, positionen_cat FROM jobs WHERE jobid = " + pID
+ ";");
return rs.getString("positionen_cat");
} catch (SQLException e) {
System.err.println("Couldn't handle DB-Query");
e.printStackTrace();
return "404";
}
}
public String getState_Job(int pID)
{ // Gibt den Nutzernamen zurück
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(
"SELECT jobid, state FROM jobs WHERE jobid = " + pID + ";");
return rs.getString("state");
} catch (SQLException e) {
System.err.println("Couldn't handle DB-Query");
e.printStackTrace();
return "404";
}
}
public String getJobValue_Job(int pID)
{ // Gibt den Nutzernamen zurück
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(
"SELECT jobid, jobvalue FROM jobs WHERE jobid = " + pID + ";");
return rs.getString("jobvalue");
} catch (SQLException e) {
System.err.println("Couldn't handle DB-Query");
e.printStackTrace();
return "404";
}
}
public String getAllJobValue_Job()
{ // Gibt den Nutzernamen zurück
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(
"SELECT state, jobvalue, SUM(jobvalue) AS ALLVALUE FROM jobs WHERE state = "
+ '"' + "verbucht" + '"' + ";");
return rs.getString("ALLVALUE");
} catch (SQLException e) {
System.err.println("Couldn't handle DB-Query");
e.printStackTrace();
return "0";
}
}
public void setStatus_Jobs(int pID, String pStatus)
{ // Setzt das Konto
try {
Statement stmt = connection.createStatement();
stmt.executeUpdate("UPDATE jobs SET state = '" + pStatus
+ "'WHERE jobid =" + pID + ";");
} catch (SQLException e) {
System.err.println("Couldn't handle DB-Query");
e.printStackTrace();
}
}
public ArrayList<tableDataJob> loadTableJobs_Job()
{ // Gibt den Nutzernamen zurück
ArrayList<tableDataJob> tmp = new ArrayList<tableDataJob>();
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(
"SELECT jobid, time, positionen_quantity, positionen_name, positionen_value, positionen_cat, state, jobvalue FROM jobs;");
while (rs.next()) {
try {
// return rs.getString("jobvalue");
String tablePosition = rs.getString("positionen_name");
tableDataJob data = new tableDataJob(rs.getInt("jobid"),
rs.getString("time"), tablePosition, rs.getString("state"),
rs.getString("jobvalue"));
tmp.add(data);
} catch (SQLException e) {
System.err.println("Couldn't handle DB-Query");
e.printStackTrace();
}
}
} catch (SQLException e) {
System.err.println("Couldn't handle DB-Query");
e.printStackTrace();
}
return tmp;
}
public void fillJobs_Jobs(int pID, String pTime, String pPositionen_quantity,
String pPositionen_name, String pPositionen_value,
String pPositionen_cat, String pState, String pJobvalue)
{ {
System.out.println("Create new Job Entry"); System.out.println("Create new Job Entry");
try { try {
PreparedStatement ps = connection PreparedStatement ps = connection.prepareStatement(
.prepareStatement("INSERT INTO jobs VALUES (?, ?, ?, ?, ?, ?, ?, ?);"); "INSERT INTO jobs VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
ps.setInt(1, pID); // primary ps.setInt(1, pID); // primary
ps.setString(2, pTime); ps.setString(2, pTime);
ps.setString(3, pPositionen_quantity); ps.setString(3, pPositionen_quantity);

View File

@ -77,6 +77,7 @@ public class Main extends Application
dbc.connectDatabase(); // estabishing DB conection dbc.connectDatabase(); // estabishing DB conection
mwc.fillTablePositionen(); // fill TreeTable 'Positionen' mwc.fillTablePositionen(); // fill TreeTable 'Positionen'
mwc.fillCategory(); mwc.fillCategory();
mwc.fillTableJobs();
mwc.loadGridButtons(); mwc.loadGridButtons();
mwc.getSelectedCat(); //Load DB entries in Chois Box mwc.getSelectedCat(); //Load DB entries in Chois Box
mwc.createNewJob(); mwc.createNewJob();

View File

@ -113,12 +113,15 @@
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children> <children>
<TreeTableView fx:id="entryTreeTable" layoutX="11.0" layoutY="10.0" prefHeight="502.0" prefWidth="1346.0"> <TreeTableView fx:id="entryTreeTable" layoutX="11.0" layoutY="10.0" prefHeight="502.0" prefWidth="1346.0">
<placeholder>
<Label text="" />
</placeholder>
<columns> <columns>
<TreeTableColumn fx:id="columnColor" editable="false" maxWidth="428.0" minWidth="119.333251953125" prefWidth="119.333251953125" resizable="false" sortable="false" text="Farbe" /> <TreeTableColumn fx:id="columnColor" editable="false" maxWidth="428.0" minWidth="119.333251953125" prefWidth="119.333251953125" resizable="false" sortable="false" text="Farbe" />
<TreeTableColumn fx:id="columnCat" editable="false" maxWidth="800.0" minWidth="94.0" prefWidth="300.0" resizable="false" sortable="false" text="Kategorie" /> <TreeTableColumn fx:id="columnCat" editable="false" maxWidth="800.0" minWidth="94.0" prefWidth="300.0" resizable="false" sortable="false" text="Kategorie" />
<TreeTableColumn fx:id="columnPrize" editable="false" maxWidth="693.3333129882812" minWidth="44.33331298828125" prefWidth="140.33331298828125" resizable="false" sortable="false" text="Preis" /> <TreeTableColumn fx:id="columnPrize" editable="false" maxWidth="693.3333129882812" minWidth="44.33331298828125" prefWidth="140.33331298828125" resizable="false" sortable="false" text="Preis" />
<TreeTableColumn fx:id="columnPositionsEdit" editable="false" maxWidth="1581.6666870117188" minWidth="38.0" prefWidth="596.333251953125" resizable="false" sortable="false" text="Positionen" /> <TreeTableColumn fx:id="columnPositionsEdit" editable="false" maxWidth="1581.6666870117188" minWidth="38.0" prefWidth="596.333251953125" resizable="false" sortable="false" text="Positionen" />
<TreeTableColumn fx:id="columnPosnumber" editable="false" maxWidth="1218.0" minWidth="59.0" prefWidth="144.666748046875" resizable="false" sortable="false" text="Nummer" /> <TreeTableColumn fx:id="columnPosnumber" editable="false" maxWidth="1218.0" minWidth="59.0" prefWidth="181.6666259765625" resizable="false" sortable="false" text="Nummer" />
</columns> </columns>
<columnResizePolicy> <columnResizePolicy>
<TreeTableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> <TreeTableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
@ -138,7 +141,7 @@
<content> <content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children> <children>
<Label fx:id="lableNewPosition" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="455.0" layoutY="10.0" prefHeight="34.0" prefWidth="105.0" text="Position:"> <Label fx:id="labelNewPosition" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="455.0" layoutY="10.0" prefHeight="34.0" prefWidth="105.0" text="Position:">
<font> <font>
<Font name="Cantarell Regular" size="18.0" /> <Font name="Cantarell Regular" size="18.0" />
</font> </font>
@ -158,13 +161,13 @@
<Font name="Cantarell Regular" size="13.0" /> <Font name="Cantarell Regular" size="13.0" />
</font> </font>
</JFXTextField> </JFXTextField>
<Label fx:id="lableNewColor" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="455.0" layoutY="90.0" prefHeight="34.0" prefWidth="105.0" text="Farbe:"> <Label fx:id="labelNewColor" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="455.0" layoutY="90.0" prefHeight="34.0" prefWidth="105.0" text="Farbe:">
<font> <font>
<Font name="Cantarell Regular" size="18.0" /> <Font name="Cantarell Regular" size="18.0" />
</font> </font>
</Label> </Label>
<ChoiceBox fx:id="colorChoise" layoutX="346.0" layoutY="90.0" prefHeight="25.0" prefWidth="96.0" /> <ChoiceBox fx:id="colorChoise" layoutX="346.0" layoutY="90.0" prefHeight="25.0" prefWidth="96.0" />
<Label fx:id="lableSelectCat" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="204.0" layoutY="90.0" prefHeight="34.0" prefWidth="105.0" text="Kategorie:"> <Label fx:id="labelSelectCat" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="204.0" layoutY="90.0" prefHeight="34.0" prefWidth="105.0" text="Kategorie:">
<font> <font>
<Font name="Cantarell Regular" size="18.0" /> <Font name="Cantarell Regular" size="18.0" />
</font> </font>
@ -186,15 +189,15 @@
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="850.0" prefWidth="1536.0"> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="850.0" prefWidth="1536.0">
<children> <children>
<TreeTableView fx:id="jobsTreeTable" layoutX="11.0" layoutY="10.0" prefHeight="541.0" prefWidth="1346.0"> <TreeTableView fx:id="jobsTreeTable" layoutX="11.0" layoutY="10.0" prefHeight="541.0" prefWidth="1346.0">
<placeholder> <placeholder>
<Label text="" /> <Label text="" />
</placeholder> </placeholder>
<columns> <columns>
<TreeTableColumn fx:id="columnJobValue" editable="false" prefWidth="90.6666259765625" resizable="false" text="Betrag" /> <TreeTableColumn fx:id="columnJobValue" editable="false" prefWidth="111.0" resizable="false" text="Betrag" />
<TreeTableColumn fx:id="columnState" editable="false" prefWidth="91.0" resizable="false" text="Zustand" /> <TreeTableColumn fx:id="columnState" editable="false" prefWidth="101.0" resizable="false" text="Zustand" />
<TreeTableColumn fx:id="columnPositions" editable="false" prefWidth="981.333251953125" resizable="false" sortable="false" text="Positionen" /> <TreeTableColumn fx:id="columnPositions" editable="false" prefWidth="861.0" resizable="false" sortable="false" text="Positionen" />
<TreeTableColumn fx:id="columnTime" editable="false" prefWidth="99.666748046875" resizable="false" text="Zeit" /> <TreeTableColumn fx:id="columnTime" editable="false" prefWidth="159.0" resizable="false" text="Zeit" />
<TreeTableColumn fx:id="columnJobNumber" editable="false" maxWidth="3000.0" prefWidth="83.6666259765625" resizable="false" text="Nummer" /> <TreeTableColumn fx:id="columnJobNumber" editable="false" maxWidth="3000.0" prefWidth="110.666748046875" resizable="false" text="Nummer" />
</columns> </columns>
</TreeTableView> </TreeTableView>
<Button fx:id="btnReprintJob" layoutX="378.0" layoutY="603.0" mnemonicParsing="false" onAction="#btnReprintJobAction" text="Ausgewählter Auftrag drucken"> <Button fx:id="btnReprintJob" layoutX="378.0" layoutY="603.0" mnemonicParsing="false" onAction="#btnReprintJobAction" text="Ausgewählter Auftrag drucken">
@ -202,21 +205,21 @@
<Font name="Cantarell Regular" size="17.0" /> <Font name="Cantarell Regular" size="17.0" />
</font> </font>
</Button> </Button>
<TitledPane fx:id="titlePaneStats" alignment="CENTER" collapsible="false" contentDisplay="CENTER" layoutX="992.0" layoutY="561.0" prefHeight="118.0" prefWidth="365.0" text="Statistik - 30.03.2018 15:15 Uhr"> <TitledPane fx:id="titlePaneStats" alignment="CENTER" collapsible="false" contentDisplay="CENTER" layoutX="957.0" layoutY="561.0" prefHeight="118.0" prefWidth="400.0" text="Statistik - 30.03.2018 15:15 Uhr">
<content> <content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="59.0" prefWidth="483.0"> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="92.0" prefWidth="414.0">
<children> <children>
<Label fx:id="lableJobCount" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="17.0" layoutY="2.0" prefHeight="34.0" prefWidth="340.0" text="Anzahl Aufträge: 2781"> <Label fx:id="labelJobCount" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="41.0" layoutY="2.0" prefHeight="34.0" prefWidth="340.0" text="Anzahl Aufträge: 2781">
<font> <font>
<Font name="Cantarell Regular" size="18.0" /> <Font name="Cantarell Regular" size="18.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelAvgJob" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="17.0" layoutY="30.0" prefHeight="34.0" prefWidth="340.0" text="Durchschnittlicher Auftragswert: 12,90€"> <Label fx:id="labelAvgJob" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="41.0" layoutY="30.0" prefHeight="34.0" prefWidth="340.0" text="Durchschnittlicher Auftragswert: 12,90€">
<font> <font>
<Font name="Cantarell Regular" size="18.0" /> <Font name="Cantarell Regular" size="18.0" />
</font> </font>
</Label> </Label>
<Label fx:id="lableAllValue" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="17.0" layoutY="60.0" prefHeight="34.0" prefWidth="340.0" text="Gesamt: 1088,48€"> <Label fx:id="labelAllValue" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="41.0" layoutY="60.0" prefHeight="34.0" prefWidth="340.0" text="Gesamt: 1088,48€">
<font> <font>
<Font name="Cantarell Regular" size="18.0" /> <Font name="Cantarell Regular" size="18.0" />
</font> </font>
@ -398,7 +401,7 @@
</JFXButton> </JFXButton>
</children> </children>
</GridPane> </GridPane>
<Button fx:id="btnPrintBill" contentDisplay="CENTER" defaultButton="true" graphicTextGap="1.0" layoutX="75.0" layoutY="599.0" maxHeight="88.0" minHeight="75.0" mnemonicParsing="false" onAction="#btnPrintBillAction" prefHeight="88.0" prefWidth="258.0" text="Drucken" wrapText="true"> <Button fx:id="btnPrintBill" contentDisplay="CENTER" defaultButton="true" graphicTextGap="1.0" layoutX="75.0" layoutY="599.0" maxHeight="88.0" minHeight="75.0" mnemonicParsing="false" onAction="#btnPrintBillAction" prefHeight="88.0" prefWidth="258.0" text="Drucken" textAlignment="CENTER" wrapText="true">
<font> <font>
<Font name="Cantarell Bold" size="48.0" /> <Font name="Cantarell Bold" size="48.0" />
</font> </font>
@ -408,7 +411,7 @@
<Font name="Cantarell Regular" size="20.0" /> <Font name="Cantarell Regular" size="20.0" />
</font> </font>
</Button> </Button>
<Label fx:id="labelAllPrize" alignment="CENTER" contentDisplay="CENTER" layoutX="10.0" layoutY="505.0" prefHeight="15.0" prefWidth="386.0" text="0,00 €" textAlignment="CENTER"> <Label fx:id="labelAllPrize" alignment="CENTER" contentDisplay="CENTER" layoutX="10.0" layoutY="511.0" prefHeight="15.0" prefWidth="386.0" text="0,00 €" textAlignment="CENTER">
<font> <font>
<Font name="Cantarell Regular" size="70.0" /> <Font name="Cantarell Regular" size="70.0" />
</font> </font>

View File

@ -24,7 +24,7 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Properties; import java.util.Properties;
import org.omg.CORBA.PUBLIC_MEMBER;
import com.jfoenix.controls.JFXTextField; import com.jfoenix.controls.JFXTextField;
@ -39,6 +39,7 @@ import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.util.Pair; import javafx.util.Pair;
public class MainWindowController public class MainWindowController
{ {
@ -51,9 +52,9 @@ public class MainWindowController
@FXML @FXML
private AnchorPane paneDB; private AnchorPane paneDB;
@FXML @FXML
private Tab tapPosEdit; private Tab tapPosEdit;
@FXML @FXML
private TreeTableView<tableDataCurrentOrder> tableCurrentOrder; private TreeTableView<tableDataCurrentOrder> tableCurrentOrder;
@ -84,7 +85,7 @@ public class MainWindowController
private TreeTableColumn<tableDataJob, String> columnTime; private TreeTableColumn<tableDataJob, String> columnTime;
@FXML @FXML
private TreeTableColumn<tableDataJob, String> columnJobNumber; private TreeTableColumn<tableDataJob, Integer> columnJobNumber;
@FXML @FXML
private TreeTableColumn<tableDataJob, Integer> idSpalte02 = new TreeTableColumn<>( private TreeTableColumn<tableDataJob, Integer> idSpalte02 = new TreeTableColumn<>(
@ -265,25 +266,25 @@ public class MainWindowController
private Label labelTime; private Label labelTime;
@FXML @FXML
private Label lableJobCount; private Label labelJobCount;
@FXML @FXML
private Label labelAvgJob; private Label labelAvgJob;
@FXML @FXML
private Label lableAllValue; private Label labelAllValue;
@FXML @FXML
private Label lableSelectCat; private Label labelSelectCat;
@FXML @FXML
private Label lableNewPosition; private Label labelNewPosition;
@FXML @FXML
private Label labelNewValue; private Label labelNewValue;
@FXML @FXML
private Label lableNewColor; private Label labelNewColor;
@FXML @FXML
private Label labelDBStatus; private Label labelDBStatus;
@ -331,15 +332,17 @@ public class MainWindowController
private Job currentJob = null; private Job currentJob = null;
String currentOrderPosName; private String currentOrderPosName;
private int selectedJobId;
@FXML @FXML
TreeItem<tableDataCurrentOrder> rootCurrentJob = new TreeItem<>( TreeItem<tableDataCurrentOrder> rootCurrentJob = new TreeItem<>(
new tableDataCurrentOrder("0", 0)); new tableDataCurrentOrder("0", 0));
@FXML @FXML
TreeItem<tableDataCurrentOrder> rootJobs = new TreeItem<>( TreeItem<tableDataJob> rootJobs = new TreeItem<>(
new tableDataCurrentOrder("0", 0)); new tableDataJob(0, "0", "0", "0", "0"));
@FXML @FXML
TreeItem<tableDataPositionen> rootPositionen = new TreeItem<>( TreeItem<tableDataPositionen> rootPositionen = new TreeItem<>(
@ -355,7 +358,7 @@ public class MainWindowController
Dialog<Pair<String, String>> dialog = new Dialog<>(); Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("Über jFxKasse"); dialog.setTitle("Über jFxKasse");
dialog.setHeaderText( dialog.setHeaderText(
"Informationen und Lizenzen - Version 0.9.4 - Techdemo"); "Informationen und Lizenzen - Version 0.1 - Without Printer");
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK);
@ -366,7 +369,7 @@ public class MainWindowController
grid.add(new Label( grid.add(new Label(
"Einfaches Kassensystem für kleine bis mittel große Veranstaltungen mit Bon-Drucker\n" "Einfaches Kassensystem für kleine bis mittel große Veranstaltungen mit Bon-Drucker\n"
+ "\nUnter Lizenz GPL-3.0 abrufbar auf https://github.com/Windoofs/jFxKasse\n" + "\nUnter Lizenz GPL-3.0 abrufbar auf https://git.mosad.xyz/localhorst/jFxKasse\n"
+ "\nDatenbank: sqlite.org - Public Domain" + "\nDatenbank: sqlite.org - Public Domain"
+ " \nUI Design01: eclipse.org/efxclipse/install.html - Eclipse Public License 1.0" + " \nUI Design01: eclipse.org/efxclipse/install.html - Eclipse Public License 1.0"
+ " \nUI Design02: http://www.jfoenix.com/ - Apache License 2.0" + " \nUI Design02: http://www.jfoenix.com/ - Apache License 2.0"
@ -391,6 +394,13 @@ public class MainWindowController
@FXML @FXML
public void btnCreateNewDatabaseAction(ActionEvent event) throws Exception public void btnCreateNewDatabaseAction(ActionEvent event) throws Exception
{ {
if(!(tftNewDBName.getText().equals(""))) {
setDatabaseName(tftNewDBName.getText()); setDatabaseName(tftNewDBName.getText());
dbc.dbname = getDatabaseName(); dbc.dbname = getDatabaseName();
dbc.connectDatabase(); // establish DB connection dbc.connectDatabase(); // establish DB connection
@ -410,9 +420,9 @@ public class MainWindowController
initUI(); // Starting the UI elements initUI(); // Starting the UI elements
getSelectedCat(); getSelectedCat();
createNewJob(); createNewJob();
btnLock.setDisable(false);
btnLock.setDisable(false);
}
} }
@FXML @FXML
@ -444,7 +454,27 @@ public class MainWindowController
@FXML @FXML
public void btnCalcStatsAction(ActionEvent event) public void btnCalcStatsAction(ActionEvent event)
{ {
System.out.println("Button!");
System.out.println(dbc.getAllJobValue_Job());
if(dbc.getAllJobValue_Job() != null) {
float allValue = Float.valueOf(dbc.getAllJobValue_Job());
float avgJobValue = ((float) allValue / dbc.getLatestJobNumber_Job());
setJobStatLabel(dbc.getLatestJobNumber_Job(), avgJobValue, allValue);
}else {
setJobStatLabel(dbc.getLatestJobNumber_Job(), 0, 0);
}
titlePaneStats.setVisible(true);
} }
@FXML @FXML
@ -456,7 +486,8 @@ public class MainWindowController
@FXML @FXML
public void btnCancelJobAction(ActionEvent event) public void btnCancelJobAction(ActionEvent event)
{ {
dbc.setStatus_Jobs(selectedJobId + 1, "storniert");
fillTableJobs();
} }
@FXML @FXML
@ -520,7 +551,7 @@ public class MainWindowController
@FXML @FXML
public void btnPrintBillAction(ActionEvent event) public void btnPrintBillAction(ActionEvent event)
{ {
//currentJob.printJobOnConsole(); // currentJob.printJobOnConsole();
btnPrintBill.setDisable(true); btnPrintBill.setDisable(true);
tapPosEdit.setDisable(false); tapPosEdit.setDisable(false);
@ -539,6 +570,8 @@ public class MainWindowController
currentJob.createPosCatDBString(), "verbucht", currentJob.createPosCatDBString(), "verbucht",
String.valueOf(currentJob.getJobValue())); String.valueOf(currentJob.getJobValue()));
fillTableJobs();
currentJob = null; currentJob = null;
createNewJob(); createNewJob();
@ -704,10 +737,28 @@ public class MainWindowController
rootPositionen.getChildren().size()); rootPositionen.getChildren().size());
for (int i = 0; i < dbc.ladeTabellePositionen().size(); i++) { for (int i = 0; i < dbc.ladeTabellePositionen().size(); i++) {
float fValue = Float.valueOf(dbc.ladeTabellePositionen().get(i).getValue());
String strValue = String.format("%.02f", fValue);
strValue.replace('.', ',');
tableDataPositionen helpTableData = new tableDataPositionen( tableDataPositionen helpTableData = new tableDataPositionen(
dbc.ladeTabellePositionen().get(i).getID(), dbc.ladeTabellePositionen().get(i).getID(),
dbc.ladeTabellePositionen().get(i).getName(), dbc.ladeTabellePositionen().get(i).getName(),
dbc.ladeTabellePositionen().get(i).getValue() + "",
(strValue + "")
,
dbc.getCategoryNameFromPositionen(i + 1), dbc.getCategoryNameFromPositionen(i + 1),
getColorNames(dbc.ladeTabellePositionen().get(i).getColor())); getColorNames(dbc.ladeTabellePositionen().get(i).getColor()));
rootPositionen.getChildren() rootPositionen.getChildren()
@ -723,13 +774,13 @@ public class MainWindowController
} }
tftNewDBName.setText(getDatabaseName()); tftNewDBName.setText(getDatabaseName());
tftKat05.setDisable(true); tftKat05.setDisable(true);
titlePaneStats.setVisible(false);
btnPrintBill.setDisable(true); btnPrintBill.setDisable(true);
btnDeleteSelectedPosition.setDisable(true); btnDeleteSelectedPosition.setDisable(true);
isPrintBtnDisabled = true; isPrintBtnDisabled = true;
initPositionen(); initPositionen();
initCurrentOrderTreeTableView(); initCurrentOrderTreeTableView();
initJobTreeTableView();
} }
@ -793,6 +844,13 @@ public class MainWindowController
entryTreeTable.setRoot(rootPositionen); entryTreeTable.setRoot(rootPositionen);
entryTreeTable.setShowRoot(false); entryTreeTable.setShowRoot(false);
entryTreeTable.setEditable(false); entryTreeTable.setEditable(false);
columnPosnumber.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
columnPositionsEdit.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
columnPrize.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
columnCat.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
columnColor.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
ObservableList<String> color = FXCollections.observableArrayList("Rot", ObservableList<String> color = FXCollections.observableArrayList("Rot",
"Orange", "Braun", "Weiß", "Gelb", "Gr\u00fcn", "Blau", "Indigo"); "Orange", "Braun", "Weiß", "Gelb", "Gr\u00fcn", "Blau", "Indigo");
@ -834,7 +892,7 @@ public class MainWindowController
.getSelectedIndex(); // get selected item .getSelectedIndex(); // get selected item
idPositionen = columnPosnumber.getCellData(selected); idPositionen = columnPosnumber.getCellData(selected);
try { try {
tftNewPosition tftNewPosition
.setText(dbc.getName_Positionen(idPositionen)); .setText(dbc.getName_Positionen(idPositionen));
@ -852,11 +910,7 @@ public class MainWindowController
} }
}); });
columnPosnumber.setStyle("-fx-alignment: CENTER;");
columnPositionsEdit.setStyle("-fx-alignment: CENTER;");
columnPrize.setStyle("-fx-alignment: CENTER;");
columnCat.setStyle("-fx-alignment: CENTER;");
columnColor.setStyle("-fx-alignment: CENTER;");
tftNewValue.textProperty().addListener(new ChangeListener<String>() { tftNewValue.textProperty().addListener(new ChangeListener<String>() {
@Override @Override
@ -1044,12 +1098,11 @@ public class MainWindowController
btnCalcStats.setDisable(pState); btnCalcStats.setDisable(pState);
btnClearEntry.setDisable(pState); btnClearEntry.setDisable(pState);
if ((!isPrintBtnDisabled) && (!pState)) { if ((!isPrintBtnDisabled) && (!pState)) {
// print was not disabled and will be enabled again // print was not disabled and will be enabled again
btnPrintBill.setDisable(pState); btnPrintBill.setDisable(pState);
btnDeleteSelectedPosition.setDisable(pState); btnDeleteSelectedPosition.setDisable(pState);
} }
if (pState) { if (pState) {
@ -1072,13 +1125,16 @@ public class MainWindowController
catChoise.setDisable(pState); catChoise.setDisable(pState);
tableCurrentOrder.setDisable(pState); tableCurrentOrder.setDisable(pState);
// jobsTreeTable.setDisable(pState); jobsTreeTable.setDisable(pState);
entryTreeTable.setDisable(pState); entryTreeTable.setDisable(pState);
labelAllPrize.setVisible(!pState); labelAllPrize.setVisible(!pState);
labelJobCounter.setVisible(!pState); labelJobCounter.setVisible(!pState);
titlePaneStats.setVisible(!pState); if(pState) {
titlePaneStats.setVisible(!pState);
}
titledPaneEntry.setDisable(pState); titledPaneEntry.setDisable(pState);
titlePaneCat.setDisable(pState); titlePaneCat.setDisable(pState);
@ -1113,6 +1169,7 @@ public class MainWindowController
} }
} }
public Button getButtonByID(int pID) public Button getButtonByID(int pID)
{ {
@ -1171,6 +1228,7 @@ public class MainWindowController
return gridButton01; return gridButton01;
} }
} }
private void handelGridButtons(int pID) private void handelGridButtons(int pID)
{ {
@ -1194,6 +1252,7 @@ public class MainWindowController
setJobPrizeLabel(currentJob.getJobValue()); setJobPrizeLabel(currentJob.getJobValue());
} }
private void initCurrentOrderTreeTableView() private void initCurrentOrderTreeTableView()
{ {
@ -1231,6 +1290,93 @@ public class MainWindowController
}); });
} }
private void initJobTreeTableView()
{
columnJobNumber
.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
columnTime.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
columnPositions
.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
columnState.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
columnJobValue
.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
jobsTreeTable.setRoot(rootJobs);
jobsTreeTable.setShowRoot(false);
jobsTreeTable.setEditable(false);
columnJobNumber.setCellValueFactory(cellData -> cellData.getValue()
.getValue().numberProperty().asObject());
columnTime.setCellValueFactory(
cellData -> cellData.getValue().getValue().timeProperty());
columnPositions.setCellValueFactory(
cellData -> cellData.getValue().getValue().positionProperty());
columnState.setCellValueFactory(
cellData -> cellData.getValue().getValue().statusProperty());
columnJobValue.setCellValueFactory(
cellData -> cellData.getValue().getValue().valueProperty());
jobsTreeTable.getSelectionModel().selectedItemProperty()
.addListener(new ChangeListener<Object>() {
@Override
public void changed(ObservableValue<?> observable, Object oldVal,
Object newVal)
{
selectedJobId = jobsTreeTable.getSelectionModel()
.getSelectedIndex(); // get selected item
if(dbc.getState_Job(selectedJobId+1).equals("storniert")) {
btnCancelJob.setDisable(true);
}else {
btnCancelJob.setDisable(false);
}
}
});
}
@FXML
public void fillTableJobs()
{ // loads the table in the TreeTableView
rootJobs.getChildren().remove(0, rootJobs.getChildren().size());
for (int i = 0; i < dbc.loadTableJobs_Job().size(); i++) {
float fValue = Float
.valueOf(dbc.loadTableJobs_Job().get(i).getValue());
String strValue = String.format("%.02f", fValue);
strValue.replace('.', ',');
strValue = (strValue + "");
String strJobDescription = createJobDescription(
dbc.loadTableJobs_Job().get(i).getPosition(),
dbc.getQuantity_Job(dbc.loadTableJobs_Job().get(i).getNumber()));
tableDataJob tmp = new tableDataJob(
dbc.loadTableJobs_Job().get(i).getNumber(),
dbc.loadTableJobs_Job().get(i).getTime(), strJobDescription,
dbc.loadTableJobs_Job().get(i).getStatus(), strValue);
rootJobs.getChildren().add(new TreeItem<tableDataJob>(tmp));
}
}
public void createNewJob() public void createNewJob()
{ {
@ -1239,28 +1385,66 @@ public class MainWindowController
labelJobCounter.setText("Auftragsnummer: " labelJobCounter.setText("Auftragsnummer: "
+ String.valueOf(dbc.getLatestJobNumber_Job() + 1)); + String.valueOf(dbc.getLatestJobNumber_Job() + 1));
} }
private static String createJobDescription(String pNames, String pQuantities)
{
String line = pQuantities;
int size = line.length() - line.replace(";", "").length() + 1;
String[] namesArray = new String[size];
String[] quantitiesArray = new String[size];
namesArray = pNames.split(";");
quantitiesArray = pQuantities.split(";");
String tmp = quantitiesArray[0] + "x " + namesArray[0];
for (int i = 1; i < namesArray.length; i++) {
tmp = tmp + ", " + quantitiesArray[i] + "x " + namesArray[i];
}
return tmp;
}
private void setJobPrizeLabel(float pPrize) private void setJobPrizeLabel(float pPrize)
{ {
// String str = String.valueOf(pPrize);
String str = String.format("%.02f", pPrize); String str = String.format("%.02f", pPrize);
str.replace('.', ','); str.replace('.', ',');
labelAllPrize.setText(str + ""); labelAllPrize.setText(str + "");
}
private void setJobStatLabel(int pCounter, float pAvgValue, float pAllValue)
{
labelJobCount.setText("Anzahl Aufträge: " + pCounter);
String str = String.format("%.02f", pAvgValue);
str.replace('.', ',');
labelAvgJob.setText("Durchschnittlicher Auftragswert: " + str + "");
str = String.format("%.02f", pAllValue);
str.replace('.', ',');
labelAllValue.setText("Gesamt: " + str + "");
titlePaneStats.setText("Statistik - " + getSystemTime() + " " + getSystemDate());
} }
public void updateTimeLabel() public void updateTimeLabel()
{ {
labelTime.setText("Uhrzeit: " + getSystemTime()); labelTime.setText("Uhrzeit: " + getSystemTime());
} }
public void blockUnlock() {
public void blockUnlock()
{
btnLock.setDisable(true); btnLock.setDisable(true);
} }

View File

@ -6,27 +6,62 @@ import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
public class tableDataJob public class tableDataJob
{ {
private final StringProperty position = new SimpleStringProperty(); private final IntegerProperty number = new SimpleIntegerProperty();
private final IntegerProperty quantity = new SimpleIntegerProperty(); private final StringProperty time = new SimpleStringProperty();
public tableDataJob(final String pPosition, final Integer pQuantity) private final StringProperty positionen = new SimpleStringProperty();
private final StringProperty status = new SimpleStringProperty();
private final StringProperty value = new SimpleStringProperty();
public tableDataJob(final Integer pNumber, final String pTime,
final String pPositionen, final String pStatus, final String pValue)
{ {
this.position.set(pPosition); this.number.set(pNumber);
this.quantity.set(pQuantity); this.time.set(pTime);
this.positionen.set(pPositionen);
this.status.set(pStatus);
this.value.set(pValue);
} }
public IntegerProperty numberProperty()
{
return number;
}
public StringProperty timeProperty()
{
return time;
}
public StringProperty positionProperty() public StringProperty positionProperty()
{ {
return position; return positionen;
} }
public IntegerProperty quantityProperty() public StringProperty statusProperty()
{ {
return quantity; return status;
}
public StringProperty valueProperty()
{
return value;
}
public Integer getNumber()
{
return numberProperty().get();
}
public String getTime()
{
return timeProperty().get();
} }
public String getPosition() public String getPosition()
@ -34,9 +69,24 @@ public class tableDataJob
return positionProperty().get(); return positionProperty().get();
} }
public Integer getQuantity() public String getStatus()
{ {
return quantityProperty().get(); return statusProperty().get();
}
public String getValue()
{
return valueProperty().get();
}
public final void setNumber(int pNumber)
{
numberProperty().set(pNumber);
}
public final void setTime(String pTime)
{
timeProperty().set(pTime);
} }
public final void setPosition(String pPosition) public final void setPosition(String pPosition)
@ -44,8 +94,14 @@ public class tableDataJob
positionProperty().set(pPosition); positionProperty().set(pPosition);
} }
public final void setQuantity(int pQuantity) public final void setStatus(String pStatus)
{ {
quantityProperty().set(pQuantity); statusProperty().set(pStatus);
} }
public final void setValue(String pValue)
{
valueProperty().set(pValue);
}
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 577 B