code cleanup and ui fixes

This commit is contained in:
2018-12-06 23:59:01 +01:00
parent 88b39820ca
commit 96d5968fef
13 changed files with 86 additions and 90 deletions

View File

@ -54,11 +54,13 @@ public class PrintJob
} else {
// printer selected
pc.selectPrinter(xmlc.getPrintername());
/* Single bill or splitted */
if (xmlc.getCategorySplitted()) {
// split the bills
PrintDataSplitted pdsplitted = new PrintDataSplitted(xmlc.getLinebreak(),
xmlc.getOffsetHeader(), xmlc.getOffsetFooter(),
PrintDataSplitted pdsplitted = new PrintDataSplitted(
xmlc.getLinebreak(), xmlc.getOffsetHeader(),
xmlc.getOffsetFooter(),
timedate.getSystemTime() + " " + timedate.getSystemDate(),
xmlc.getHeader(), xmlc.getFooter());
@ -66,16 +68,15 @@ public class PrintJob
dbc.getQuantity_Job(jobID), dbc.getName_Job(jobID),
dbc.getValue_Job(jobID), dbc.getCategory_Job(jobID),
dbc.getJobValue_Job(jobID));
System.out.println("Printing job ...");
ArrayList<String> printString = pdsplitted.getPrintStrings();
for(int i = 0; i < printString.size(); i++) {
for (int i = 0; i < printString.size(); i++) {
pc.printString(printString.get(i));
}
} else {
// one single bills
PrintDataSimple pds = new PrintDataSimple(xmlc.getLinebreak(),

View File

@ -6,7 +6,6 @@ import java.util.Date;
public class TimeDate
{
public String getSystemTime()
{
DateFormat dateFormat = new SimpleDateFormat("HH:mm");
@ -22,5 +21,4 @@ public class TimeDate
String dateStr = dateFormat.format(date);
return dateStr;
}
}

View File

@ -378,7 +378,7 @@ public class MainWindowController
// creates a dialog
Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("Über jFxKasse");
dialog.setHeaderText("Informationen und Lizenzen - Version 0.2");
dialog.setHeaderText("Informationen und Lizenzen - Version 0.3.0");
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK);

View File

@ -89,7 +89,6 @@ public class PrinterController implements Printable
*/
public void printString(String text)
{
PrintService service = selectedPrinter;
DocPrintJob job = service.createPrintJob();

View File

@ -9,7 +9,6 @@ import java.util.Properties;
public class XMLController
{
private String databaseName = null;
private String printername = null;

View File

@ -2,7 +2,6 @@ package com.jFxKasse.datatypes;
public class Category
{
private String categoryName;
private String positionsString = "\n";
@ -11,28 +10,23 @@ public class Category
{
this.categoryName = categoryName;
}
// public void setCategoryName(String categoryName) {
// this.categoryName = categoryName;
// }
public String getCategoryName()
{
return categoryName;
}
public void addPosition(int quantity, String name, String value, PrintData pd)
public void addPosition(int quantity, String name, String value,
PrintData pd)
{
//positionenString = pd.setRight(pd.breakLines(name), value + " €") + "\n";
for (int i = 0; i < quantity; i++) {
positionsString = positionsString
+ pd.setRight(pd.breakLines(name), value + "") + "\n";
}
}
public String getPositionsString() {
return positionsString;
}
}
public String getPositionsString()
{
return positionsString;
}
}

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
public class Job
{
private int jobnumber;
private float jobvalue;
@ -55,13 +54,10 @@ public class Job
public void addPosition(String pPositionenName, float pPositionenValue,
String pPositionenCat)
{
// System.out.println("addName");
for (int i = 0; i < positionenName.size(); i++) {
if (positionenName.get(i).equals(pPositionenName)) {
// Item is already in list, increase quantity
positionenQuantity.set(i, positionenQuantity.get(i) + 1);
// System.out.println("Item exists, increasing quantity");
return;
}
}
@ -76,24 +72,15 @@ public class Job
public void printJobOnConsole()
{
System.out.println("---------------------------------------------");
System.out.println("JobNummer: " + jobnumber);
System.out.println("---------------------------------------------");
// System.out.println("Größe: " + positionenName.size());
for (int i = 0; i < positionenName.size(); i++) {
System.out.println(
positionenQuantity.get(i) + " " + positionenName.get(i) + " "
+ positionenValue.get(i) + " " + positionenCat.get(i));
/*
* System.out.println("i is: " + i);
* System.out.println(positionenName.get(i));
* System.out.println(positionenQuantity.get(i));
*/
}
System.out.println("---------------------------------------------");
@ -102,33 +89,26 @@ public class Job
public ArrayList<tableDataCurrentOrder> getCurrentJobPositionen()
{
ArrayList<tableDataCurrentOrder> jobitems = new ArrayList<tableDataCurrentOrder>();
for (int i = 0; i < positionenName.size(); i++) {
tableDataCurrentOrder tmp = new tableDataCurrentOrder(
positionenName.get(i), positionenQuantity.get(i));
jobitems.add(tmp);
}
return jobitems;
}
private void calcJobValue()
{
jobvalue = 0;
for (int i = 0; i < positionenValue.size(); i++) {
jobvalue = jobvalue
+ (positionenQuantity.get(i) * positionenValue.get(i));
}
}
public String createPosQuantityDBString()

View File

@ -103,7 +103,6 @@ public abstract class PrintData
// data string not long enough
next = false;
}
}
// add the last part
return tmp + "\n" + data.substring(count);

View File

@ -6,7 +6,7 @@ public class PrintDataSimple extends PrintData
private String printString;
/**
* Constructor with all data that is not in the DB
* Constructor with all data that is not in the DB
* @param lineBreak
* @param headerSpace
* @param footerSpace
@ -62,9 +62,9 @@ public class PrintDataSimple extends PrintData
String[] positionValue = positionsValue.split(";");
for (int i = 0; i < posCount; i++) { //All different posNames
for (int i = 0; i < posCount; i++) { // All different posNames
int quantity = Integer.parseInt(positionQuantity[i]);
for (int j = 0; j < quantity; j++) { //quantities
for (int j = 0; j < quantity; j++) { // quantities
positionen = positionen + setRight(breakLines(positionName[i]),
positionValue[i] + "") + "\n";
}

View File

@ -83,7 +83,7 @@ public class PrintDataSplitted extends PrintData
/* first bill ends here */
/* Categories in extra bills*/
/* Categories in extra bills */
String positions = null;
@ -127,9 +127,9 @@ public class PrintDataSplitted extends PrintData
/* Footer */
footer = setCenter(this.footer);
footer = "\n";
for (int o = 1; o < footerSpace; o++) {
for (int o = 2; o < footerSpace; o++) {
footer = footer + "\n";
}
footer = footer + "_";
@ -137,8 +137,8 @@ public class PrintDataSplitted extends PrintData
thisBill = header + "\n" + getSeparator() + "\n" + info + "\n"
+ getSeparator() + "\n"
+ setCenter(categories.get(i).getCategoryName()) + "\n"
+ getSeparator() +
positions + "\n" + getSeparator();
+ getSeparator() + positions + "\n" + getSeparator() + "\n"
+ footer;
printString.add(thisBill);

View File

@ -16,7 +16,6 @@ public class tableDataCurrentOrder
{
this.position.set(pPosition);
this.quantity.set(pQuantity);
}
public StringProperty positionProperty()