diff --git a/PR2 KI Projekt/fakturama_data.xml b/PR2 KI Projekt/fakturama_data.xml
new file mode 100644
index 0000000..01d8d63
--- /dev/null
+++ b/PR2 KI Projekt/fakturama_data.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/PR2 KI Projekt/src/Main.java b/PR2 KI Projekt/src/Main.java
index ef47cdc..9b21331 100644
--- a/PR2 KI Projekt/src/Main.java
+++ b/PR2 KI Projekt/src/Main.java
@@ -838,6 +838,43 @@ public class Main {
return defaultValue;
}
}
+
+ public static void deleteCustomer(int index) {
+ if (index >= 0 && index < customers.size()) {
+ customers.remove(index);
+ }
+ }
+
+ public static void deleteArticle(int index) {
+ if (index >= 0 && index < articles.size()) {
+ articles.remove(index);
+ }
+ }
+
+ public static void deleteOffer(int index) {
+ if (index >= 0 && index < offers.size()) {
+ offers.remove(index);
+ }
+ }
+
+ public static void deleteOrderConfirmation(int index) {
+ if (index >= 0 && index < orderConfirmations.size()) {
+ orderConfirmations.remove(index);
+ }
+ }
+
+ public static void deleteDeliveryNote(int index) {
+ if (index >= 0 && index < deliveryNotes.size()) {
+ deliveryNotes.remove(index);
+ }
+ }
+
+ public static void deleteInvoice(int index) {
+ if (index >= 0 && index < invoices.size()) {
+ invoices.remove(index);
+ }
+ }
+
}
diff --git a/PR2 KI Projekt/src/MainGUI.java b/PR2 KI Projekt/src/MainGUI.java
index f3ef673..6f0ba77 100644
--- a/PR2 KI Projekt/src/MainGUI.java
+++ b/PR2 KI Projekt/src/MainGUI.java
@@ -33,26 +33,50 @@ public class MainGUI {
JMenuItem addCustomerItem = new JMenuItem("Kunde hinzufügen");
menu.add(addCustomerItem);
addCustomerItem.addActionListener(e -> showAddCustomerPanel());
+
+ JMenuItem deleteCustomerItem = new JMenuItem("Kunde löschen");
+ menu.add(deleteCustomerItem);
+ deleteCustomerItem.addActionListener(e -> showDeleteCustomerPanel());
JMenuItem addArticleItem = new JMenuItem("Artikel hinzufügen");
menu.add(addArticleItem);
addArticleItem.addActionListener(e -> showAddArticlePanel());
+
+ JMenuItem deleteArticleItem = new JMenuItem("Artikel löschen");
+ menu.add(deleteArticleItem);
+ deleteArticleItem.addActionListener(e -> showDeleteArticlePanel());
JMenuItem createOfferItem = new JMenuItem("Angebot erstellen");
menu.add(createOfferItem);
createOfferItem.addActionListener(e -> showCreateOfferPanel());
+
+ JMenuItem deleteOfferItem = new JMenuItem("Angebot löschen");
+ menu.add(deleteOfferItem);
+ deleteOfferItem.addActionListener(e -> showDeleteOfferPanel());
JMenuItem createOrderConfirmationItem = new JMenuItem("Auftragsbestätigung erstellen");
menu.add(createOrderConfirmationItem);
createOrderConfirmationItem.addActionListener(e -> showCreateOrderConfirmationPanel());
+
+ JMenuItem deleteOrderConfirmationItem = new JMenuItem("Auftragsbestätigung löschen");
+ menu.add(deleteOrderConfirmationItem);
+ deleteOrderConfirmationItem.addActionListener(e -> showDeleteOrderConfirmationPanel());
JMenuItem createDeliveryNoteItem = new JMenuItem("Lieferschein erstellen");
menu.add(createDeliveryNoteItem);
createDeliveryNoteItem.addActionListener(e -> showCreateDeliveryNotePanel());
+
+ JMenuItem deleteDeliveryNoteItem = new JMenuItem("Lieferschein löschen");
+ menu.add(deleteDeliveryNoteItem);
+ deleteDeliveryNoteItem.addActionListener(e -> showDeleteDeliveryNotePanel());
JMenuItem createInvoiceItem = new JMenuItem("Rechnung erstellen");
menu.add(createInvoiceItem);
createInvoiceItem.addActionListener(e -> showCreateInvoicePanel());
+
+ JMenuItem deleteInvoiceItem = new JMenuItem("Rechnung löschen");
+ menu.add(deleteInvoiceItem);
+ deleteInvoiceItem.addActionListener(e -> showDeleteInvoicePanel());
JMenuItem saveDataItem = new JMenuItem("Daten speichern");
menu.add(saveDataItem);
@@ -346,34 +370,219 @@ public class MainGUI {
private void updateTextArea() {
StringBuilder sb = new StringBuilder();
sb.append("Kunden:\n");
- for (Main.Customer customer : Main.customers) {
- sb.append(customer.name).append(" - ").append(customer.address).append(" - ").append(customer.contactPerson).append(" - ").append(customer.taxExempt ? "§ 4 UStG" : "").append(" - ").append(customer.smallBusiness ? "Kleinunternehmer" : "").append("\n");
+ for (int i = 0; i < Main.customers.size(); i++) {
+ Main.Customer customer = Main.customers.get(i);
+ sb.append(i + 1).append(". ").append(customer.name).append(" - ").append(customer.address).append(" - ").append(customer.contactPerson).append(" - ").append(customer.taxExempt ? "§ 4 UStG" : "").append(" - ").append(customer.smallBusiness ? "Kleinunternehmer" : "").append("\n");
}
sb.append("\nArtikel:\n");
- for (Main.Article article : Main.articles) {
- sb.append(article.description).append(" - ").append(article.unit).append(" - ").append(article.netPrice).append(" € - ").append(article.vatRate).append(" %").append("\n");
+ for (int i = 0; i < Main.articles.size(); i++) {
+ Main.Article article = Main.articles.get(i);
+ sb.append(i + 1).append(". ").append(article.description).append(" - ").append(article.unit).append(" - ").append(article.netPrice).append(" € - ").append(article.vatRate).append(" %").append("\n");
}
sb.append("\nAngebote:\n");
- for (Main.Offer offer : Main.offers) {
- sb.append("Angebot #").append(offer.id).append(" - ").append(offer.customer.name).append(" - ").append(offer.date).append(" - ").append(offer.status).append("\n");
+ for (int i = 0; i < Main.offers.size(); i++) {
+ Main.Offer offer = Main.offers.get(i);
+ sb.append(i + 1).append(". Angebot #").append(offer.id).append(" - ").append(offer.customer.name).append(" - ").append(offer.date).append(" - ").append(offer.status).append("\n");
for (Main.Article article : offer.articles) {
sb.append(" ").append(article.description).append(" - ").append(article.unit).append(" - ").append(article.netPrice).append(" € - ").append(article.vatRate).append(" %").append("\n");
}
}
sb.append("\nAuftragsbestätigungen:\n");
- for (Main.OrderConfirmation orderConfirmation : Main.orderConfirmations) {
- sb.append("Auftragsbestätigung #").append(orderConfirmation.id).append(" - ").append(orderConfirmation.offer.customer.name).append(" - ").append(orderConfirmation.date).append(" - ").append(orderConfirmation.status).append("\n");
+ for (int i = 0; i < Main.orderConfirmations.size(); i++) {
+ Main.OrderConfirmation orderConfirmation = Main.orderConfirmations.get(i);
+ sb.append(i + 1).append(". Auftragsbestätigung #").append(orderConfirmation.id).append(" - ").append(orderConfirmation.offer.customer.name).append(" - ").append(orderConfirmation.date).append(" - ").append(orderConfirmation.status).append("\n");
}
sb.append("\nLieferscheine:\n");
- for (Main.DeliveryNote deliveryNote : Main.deliveryNotes) {
- sb.append("Lieferschein #").append(deliveryNote.id).append(" - ").append(deliveryNote.orderConfirmation.offer.customer.name).append(" - ").append(deliveryNote.date).append(" - ").append(deliveryNote.status).append("\n");
+ for (int i = 0; i < Main.deliveryNotes.size(); i++) {
+ Main.DeliveryNote deliveryNote = Main.deliveryNotes.get(i);
+ sb.append(i + 1).append(". Lieferschein #").append(deliveryNote.id).append(" - ").append(deliveryNote.orderConfirmation.offer.customer.name).append(" - ").append(deliveryNote.date).append(" - ").append(deliveryNote.status).append("\n");
}
sb.append("\nRechnungen:\n");
- for (Main.Invoice invoice : Main.invoices) {
- sb.append("Rechnung #").append(invoice.id).append(" - ").append(invoice.deliveryNote.orderConfirmation.offer.customer.name).append(" - ").append(invoice.date).append(" - ").append(invoice.status).append("\n");
+ for (int i = 0; i < Main.invoices.size(); i++) {
+ Main.Invoice invoice = Main.invoices.get(i);
+ sb.append(i + 1).append(". Rechnung #").append(invoice.id).append(" - ").append(invoice.deliveryNote.orderConfirmation.offer.customer.name).append(" - ").append(invoice.date).append(" - ").append(invoice.status).append("\n");
}
textArea.setText(sb.toString());
}
+
+ private void showDeleteCustomerPanel() {
+ JPanel panel = new JPanel(new GridLayout(3, 2));
+ JLabel customerLabel = new JLabel("Kunde:");
+ JComboBox customerBox = new JComboBox<>();
+ for (Main.Customer customer : Main.customers) {
+ customerBox.addItem(customer.name);
+ }
+
+ JButton deleteButton = new JButton("Löschen");
+ deleteButton.setBackground(new Color(255, 99, 71)); // Tomatenrot
+ deleteButton.addActionListener(e -> {
+ String customerName = (String) customerBox.getSelectedItem();
+ Main.customers.removeIf(c -> c.name.equals(customerName));
+ updateTextArea();
+ cardLayout.show(mainPanel, "Home");
+ });
+
+ JButton backButton = new JButton("Zurück");
+ backButton.addActionListener(e -> cardLayout.show(mainPanel, "Home"));
+
+ panel.add(customerLabel);
+ panel.add(customerBox);
+ panel.add(backButton);
+ panel.add(deleteButton);
+
+ mainPanel.add(panel, "DeleteCustomer");
+ cardLayout.show(mainPanel, "DeleteCustomer");
+ }
+
+ private void showDeleteArticlePanel() {
+ JPanel panel = new JPanel(new GridLayout(3, 2));
+ JLabel articleLabel = new JLabel("Artikel:");
+ JComboBox articleBox = new JComboBox<>();
+ for (Main.Article article : Main.articles) {
+ articleBox.addItem(article.description);
+ }
+
+ JButton deleteButton = new JButton("Löschen");
+ deleteButton.setBackground(new Color(255, 99, 71)); // Tomatenrot
+ deleteButton.addActionListener(e -> {
+ String articleDescription = (String) articleBox.getSelectedItem();
+ Main.articles.removeIf(a -> a.description.equals(articleDescription));
+ updateTextArea();
+ cardLayout.show(mainPanel, "Home");
+ });
+
+ JButton backButton = new JButton("Zurück");
+ backButton.addActionListener(e -> cardLayout.show(mainPanel, "Home"));
+
+ panel.add(articleLabel);
+ panel.add(articleBox);
+ panel.add(backButton);
+ panel.add(deleteButton);
+
+ mainPanel.add(panel, "DeleteArticle");
+ cardLayout.show(mainPanel, "DeleteArticle");
+ }
+
+ private void showDeleteOfferPanel() {
+ JPanel panel = new JPanel(new GridLayout(3, 2));
+ JLabel offerLabel = new JLabel("Angebot:");
+ JComboBox offerBox = new JComboBox<>();
+ for (Main.Offer offer : Main.offers) {
+ offerBox.addItem("Angebot #" + offer.id + " - Kunde: " + offer.customer.name);
+ }
+
+ JButton deleteButton = new JButton("Löschen");
+ deleteButton.setBackground(new Color(255, 99, 71)); // Tomatenrot
+ deleteButton.addActionListener(e -> {
+ String offerInfo = (String) offerBox.getSelectedItem();
+ int offerId = Integer.parseInt(offerInfo.split(" ")[1].substring(1));
+ Main.offers.removeIf(o -> o.id == offerId);
+ updateTextArea();
+ cardLayout.show(mainPanel, "Home");
+ });
+
+ JButton backButton = new JButton("Zurück");
+ backButton.addActionListener(e -> cardLayout.show(mainPanel, "Home"));
+
+ panel.add(offerLabel);
+ panel.add(offerBox);
+ panel.add(backButton);
+ panel.add(deleteButton);
+
+ mainPanel.add(panel, "DeleteOffer");
+ cardLayout.show(mainPanel, "DeleteOffer");
+ }
+
+ private void showDeleteOrderConfirmationPanel() {
+ JPanel panel = new JPanel(new GridLayout(3, 2));
+ JLabel orderConfirmationLabel = new JLabel("Auftragsbestätigung:");
+ JComboBox orderConfirmationBox = new JComboBox<>();
+ for (Main.OrderConfirmation orderConfirmation : Main.orderConfirmations) {
+ orderConfirmationBox.addItem("Auftragsbestätigung #" + orderConfirmation.id + " - Kunde: " + orderConfirmation.offer.customer.name);
+ }
+
+ JButton deleteButton = new JButton("Löschen");
+ deleteButton.setBackground(new Color(255, 99, 71)); // Tomatenrot
+ deleteButton.addActionListener(e -> {
+ String orderConfirmationInfo = (String) orderConfirmationBox.getSelectedItem();
+ int orderConfirmationId = Integer.parseInt(orderConfirmationInfo.split(" ")[1].substring(1));
+ Main.orderConfirmations.removeIf(oc -> oc.id == orderConfirmationId);
+ updateTextArea();
+ cardLayout.show(mainPanel, "Home");
+ });
+
+ JButton backButton = new JButton("Zurück");
+ backButton.addActionListener(e -> cardLayout.show(mainPanel, "Home"));
+
+ panel.add(orderConfirmationLabel);
+ panel.add(orderConfirmationBox);
+ panel.add(backButton);
+ panel.add(deleteButton);
+
+ mainPanel.add(panel, "DeleteOrderConfirmation");
+ cardLayout.show(mainPanel, "DeleteOrderConfirmation");
+ }
+
+ private void showDeleteDeliveryNotePanel() {
+ JPanel panel = new JPanel(new GridLayout(3, 2));
+ JLabel deliveryNoteLabel = new JLabel("Lieferschein:");
+ JComboBox deliveryNoteBox = new JComboBox<>();
+ for (Main.DeliveryNote deliveryNote : Main.deliveryNotes) {
+ deliveryNoteBox.addItem("Lieferschein #" + deliveryNote.id + " - Kunde: " + deliveryNote.orderConfirmation.offer.customer.name);
+ }
+
+ JButton deleteButton = new JButton("Löschen");
+ deleteButton.setBackground(new Color(255, 99, 71)); // Tomatenrot
+ deleteButton.addActionListener(e -> {
+ String deliveryNoteInfo = (String) deliveryNoteBox.getSelectedItem();
+ int deliveryNoteId = Integer.parseInt(deliveryNoteInfo.split(" ")[1].substring(1));
+ Main.deliveryNotes.removeIf(dn -> dn.id == deliveryNoteId);
+ updateTextArea();
+ cardLayout.show(mainPanel, "Home");
+ });
+
+ JButton backButton = new JButton("Zurück");
+ backButton.addActionListener(e -> cardLayout.show(mainPanel, "Home"));
+
+ panel.add(deliveryNoteLabel);
+ panel.add(deliveryNoteBox);
+ panel.add(backButton);
+ panel.add(deleteButton);
+
+ mainPanel.add(panel, "DeleteDeliveryNote");
+ cardLayout.show(mainPanel, "DeleteDeliveryNote");
+ }
+
+ private void showDeleteInvoicePanel() {
+ JPanel panel = new JPanel(new GridLayout(3, 2));
+ JLabel invoiceLabel = new JLabel("Rechnung:");
+ JComboBox invoiceBox = new JComboBox<>();
+ for (Main.Invoice invoice : Main.invoices) {
+ invoiceBox.addItem("Rechnung #" + invoice.id + " - Kunde: " + invoice.deliveryNote.orderConfirmation.offer.customer.name);
+ }
+
+ JButton deleteButton = new JButton("Löschen");
+ deleteButton.setBackground(new Color(255, 99, 71)); // Tomatenrot
+ deleteButton.addActionListener(e -> {
+ String invoiceInfo = (String) invoiceBox.getSelectedItem();
+ int invoiceId = Integer.parseInt(invoiceInfo.split(" ")[1].substring(1));
+ Main.invoices.removeIf(i -> i.id == invoiceId);
+ updateTextArea();
+ cardLayout.show(mainPanel, "Home");
+ });
+
+ JButton backButton = new JButton("Zurück");
+ backButton.addActionListener(e -> cardLayout.show(mainPanel, "Home"));
+
+ panel.add(invoiceLabel);
+ panel.add(invoiceBox);
+ panel.add(backButton);
+ panel.add(deleteButton);
+
+ mainPanel.add(panel, "DeleteInvoice");
+ cardLayout.show(mainPanel, "DeleteInvoice");
+ }
+
public static void main(String[] args) {
EventQueue.invokeLater(() -> {