avgJobValue is now correct
This commit is contained in:
parent
244243f07a
commit
279f358392
@ -527,6 +527,24 @@ public class DBController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getJobCount()
|
||||||
|
{ // Gibt den Nutzernamen zurück
|
||||||
|
try {
|
||||||
|
Statement stmt = connection.createStatement();
|
||||||
|
ResultSet rs = stmt.executeQuery(
|
||||||
|
"SELECT count(*) AS JOBCOUNT FROM jobs WHERE state = "
|
||||||
|
+ '"' + "verbucht" + '"' + ";");
|
||||||
|
return rs.getString("JOBCOUNT");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.err.println("Couldn't handle DB-Query");
|
||||||
|
e.printStackTrace();
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setStatus_Jobs(int pID, String pStatus)
|
public void setStatus_Jobs(int pID, String pStatus)
|
||||||
{ // Setzt das Konto
|
{ // Setzt das Konto
|
||||||
try {
|
try {
|
||||||
|
@ -24,8 +24,6 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.jfoenix.controls.JFXTextField;
|
import com.jfoenix.controls.JFXTextField;
|
||||||
|
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
@ -44,7 +42,6 @@ import com.jFxKasse.datatypes.tableDataCurrentOrder;
|
|||||||
import com.jFxKasse.datatypes.tableDataJob;
|
import com.jFxKasse.datatypes.tableDataJob;
|
||||||
import com.jFxKasse.datatypes.tableDataPositionen;
|
import com.jFxKasse.datatypes.tableDataPositionen;
|
||||||
|
|
||||||
|
|
||||||
public class MainWindowController
|
public class MainWindowController
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -400,33 +397,29 @@ public class MainWindowController
|
|||||||
public void btnCreateNewDatabaseAction(ActionEvent event) throws Exception
|
public void btnCreateNewDatabaseAction(ActionEvent event) throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!(tftNewDBName.getText().equals(""))) {
|
if (!(tftNewDBName.getText().equals(""))) {
|
||||||
|
|
||||||
|
setDatabaseName(tftNewDBName.getText());
|
||||||
|
dbc.dbname = getDatabaseName();
|
||||||
|
dbc.connectDatabase(); // establish DB connection
|
||||||
|
dbc.createTablePositionen(); // Create new table
|
||||||
|
dbc.erstelleTabelleJobs(); // Create new table
|
||||||
|
dbc.createTableCategory(); // Create new table
|
||||||
|
try {
|
||||||
|
saveSettings(getDatabaseName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
setDBLabel(); // Set new databese labels
|
||||||
|
blockUI(false); // unlock UI elements that need DB
|
||||||
|
fillTablePositionen(); // fill TreeTable 'Positionen'
|
||||||
|
fillCategory();
|
||||||
|
initUI(); // Starting the UI elements
|
||||||
|
getSelectedCat();
|
||||||
|
createNewJob();
|
||||||
|
|
||||||
|
btnLock.setDisable(false);
|
||||||
|
|
||||||
|
|
||||||
setDatabaseName(tftNewDBName.getText());
|
|
||||||
dbc.dbname = getDatabaseName();
|
|
||||||
dbc.connectDatabase(); // establish DB connection
|
|
||||||
dbc.createTablePositionen(); // Create new table
|
|
||||||
dbc.erstelleTabelleJobs(); // Create new table
|
|
||||||
dbc.createTableCategory(); // Create new table
|
|
||||||
try {
|
|
||||||
saveSettings(getDatabaseName());
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
setDBLabel(); // Set new databese labels
|
|
||||||
blockUI(false); // unlock UI elements that need DB
|
|
||||||
fillTablePositionen(); // fill TreeTable 'Positionen'
|
|
||||||
fillCategory();
|
|
||||||
initUI(); // Starting the UI elements
|
|
||||||
getSelectedCat();
|
|
||||||
createNewJob();
|
|
||||||
|
|
||||||
btnLock.setDisable(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,27 +452,24 @@ public class MainWindowController
|
|||||||
@FXML
|
@FXML
|
||||||
public void btnCalcStatsAction(ActionEvent event)
|
public void btnCalcStatsAction(ActionEvent event)
|
||||||
{
|
{
|
||||||
|
// System.out.println(dbc.getAllJobValue_Job());
|
||||||
|
|
||||||
System.out.println(dbc.getAllJobValue_Job());
|
int allActiveJobs = Integer.valueOf(dbc.getJobCount());
|
||||||
|
|
||||||
if(dbc.getAllJobValue_Job() != null) {
|
|
||||||
|
|
||||||
|
|
||||||
|
if (dbc.getAllJobValue_Job() != null) {
|
||||||
|
|
||||||
|
// summed up values of all jobs that are active
|
||||||
float allValue = Float.valueOf(dbc.getAllJobValue_Job());
|
float allValue = Float.valueOf(dbc.getAllJobValue_Job());
|
||||||
|
|
||||||
float avgJobValue = ((float) allValue / dbc.getLatestJobNumber_Job());
|
// count of all jobs that are active
|
||||||
|
|
||||||
setJobStatLabel(dbc.getLatestJobNumber_Job(), avgJobValue, allValue);
|
float avgJobValue = ((float) allValue / allActiveJobs);
|
||||||
}else {
|
|
||||||
setJobStatLabel(dbc.getLatestJobNumber_Job(), 0, 0);
|
setJobStatLabel(allActiveJobs, avgJobValue, allValue);
|
||||||
|
} else {
|
||||||
|
setJobStatLabel(allActiveJobs, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
titlePaneStats.setVisible(true);
|
titlePaneStats.setVisible(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@ -743,26 +733,20 @@ public class MainWindowController
|
|||||||
|
|
||||||
for (int i = 0; i < dbc.ladeTabellePositionen().size(); i++) {
|
for (int i = 0; i < dbc.ladeTabellePositionen().size(); i++) {
|
||||||
|
|
||||||
|
float fValue = Float
|
||||||
float fValue = Float.valueOf(dbc.ladeTabellePositionen().get(i).getValue());
|
.valueOf(dbc.ladeTabellePositionen().get(i).getValue());
|
||||||
|
|
||||||
String strValue = String.format("%.02f", fValue);
|
String strValue = String.format("%.02f", fValue);
|
||||||
|
|
||||||
strValue.replace('.', ',');
|
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(),
|
||||||
|
|
||||||
(strValue + "€")
|
(strValue + "€")
|
||||||
|
|
||||||
,
|
,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dbc.getCategoryNameFromPositionen(i + 1),
|
dbc.getCategoryNameFromPositionen(i + 1),
|
||||||
getColorNames(dbc.ladeTabellePositionen().get(i).getColor()));
|
getColorNames(dbc.ladeTabellePositionen().get(i).getColor()));
|
||||||
@ -850,13 +834,14 @@ public class MainWindowController
|
|||||||
entryTreeTable.setShowRoot(false);
|
entryTreeTable.setShowRoot(false);
|
||||||
entryTreeTable.setEditable(false);
|
entryTreeTable.setEditable(false);
|
||||||
|
|
||||||
columnPosnumber.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
|
columnPosnumber
|
||||||
columnPositionsEdit.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
|
.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;");
|
columnPrize.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
|
||||||
columnCat.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;");
|
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");
|
||||||
colorChoise.setItems(color);
|
colorChoise.setItems(color);
|
||||||
@ -915,20 +900,15 @@ public class MainWindowController
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tftNewValue.textProperty().addListener(new ChangeListener<String>() {
|
tftNewValue.textProperty().addListener(new ChangeListener<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<? extends String> observable,
|
public void changed(ObservableValue<? extends String> observable,
|
||||||
String oldValue, String newValue)
|
String oldValue, String newValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!newValue.matches("\\d{0,4}([\\.]\\d{0,2})?")) {
|
if (!newValue.matches("\\d{0,4}([\\.]\\d{0,2})?")) {
|
||||||
tftNewValue.setText(oldValue);
|
tftNewValue.setText(oldValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1141,7 +1121,7 @@ public class MainWindowController
|
|||||||
labelAllPrize.setVisible(!pState);
|
labelAllPrize.setVisible(!pState);
|
||||||
labelJobCounter.setVisible(!pState);
|
labelJobCounter.setVisible(!pState);
|
||||||
|
|
||||||
if(pState) {
|
if (pState) {
|
||||||
titlePaneStats.setVisible(!pState);
|
titlePaneStats.setVisible(!pState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1180,7 +1160,6 @@ public class MainWindowController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Button getButtonByID(int pID)
|
public Button getButtonByID(int pID)
|
||||||
{
|
{
|
||||||
switch (pID) {
|
switch (pID) {
|
||||||
@ -1239,7 +1218,6 @@ public class MainWindowController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void handelGridButtons(int pID)
|
private void handelGridButtons(int pID)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1263,7 +1241,6 @@ public class MainWindowController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initCurrentOrderTreeTableView()
|
private void initCurrentOrderTreeTableView()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1301,7 +1278,6 @@ public class MainWindowController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initJobTreeTableView()
|
private void initJobTreeTableView()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1346,13 +1322,12 @@ public class MainWindowController
|
|||||||
selectedJobId = jobsTreeTable.getSelectionModel()
|
selectedJobId = jobsTreeTable.getSelectionModel()
|
||||||
.getSelectedIndex(); // get selected item
|
.getSelectedIndex(); // get selected item
|
||||||
|
|
||||||
if(dbc.getState_Job(selectedJobId+1).equals("storniert")) {
|
if (dbc.getState_Job(selectedJobId + 1).equals("storniert")) {
|
||||||
btnCancelJob.setDisable(true);
|
btnCancelJob.setDisable(true);
|
||||||
}else {
|
} else {
|
||||||
btnCancelJob.setDisable(false);
|
btnCancelJob.setDisable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1396,7 +1371,6 @@ public class MainWindowController
|
|||||||
+ String.valueOf(dbc.getLatestJobNumber_Job() + 1));
|
+ String.valueOf(dbc.getLatestJobNumber_Job() + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String createJobDescription(String pNames, String pQuantities)
|
private static String createJobDescription(String pNames, String pQuantities)
|
||||||
{
|
{
|
||||||
String line = pQuantities;
|
String line = pQuantities;
|
||||||
@ -1416,7 +1390,6 @@ public class MainWindowController
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setJobPrizeLabel(float pPrize)
|
private void setJobPrizeLabel(float pPrize)
|
||||||
{
|
{
|
||||||
String str = String.format("%.02f", pPrize);
|
String str = String.format("%.02f", pPrize);
|
||||||
@ -1442,7 +1415,8 @@ public class MainWindowController
|
|||||||
|
|
||||||
labelAllValue.setText("Gesamt: " + str + "€");
|
labelAllValue.setText("Gesamt: " + str + "€");
|
||||||
|
|
||||||
titlePaneStats.setText("Statistik - " + getSystemTime() + " " + getSystemDate());
|
titlePaneStats
|
||||||
|
.setText("Statistik - " + getSystemTime() + " " + getSystemDate());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1452,7 +1426,6 @@ public class MainWindowController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void blockUnlock()
|
public void blockUnlock()
|
||||||
{
|
{
|
||||||
btnLock.setDisable(true);
|
btnLock.setDisable(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user