avgJobValue is now correct
This commit is contained in:
parent
244243f07a
commit
279f358392
|
@ -526,6 +526,24 @@ public class DBController
|
|||
return "0";
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{ // Setzt das Konto
|
||||
|
|
|
@ -24,8 +24,6 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
|
@ -44,7 +42,6 @@ import com.jFxKasse.datatypes.tableDataCurrentOrder;
|
|||
import com.jFxKasse.datatypes.tableDataJob;
|
||||
import com.jFxKasse.datatypes.tableDataPositionen;
|
||||
|
||||
|
||||
public class MainWindowController
|
||||
{
|
||||
|
||||
|
@ -399,34 +396,30 @@ public class MainWindowController
|
|||
@FXML
|
||||
public void btnCreateNewDatabaseAction(ActionEvent event) throws Exception
|
||||
{
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -459,27 +452,24 @@ public class MainWindowController
|
|||
@FXML
|
||||
public void btnCalcStatsAction(ActionEvent event)
|
||||
{
|
||||
|
||||
System.out.println(dbc.getAllJobValue_Job());
|
||||
|
||||
if(dbc.getAllJobValue_Job() != null) {
|
||||
|
||||
|
||||
|
||||
// System.out.println(dbc.getAllJobValue_Job());
|
||||
|
||||
int allActiveJobs = Integer.valueOf(dbc.getJobCount());
|
||||
|
||||
if (dbc.getAllJobValue_Job() != null) {
|
||||
|
||||
// summed up values of all jobs that are active
|
||||
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);
|
||||
}else {
|
||||
setJobStatLabel(dbc.getLatestJobNumber_Job(), 0, 0);
|
||||
float avgJobValue = ((float) allValue / allActiveJobs);
|
||||
|
||||
setJobStatLabel(allActiveJobs, avgJobValue, allValue);
|
||||
} else {
|
||||
setJobStatLabel(allActiveJobs, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
titlePaneStats.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -742,28 +732,22 @@ public class MainWindowController
|
|||
rootPositionen.getChildren().size());
|
||||
|
||||
for (int i = 0; i < dbc.ladeTabellePositionen().size(); i++) {
|
||||
|
||||
|
||||
float fValue = Float.valueOf(dbc.ladeTabellePositionen().get(i).getValue());
|
||||
|
||||
|
||||
float fValue = Float
|
||||
.valueOf(dbc.ladeTabellePositionen().get(i).getValue());
|
||||
|
||||
String strValue = String.format("%.02f", fValue);
|
||||
|
||||
strValue.replace('.', ',');
|
||||
|
||||
|
||||
|
||||
|
||||
tableDataPositionen helpTableData = new tableDataPositionen(
|
||||
dbc.ladeTabellePositionen().get(i).getID(),
|
||||
dbc.ladeTabellePositionen().get(i).getName(),
|
||||
|
||||
|
||||
(strValue + "€")
|
||||
|
||||
,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
,
|
||||
|
||||
dbc.getCategoryNameFromPositionen(i + 1),
|
||||
getColorNames(dbc.ladeTabellePositionen().get(i).getColor()));
|
||||
rootPositionen.getChildren()
|
||||
|
@ -849,13 +833,14 @@ public class MainWindowController
|
|||
entryTreeTable.setRoot(rootPositionen);
|
||||
entryTreeTable.setShowRoot(false);
|
||||
entryTreeTable.setEditable(false);
|
||||
|
||||
columnPosnumber.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
|
||||
columnPositionsEdit.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
|
||||
|
||||
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",
|
||||
"Orange", "Braun", "Weiß", "Gelb", "Gr\u00fcn", "Blau", "Indigo");
|
||||
|
@ -915,21 +900,16 @@ public class MainWindowController
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
tftNewValue.textProperty().addListener(new ChangeListener<String>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends String> observable,
|
||||
String oldValue, String newValue)
|
||||
{
|
||||
|
||||
if (!newValue.matches("\\d{0,4}([\\.]\\d{0,2})?")) {
|
||||
tftNewValue.setText(oldValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (!newValue.matches("\\d{0,4}([\\.]\\d{0,2})?")) {
|
||||
tftNewValue.setText(oldValue);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1141,10 +1121,10 @@ public class MainWindowController
|
|||
labelAllPrize.setVisible(!pState);
|
||||
labelJobCounter.setVisible(!pState);
|
||||
|
||||
if(pState) {
|
||||
if (pState) {
|
||||
titlePaneStats.setVisible(!pState);
|
||||
}
|
||||
|
||||
|
||||
titledPaneEntry.setDisable(pState);
|
||||
titlePaneCat.setDisable(pState);
|
||||
|
||||
|
@ -1179,7 +1159,6 @@ public class MainWindowController
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Button getButtonByID(int pID)
|
||||
{
|
||||
|
@ -1238,7 +1217,6 @@ public class MainWindowController
|
|||
return gridButton01;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void handelGridButtons(int pID)
|
||||
{
|
||||
|
@ -1262,7 +1240,6 @@ public class MainWindowController
|
|||
setJobPrizeLabel(currentJob.getJobValue());
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initCurrentOrderTreeTableView()
|
||||
{
|
||||
|
@ -1300,7 +1277,6 @@ public class MainWindowController
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initJobTreeTableView()
|
||||
{
|
||||
|
@ -1345,14 +1321,13 @@ public class MainWindowController
|
|||
{
|
||||
selectedJobId = jobsTreeTable.getSelectionModel()
|
||||
.getSelectedIndex(); // get selected item
|
||||
|
||||
if(dbc.getState_Job(selectedJobId+1).equals("storniert")) {
|
||||
|
||||
if (dbc.getState_Job(selectedJobId + 1).equals("storniert")) {
|
||||
btnCancelJob.setDisable(true);
|
||||
}else {
|
||||
} else {
|
||||
btnCancelJob.setDisable(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1395,7 +1370,6 @@ public class MainWindowController
|
|||
labelJobCounter.setText("Auftragsnummer: "
|
||||
+ String.valueOf(dbc.getLatestJobNumber_Job() + 1));
|
||||
}
|
||||
|
||||
|
||||
private static String createJobDescription(String pNames, String pQuantities)
|
||||
{
|
||||
|
@ -1415,7 +1389,6 @@ public class MainWindowController
|
|||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
private void setJobPrizeLabel(float pPrize)
|
||||
{
|
||||
|
@ -1441,8 +1414,9 @@ public class MainWindowController
|
|||
str.replace('.', ',');
|
||||
|
||||
labelAllValue.setText("Gesamt: " + str + "€");
|
||||
|
||||
titlePaneStats.setText("Statistik - " + getSystemTime() + " " + getSystemDate());
|
||||
|
||||
titlePaneStats
|
||||
.setText("Statistik - " + getSystemTime() + " " + getSystemDate());
|
||||
|
||||
}
|
||||
|
||||
|
@ -1451,7 +1425,6 @@ public class MainWindowController
|
|||
labelTime.setText("Uhrzeit: " + getSystemTime());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void blockUnlock()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue