Finished the current Order Table and the DB saving
This commit is contained in:
parent
1c640de416
commit
786586c382
|
@ -24,9 +24,6 @@ public class Job
|
|||
this.jobnumber = pJobnumber;
|
||||
this.jobtime = pTime;
|
||||
|
||||
System.out
|
||||
.println("Neuer Job: " + this.jobnumber + " Time: " + this.jobtime);
|
||||
|
||||
positionenQuantity = new ArrayList<Integer>();
|
||||
positionenName = new ArrayList<String>();
|
||||
positionenValue = new ArrayList<Float>();
|
||||
|
@ -49,6 +46,8 @@ public class Job
|
|||
public float getJobValue()
|
||||
{
|
||||
|
||||
calcJobValue();
|
||||
|
||||
return this.jobvalue;
|
||||
}
|
||||
|
||||
|
@ -120,6 +119,8 @@ public class Job
|
|||
private void calcJobValue()
|
||||
{
|
||||
|
||||
jobvalue = 0;
|
||||
|
||||
for (int i = 0; i < positionenValue.size(); i++) {
|
||||
|
||||
jobvalue = jobvalue
|
||||
|
@ -131,42 +132,77 @@ public class Job
|
|||
|
||||
public String createPosQuantityDBString()
|
||||
{
|
||||
String tmp = "";
|
||||
for (int i = 0; i < positionenName.size(); i++) {
|
||||
String tmp = String.valueOf(positionenQuantity.get(0));
|
||||
for (int i = 1; i < positionenName.size(); i++) {
|
||||
|
||||
tmp = tmp + ";" + positionenQuantity.get(i);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
public String createPosNameDBString()
|
||||
{
|
||||
String tmp = "";
|
||||
for (int i = 0; i < positionenName.size(); i++) {
|
||||
String tmp = positionenName.get(0);
|
||||
for (int i = 1; i < positionenName.size(); i++) {
|
||||
|
||||
tmp = tmp + ";" + positionenName.get(i);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
public String createPosValueDBString()
|
||||
{
|
||||
String tmp = "";
|
||||
for (int i = 0; i < positionenName.size(); i++) {
|
||||
String tmp = String.valueOf(positionenValue.get(0));
|
||||
for (int i = 1; i < positionenName.size(); i++) {
|
||||
|
||||
tmp = tmp + ";" + positionenValue.get(i);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
public String createPosCatDBString()
|
||||
{
|
||||
String tmp = "";
|
||||
for (int i = 0; i < positionenName.size(); i++) {
|
||||
String tmp = positionenCat.get(0);
|
||||
for (int i = 1; i < positionenName.size(); i++) {
|
||||
|
||||
tmp = tmp + ";" + positionenCat.get(i);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public void deletePosName(String pPosName)
|
||||
{
|
||||
|
||||
for (int i = 0; i < positionenName.size(); i++) {
|
||||
|
||||
if (positionenName.get(i).equals(pPosName)) {
|
||||
|
||||
if (positionenQuantity.get(i) > 1) {
|
||||
positionenQuantity.set(i, positionenQuantity.get(i) - 1);
|
||||
} else {
|
||||
|
||||
positionenQuantity.remove(i);
|
||||
positionenName.remove(i);
|
||||
positionenValue.remove(i);
|
||||
positionenCat.remove(i);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean existsPosName(String pPosName)
|
||||
{
|
||||
for (int i = 0; i < positionenName.size(); i++) {
|
||||
if (positionenName.get(i).equals(pPosName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
</AnchorPane>
|
||||
</content>
|
||||
</Tab>
|
||||
<Tab text="Positionen bearbeiten">
|
||||
<Tab fx:id="tapPosEdit" text="Positionen bearbeiten">
|
||||
<content>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||
<children>
|
||||
|
@ -153,7 +153,7 @@
|
|||
<Font name="Cantarell Regular" size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<JFXTextField fx:id="tftNewValue" alignment="CENTER" layoutX="380.0" layoutY="50.0" prefHeight="25.0" prefWidth="58.0">
|
||||
<JFXTextField fx:id="tftNewValue" alignment="CENTER" labelFloat="true" layoutX="380.0" layoutY="50.0" prefHeight="25.0" prefWidth="58.0">
|
||||
<font>
|
||||
<Font name="Cantarell Regular" size="13.0" />
|
||||
</font>
|
||||
|
@ -186,6 +186,9 @@
|
|||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="850.0" prefWidth="1536.0">
|
||||
<children>
|
||||
<TreeTableView fx:id="jobsTreeTable" layoutX="11.0" layoutY="10.0" prefHeight="541.0" prefWidth="1346.0">
|
||||
<placeholder>
|
||||
<Label text="" />
|
||||
</placeholder>
|
||||
<columns>
|
||||
<TreeTableColumn fx:id="columnJobValue" editable="false" prefWidth="90.6666259765625" resizable="false" text="Betrag" />
|
||||
<TreeTableColumn fx:id="columnState" editable="false" prefWidth="91.0" resizable="false" text="Zustand" />
|
||||
|
@ -241,10 +244,16 @@
|
|||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="850.0" prefWidth="1536.0">
|
||||
<children>
|
||||
<TreeTableView fx:id="tableCurrentOrder" layoutX="15.0" layoutY="85.0" prefHeight="379.0" prefWidth="382.0">
|
||||
<placeholder>
|
||||
<Label text="" />
|
||||
</placeholder>
|
||||
<columns>
|
||||
<TreeTableColumn fx:id="columnPosition" editable="false" prefWidth="282.3333740234375" resizable="false" sortable="false" text="Position" />
|
||||
<TreeTableColumn fx:id="columnQuantity" editable="false" prefWidth="81.66668701171875" resizable="false" sortable="false" text="Anzahl" />
|
||||
<TreeTableColumn fx:id="columnPosition" editable="false" prefWidth="320.0" resizable="false" sortable="false" text="Position" />
|
||||
<TreeTableColumn fx:id="columnQuantity" editable="false" prefWidth="60.0" resizable="false" sortable="false" text="Anzahl" />
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TreeTableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
</columnResizePolicy>
|
||||
</TreeTableView>
|
||||
<GridPane gridLinesVisible="true" layoutX="430.0" layoutY="15.0" prefHeight="670.0" prefWidth="920.0">
|
||||
<columnConstraints>
|
||||
|
@ -401,7 +410,7 @@
|
|||
</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">
|
||||
<font>
|
||||
<Font name="Open Sans" size="70.0" />
|
||||
<Font name="Cantarell Regular" size="70.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="labelJobCounter" alignment="TOP_RIGHT" contentDisplay="CENTER" layoutX="5.0" layoutY="45.0" prefHeight="34.0" prefWidth="392.0" text="Auftragsnummer: 0" textAlignment="CENTER">
|
||||
|
|
|
@ -32,6 +32,7 @@ import javafx.collections.FXCollections;
|
|||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.util.Pair;
|
||||
|
@ -48,6 +49,9 @@ public class MainWindowController
|
|||
|
||||
@FXML
|
||||
private AnchorPane paneDB;
|
||||
|
||||
@FXML
|
||||
private Tab tapPosEdit;
|
||||
|
||||
@FXML
|
||||
private TreeTableView<tableDataCurrentOrder> tableCurrentOrder;
|
||||
|
@ -325,6 +329,8 @@ public class MainWindowController
|
|||
|
||||
private Job currentJob = null;
|
||||
|
||||
String currentOrderPosName;
|
||||
|
||||
@FXML
|
||||
TreeItem<tableDataCurrentOrder> rootCurrentJob = new TreeItem<>(
|
||||
new tableDataCurrentOrder("0", 0));
|
||||
|
@ -401,14 +407,13 @@ public class MainWindowController
|
|||
fillCategory();
|
||||
initUI(); // Starting the UI elements
|
||||
getSelectedCat();
|
||||
createNewJob();
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void btnSaveEntryAction(ActionEvent event)
|
||||
{
|
||||
System.out.println("Speichere Eintrag!");
|
||||
|
||||
dbc.setName_Positionen(idPositionen, tftNewPosition.getText());
|
||||
dbc.setValue_Positionen(idPositionen, tftNewValue.getText());
|
||||
dbc.setColor_Positionen(idPositionen, getColorCodes(selectedColorName));
|
||||
|
@ -447,7 +452,7 @@ public class MainWindowController
|
|||
@FXML
|
||||
public void btnCancelJobAction(ActionEvent event)
|
||||
{
|
||||
System.out.println("Button!");
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -468,8 +473,6 @@ public class MainWindowController
|
|||
@FXML
|
||||
public void btnSaveCatAction(ActionEvent event)
|
||||
{
|
||||
System.out.println("Cat´s speichern");
|
||||
|
||||
dbc.setName_Category(1, tftKat01.getText());
|
||||
dbc.setName_Category(2, tftKat02.getText());
|
||||
dbc.setName_Category(3, tftKat03.getText());
|
||||
|
@ -485,23 +488,43 @@ public class MainWindowController
|
|||
@FXML
|
||||
public void btnDeleteSelectedPositionAction(ActionEvent event)
|
||||
{
|
||||
System.out.println("Button!");
|
||||
currentJob.deletePosName(currentOrderPosName);
|
||||
rootCurrentJob.getChildren().remove(0,
|
||||
rootCurrentJob.getChildren().size());
|
||||
|
||||
for (int i = 0; i < currentJob.getCurrentJobPositionen().size(); i++) {
|
||||
rootCurrentJob.getChildren().add(new TreeItem<tableDataCurrentOrder>(
|
||||
currentJob.getCurrentJobPositionen().get(i)));
|
||||
|
||||
}
|
||||
setJobPrizeLabel(currentJob.getJobValue());
|
||||
// currentJob.printJobOnConsole();
|
||||
|
||||
if (rootCurrentJob.getChildren().size() == 0) {
|
||||
btnPrintBill.setDisable(true);
|
||||
isPrintBtnDisabled = true;
|
||||
tapPosEdit.setDisable(false);
|
||||
btnDeleteSelectedPosition.setDisable(true);
|
||||
}
|
||||
|
||||
if (!currentJob.existsPosName(currentOrderPosName)) {
|
||||
btnDeleteSelectedPosition.setDisable(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void btnPrintBillAction(ActionEvent event)
|
||||
{
|
||||
// System.out.println("Button!");
|
||||
|
||||
currentJob.printJobOnConsole();
|
||||
|
||||
currentJob = null;
|
||||
|
||||
createNewJob();
|
||||
//currentJob.printJobOnConsole();
|
||||
|
||||
btnPrintBill.setDisable(true);
|
||||
tapPosEdit.setDisable(false);
|
||||
btnDeleteSelectedPosition.setDisable(true);
|
||||
isPrintBtnDisabled = true;
|
||||
|
||||
setJobPrizeLabel(0);
|
||||
|
||||
rootCurrentJob.getChildren().remove(0,
|
||||
rootCurrentJob.getChildren().size());
|
||||
|
||||
|
@ -512,6 +535,10 @@ public class MainWindowController
|
|||
currentJob.createPosCatDBString(), "verbucht",
|
||||
String.valueOf(currentJob.getJobValue()));
|
||||
|
||||
currentJob = null;
|
||||
|
||||
createNewJob();
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -693,15 +720,12 @@ public class MainWindowController
|
|||
tftNewDBName.setText(getDatabaseName());
|
||||
tftKat05.setDisable(true);
|
||||
btnPrintBill.setDisable(true);
|
||||
btnDeleteSelectedPosition.setDisable(true);
|
||||
isPrintBtnDisabled = true;
|
||||
initPositionen();
|
||||
initCurrentOrderTreeTableView();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -738,7 +762,6 @@ public class MainWindowController
|
|||
selectedCatName = catChoise.getItems().get((int) new_value)
|
||||
.toString();
|
||||
|
||||
// System.out.println("Ausgewählte Cat: " + selectedCatName);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -778,8 +801,6 @@ public class MainWindowController
|
|||
{
|
||||
selectedColorName = colorChoise.getItems()
|
||||
.get((int) new_value).toString();
|
||||
// System.out.println("Ausgewählte Farbe: " +
|
||||
// selectedColorName);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -808,13 +829,8 @@ public class MainWindowController
|
|||
int selected = entryTreeTable.getSelectionModel()
|
||||
.getSelectedIndex(); // get selected item
|
||||
|
||||
idPositionen = columnPosnumber.getCellData(selected); // Ausgewählte
|
||||
// Spalte
|
||||
|
||||
System.out.println(
|
||||
"Positionen - Ausgewaehlte Spalte: " + idPositionen);
|
||||
|
||||
try { // Setzt den Inhalt in die Textfelder
|
||||
idPositionen = columnPosnumber.getCellData(selected);
|
||||
try {
|
||||
|
||||
tftNewPosition
|
||||
.setText(dbc.getName_Positionen(idPositionen));
|
||||
|
@ -1023,16 +1039,19 @@ public class MainWindowController
|
|||
{
|
||||
btnCalcStats.setDisable(pState);
|
||||
btnClearEntry.setDisable(pState);
|
||||
btnDeleteSelectedPosition.setDisable(pState);
|
||||
|
||||
|
||||
if ((!isPrintBtnDisabled) && (!pState)) {
|
||||
// print was not disabled and will be enabled again
|
||||
btnPrintBill.setDisable(pState);
|
||||
btnDeleteSelectedPosition.setDisable(pState);
|
||||
|
||||
}
|
||||
|
||||
if (pState) {
|
||||
// disable allways
|
||||
btnPrintBill.setDisable(pState);
|
||||
btnDeleteSelectedPosition.setDisable(pState);
|
||||
}
|
||||
|
||||
btnReprintJob.setDisable(pState);
|
||||
|
@ -1152,14 +1171,13 @@ public class MainWindowController
|
|||
private void handelGridButtons(int pID)
|
||||
{
|
||||
|
||||
System.out.println("Button: " + pID);
|
||||
|
||||
currentJob.addPosition(dbc.getName_Positionen(pID),
|
||||
Float.parseFloat(dbc.getValue_Positionen(pID)),
|
||||
dbc.getCategoryNameFromPositionen(pID));
|
||||
|
||||
btnPrintBill.setDisable(false);
|
||||
isPrintBtnDisabled = false;
|
||||
tapPosEdit.setDisable(true);
|
||||
|
||||
rootCurrentJob.getChildren().remove(0,
|
||||
rootCurrentJob.getChildren().size());
|
||||
|
@ -1169,13 +1187,17 @@ public class MainWindowController
|
|||
currentJob.getCurrentJobPositionen().get(i)));
|
||||
}
|
||||
|
||||
setJobPrizeLabel(currentJob.getJobValue());
|
||||
|
||||
}
|
||||
|
||||
private void initCurrentOrderTreeTableView()
|
||||
{
|
||||
|
||||
columnQuantity.setStyle("-fx-alignment: CENTER;");
|
||||
columnPosition.setStyle("-fx-alignment: CENTER;");
|
||||
columnQuantity
|
||||
.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
|
||||
columnPosition
|
||||
.setStyle("-fx-alignment: CENTER; -fx-font: 17px Cantarell;");
|
||||
|
||||
tableCurrentOrder.setRoot(rootCurrentJob);
|
||||
tableCurrentOrder.setShowRoot(false);
|
||||
|
@ -1197,31 +1219,9 @@ public class MainWindowController
|
|||
int selected = tableCurrentOrder.getSelectionModel()
|
||||
.getSelectedIndex(); // get selected item
|
||||
|
||||
// String currentOrderPosNamr =
|
||||
// columnPosition.getCellData(selected); // Ausgewählte
|
||||
// Spalte
|
||||
|
||||
System.out.println(
|
||||
"CurrentOrder - Ausgewaehlte Spalte: " + selected);
|
||||
|
||||
try { // Setzt den Inhalt in die Textfelder
|
||||
|
||||
/*
|
||||
*
|
||||
* tftNewPosition
|
||||
* .setText(dbc.getName_Positionen(idPositionen));
|
||||
* tftNewValue.setText(dbc.getValue_Positionen(idPositionen
|
||||
* )); colorChoise.getSelectionModel().select(
|
||||
* getColorID(dbc.getColor_Positionen(idPositionen)));
|
||||
*
|
||||
* catChoise.getSelectionModel().select(
|
||||
* dbc.getCategoryNameFromPositionen(idPositionen));
|
||||
*
|
||||
*/
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
if (columnPosition.getCellData(selected) != null) {
|
||||
currentOrderPosName = columnPosition.getCellData(selected); // Ausgewählte
|
||||
btnDeleteSelectedPosition.setDisable(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1236,9 +1236,21 @@ public class MainWindowController
|
|||
+ String.valueOf(dbc.getLatestJobNumber_Job() + 1));
|
||||
}
|
||||
|
||||
private void setJobPrizeLabel(float pPrize)
|
||||
{
|
||||
|
||||
// String str = String.valueOf(pPrize);
|
||||
|
||||
String str = String.format("%.02f", pPrize);
|
||||
|
||||
str.replace('.', ',');
|
||||
|
||||
labelAllPrize.setText(str + "€");
|
||||
|
||||
}
|
||||
|
||||
public void updateTimeLabel()
|
||||
{
|
||||
// System.out.println(getSystemTime());
|
||||
labelTime.setText("Uhrzeit: " + getSystemTime());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue