order.txt testdatei + Data changeorder() geändert
This commit is contained in:
parent
4ccb2c80f2
commit
d222db8816
@ -0,0 +1,5 @@
|
|||||||
|
2002-02-12;1234567;Vegan;DessertV
|
||||||
|
2002-02-12;12345678;Vegan;DessertV
|
||||||
|
2002-02-12;123464353;Vegan;DessertV
|
||||||
|
2002-02-12;724373;Vegan;DessertV
|
||||||
|
2002-02-12;73473;Vegan;DessertV
|
@ -16,6 +16,7 @@ import java.util.List;
|
|||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data is a class to edit files.
|
* Data is a class to edit files.
|
||||||
@ -354,19 +355,16 @@ public class Data {
|
|||||||
|
|
||||||
public ArrayList<com.example.vpr_javafx.Order> changeOrder(String userLogin) {
|
public ArrayList<com.example.vpr_javafx.Order> changeOrder(String userLogin) {
|
||||||
|
|
||||||
/*
|
|
||||||
File orderFile = new File("C:/Unterricht/VPR/orders.txt");
|
|
||||||
if (orderFile.delete()) {
|
|
||||||
System.out.println("Datei gelöscht: " + orderFile.getName());
|
|
||||||
} else {
|
|
||||||
System.out.println("Fehler, " + orderFile.getName() + " nicht gelöscht.");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
ArrayList<com.example.vpr_javafx.Order> changedOrderList = new ArrayList<>();
|
ArrayList<com.example.vpr_javafx.Order> changedOrderList = new ArrayList<>();
|
||||||
List<String> rows = getRows();
|
List<String> rows = getRows();
|
||||||
int changedEntries = 0;
|
int changedEntries = 0;
|
||||||
|
|
||||||
|
//ImageIcon icon = new ImageIcon("file:target/classes/com/example/vpr_javafx/pics/vegetarisch.png");
|
||||||
|
UIManager.put("OptionPane.noButtonText", "Nein");
|
||||||
|
UIManager.put("OptionPane.yesButtonText", "Ja");
|
||||||
|
int result = JOptionPane.showInternalConfirmDialog(null, "Bestellungen wirklich Löschen?", "Bestätigung", JOptionPane.YES_NO_OPTION);
|
||||||
|
|
||||||
|
if (result == JOptionPane.YES_OPTION) {
|
||||||
for (String row : rows) {
|
for (String row : rows) {
|
||||||
String[] parts = row.split(";");
|
String[] parts = row.split(";");
|
||||||
|
|
||||||
@ -380,17 +378,23 @@ public class Data {
|
|||||||
changedEntries++;
|
changedEntries++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileWriter writer = new FileWriter("orders2.txt");
|
FileWriter writer = new FileWriter("orders2.txt");
|
||||||
for(com.example.vpr_javafx.Order str: changedOrderList) {
|
for(com.example.vpr_javafx.Order str: changedOrderList) {
|
||||||
writer.write(str + System.lineSeparator());
|
writer.write(str + System.lineSeparator());
|
||||||
}
|
}
|
||||||
writer.close();
|
writer.close();
|
||||||
System.out.println("Daten gelöscht");
|
|
||||||
System.out.println(changedEntries + " Einträge entfernt.");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
JOptionPane.showMessageDialog(null, changedEntries + " Bestellungen Gelöscht, Sie können eine neue Bestellung aufgeben");
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(null, "Bestellung nicht gelöscht.");
|
||||||
}
|
}
|
||||||
return changedOrderList;
|
return changedOrderList;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
module com.example.vpr_javafx {
|
module com.example.vpr_javafx {
|
||||||
requires javafx.controls;
|
requires javafx.controls;
|
||||||
requires javafx.fxml;
|
requires javafx.fxml;
|
||||||
|
requires java.desktop;
|
||||||
|
|
||||||
|
|
||||||
opens com.example.vpr_javafx to javafx.fxml;
|
opens com.example.vpr_javafx to javafx.fxml;
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user