Update dependencies and build system #2
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
target/
|
||||
dependency-reduced-pom.xml
|
||||
26
.vscode/eclipse-formatter.xml
vendored
Normal file
26
.vscode/eclipse-formatter.xml
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<profiles version="21">
|
||||
<profile kind="CodeFormatterProfile" name="jFxKasse" version="21">
|
||||
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="tab"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
|
||||
</profile>
|
||||
</profiles>
|
||||
7
.vscode/extensions.json
vendored
Normal file
7
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"vscjava.vscode-java-pack",
|
||||
"vscjava.vscode-maven",
|
||||
"redhat.java"
|
||||
]
|
||||
}
|
||||
20
.vscode/launch.json
vendored
Normal file
20
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "java",
|
||||
"name": "Run jFxKasse",
|
||||
"request": "launch",
|
||||
"mainClass": "com.jFxKasse.application.JavaFX11Main",
|
||||
"projectName": "jFxKasse",
|
||||
"vmArgs": "--module-path ${env:PATH_TO_FX} --add-modules javafx.controls,javafx.fxml --add-opens javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED"
|
||||
},
|
||||
{
|
||||
"type": "java",
|
||||
"name": "Run jFxKasse (Maven)",
|
||||
"request": "launch",
|
||||
"mainClass": "com.jFxKasse.application.JavaFX11Main",
|
||||
"projectName": "jFxKasse"
|
||||
}
|
||||
]
|
||||
}
|
||||
18
.vscode/settings.json
vendored
Normal file
18
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"java.project.sourcePaths": [
|
||||
"src/main/java"
|
||||
],
|
||||
"java.project.outputPath": "target/classes",
|
||||
"java.project.referencedLibraries": [],
|
||||
"java.configuration.updateBuildConfiguration": "automatic",
|
||||
"java.compile.nullAnalysis.mode": "automatic",
|
||||
"editor.formatOnSave": true,
|
||||
"files.encoding": "utf8",
|
||||
|
||||
// Java formatter: point to workspace-local Eclipse formatter profile
|
||||
"java.format.settings.url": ".vscode/eclipse-formatter.xml",
|
||||
"java.format.settings.profile": "jFxKasse",
|
||||
"[java]": {
|
||||
"editor.defaultFormatter": "redhat.java"
|
||||
}
|
||||
}
|
||||
51
.vscode/tasks.json
vendored
Normal file
51
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "mvn compile",
|
||||
"type": "shell",
|
||||
"command": "mvn compile",
|
||||
"group": "build",
|
||||
"problemMatcher": [
|
||||
"$javac"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "mvn package",
|
||||
"type": "shell",
|
||||
"command": "mvn package -DskipTests",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$javac"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "mvn clean",
|
||||
"type": "shell",
|
||||
"command": "mvn clean",
|
||||
"group": "build",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "mvn javafx:run",
|
||||
"type": "shell",
|
||||
"command": "mvn javafx:run",
|
||||
"group": "build",
|
||||
"problemMatcher": [
|
||||
"$javac"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "mvn test",
|
||||
"type": "shell",
|
||||
"command": "mvn test",
|
||||
"group": "test",
|
||||
"problemMatcher": [
|
||||
"$javac"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
70
README.md
70
README.md
@ -1,38 +1,60 @@
|
||||
# jFxKasse
|
||||
easy payment system for small to middel sized events with a sales slip printer
|
||||
|
||||
Simples Kassensystem für kleine bis mittlere Veranstaltungen mit Bon-Drucker
|
||||
Simple POS (Point of Sale) system for small to medium-sized events with receipt printer support.
|
||||
|
||||
## Requirements
|
||||
|
||||
- Java JDK 21+
|
||||
- Maven 3.9+
|
||||
- Display >= 1366x768
|
||||
|
||||
## Video Tutorials (German | Deutsch)
|
||||
[YouTube Video: jFxKasse - Kassensystem - Kurzanleitung](https://www.youtube.com/watch?v=DV9DDESw40I)
|
||||
|
||||
[YouTube Video: jFxKasse - Kassensystem - Installieren](https://www.youtube.com/watch?v=IY1bqRjwh0Q)
|
||||
|
||||
## Setup (VSCode on openSUSE Tumbleweed)
|
||||
|
||||
### 1. Install dependencies
|
||||
|
||||
```bash
|
||||
sudo zypper install java-21-openjdk java-21-openjdk-devel maven
|
||||
```
|
||||
|
||||
### 2. Install VSCode extensions
|
||||
|
||||
Open the project in VSCode. You will be prompted to install the recommended extensions:
|
||||
|
||||
- **Extension Pack for Java** (`vscjava.vscode-java-pack`)
|
||||
- **Maven for Java** (`vscjava.vscode-maven`)
|
||||
- **Language Support for Java** (`redhat.java`)
|
||||
|
||||
### 3. Build & Run
|
||||
|
||||
```bash
|
||||
# Compile
|
||||
mvn compile
|
||||
|
||||
# Run via Maven
|
||||
mvn javafx:run
|
||||
|
||||
# Package as fat JAR
|
||||
mvn package
|
||||
java -jar target/jFxKasse-shaded.jar
|
||||
```
|
||||
|
||||
Or use the preconfigured VSCode tasks (`Ctrl+Shift+B`) and launch configurations (`F5`).
|
||||
|
||||
## Screenshots
|
||||
|
||||
### Main View | Hauptansicht
|
||||

|
||||
| Main View | Jobs | Positions | Settings |
|
||||
|-----------|------|-----------|----------|
|
||||
|  |  |  |  |
|
||||
|
||||
### Jobs | Auftäge
|
||||

|
||||
## Hardware
|
||||
|
||||
### Positions | Positionen
|
||||

|
||||
Tested with: [Epson TM T20II](https://www.epson.de/products/sd/pos-printer/epson-tm-t20ii). Other receipt printers should work as well.
|
||||
|
||||
### Settings | Einstellungen
|
||||

|
||||
## License
|
||||
|
||||
|
||||
## Requirements | Anforderungen
|
||||
|
||||
### Software
|
||||
|
||||
* Java JRE 11
|
||||
* Display/Bildschirm > 1366px X 768px
|
||||
* Windoofs, Mac, GNU/Linux (openSuse tested)
|
||||
|
||||
### Hardware
|
||||
|
||||
I used this printer: [Epson TM T20II](https://www.epson.de/products/sd/pos-printer/epson-tm-t20ii)
|
||||
|
||||
Other sales slip printer are possible.
|
||||
GPL-3.0
|
||||
57
pom.xml
57
pom.xml
@ -1,42 +1,49 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com</groupId>
|
||||
<artifactId>jFxKasse</artifactId>
|
||||
<version>0.3.2</version>
|
||||
<version>0.4.0</version>
|
||||
<name>jFxKasse</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.release>21</maven.compiler.release>
|
||||
<javafx.version>23.0.1</javafx.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>6.0.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>11</version>
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
<version>11</version>
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.jfoenix</groupId>
|
||||
<artifactId>jfoenix</artifactId>
|
||||
<version>9.0.8</version>
|
||||
<version>9.0.10</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.23.1</version>
|
||||
<version>3.51.2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -46,11 +53,11 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<version>3.15.0</version>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
<!--<release>11</release> -->
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
<release>21</release>
|
||||
<showWarnings>true</showWarnings>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
@ -59,7 +66,7 @@
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<version>3.6.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@ -71,17 +78,16 @@
|
||||
<mainClass>com.jFxKasse.application.Main</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<finalName>jFxKasse</finalName>
|
||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||
<transformers>
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>com.jFxKasse.application.JavaFX11Main</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
@ -95,7 +101,16 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
<version>0.0.8</version>
|
||||
<configuration>
|
||||
<mainClass>com.jFxKasse.application.JavaFX11Main</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
</project>
|
||||
@ -1,12 +1,8 @@
|
||||
package com.jFxKasse.application;
|
||||
|
||||
import com.jFxKasse.application.Main;
|
||||
public class JavaFX11Main {
|
||||
|
||||
public class JavaFX11Main
|
||||
{
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Main.main(args);
|
||||
public static void main(String[] args) {
|
||||
Main.main(args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,129 +1,153 @@
|
||||
package com.jFxKasse.application;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.event.EventHandler;
|
||||
|
||||
import java.io.File;
|
||||
import javafx.animation.Animation;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
import com.jFxKasse.controller.MainWindowController;
|
||||
import com.jFxKasse.controller.PrinterController;
|
||||
import com.jFxKasse.controller.XMLController;
|
||||
import com.jFxKasse.controller.DBController;
|
||||
import com.jFxKasse.controller.KeyController;
|
||||
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
|
||||
public class Main extends Application
|
||||
{
|
||||
// path to config.xml and the database
|
||||
public static String filepath;
|
||||
|
||||
private static String osName = System.getProperty("os.name");
|
||||
|
||||
private static String userHome = System.getProperty("user.home");
|
||||
|
||||
private MainWindowController mwc;
|
||||
|
||||
private XMLController xmlc = new XMLController(filepath);
|
||||
|
||||
private DBController dbc = new DBController(filepath);
|
||||
|
||||
private PrinterController pc = new PrinterController();
|
||||
|
||||
private KeyController kc;
|
||||
|
||||
private Stage primaryStage;
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage)
|
||||
{
|
||||
this.primaryStage = primaryStage;
|
||||
System.out.println("\nstarting jFxKasse\n");
|
||||
mainWindow();
|
||||
}
|
||||
|
||||
private void mainWindow()
|
||||
{
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(
|
||||
getClass().getResource("/fxml/MainWindow.fxml"));
|
||||
|
||||
AnchorPane pane = loader.load();
|
||||
primaryStage.setTitle("jFxKasse"); // Title of window
|
||||
|
||||
mwc = loader.getController(); // set the mwc as the JavaFx
|
||||
// MainWindowController
|
||||
pc.searchPrinters(); // search for available printers
|
||||
mwc.setMain(this, dbc, xmlc, pc); // set the created instances to the
|
||||
// mwc
|
||||
|
||||
firstStart(); // test if this is the first run
|
||||
|
||||
Scene scene = new Scene(pane);
|
||||
scene.getStylesheets().add(
|
||||
Main.class.getResource("/css/application.css").toExternalForm());
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show(); // shows the stage
|
||||
|
||||
//attach the KeyController
|
||||
kc = new KeyController(scene, mwc);
|
||||
|
||||
Timeline timeline = new Timeline(
|
||||
new KeyFrame(Duration.seconds(1), ev -> {
|
||||
mwc.updateTimeLabel(); // update time label on UI
|
||||
}));
|
||||
timeline.setCycleCount(Animation.INDEFINITE);
|
||||
timeline.play();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
if (osName.contains("Windows")) {
|
||||
System.out.println("FCK Windows");
|
||||
filepath = userHome + "/Documents/jFxKasse/";
|
||||
} else {
|
||||
filepath = userHome + "/jFxKasse/";
|
||||
}
|
||||
launch(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the config.xml is preset.
|
||||
*/
|
||||
private void firstStart() throws Exception
|
||||
{
|
||||
if (xmlc.loadSettings()) {
|
||||
// config.xml found, app starting normal
|
||||
System.out.println("XML found!");
|
||||
mwc.initUI(); // Starting the UI elements
|
||||
mwc.setDBLabel(); // Set database labels
|
||||
dbc.setDbname(xmlc.getDatabaseName()); // handover database name
|
||||
dbc.connectDatabase(); // estabishing DB conection
|
||||
mwc.fillTablePositionen(); // fill TreeTable 'Positionen'
|
||||
mwc.fillCategory();
|
||||
mwc.fillPrinterSettings();
|
||||
mwc.fillTableJobs();
|
||||
mwc.loadGridButtons();
|
||||
mwc.getSelectedCat(); // Load DB entries in Chois Box
|
||||
mwc.createNewJob();
|
||||
} else {
|
||||
// config.xml NOT found, first start of app
|
||||
System.out.println("no XML found!");
|
||||
xmlc.initXML(); // set default values
|
||||
mwc.blockUI(true); // disable UI elements that need DB
|
||||
mwc.blockUnlock();
|
||||
File dir = new File(filepath);
|
||||
dir.mkdir(); // Create new Subfolder
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.jFxKasse.application;
|
||||
|
||||
import com.jFxKasse.controller.MainWindowController;
|
||||
import com.jFxKasse.controller.PrinterController;
|
||||
import com.jFxKasse.controller.XMLController;
|
||||
import com.jFxKasse.controller.DBController;
|
||||
import com.jFxKasse.controller.KeyController;
|
||||
|
||||
import javafx.application.Application;
|
||||
import java.io.File;
|
||||
import javafx.animation.Animation;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
|
||||
public class Main extends Application {
|
||||
// Path to config.xml and the database
|
||||
public static String filepath;
|
||||
|
||||
private static String osName = System.getProperty("os.name");
|
||||
|
||||
private static String userHome = System.getProperty("user.home");
|
||||
|
||||
private MainWindowController mwc;
|
||||
|
||||
// Initialized in start() after filepath is set by main()
|
||||
private XMLController xmlc;
|
||||
|
||||
private DBController dbc;
|
||||
|
||||
private PrinterController pc = new PrinterController();
|
||||
|
||||
private KeyController kc;
|
||||
|
||||
private Stage primaryStage;
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
this.primaryStage = primaryStage;
|
||||
// filepath is set by main() before launch(); initialize controllers here
|
||||
xmlc = new XMLController(filepath);
|
||||
dbc = new DBController(filepath);
|
||||
System.out.println("\nstarting jFxKasse\n");
|
||||
mainWindow();
|
||||
}
|
||||
|
||||
private void mainWindow() {
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/MainWindow.fxml"));
|
||||
|
||||
AnchorPane pane = loader.load();
|
||||
primaryStage.setTitle("jFxKasse"); // Window title
|
||||
|
||||
mwc = loader.getController(); // Set the MainWindowController
|
||||
pc.searchPrinters(); // Search for available printers
|
||||
mwc.setMain(this, dbc, xmlc, pc); // Pass instances to the controller
|
||||
|
||||
firstStart(); // Check if this is the first run
|
||||
|
||||
Scene scene = new Scene(pane);
|
||||
scene.getStylesheets().add(Main.class.getResource("/css/application.css").toExternalForm());
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show(); // Show the stage
|
||||
|
||||
// Attach the KeyController
|
||||
kc = new KeyController(scene, mwc);
|
||||
|
||||
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), ev -> {
|
||||
mwc.updateTimeLabel(); // Update time label on UI
|
||||
}));
|
||||
timeline.setCycleCount(Animation.INDEFINITE);
|
||||
timeline.play();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (osName.contains("Windows")) {
|
||||
System.out.println("FCK Windows");
|
||||
filepath = userHome + "/Documents/jFxKasse/";
|
||||
}
|
||||
else {
|
||||
filepath = userHome + "/jFxKasse/";
|
||||
}
|
||||
launch(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the config.xml is present and initializes accordingly.
|
||||
*/
|
||||
private void firstStart() throws Exception {
|
||||
if (xmlc.loadSettings()) {
|
||||
// config.xml found, app starting normally
|
||||
System.out.println("XML found!");
|
||||
mwc.initUI(); // Initialize the UI elements
|
||||
mwc.setDBLabel(); // Set database labels
|
||||
dbc.setDbname(xmlc.getDatabaseName()); // Pass database name
|
||||
try {
|
||||
dbc.connectDatabase(); // Establish DB connection
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
showErrorDialog("Datenbankfehler", "Die Datenbank konnte nicht geöffnet werden.",
|
||||
"Datei: " + xmlc.getDatabaseName() + ".db\n\n"
|
||||
+ "Bitte prüfen Sie, ob die Datei vorhanden und nicht beschädigt ist.\n"
|
||||
+ "Fehlermeldung: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
mwc.fillTablePositionen(); // Fill TreeTable 'Positions'
|
||||
mwc.fillCategory();
|
||||
mwc.fillPrinterSettings();
|
||||
mwc.fillTableJobs();
|
||||
mwc.loadGridButtons();
|
||||
mwc.getSelectedCat(); // Load DB entries in ChoiceBox
|
||||
mwc.createNewJob();
|
||||
}
|
||||
else {
|
||||
// config.xml NOT found — first start of app
|
||||
System.out.println("no XML found!");
|
||||
xmlc.initXML(); // Set default values in memory
|
||||
File dir = new File(filepath);
|
||||
dir.mkdir(); // Create config directory
|
||||
try {
|
||||
xmlc.saveSettings(); // Persist defaults immediately so next start is normal
|
||||
System.out.println("Default config.xml written.");
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
showErrorDialog("Konfigurationsfehler", "Die Konfigurationsdatei konnte nicht geschrieben werden.",
|
||||
"Pfad: " + filepath + "config.xml\n\n" + "Bitte prüfen Sie die Schreibrechte.\n"
|
||||
+ "Fehlermeldung: " + e.getMessage());
|
||||
}
|
||||
mwc.blockUI(true); // Disable UI elements that need a DB
|
||||
mwc.blockUnlock(); // Show first-start hint, disable lock button
|
||||
}
|
||||
}
|
||||
|
||||
/** Shows a modal error alert dialog on the JavaFX thread. */
|
||||
private void showErrorDialog(String title, String header, String content) {
|
||||
javafx.scene.control.Alert alert = new javafx.scene.control.Alert(javafx.scene.control.Alert.AlertType.ERROR);
|
||||
alert.setTitle(title);
|
||||
alert.setHeaderText(header);
|
||||
alert.setContentText(content);
|
||||
alert.setResizable(true);
|
||||
alert.showAndWait();
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,25 +16,20 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.util.Pair;
|
||||
|
||||
public class PrintJob
|
||||
{
|
||||
public class PrintJob {
|
||||
|
||||
private TimeDate timedate = new TimeDate();
|
||||
|
||||
public void printJob(int jobID, XMLController xmlc, DBController dbc,
|
||||
PrinterController pc)
|
||||
{
|
||||
public void printJob(int jobID, XMLController xmlc, DBController dbc, PrinterController pc) {
|
||||
|
||||
if ((xmlc.getPrintername().equals("Drucker auswählen")
|
||||
|| xmlc.getPrintername() == null)) {
|
||||
// no printer selected
|
||||
System.out.println("Kein Drucker eingestellt!!!");
|
||||
if ((xmlc.getPrintername().equals("Drucker auswählen") || xmlc.getPrintername() == null)) {
|
||||
// No printer selected
|
||||
System.out.println("No printer configured!");
|
||||
|
||||
// creates a dialog
|
||||
Dialog<Pair<String, String>> dialog = new Dialog<>();
|
||||
dialog.setTitle("Kein Drucker");
|
||||
dialog.setHeaderText("Es ist kein Drucker einestellt.\n"
|
||||
+ "In den Einstellungen einen Drucker auswählen.");
|
||||
dialog.setHeaderText("Es ist kein Drucker einestellt.\n" + "In den Einstellungen einen Drucker auswählen.");
|
||||
|
||||
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK);
|
||||
|
||||
@ -43,30 +38,29 @@ public class PrintJob
|
||||
grid.setVgap(10);
|
||||
grid.setPadding(new Insets(20, 150, 10, 10));
|
||||
|
||||
grid.add(new Label("Tipp:\n"
|
||||
+ "Es kann ein virtueller Drucker installiert werden: \n\n"
|
||||
+ "www.cups-pdf.de"), 0, 0);
|
||||
grid.add(
|
||||
new Label(
|
||||
"Tipp:\n" + "Es kann ein virtueller Drucker installiert werden: \n\n" + "www.cups-pdf.de"),
|
||||
0, 0);
|
||||
|
||||
dialog.getDialogPane().setContent(grid);
|
||||
dialog.setResizable(true);
|
||||
dialog.showAndWait();
|
||||
|
||||
} else {
|
||||
// printer selected
|
||||
}
|
||||
else {
|
||||
// Printer selected
|
||||
pc.selectPrinter(xmlc.getPrintername());
|
||||
/* Single bill or splitted */
|
||||
/* Single bill or split by category */
|
||||
if (xmlc.getCategorySplitted()) {
|
||||
// split the bills
|
||||
// Split the bills
|
||||
|
||||
PrintDataSplitted pdsplitted = new PrintDataSplitted(
|
||||
xmlc.getLinebreak(), xmlc.getOffsetHeader(),
|
||||
xmlc.getOffsetFooter(),
|
||||
timedate.getSystemTime() + " " + timedate.getSystemDate(),
|
||||
PrintDataSplitted pdsplitted = new PrintDataSplitted(xmlc.getLinebreak(), xmlc.getOffsetHeader(),
|
||||
xmlc.getOffsetFooter(), timedate.getSystemTime() + " " + timedate.getSystemDate(),
|
||||
xmlc.getHeader(), xmlc.getFooter());
|
||||
|
||||
pdsplitted.setData(Integer.toString(jobID), dbc.getTime_Job(jobID),
|
||||
dbc.getQuantity_Job(jobID), dbc.getName_Job(jobID),
|
||||
dbc.getValue_Job(jobID), dbc.getCategory_Job(jobID),
|
||||
pdsplitted.setData(Integer.toString(jobID), dbc.getTime_Job(jobID), 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 ...");
|
||||
@ -77,16 +71,15 @@ public class PrintJob
|
||||
pc.printString(printString.get(i));
|
||||
}
|
||||
|
||||
} else {
|
||||
// one single bills
|
||||
PrintDataSimple pds = new PrintDataSimple(xmlc.getLinebreak(),
|
||||
xmlc.getOffsetHeader(), xmlc.getOffsetFooter(),
|
||||
timedate.getSystemTime() + " " + timedate.getSystemDate(),
|
||||
}
|
||||
else {
|
||||
// Single bill
|
||||
PrintDataSimple pds = new PrintDataSimple(xmlc.getLinebreak(), xmlc.getOffsetHeader(),
|
||||
xmlc.getOffsetFooter(), timedate.getSystemTime() + " " + timedate.getSystemDate(),
|
||||
xmlc.getHeader(), xmlc.getFooter());
|
||||
|
||||
pds.setData(Integer.toString(jobID), dbc.getTime_Job(jobID),
|
||||
dbc.getQuantity_Job(jobID), dbc.getName_Job(jobID),
|
||||
dbc.getValue_Job(jobID), dbc.getCategory_Job(jobID),
|
||||
pds.setData(Integer.toString(jobID), dbc.getTime_Job(jobID), 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 ...");
|
||||
pc.printString(pds.getPrintString());
|
||||
|
||||
@ -4,18 +4,15 @@ import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class TimeDate
|
||||
{
|
||||
public String getSystemTime()
|
||||
{
|
||||
public class TimeDate {
|
||||
public String getSystemTime() {
|
||||
DateFormat dateFormat = new SimpleDateFormat("HH:mm");
|
||||
Date date = new Date();
|
||||
String time = dateFormat.format(date);
|
||||
return time;
|
||||
}
|
||||
|
||||
public String getSystemDate()
|
||||
{
|
||||
public String getSystemDate() {
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
||||
Date date = new Date();
|
||||
String dateStr = dateFormat.format(date);
|
||||
|
||||
@ -11,83 +11,77 @@ import com.jFxKasse.datatypes.tableDataJob;
|
||||
import com.jFxKasse.datatypes.tableDataPositionen;
|
||||
import java.io.File;
|
||||
|
||||
public class DBController
|
||||
{
|
||||
public class DBController {
|
||||
private Connection connection;
|
||||
|
||||
private String DB_PATH;
|
||||
|
||||
private String dbname;
|
||||
|
||||
public void main()
|
||||
{
|
||||
public void main() {
|
||||
try {
|
||||
connection = DriverManager
|
||||
.getConnection("jdbc:sqlite:" + DB_PATH + dbname + ".db");
|
||||
} catch (SQLException e) {
|
||||
connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH + dbname + ".db");
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public DBController(String path)
|
||||
{
|
||||
public DBController(String path) {
|
||||
this.DB_PATH = path;
|
||||
}
|
||||
|
||||
public void setDbname(String dbname)
|
||||
{
|
||||
public void setDbname(String dbname) {
|
||||
this.dbname = dbname;
|
||||
}
|
||||
|
||||
public void connectDatabase()
|
||||
{ // connect to database
|
||||
public void connectDatabase() { // Connect to database
|
||||
System.out.println("Connecting... DB name: " + dbname);
|
||||
try {
|
||||
if (connection != null)
|
||||
return;
|
||||
connection = DriverManager
|
||||
.getConnection("jdbc:sqlite:" + DB_PATH + dbname + ".db");
|
||||
connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH + dbname + ".db");
|
||||
if (!connection.isClosed())
|
||||
System.out.println("DB connection established");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
public void run()
|
||||
{
|
||||
public void run() {
|
||||
try {
|
||||
if (!connection.isClosed() && connection != null) {
|
||||
connection.close();
|
||||
if (connection.isClosed())
|
||||
System.out.println();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean existDB(String pPfad)
|
||||
{ // does the DB exists?
|
||||
public boolean existDB(String pPfad) { // Check if the DB exists
|
||||
File varTmpDir = new File(pPfad);
|
||||
if (!varTmpDir.exists()) {
|
||||
return false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public String getCategoryNameFromPositionen(int pID)
|
||||
{
|
||||
public String getCategoryNameFromPositionen(int pID) {
|
||||
int catInPos = 0;
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT posid, cat FROM positionen "
|
||||
+ "WHERE posid = " + pID + ";");
|
||||
ResultSet rs = stmt.executeQuery("SELECT posid, cat FROM positionen " + "WHERE posid = " + pID + ";");
|
||||
catInPos = rs.getInt("cat");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
|
||||
@ -97,10 +91,11 @@ public class DBController
|
||||
}
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT catid, catname FROM category "
|
||||
+ "WHERE catid = " + catInPos + ";");
|
||||
ResultSet rs = stmt
|
||||
.executeQuery("SELECT catid, catname FROM category " + "WHERE catid = " + catInPos + ";");
|
||||
return rs.getString("catname");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return "keine Kategorie";
|
||||
@ -108,34 +103,31 @@ public class DBController
|
||||
|
||||
}
|
||||
|
||||
// table Position section //
|
||||
public void createTablePositionen()
|
||||
{ // create table position
|
||||
// Table 'Positionen' section //
|
||||
public void createTablePositionen() { // Create table 'positionen'
|
||||
System.out.println("Creating table Positionen");
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("DROP TABLE IF EXISTS positionen;");
|
||||
stmt.executeUpdate(
|
||||
"CREATE TABLE positionen (posid, name, value, cat, color);");
|
||||
} catch (SQLException e) {
|
||||
stmt.executeUpdate("CREATE TABLE positionen (posid, name, value, cat, color);");
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// create 25 demo/default data entries
|
||||
// Create 25 demo/default data entries
|
||||
for (int i = 0; i < 25; i++) {
|
||||
fillPositionen_Positionen(i + 1, "Noch frei", (float) 0.00, 6,
|
||||
"#ad0000");
|
||||
fillPositionen_Positionen(i + 1, "Noch frei", (float) 0.00, 6, "#ad0000");
|
||||
}
|
||||
}
|
||||
|
||||
public void fillPositionen_Positionen(int pID, String pName, float pValue,
|
||||
int pCat, String pColor)
|
||||
{ // create new data in table
|
||||
public void fillPositionen_Positionen(int pID, String pName, float pValue, int pCat, String pColor) { // Create new
|
||||
// entry in
|
||||
// table
|
||||
System.out.println("Creating new positionen entry");
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(
|
||||
"INSERT INTO positionen VALUES (?, ?, ?, ?, ?);");
|
||||
PreparedStatement ps = connection.prepareStatement("INSERT INTO positionen VALUES (?, ?, ?, ?, ?);");
|
||||
ps.setInt(1, pID); // primary
|
||||
ps.setString(2, pName);
|
||||
ps.setFloat(3, pValue);
|
||||
@ -146,144 +138,134 @@ public class DBController
|
||||
connection.setAutoCommit(false);
|
||||
ps.executeBatch(); // SQL execution
|
||||
connection.setAutoCommit(true);
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getName_Positionen(int pID)
|
||||
{
|
||||
public String getName_Positionen(int pID) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT posid, name FROM positionen WHERE posid = " + pID + ";");
|
||||
ResultSet rs = stmt.executeQuery("SELECT posid, name FROM positionen WHERE posid = " + pID + ";");
|
||||
return rs.getString("name");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return "Error 404";
|
||||
}
|
||||
}
|
||||
|
||||
public String getValue_Positionen(int pID)
|
||||
{
|
||||
public String getValue_Positionen(int pID) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT posid, value FROM positionen WHERE posid = " + pID
|
||||
+ ";");
|
||||
ResultSet rs = stmt.executeQuery("SELECT posid, value FROM positionen WHERE posid = " + pID + ";");
|
||||
return rs.getString("value");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return "Error 404";
|
||||
}
|
||||
}
|
||||
|
||||
public int getCat_Positionen(int pID)
|
||||
{
|
||||
public int getCat_Positionen(int pID) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT catid, cat FROM positionen WHERE catid = " + pID + ";");
|
||||
ResultSet rs = stmt.executeQuery("SELECT catid, cat FROM positionen WHERE catid = " + pID + ";");
|
||||
System.out.println("getCarTet: " + rs.getInt("cat"));
|
||||
return rs.getInt("cat");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public String getColor_Positionen(int pID)
|
||||
{
|
||||
public String getColor_Positionen(int pID) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT posid, color FROM positionen WHERE posid = " + pID
|
||||
+ ";");
|
||||
ResultSet rs = stmt.executeQuery("SELECT posid, color FROM positionen WHERE posid = " + pID + ";");
|
||||
return rs.getString("color");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return "Error 404";
|
||||
}
|
||||
}
|
||||
|
||||
public void setName_Positionen(int pID, String pName)
|
||||
{
|
||||
public void setName_Positionen(int pID, String pName) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE positionen SET name = '" + pName
|
||||
+ "'WHERE posid =" + pID + ";");
|
||||
} catch (SQLException e) {
|
||||
stmt.executeUpdate("UPDATE positionen SET name = '" + pName + "'WHERE posid =" + pID + ";");
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue_Positionen(int pID, String pValue)
|
||||
{
|
||||
public void setValue_Positionen(int pID, String pValue) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE positionen SET value = '" + pValue
|
||||
+ "'WHERE posid =" + pID + ";");
|
||||
} catch (SQLException e) {
|
||||
stmt.executeUpdate("UPDATE positionen SET value = '" + pValue + "'WHERE posid =" + pID + ";");
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCat_Positionen(int pID, int pCat)
|
||||
{
|
||||
public void setCat_Positionen(int pID, int pCat) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE positionen SET cat = '" + pCat
|
||||
+ "'WHERE posid =" + pID + ";");
|
||||
} catch (SQLException e) {
|
||||
stmt.executeUpdate("UPDATE positionen SET cat = '" + pCat + "'WHERE posid =" + pID + ";");
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setColor_Positionen(int pID, String pColor)
|
||||
{
|
||||
public void setColor_Positionen(int pID, String pColor) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE positionen SET color = '" + pColor
|
||||
+ "'WHERE posid =" + pID + ";");
|
||||
} catch (SQLException e) {
|
||||
stmt.executeUpdate("UPDATE positionen SET color = '" + pColor + "'WHERE posid =" + pID + ";");
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<tableDataPositionen> ladeTabellePositionen()
|
||||
{
|
||||
public ArrayList<tableDataPositionen> ladeTabellePositionen() {
|
||||
ArrayList<tableDataPositionen> daten = new ArrayList<>();
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM positionen;");
|
||||
while (rs.next()) {
|
||||
try {
|
||||
daten.add(new tableDataPositionen(rs.getInt("posid"),
|
||||
rs.getString("name"), rs.getString("value"),
|
||||
daten.add(new tableDataPositionen(rs.getInt("posid"), rs.getString("name"), rs.getString("value"),
|
||||
rs.getString("cat"), rs.getString("color")));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return daten;
|
||||
}
|
||||
|
||||
public void ausgebenSysoPositionen()
|
||||
{
|
||||
public void ausgebenSysoPositionen() {
|
||||
System.out.println("Print positionen");
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
@ -296,21 +278,22 @@ public class DBController
|
||||
System.out.println(" ");
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// table Category section //
|
||||
public void createTableCategory()
|
||||
{ // create table position
|
||||
System.out.println("Erstelle Tabelle Kategorie");
|
||||
// Table 'Category' section //
|
||||
public void createTableCategory() { // Create table 'category'
|
||||
System.out.println("Creating table Category");
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("DROP TABLE IF EXISTS category;");
|
||||
stmt.executeUpdate("CREATE TABLE category (catid, catname);");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -323,76 +306,71 @@ public class DBController
|
||||
|
||||
}
|
||||
|
||||
public void setName_Category(int pID, String pName)
|
||||
{
|
||||
public void setName_Category(int pID, String pName) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE category SET catname = '" + pName
|
||||
+ "'WHERE catid =" + pID + ";");
|
||||
} catch (SQLException e) {
|
||||
stmt.executeUpdate("UPDATE category SET catname = '" + pName + "'WHERE catid =" + pID + ";");
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void fillCategory_Category(int pID, String pName)
|
||||
{
|
||||
public void fillCategory_Category(int pID, String pName) {
|
||||
|
||||
System.out.println("Erstelle neuen Kategorie Eintrag");
|
||||
System.out.println("Creating new category entry");
|
||||
try {
|
||||
PreparedStatement ps = connection
|
||||
.prepareStatement("INSERT INTO category VALUES (?, ?);");
|
||||
PreparedStatement ps = connection.prepareStatement("INSERT INTO category VALUES (?, ?);");
|
||||
ps.setInt(1, pID); // primary
|
||||
ps.setString(2, pName);
|
||||
ps.addBatch();
|
||||
connection.setAutoCommit(false);
|
||||
ps.executeBatch(); // SQL execution
|
||||
connection.setAutoCommit(true);
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getName_Category(int pID)
|
||||
{
|
||||
public String getName_Category(int pID) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT catid, catname FROM category WHERE catid = " + pID
|
||||
+ ";");
|
||||
ResultSet rs = stmt.executeQuery("SELECT catid, catname FROM category WHERE catid = " + pID + ";");
|
||||
return rs.getString("catname");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return "Error 404";
|
||||
}
|
||||
}
|
||||
|
||||
// table Jobs section //
|
||||
public void erstelleTabelleJobs()
|
||||
{ // create table jobs
|
||||
// Table 'Jobs' section //
|
||||
public void erstelleTabelleJobs() { // Create table 'jobs'
|
||||
System.out.println("Creating table Jobs");
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("DROP TABLE IF EXISTS jobs;");
|
||||
stmt.executeUpdate(
|
||||
"CREATE TABLE jobs (jobid, time, positionen_quantity, positionen_name, positionen_value, positionen_cat, state, jobvalue);");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public int getLatestJobNumber_Job()
|
||||
{
|
||||
public int getLatestJobNumber_Job() {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT jobid from jobs ORDER BY jobid DESC LIMIT 1;");
|
||||
ResultSet rs = stmt.executeQuery("SELECT jobid from jobs ORDER BY jobid DESC LIMIT 1;");
|
||||
return rs.getInt("jobid");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// System.err.println("Couldn't handle DB-Query");
|
||||
// e.printStackTrace();
|
||||
|
||||
@ -400,152 +378,138 @@ public class DBController
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getTime_Job(int pID)
|
||||
{
|
||||
public String getTime_Job(int pID) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT jobid, time FROM jobs WHERE jobid = " + pID + ";");
|
||||
ResultSet rs = stmt.executeQuery("SELECT jobid, time FROM jobs WHERE jobid = " + pID + ";");
|
||||
return rs.getString("time");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return "404";
|
||||
}
|
||||
}
|
||||
|
||||
public String getQuantity_Job(int pID)
|
||||
{
|
||||
public String getQuantity_Job(int pID) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT jobid, positionen_quantity FROM jobs WHERE jobid = "
|
||||
+ pID + ";");
|
||||
ResultSet rs = stmt.executeQuery("SELECT jobid, positionen_quantity FROM jobs WHERE jobid = " + pID + ";");
|
||||
return rs.getString("positionen_quantity");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return "404";
|
||||
}
|
||||
}
|
||||
|
||||
public String getName_Job(int pID)
|
||||
{
|
||||
public String getName_Job(int pID) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT jobid, positionen_name FROM jobs WHERE jobid = " + pID
|
||||
+ ";");
|
||||
ResultSet rs = stmt.executeQuery("SELECT jobid, positionen_name FROM jobs WHERE jobid = " + pID + ";");
|
||||
return rs.getString("positionen_name");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return "404";
|
||||
}
|
||||
}
|
||||
|
||||
public String getValue_Job(int pID)
|
||||
{
|
||||
public String getValue_Job(int pID) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT jobid, positionen_value FROM jobs WHERE jobid = " + pID
|
||||
+ ";");
|
||||
ResultSet rs = stmt.executeQuery("SELECT jobid, positionen_value FROM jobs WHERE jobid = " + pID + ";");
|
||||
return rs.getString("positionen_value");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return "404";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCategory_Job(int pID)
|
||||
{
|
||||
public String getCategory_Job(int pID) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT jobid, positionen_cat FROM jobs WHERE jobid = " + pID
|
||||
+ ";");
|
||||
ResultSet rs = stmt.executeQuery("SELECT jobid, positionen_cat FROM jobs WHERE jobid = " + pID + ";");
|
||||
return rs.getString("positionen_cat");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return "404";
|
||||
}
|
||||
}
|
||||
|
||||
public String getState_Job(int pID)
|
||||
{
|
||||
public String getState_Job(int pID) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT jobid, state FROM jobs WHERE jobid = " + pID + ";");
|
||||
ResultSet rs = stmt.executeQuery("SELECT jobid, state FROM jobs WHERE jobid = " + pID + ";");
|
||||
return rs.getString("state");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return "404";
|
||||
}
|
||||
}
|
||||
|
||||
public String getJobValue_Job(int pID)
|
||||
{
|
||||
public String getJobValue_Job(int pID) {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT jobid, jobvalue FROM jobs WHERE jobid = " + pID + ";");
|
||||
ResultSet rs = stmt.executeQuery("SELECT jobid, jobvalue FROM jobs WHERE jobid = " + pID + ";");
|
||||
return rs.getString("jobvalue");
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
return "404";
|
||||
}
|
||||
}
|
||||
|
||||
public String getAllJobValue_Job()
|
||||
{
|
||||
public String getAllJobValue_Job() {
|
||||
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 String getJobCount()
|
||||
{
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT count(*) AS JOBCOUNT FROM jobs WHERE state = " + '"'
|
||||
ResultSet rs = stmt
|
||||
.executeQuery("SELECT state, jobvalue, SUM(jobvalue) AS ALLVALUE FROM jobs WHERE state = " + '"'
|
||||
+ "verbucht" + '"' + ";");
|
||||
return rs.getString("JOBCOUNT");
|
||||
} catch (SQLException e) {
|
||||
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)
|
||||
{
|
||||
public String getJobCount() {
|
||||
try {
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.executeUpdate("UPDATE jobs SET state = '" + pStatus
|
||||
+ "'WHERE jobid =" + pID + ";");
|
||||
} catch (SQLException e) {
|
||||
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) {
|
||||
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()
|
||||
{
|
||||
public ArrayList<tableDataJob> loadTableJobs_Job() {
|
||||
|
||||
ArrayList<tableDataJob> tmp = new ArrayList<tableDataJob>();
|
||||
try {
|
||||
@ -557,31 +521,29 @@ public class DBController
|
||||
|
||||
String tablePosition = rs.getString("positionen_name");
|
||||
|
||||
tableDataJob data = new tableDataJob(rs.getInt("jobid"),
|
||||
rs.getString("time"), tablePosition, rs.getString("state"),
|
||||
rs.getString("jobvalue"));
|
||||
tableDataJob data = new tableDataJob(rs.getInt("jobid"), rs.getString("time"), tablePosition,
|
||||
rs.getString("state"), rs.getString("jobvalue"));
|
||||
|
||||
tmp.add(data);
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
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");
|
||||
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("Creating new job entry");
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(
|
||||
"INSERT INTO jobs VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
|
||||
PreparedStatement ps = connection.prepareStatement("INSERT INTO jobs VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
|
||||
ps.setInt(1, pID); // primary
|
||||
ps.setString(2, pTime);
|
||||
ps.setString(3, pPositionen_quantity);
|
||||
@ -594,7 +556,8 @@ public class DBController
|
||||
connection.setAutoCommit(false);
|
||||
ps.executeBatch(); // SQL execution
|
||||
connection.setAutoCommit(true);
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
System.err.println("Couldn't handle DB-Query");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -5,18 +5,15 @@ import javafx.scene.Scene;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
|
||||
public class KeyController
|
||||
{
|
||||
public class KeyController {
|
||||
private MainWindowController mwc;
|
||||
|
||||
public KeyController(Scene scene, MainWindowController mwc)
|
||||
{
|
||||
public KeyController(Scene scene, MainWindowController mwc) {
|
||||
this.mwc = mwc;
|
||||
|
||||
scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
|
||||
@Override
|
||||
public void handle(KeyEvent keyEvent)
|
||||
{
|
||||
public void handle(KeyEvent keyEvent) {
|
||||
switch (mwc.getActiveTab()) {
|
||||
case 0:
|
||||
handleTabNewJob(keyEvent);
|
||||
@ -42,10 +39,8 @@ public class KeyController
|
||||
|
||||
}
|
||||
|
||||
private void handleTabNewJob(KeyEvent key)
|
||||
{
|
||||
if ((key.getCode() == KeyCode.ENTER)
|
||||
&& (!mwc.btnPrintBill.isDisabled())) {
|
||||
private void handleTabNewJob(KeyEvent key) {
|
||||
if ((key.getCode() == KeyCode.ENTER) && (!mwc.btnPrintBill.isDisabled())) {
|
||||
mwc.btnPrintBillAction(null);
|
||||
}
|
||||
|
||||
@ -53,8 +48,7 @@ public class KeyController
|
||||
mwc.btnLockAction(null);
|
||||
}
|
||||
|
||||
if ((key.getCode() == KeyCode.DELETE)
|
||||
&& (!mwc.btnDeleteSelectedPosition.isDisabled())) {
|
||||
if ((key.getCode() == KeyCode.DELETE) && (!mwc.btnDeleteSelectedPosition.isDisabled())) {
|
||||
mwc.btnDeleteSelectedPositionAction(null);
|
||||
}
|
||||
|
||||
@ -62,15 +56,12 @@ public class KeyController
|
||||
|
||||
}
|
||||
|
||||
private void handleTabJobs(KeyEvent key)
|
||||
{
|
||||
if ((key.getCode() == KeyCode.ENTER)
|
||||
&& (!mwc.btnReprintJob.isDisabled())) {
|
||||
private void handleTabJobs(KeyEvent key) {
|
||||
if ((key.getCode() == KeyCode.ENTER) && (!mwc.btnReprintJob.isDisabled())) {
|
||||
mwc.btnReprintJobAction(null);
|
||||
}
|
||||
|
||||
if ((key.getCode() == KeyCode.DELETE)
|
||||
&& (!mwc.btnCancelJob.isDisabled())) {
|
||||
if ((key.getCode() == KeyCode.DELETE) && (!mwc.btnCancelJob.isDisabled())) {
|
||||
mwc.btnCancelJobAction(null);
|
||||
}
|
||||
|
||||
@ -79,23 +70,18 @@ public class KeyController
|
||||
}
|
||||
}
|
||||
|
||||
private void handleTabPosEdit(KeyEvent key)
|
||||
{
|
||||
if ((key.getCode() == KeyCode.ENTER)
|
||||
&& (!mwc.btnSaveEntry.isDisabled())) {
|
||||
private void handleTabPosEdit(KeyEvent key) {
|
||||
if ((key.getCode() == KeyCode.ENTER) && (!mwc.btnSaveEntry.isDisabled())) {
|
||||
mwc.btnSaveEntryAction(null);
|
||||
}
|
||||
|
||||
if ((key.getCode() == KeyCode.DELETE)
|
||||
&& (!mwc.btnClearEntry.isDisabled())) {
|
||||
if ((key.getCode() == KeyCode.DELETE) && (!mwc.btnClearEntry.isDisabled())) {
|
||||
mwc.btnClearEntryAction(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleTabSettings(KeyEvent key)
|
||||
{
|
||||
if ((key.getCode() == KeyCode.ENTER)
|
||||
&& (!mwc.btnSavePrinter.isDisabled())) {
|
||||
private void handleTabSettings(KeyEvent key) {
|
||||
if ((key.getCode() == KeyCode.ENTER) && (!mwc.btnSavePrinter.isDisabled())) {
|
||||
mwc.btnSavePrinterAction(null);
|
||||
}
|
||||
|
||||
@ -103,18 +89,17 @@ public class KeyController
|
||||
mwc.btnSaveCatAction(null);
|
||||
}
|
||||
|
||||
if ((key.getCode() == KeyCode.ENTER)
|
||||
&& (!mwc.btnCreateNewDatabase.isDisabled())) {
|
||||
if ((key.getCode() == KeyCode.ENTER) && (!mwc.btnCreateNewDatabase.isDisabled())) {
|
||||
try {
|
||||
mwc.btnCreateNewDatabaseAction(null);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handelGridButtons(KeyEvent key)
|
||||
{
|
||||
void handelGridButtons(KeyEvent key) {
|
||||
|
||||
switch (key.getCode()) {
|
||||
case Q:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* some parts are from http://www.mets-blog.com/java-pos-thermal-printer-example/
|
||||
* Some parts are from http://www.mets-blog.com/java-pos-thermal-printer-example/
|
||||
*/
|
||||
|
||||
package com.jFxKasse.controller;
|
||||
@ -21,26 +21,23 @@ import javax.print.SimpleDoc;
|
||||
import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
|
||||
public class PrinterController implements Printable
|
||||
{
|
||||
// All available Printers on this system
|
||||
public class PrinterController implements Printable {
|
||||
// All available printers on this system
|
||||
private PrintService[] printService;
|
||||
|
||||
// selected printer
|
||||
// Selected printer
|
||||
private PrintService selectedPrinter;
|
||||
|
||||
private DocFlavor flavor;
|
||||
|
||||
public PrinterController()
|
||||
{
|
||||
public PrinterController() {
|
||||
flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A String array with all available printers
|
||||
*/
|
||||
public String[] getAvailablePrinters()
|
||||
{
|
||||
public String[] getAvailablePrinters() {
|
||||
int printerSize = PrinterJob.lookupPrintServices().length;
|
||||
String printers[] = new String[printerSize];
|
||||
|
||||
@ -51,10 +48,9 @@ public class PrinterController implements Printable
|
||||
}
|
||||
|
||||
/**
|
||||
* searchs connected printers on the system
|
||||
* Searches for connected printers on the system
|
||||
*/
|
||||
public void searchPrinters()
|
||||
{
|
||||
public void searchPrinters() {
|
||||
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
|
||||
this.printService = PrintServiceLookup.lookupPrintServices(flavor, pras);
|
||||
String printers[] = getAvailablePrinters();
|
||||
@ -67,11 +63,11 @@ public class PrinterController implements Printable
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects the printer via its name
|
||||
* Selects the printer by its name
|
||||
*
|
||||
* @param printerName
|
||||
*/
|
||||
public void selectPrinter(String printerName)
|
||||
{
|
||||
public void selectPrinter(String printerName) {
|
||||
String printers[] = getAvailablePrinters();
|
||||
|
||||
for (int i = 0; i < printers.length; i++) {
|
||||
@ -84,11 +80,11 @@ public class PrinterController implements Printable
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a string to the selected printer
|
||||
*
|
||||
* @param input data as String
|
||||
* @param text data as String
|
||||
*/
|
||||
public void printString(String text)
|
||||
{
|
||||
public void printString(String text) {
|
||||
PrintService service = selectedPrinter;
|
||||
DocPrintJob job = service.createPrintJob();
|
||||
|
||||
@ -97,21 +93,21 @@ public class PrinterController implements Printable
|
||||
bytes = text.getBytes(StandardCharsets.UTF_8);
|
||||
Doc doc = new SimpleDoc(bytes, flavor, null);
|
||||
job.print(doc, null);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public int print(Graphics g, PageFormat pf, int page) throws PrinterException
|
||||
{
|
||||
public int print(Graphics g, PageFormat pf, int page) throws PrinterException {
|
||||
if (page > 0) { /* We have only one page, and 'page' is zero-based */
|
||||
return NO_SUCH_PAGE;
|
||||
}
|
||||
|
||||
/*
|
||||
* User (0,0) is typically outside the imageable area, so we must
|
||||
* translate by the X and Y values in the PageFormat to avoid clipping
|
||||
* User (0,0) is typically outside the imageable area, so we must translate by
|
||||
* the X and Y values in the PageFormat to avoid clipping
|
||||
*/
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.translate(pf.getImageableX(), pf.getImageableY());
|
||||
@ -119,21 +115,20 @@ public class PrinterController implements Printable
|
||||
return PAGE_EXISTS;
|
||||
}
|
||||
|
||||
public void printBytes(byte[] bytes)
|
||||
{
|
||||
public void printBytes(byte[] bytes) {
|
||||
PrintService service = selectedPrinter;
|
||||
DocPrintJob job = service.createPrintJob();
|
||||
|
||||
try {
|
||||
Doc doc = new SimpleDoc(bytes, flavor, null);
|
||||
job.print(doc, null);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void cutPaper()
|
||||
{
|
||||
public void cutPaper() {
|
||||
byte[] cutP = new byte[] { 0x1d, 'V', 1 };
|
||||
printBytes(cutP);
|
||||
}
|
||||
|
||||
@ -7,8 +7,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class XMLController
|
||||
{
|
||||
public class XMLController {
|
||||
private String databaseName = null;
|
||||
|
||||
private String printername = null;
|
||||
@ -25,18 +24,18 @@ public class XMLController
|
||||
|
||||
private boolean categorySplitted;
|
||||
|
||||
private boolean autoPrintBill;
|
||||
|
||||
private String filePath = null;
|
||||
|
||||
private Properties props = null;
|
||||
|
||||
public XMLController(String filePath)
|
||||
{
|
||||
public XMLController(String filePath) {
|
||||
this.filePath = filePath + "config.xml";
|
||||
props = new Properties();
|
||||
}
|
||||
|
||||
public void saveSettings() throws Exception
|
||||
{ // Save settings to config.xml
|
||||
public void saveSettings() throws Exception { // Save settings to config.xml
|
||||
|
||||
System.out.println("Saving XML");
|
||||
|
||||
@ -50,10 +49,20 @@ public class XMLController
|
||||
|
||||
if (this.categorySplitted) {
|
||||
categorySplitted = "true";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
categorySplitted = "false";
|
||||
}
|
||||
|
||||
String autoPrintBill = null;
|
||||
|
||||
if (this.autoPrintBill) {
|
||||
autoPrintBill = "true";
|
||||
}
|
||||
else {
|
||||
autoPrintBill = "false";
|
||||
}
|
||||
|
||||
try {
|
||||
props.setProperty("databasename", this.databaseName);
|
||||
props.setProperty("printername", this.printername);
|
||||
@ -63,16 +72,17 @@ public class XMLController
|
||||
props.setProperty("header", this.header);
|
||||
props.setProperty("footer", this.footer);
|
||||
props.setProperty("categorySplitted", categorySplitted);
|
||||
props.setProperty("autoPrintBill", autoPrintBill);
|
||||
|
||||
outputStream = new FileOutputStream(filePath);
|
||||
props.storeToXML(outputStream, "jFxKasse settings");
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean loadSettings() throws Exception
|
||||
{ // reads the settings from config.xml
|
||||
public boolean loadSettings() throws Exception { // Read settings from config.xml
|
||||
InputStream inputStream;
|
||||
try {
|
||||
inputStream = new FileInputStream(filePath);
|
||||
@ -82,21 +92,22 @@ public class XMLController
|
||||
|
||||
try {
|
||||
this.linebreak = Integer.valueOf(props.getProperty("linebreak"));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.linebreak = 28;
|
||||
}
|
||||
|
||||
try {
|
||||
this.offsetHeader = Integer
|
||||
.valueOf(props.getProperty("offsetHeader"));
|
||||
} catch (Exception e) {
|
||||
this.offsetHeader = Integer.valueOf(props.getProperty("offsetHeader"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.offsetHeader = 1;
|
||||
}
|
||||
|
||||
try {
|
||||
this.offsetFooter = Integer
|
||||
.valueOf(props.getProperty("offsetFooter"));
|
||||
} catch (Exception e) {
|
||||
this.offsetFooter = Integer.valueOf(props.getProperty("offsetFooter"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.offsetFooter = 2;
|
||||
}
|
||||
|
||||
@ -106,23 +117,37 @@ public class XMLController
|
||||
try {
|
||||
if (props.getProperty("categorySplitted").equals("true")) {
|
||||
this.categorySplitted = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.categorySplitted = false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.categorySplitted = false;
|
||||
}
|
||||
|
||||
try {
|
||||
if (props.getProperty("autoPrintBill").equals("true")) {
|
||||
this.autoPrintBill = true;
|
||||
}
|
||||
else {
|
||||
this.autoPrintBill = false;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.autoPrintBill = false;
|
||||
}
|
||||
|
||||
inputStream.close();
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void initXML()
|
||||
{
|
||||
public void initXML() {
|
||||
this.printername = "Drucker auswählen";
|
||||
|
||||
this.offsetHeader = 1;
|
||||
@ -132,88 +157,82 @@ public class XMLController
|
||||
|
||||
this.categorySplitted = false;
|
||||
|
||||
this.autoPrintBill = false;
|
||||
|
||||
this.header = "XYZ GmbH";
|
||||
this.footer = "Vielen Dank für den Einkauf";
|
||||
}
|
||||
|
||||
public String getDatabaseName()
|
||||
{
|
||||
public String getDatabaseName() {
|
||||
return databaseName;
|
||||
}
|
||||
|
||||
public void setDatabaseName(String databaseName)
|
||||
{
|
||||
public void setDatabaseName(String databaseName) {
|
||||
this.databaseName = databaseName;
|
||||
}
|
||||
|
||||
public String getPrintername()
|
||||
{
|
||||
public String getPrintername() {
|
||||
return printername;
|
||||
}
|
||||
|
||||
public void setPrintername(String printername)
|
||||
{
|
||||
public void setPrintername(String printername) {
|
||||
this.printername = printername;
|
||||
}
|
||||
|
||||
public int getLinebreak()
|
||||
{
|
||||
public int getLinebreak() {
|
||||
return linebreak;
|
||||
}
|
||||
|
||||
public void setLinebreak(int linebreak)
|
||||
{
|
||||
public void setLinebreak(int linebreak) {
|
||||
this.linebreak = linebreak;
|
||||
}
|
||||
|
||||
public int getOffsetHeader()
|
||||
{
|
||||
public int getOffsetHeader() {
|
||||
return offsetHeader;
|
||||
}
|
||||
|
||||
public void setOffsetHeader(int offsetHeader)
|
||||
{
|
||||
public void setOffsetHeader(int offsetHeader) {
|
||||
this.offsetHeader = offsetHeader;
|
||||
}
|
||||
|
||||
public int getOffsetFooter()
|
||||
{
|
||||
public int getOffsetFooter() {
|
||||
return offsetFooter;
|
||||
}
|
||||
|
||||
public void setOffsetFooter(int offsetFooter)
|
||||
{
|
||||
public void setOffsetFooter(int offsetFooter) {
|
||||
this.offsetFooter = offsetFooter;
|
||||
}
|
||||
|
||||
public String getHeader()
|
||||
{
|
||||
public String getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public void setHeader(String header)
|
||||
{
|
||||
public void setHeader(String header) {
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
public String getFooter()
|
||||
{
|
||||
public String getFooter() {
|
||||
return footer;
|
||||
}
|
||||
|
||||
public void setFooter(String footer)
|
||||
{
|
||||
public void setFooter(String footer) {
|
||||
this.footer = footer;
|
||||
}
|
||||
|
||||
public boolean getCategorySplitted()
|
||||
{
|
||||
public boolean getCategorySplitted() {
|
||||
return categorySplitted;
|
||||
}
|
||||
|
||||
public void setCategorySplitted(boolean categorySplitted)
|
||||
{
|
||||
public void setCategorySplitted(boolean categorySplitted) {
|
||||
this.categorySplitted = categorySplitted;
|
||||
}
|
||||
|
||||
public boolean getAutoPrintBill() {
|
||||
return autoPrintBill;
|
||||
}
|
||||
|
||||
public void setAutoPrintBill(boolean autoPrintBill) {
|
||||
this.autoPrintBill = autoPrintBill;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,32 +1,25 @@
|
||||
package com.jFxKasse.datatypes;
|
||||
|
||||
public class Category
|
||||
{
|
||||
public class Category {
|
||||
private String categoryName;
|
||||
|
||||
private String positionsString = "\n";
|
||||
|
||||
public Category(String categoryName)
|
||||
{
|
||||
public Category(String categoryName) {
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public String getCategoryName()
|
||||
{
|
||||
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) {
|
||||
for (int i = 0; i < quantity; i++) {
|
||||
positionsString = positionsString
|
||||
+ pd.setRight(pd.breakLines(name), value + " €") + "\n";
|
||||
positionsString = positionsString + pd.setRight(pd.breakLines(name), value + " €") + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
public String getPositionsString()
|
||||
{
|
||||
public String getPositionsString() {
|
||||
return positionsString;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package com.jFxKasse.datatypes;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Job
|
||||
{
|
||||
public class Job {
|
||||
private int jobnumber;
|
||||
|
||||
private float jobvalue;
|
||||
@ -19,8 +19,7 @@ public class Job
|
||||
|
||||
private ArrayList<String> positionenCat;
|
||||
|
||||
public Job(int pJobnumber)
|
||||
{
|
||||
public Job(int pJobnumber) {
|
||||
this.jobnumber = pJobnumber;
|
||||
positionenQuantity = new ArrayList<Integer>();
|
||||
positionenName = new ArrayList<String>();
|
||||
@ -29,32 +28,26 @@ public class Job
|
||||
|
||||
}
|
||||
|
||||
public void setJobtime(String jobtime)
|
||||
{
|
||||
public void setJobtime(String jobtime) {
|
||||
this.jobtime = jobtime;
|
||||
}
|
||||
|
||||
public int getJobnumber()
|
||||
{
|
||||
public int getJobnumber() {
|
||||
return this.jobnumber;
|
||||
}
|
||||
|
||||
public String getJobtime()
|
||||
{
|
||||
public String getJobtime() {
|
||||
return this.jobtime;
|
||||
}
|
||||
|
||||
public float getJobValue()
|
||||
{
|
||||
public float getJobValue() {
|
||||
|
||||
calcJobValue();
|
||||
|
||||
return this.jobvalue;
|
||||
}
|
||||
|
||||
public void addPosition(String pPositionenName, float pPositionenValue,
|
||||
String pPositionenCat)
|
||||
{
|
||||
public void addPosition(String pPositionenName, float pPositionenValue, String pPositionenCat) {
|
||||
for (int i = 0; i < positionenName.size(); i++) {
|
||||
if (positionenName.get(i).equals(pPositionenName)) {
|
||||
// Item is already in list, increase quantity
|
||||
@ -71,51 +64,44 @@ public class Job
|
||||
calcJobValue();
|
||||
}
|
||||
|
||||
public void printJobOnConsole()
|
||||
{
|
||||
public void printJobOnConsole() {
|
||||
System.out.println("---------------------------------------------");
|
||||
System.out.println("JobNummer: " + jobnumber);
|
||||
System.out.println("---------------------------------------------");
|
||||
|
||||
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(positionenQuantity.get(i) + " " + positionenName.get(i) + " " + positionenValue.get(i)
|
||||
+ " " + positionenCat.get(i));
|
||||
}
|
||||
|
||||
System.out.println("---------------------------------------------");
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<tableDataCurrentOrder> getCurrentJobPositionen()
|
||||
{
|
||||
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));
|
||||
tableDataCurrentOrder tmp = new tableDataCurrentOrder(positionenName.get(i), positionenQuantity.get(i));
|
||||
|
||||
jobitems.add(tmp);
|
||||
}
|
||||
return jobitems;
|
||||
}
|
||||
|
||||
private void calcJobValue()
|
||||
{
|
||||
private void calcJobValue() {
|
||||
jobvalue = 0;
|
||||
|
||||
for (int i = 0; i < positionenValue.size(); i++) {
|
||||
jobvalue = jobvalue
|
||||
+ (positionenQuantity.get(i) * positionenValue.get(i));
|
||||
jobvalue = jobvalue + (positionenQuantity.get(i) * positionenValue.get(i));
|
||||
}
|
||||
//Round to two decimals
|
||||
jobvalue = BigDecimal.valueOf(jobvalue).setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
|
||||
// Round to two decimal places
|
||||
jobvalue = BigDecimal.valueOf(jobvalue).setScale(2, RoundingMode.HALF_UP).floatValue();
|
||||
}
|
||||
|
||||
public String createPosQuantityDBString()
|
||||
{
|
||||
public String createPosQuantityDBString() {
|
||||
String tmp = String.valueOf(positionenQuantity.get(0));
|
||||
for (int i = 1; i < positionenName.size(); i++) {
|
||||
|
||||
@ -124,8 +110,7 @@ public class Job
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public String createPosNameDBString()
|
||||
{
|
||||
public String createPosNameDBString() {
|
||||
String tmp = positionenName.get(0);
|
||||
for (int i = 1; i < positionenName.size(); i++) {
|
||||
|
||||
@ -134,8 +119,7 @@ public class Job
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public String createPosValueDBString()
|
||||
{
|
||||
public String createPosValueDBString() {
|
||||
String tmp = String.valueOf(positionenValue.get(0));
|
||||
for (int i = 1; i < positionenName.size(); i++) {
|
||||
|
||||
@ -144,8 +128,7 @@ public class Job
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public String createPosCatDBString()
|
||||
{
|
||||
public String createPosCatDBString() {
|
||||
String tmp = positionenCat.get(0);
|
||||
for (int i = 1; i < positionenName.size(); i++) {
|
||||
|
||||
@ -154,8 +137,7 @@ public class Job
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public void deletePosName(String pPosName)
|
||||
{
|
||||
public void deletePosName(String pPosName) {
|
||||
|
||||
for (int i = 0; i < positionenName.size(); i++) {
|
||||
|
||||
@ -163,7 +145,8 @@ public class Job
|
||||
|
||||
if (positionenQuantity.get(i) > 1) {
|
||||
positionenQuantity.set(i, positionenQuantity.get(i) - 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
positionenQuantity.remove(i);
|
||||
positionenName.remove(i);
|
||||
@ -178,8 +161,15 @@ public class Job
|
||||
|
||||
}
|
||||
|
||||
public boolean existsPosName(String pPosName)
|
||||
{
|
||||
public void clearAllPositions() {
|
||||
positionenQuantity.clear();
|
||||
positionenName.clear();
|
||||
positionenValue.clear();
|
||||
positionenCat.clear();
|
||||
jobvalue = 0;
|
||||
}
|
||||
|
||||
public boolean existsPosName(String pPosName) {
|
||||
for (int i = 0; i < positionenName.size(); i++) {
|
||||
if (positionenName.get(i).equals(pPosName)) {
|
||||
return true;
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.jFxKasse.datatypes;
|
||||
|
||||
public abstract class PrintData
|
||||
{
|
||||
public abstract class PrintData {
|
||||
|
||||
protected int headerSpace;
|
||||
|
||||
@ -30,7 +29,8 @@ public abstract class PrintData
|
||||
protected String jobValue;
|
||||
|
||||
/**
|
||||
* Constructor with all data that is not in the DB
|
||||
* Constructor with all data that is not stored in the DB
|
||||
*
|
||||
* @param lineBreak
|
||||
* @param headerSpace
|
||||
* @param footerSpace
|
||||
@ -38,9 +38,8 @@ public abstract class PrintData
|
||||
* @param header
|
||||
* @param footer
|
||||
*/
|
||||
public PrintData(int lineBreak, int headerSpace, int footerSpace,
|
||||
String timeAndDatePrint, String header, String footer)
|
||||
{
|
||||
public PrintData(int lineBreak, int headerSpace, int footerSpace, String timeAndDatePrint, String header,
|
||||
String footer) {
|
||||
this.lineBreak = lineBreak;
|
||||
this.headerSpace = headerSpace;
|
||||
this.footerSpace = footerSpace;
|
||||
@ -50,7 +49,8 @@ public abstract class PrintData
|
||||
}
|
||||
|
||||
/**
|
||||
* set all Data that is in the DB
|
||||
* Set all data that is stored in the DB
|
||||
*
|
||||
* @param jobID
|
||||
* @param timeAndDateOrder
|
||||
* @param positionenQuantity
|
||||
@ -59,10 +59,8 @@ public abstract class PrintData
|
||||
* @param positionenCategory
|
||||
* @param jobValue
|
||||
*/
|
||||
public void setData(String jobID, String timeAndDateOrder,
|
||||
String positionsQuantity, String positionsName,
|
||||
String positionsValue, String positionsCategory, String jobValue)
|
||||
{
|
||||
public void setData(String jobID, String timeAndDateOrder, String positionsQuantity, String positionsName,
|
||||
String positionsValue, String positionsCategory, String jobValue) {
|
||||
this.jobID = jobID;
|
||||
this.timeAndDateOrder = timeAndDateOrder;
|
||||
this.positionsQuantity = positionsQuantity;
|
||||
@ -73,25 +71,26 @@ public abstract class PrintData
|
||||
}
|
||||
|
||||
/**
|
||||
* Breaks a string with newlines after the max line length
|
||||
*
|
||||
* @param data String
|
||||
* @return same String splitted with \n after the max. line lenght
|
||||
* @return the same String split with \n after max line length
|
||||
*/
|
||||
protected String breakLines(String data)
|
||||
{
|
||||
protected String breakLines(String data) {
|
||||
boolean next = false;
|
||||
|
||||
int count = lineBreak;
|
||||
|
||||
if (data.length() > lineBreak) {
|
||||
// Needs to be splitted
|
||||
// Needs to be split
|
||||
next = true;
|
||||
} else {
|
||||
// No need to be splitted
|
||||
}
|
||||
else {
|
||||
// No need to split
|
||||
return data;
|
||||
}
|
||||
|
||||
// first part
|
||||
// First part
|
||||
String tmp = data.substring(0, lineBreak);
|
||||
|
||||
while (next) {
|
||||
@ -99,21 +98,22 @@ public abstract class PrintData
|
||||
try {
|
||||
tmp = tmp + "\n" + data.substring(count, lineBreak + count);
|
||||
count = count + lineBreak;
|
||||
} catch (Exception e) {
|
||||
// data string not long enough
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Data string not long enough
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
// add the last part
|
||||
// Add the last part
|
||||
return tmp + "\n" + data.substring(count);
|
||||
}
|
||||
|
||||
/**
|
||||
* prints a line of '--------'
|
||||
* @return
|
||||
* Prints a line of dashes '--------'
|
||||
*
|
||||
* @return separator line
|
||||
*/
|
||||
protected String getSeparator()
|
||||
{
|
||||
protected String getSeparator() {
|
||||
String tmp = "-";
|
||||
|
||||
for (int i = 1; i < lineBreak; i++) {
|
||||
@ -123,12 +123,12 @@ public abstract class PrintData
|
||||
}
|
||||
|
||||
/**
|
||||
* sets a String into the center
|
||||
* Centers a string within the line width
|
||||
*
|
||||
* @param data
|
||||
* @return the centered String
|
||||
* @return the centered string
|
||||
*/
|
||||
protected String setCenter(String data)
|
||||
{
|
||||
protected String setCenter(String data) {
|
||||
int dataLenght = data.length();
|
||||
int prefix = ((lineBreak - dataLenght) / 2);
|
||||
String tmp = " ";
|
||||
@ -137,18 +137,18 @@ public abstract class PrintData
|
||||
tmp = tmp + " ";
|
||||
}
|
||||
tmp = tmp + data;
|
||||
|
||||
|
||||
return breakLines(tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets a String right-justified after an prefix
|
||||
* Right-justifies a string after a prefix
|
||||
*
|
||||
* @param prefix
|
||||
* @param data
|
||||
* @return the right-justified String
|
||||
* @return the right-justified string
|
||||
*/
|
||||
protected String setRight(String prefix, String data)
|
||||
{
|
||||
protected String setRight(String prefix, String data) {
|
||||
|
||||
int prefixLenght = prefix.length();
|
||||
|
||||
@ -173,7 +173,7 @@ public abstract class PrintData
|
||||
}
|
||||
|
||||
/**
|
||||
* How the print String or Strings are made
|
||||
* Defines how the print string(s) are generated
|
||||
*/
|
||||
abstract protected void generatePrintString();
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
package com.jFxKasse.datatypes;
|
||||
|
||||
public class PrintDataSimple extends PrintData
|
||||
{
|
||||
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 stored in the DB
|
||||
*
|
||||
* @param lineBreak
|
||||
* @param headerSpace
|
||||
* @param footerSpace
|
||||
@ -14,26 +14,23 @@ public class PrintDataSimple extends PrintData
|
||||
* @param header
|
||||
* @param footer
|
||||
*/
|
||||
public PrintDataSimple(int lineBreak, int headerSpace, int footerSpace,
|
||||
String timeAndDatePrint, String header, String footer)
|
||||
{
|
||||
super(lineBreak, headerSpace, footerSpace, timeAndDatePrint, header,
|
||||
footer);
|
||||
public PrintDataSimple(int lineBreak, int headerSpace, int footerSpace, String timeAndDatePrint, String header,
|
||||
String footer) {
|
||||
super(lineBreak, headerSpace, footerSpace, timeAndDatePrint, header, footer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the String
|
||||
* @return the final Print String
|
||||
* Generates the print string
|
||||
*
|
||||
* @return the final print string
|
||||
*/
|
||||
public String getPrintString()
|
||||
{
|
||||
public String getPrintString() {
|
||||
generatePrintString();
|
||||
return this.printString;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generatePrintString()
|
||||
{
|
||||
protected void generatePrintString() {
|
||||
/* Header */
|
||||
String header = " ";
|
||||
for (int i = 1; i < headerSpace; i++) {
|
||||
@ -45,16 +42,14 @@ public class PrintDataSimple extends PrintData
|
||||
|
||||
/* Info */
|
||||
|
||||
String info = setRight("Bestellung: ", timeAndDateOrder) + "\n"
|
||||
+ setRight("Druck: ", timeAndDatePrint) + "\n"
|
||||
String info = setRight("Bestellung: ", timeAndDateOrder) + "\n" + setRight("Druck: ", timeAndDatePrint) + "\n"
|
||||
+ setRight("Bestellnummer: ", jobID);
|
||||
|
||||
/* Positionen */
|
||||
|
||||
String positionen = "\n";
|
||||
|
||||
int posCount = positionsQuantity.length()
|
||||
- positionsQuantity.replace(";", "").length() + 1;
|
||||
int posCount = positionsQuantity.length() - positionsQuantity.replace(";", "").length() + 1;
|
||||
|
||||
String[] positionQuantity = positionsQuantity.split(";");
|
||||
|
||||
@ -65,8 +60,7 @@ public class PrintDataSimple extends PrintData
|
||||
for (int i = 0; i < posCount; i++) { // All different posNames
|
||||
int quantity = Integer.parseInt(positionQuantity[i]);
|
||||
for (int j = 0; j < quantity; j++) { // quantities
|
||||
positionen = positionen + setRight(breakLines(positionName[i]),
|
||||
positionValue[i] + " €") + "\n";
|
||||
positionen = positionen + setRight(breakLines(positionName[i]), positionValue[i] + " €") + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,9 +79,8 @@ public class PrintDataSimple extends PrintData
|
||||
|
||||
/* Build final Print String */
|
||||
|
||||
printString = header + "\n" + getSeparator() + "\n" + info + "\n"
|
||||
+ getSeparator() + "\n" + positionen + "\n" + getSeparator() + "\n"
|
||||
+ price + "\n" + getSeparator() + "\n" + footer;
|
||||
printString = header + "\n" + getSeparator() + "\n" + info + "\n" + getSeparator() + "\n" + positionen + "\n"
|
||||
+ getSeparator() + "\n" + price + "\n" + getSeparator() + "\n" + footer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,8 +2,7 @@ package com.jFxKasse.datatypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PrintDataSplitted extends PrintData
|
||||
{
|
||||
public class PrintDataSplitted extends PrintData {
|
||||
private ArrayList<String> printString = new ArrayList<String>();
|
||||
|
||||
private ArrayList<Category> categories = new ArrayList<Category>();
|
||||
@ -11,7 +10,8 @@ public class PrintDataSplitted extends PrintData
|
||||
private int categoryCount = 0;
|
||||
|
||||
/**
|
||||
* Constructor with all data that is not in the DB
|
||||
* Constructor with all data that is not stored in the DB
|
||||
*
|
||||
* @param lineBreak
|
||||
* @param headerSpace
|
||||
* @param footerSpace
|
||||
@ -19,26 +19,23 @@ public class PrintDataSplitted extends PrintData
|
||||
* @param header
|
||||
* @param footer
|
||||
*/
|
||||
public PrintDataSplitted(int lineBreak, int headerSpace, int footerSpace,
|
||||
String timeAndDatePrint, String header, String footer)
|
||||
{
|
||||
super(lineBreak, headerSpace, footerSpace, timeAndDatePrint, header,
|
||||
footer);
|
||||
public PrintDataSplitted(int lineBreak, int headerSpace, int footerSpace, String timeAndDatePrint, String header,
|
||||
String footer) {
|
||||
super(lineBreak, headerSpace, footerSpace, timeAndDatePrint, header, footer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the String
|
||||
* @return the final Array with the Print Strings
|
||||
* Generates the print strings
|
||||
*
|
||||
* @return the final array of print strings
|
||||
*/
|
||||
public ArrayList<String> getPrintStrings()
|
||||
{
|
||||
public ArrayList<String> getPrintStrings() {
|
||||
generatePrintString();
|
||||
return printString;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generatePrintString()
|
||||
{
|
||||
protected void generatePrintString() {
|
||||
|
||||
String firstBill;
|
||||
|
||||
@ -53,11 +50,10 @@ public class PrintDataSplitted extends PrintData
|
||||
|
||||
/* Info */
|
||||
|
||||
String info = setRight("Bestellung: ", timeAndDateOrder) + "\n"
|
||||
+ setRight("Druck: ", timeAndDatePrint) + "\n"
|
||||
String info = setRight("Bestellung: ", timeAndDateOrder) + "\n" + setRight("Druck: ", timeAndDatePrint) + "\n"
|
||||
+ setRight("Bestellnummer: ", jobID);
|
||||
|
||||
/* Splitted Bills */
|
||||
/* Splitted Bills by Category */
|
||||
|
||||
/* Price */
|
||||
|
||||
@ -74,21 +70,19 @@ public class PrintDataSplitted extends PrintData
|
||||
|
||||
/* Build first Print String */
|
||||
|
||||
firstBill = header + "\n" + getSeparator() + "\n" + info + "\n"
|
||||
+ getSeparator() + "\n" + setCenter("Bon wurde aufgeteilt") + "\n"
|
||||
+ getSeparator() + "\n" + price + "\n" + getSeparator() + "\n"
|
||||
+ footer;
|
||||
firstBill = header + "\n" + getSeparator() + "\n" + info + "\n" + getSeparator() + "\n"
|
||||
+ setCenter("Bon wurde aufgeteilt") + "\n" + getSeparator() + "\n" + price + "\n" + getSeparator()
|
||||
+ "\n" + footer;
|
||||
|
||||
printString.add(firstBill);
|
||||
|
||||
/* first bill ends here */
|
||||
/* First bill ends here */
|
||||
|
||||
/* Categories in extra bills */
|
||||
/* Category-specific extra bills */
|
||||
|
||||
String positions = null;
|
||||
|
||||
int posCount = positionsQuantity.length()
|
||||
- positionsQuantity.replace(";", "").length() + 1;
|
||||
int posCount = positionsQuantity.length() - positionsQuantity.replace(";", "").length() + 1;
|
||||
|
||||
String[] positionQuantity = positionsQuantity.split(";");
|
||||
String[] positionName = positionsName.split(";");
|
||||
@ -97,11 +91,10 @@ public class PrintDataSplitted extends PrintData
|
||||
|
||||
for (int i = 0; i < posCount; i++) { // All different posNames
|
||||
int quantity = Integer.parseInt(positionQuantity[i]);
|
||||
insertToCategory(quantity, positionName[i], positionValue[i],
|
||||
positionCategory[i]);
|
||||
insertToCategory(quantity, positionName[i], positionValue[i], positionCategory[i]);
|
||||
}
|
||||
|
||||
// loops through all categories
|
||||
// Loops through all categories
|
||||
for (int i = 0; i < categories.size(); i++) {
|
||||
|
||||
String thisBill;
|
||||
@ -117,8 +110,7 @@ public class PrintDataSplitted extends PrintData
|
||||
|
||||
/* Info */
|
||||
|
||||
info = setRight("Bestellung: ", timeAndDateOrder) + "\n"
|
||||
+ setRight("Druck: ", timeAndDatePrint) + "\n"
|
||||
info = setRight("Bestellung: ", timeAndDateOrder) + "\n" + setRight("Druck: ", timeAndDatePrint) + "\n"
|
||||
+ setRight("Bestellnummer: ", jobID);
|
||||
|
||||
/* Positions */
|
||||
@ -134,11 +126,9 @@ public class PrintDataSplitted extends PrintData
|
||||
}
|
||||
footer = footer + "_";
|
||||
|
||||
thisBill = header + "\n" + getSeparator() + "\n" + info + "\n"
|
||||
+ getSeparator() + "\n"
|
||||
+ setCenter(categories.get(i).getCategoryName()) + "\n"
|
||||
+ getSeparator() + positions + "\n" + getSeparator() + "\n"
|
||||
+ footer;
|
||||
thisBill = header + "\n" + getSeparator() + "\n" + info + "\n" + getSeparator() + "\n"
|
||||
+ setCenter(categories.get(i).getCategoryName()) + "\n" + getSeparator() + positions + "\n"
|
||||
+ getSeparator() + "\n" + footer;
|
||||
|
||||
printString.add(thisBill);
|
||||
|
||||
@ -146,9 +136,7 @@ public class PrintDataSplitted extends PrintData
|
||||
|
||||
}
|
||||
|
||||
private void insertToCategory(int quantity, String name, String value,
|
||||
String category)
|
||||
{
|
||||
private void insertToCategory(int quantity, String name, String value, String category) {
|
||||
boolean createNewCategorie = true;
|
||||
for (int i = 0; i < categoryCount; i++) {
|
||||
if (category.equals(categories.get(i).getCategoryName())) {
|
||||
@ -158,7 +146,7 @@ public class PrintDataSplitted extends PrintData
|
||||
}
|
||||
|
||||
if (createNewCategorie) {
|
||||
// position has a new category
|
||||
// Position has a new category
|
||||
categories.add(new Category(category));
|
||||
categories.get(categoryCount).addPosition(quantity, name, value, this);
|
||||
categoryCount++;
|
||||
|
||||
@ -5,46 +5,38 @@ import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
public class tableDataCurrentOrder
|
||||
{
|
||||
public class tableDataCurrentOrder {
|
||||
|
||||
private final StringProperty position = new SimpleStringProperty();
|
||||
|
||||
private final IntegerProperty quantity = new SimpleIntegerProperty();
|
||||
|
||||
public tableDataCurrentOrder(final String pPosition, final Integer pQuantity)
|
||||
{
|
||||
public tableDataCurrentOrder(final String pPosition, final Integer pQuantity) {
|
||||
this.position.set(pPosition);
|
||||
this.quantity.set(pQuantity);
|
||||
}
|
||||
|
||||
public StringProperty positionProperty()
|
||||
{
|
||||
public StringProperty positionProperty() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public IntegerProperty quantityProperty()
|
||||
{
|
||||
public IntegerProperty quantityProperty() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public String getPosition()
|
||||
{
|
||||
public String getPosition() {
|
||||
return positionProperty().get();
|
||||
}
|
||||
|
||||
public Integer getQuantity()
|
||||
{
|
||||
public Integer getQuantity() {
|
||||
return quantityProperty().get();
|
||||
}
|
||||
|
||||
public final void setPosition(String pPosition)
|
||||
{
|
||||
public final void setPosition(String pPosition) {
|
||||
positionProperty().set(pPosition);
|
||||
}
|
||||
|
||||
public final void setQuantity(int pQuantity)
|
||||
{
|
||||
public final void setQuantity(int pQuantity) {
|
||||
quantityProperty().set(pQuantity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,8 +5,7 @@ import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
public class tableDataJob
|
||||
{
|
||||
public class tableDataJob {
|
||||
|
||||
private final IntegerProperty number = new SimpleIntegerProperty();
|
||||
|
||||
@ -18,9 +17,8 @@ public class tableDataJob
|
||||
|
||||
private final StringProperty value = new SimpleStringProperty();
|
||||
|
||||
public tableDataJob(final Integer pNumber, final String pTime,
|
||||
final String pPositionen, final String pStatus, final String pValue)
|
||||
{
|
||||
public tableDataJob(final Integer pNumber, final String pTime, final String pPositionen, final String pStatus,
|
||||
final String pValue) {
|
||||
this.number.set(pNumber);
|
||||
this.time.set(pTime);
|
||||
this.positionen.set(pPositionen);
|
||||
@ -29,78 +27,63 @@ public class tableDataJob
|
||||
|
||||
}
|
||||
|
||||
public IntegerProperty numberProperty()
|
||||
{
|
||||
public IntegerProperty numberProperty() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public StringProperty timeProperty()
|
||||
{
|
||||
public StringProperty timeProperty() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public StringProperty positionProperty()
|
||||
{
|
||||
public StringProperty positionProperty() {
|
||||
return positionen;
|
||||
}
|
||||
|
||||
public StringProperty statusProperty()
|
||||
{
|
||||
public StringProperty statusProperty() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public StringProperty valueProperty()
|
||||
{
|
||||
public StringProperty valueProperty() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Integer getNumber()
|
||||
{
|
||||
public Integer getNumber() {
|
||||
return numberProperty().get();
|
||||
}
|
||||
|
||||
public String getTime()
|
||||
{
|
||||
public String getTime() {
|
||||
return timeProperty().get();
|
||||
}
|
||||
|
||||
public String getPosition()
|
||||
{
|
||||
public String getPosition() {
|
||||
return positionProperty().get();
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
public String getStatus() {
|
||||
return statusProperty().get();
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
public String getValue() {
|
||||
return valueProperty().get();
|
||||
}
|
||||
|
||||
public final void setNumber(int pNumber)
|
||||
{
|
||||
public final void setNumber(int pNumber) {
|
||||
numberProperty().set(pNumber);
|
||||
}
|
||||
|
||||
public final void setTime(String pTime)
|
||||
{
|
||||
public final void setTime(String pTime) {
|
||||
timeProperty().set(pTime);
|
||||
}
|
||||
|
||||
public final void setPosition(String pPosition)
|
||||
{
|
||||
public final void setPosition(String pPosition) {
|
||||
positionProperty().set(pPosition);
|
||||
}
|
||||
|
||||
public final void setStatus(String pStatus)
|
||||
{
|
||||
public final void setStatus(String pStatus) {
|
||||
statusProperty().set(pStatus);
|
||||
}
|
||||
|
||||
public final void setValue(String pValue)
|
||||
{
|
||||
public final void setValue(String pValue) {
|
||||
valueProperty().set(pValue);
|
||||
}
|
||||
|
||||
|
||||
@ -5,21 +5,20 @@ import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
public class tableDataPositionen
|
||||
{ // data-object with id, name, value, color
|
||||
public class tableDataPositionen { // Data object with id, name, value, color
|
||||
|
||||
private final IntegerProperty id = new SimpleIntegerProperty();
|
||||
|
||||
private final StringProperty name = new SimpleStringProperty();
|
||||
|
||||
private final StringProperty value = new SimpleStringProperty();
|
||||
|
||||
|
||||
private final StringProperty cat = new SimpleStringProperty();
|
||||
|
||||
|
||||
private final StringProperty color = new SimpleStringProperty();
|
||||
|
||||
public tableDataPositionen(final int id, final String name, final String value, final String cat, final String color)
|
||||
{
|
||||
public tableDataPositionen(final int id, final String name, final String value, final String cat,
|
||||
final String color) {
|
||||
this.id.set(id);
|
||||
this.name.set(name);
|
||||
this.value.set(value);
|
||||
@ -27,75 +26,63 @@ public class tableDataPositionen
|
||||
this.color.set(color);
|
||||
}
|
||||
|
||||
public IntegerProperty idProperty()
|
||||
{
|
||||
public IntegerProperty idProperty() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public StringProperty nameProperty()
|
||||
{
|
||||
public StringProperty nameProperty() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public StringProperty valueProperty()
|
||||
{
|
||||
public StringProperty valueProperty() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public StringProperty catProperty() {
|
||||
return cat;
|
||||
}
|
||||
|
||||
public StringProperty colorProperty()
|
||||
{
|
||||
|
||||
public StringProperty colorProperty() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public int getID()
|
||||
{
|
||||
public int getID() {
|
||||
return idProperty().get();
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return nameProperty().get();
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
public String getValue() {
|
||||
return valueProperty().get();
|
||||
}
|
||||
|
||||
|
||||
public String getCat() {
|
||||
return catProperty().get();
|
||||
}
|
||||
|
||||
public String getColor()
|
||||
{
|
||||
|
||||
public String getColor() {
|
||||
return colorProperty().get();
|
||||
}
|
||||
|
||||
public final void setID(int id)
|
||||
{
|
||||
public final void setID(int id) {
|
||||
idProperty().set(id);
|
||||
}
|
||||
|
||||
public final void setName(String name)
|
||||
{
|
||||
public final void setName(String name) {
|
||||
nameProperty().set(name);
|
||||
}
|
||||
|
||||
public final void setValue(String value)
|
||||
{
|
||||
public final void setValue(String value) {
|
||||
valueProperty().set(value);
|
||||
}
|
||||
|
||||
|
||||
public final void setCat(String cat) {
|
||||
catProperty().set(cat);
|
||||
}
|
||||
|
||||
public final void setColor(String color)
|
||||
{
|
||||
|
||||
public final void setColor(String color) {
|
||||
colorProperty().set(color);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1 +1 @@
|
||||
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
|
||||
/* JavaFX CSS - Leave this comment until you have at least one rule which uses -fx-Property */
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user