From d11cdf6f4c43d4bdf3f45711f45f06a1a69b2eea Mon Sep 17 00:00:00 2001 From: athar Date: Sun, 30 Jun 2024 20:26:08 +0200 Subject: [PATCH] Programm erstellt und bis zu 6.6 vorgearbeiet --- PR2 KI Projekt/.classpath | 1 + PR2 KI Projekt/customers.txt | 0 PR2 KI Projekt/employees.txt | 1 - PR2 KI Projekt/orders.txt | 0 PR2 KI Projekt/products.txt | 0 PR2 KI Projekt/src/Customer.java | 40 - PR2 KI Projekt/src/CustomerCellRenderer.java | 18 - PR2 KI Projekt/src/EmploycallRenderer.java | 21 - PR2 KI Projekt/src/Employee.java | 81 - PR2 KI Projekt/src/FakturamaGUI.java | 350 +++ PR2 KI Projekt/src/Main.java | 814 ++++++ PR2 KI Projekt/src/MainTest.java | 127 + PR2 KI Projekt/src/Order.java | 46 - PR2 KI Projekt/src/OrderCellRenderer.java | 15 - PR2 KI Projekt/src/Product.java | 82 - PR2 KI Projekt/src/ProductCellRenderer.java | 19 - PR2 KI Projekt/src/Supplier.java | 52 - PR2 KI Projekt/src/SupplierCellRenderer.java | 18 - PR2 KI Projekt/src/Termination.java | 25 - PR2 KI Projekt/src/Transfer.java | 31 - PR2 KI Projekt/src/User.java | 29 - PR2 KI Projekt/src/Vacation.java | 25 - .../src/Warenwirtschaftssystem.java | 2331 ----------------- PR2 KI Projekt/src/pom.xml | 69 + PR2 KI Projekt/suppliers.txt | 0 PR2 KI Projekt/users.txt | 6 - 26 files changed, 1361 insertions(+), 2840 deletions(-) delete mode 100644 PR2 KI Projekt/customers.txt delete mode 100644 PR2 KI Projekt/employees.txt delete mode 100644 PR2 KI Projekt/orders.txt delete mode 100644 PR2 KI Projekt/products.txt delete mode 100644 PR2 KI Projekt/src/Customer.java delete mode 100644 PR2 KI Projekt/src/CustomerCellRenderer.java delete mode 100644 PR2 KI Projekt/src/EmploycallRenderer.java delete mode 100644 PR2 KI Projekt/src/Employee.java create mode 100644 PR2 KI Projekt/src/FakturamaGUI.java create mode 100644 PR2 KI Projekt/src/Main.java create mode 100644 PR2 KI Projekt/src/MainTest.java delete mode 100644 PR2 KI Projekt/src/Order.java delete mode 100644 PR2 KI Projekt/src/OrderCellRenderer.java delete mode 100644 PR2 KI Projekt/src/Product.java delete mode 100644 PR2 KI Projekt/src/ProductCellRenderer.java delete mode 100644 PR2 KI Projekt/src/Supplier.java delete mode 100644 PR2 KI Projekt/src/SupplierCellRenderer.java delete mode 100644 PR2 KI Projekt/src/Termination.java delete mode 100644 PR2 KI Projekt/src/Transfer.java delete mode 100644 PR2 KI Projekt/src/User.java delete mode 100644 PR2 KI Projekt/src/Vacation.java delete mode 100644 PR2 KI Projekt/src/Warenwirtschaftssystem.java create mode 100644 PR2 KI Projekt/src/pom.xml delete mode 100644 PR2 KI Projekt/suppliers.txt delete mode 100644 PR2 KI Projekt/users.txt diff --git a/PR2 KI Projekt/.classpath b/PR2 KI Projekt/.classpath index c8b8bcc..4a4692a 100644 --- a/PR2 KI Projekt/.classpath +++ b/PR2 KI Projekt/.classpath @@ -6,5 +6,6 @@ + diff --git a/PR2 KI Projekt/customers.txt b/PR2 KI Projekt/customers.txt deleted file mode 100644 index e69de29..0000000 diff --git a/PR2 KI Projekt/employees.txt b/PR2 KI Projekt/employees.txt deleted file mode 100644 index 449f65a..0000000 --- a/PR2 KI Projekt/employees.txt +++ /dev/null @@ -1 +0,0 @@ -1,Athar,Manager,A,2500.0 diff --git a/PR2 KI Projekt/orders.txt b/PR2 KI Projekt/orders.txt deleted file mode 100644 index e69de29..0000000 diff --git a/PR2 KI Projekt/products.txt b/PR2 KI Projekt/products.txt deleted file mode 100644 index e69de29..0000000 diff --git a/PR2 KI Projekt/src/Customer.java b/PR2 KI Projekt/src/Customer.java deleted file mode 100644 index c4026fd..0000000 --- a/PR2 KI Projekt/src/Customer.java +++ /dev/null @@ -1,40 +0,0 @@ -class Customer { - private int id; - private String name; - private String address; - private String contact; - private String segment; - - public Customer(int id, String name, String address, String contact, String segment) { - this.id = id; - this.name = name; - this.address = address; - this.contact = contact; - this.segment = segment; - } - - public int getId() { - return id; - } - - public String getName() { - return name; - } - - public String getAddress() { - return address; - } - - public String getContact() { - return contact; - } - - public String getSegment() { - return segment; - } - - @Override - public String toString() { - return name; - } -} \ No newline at end of file diff --git a/PR2 KI Projekt/src/CustomerCellRenderer.java b/PR2 KI Projekt/src/CustomerCellRenderer.java deleted file mode 100644 index ccebc99..0000000 --- a/PR2 KI Projekt/src/CustomerCellRenderer.java +++ /dev/null @@ -1,18 +0,0 @@ -import java.awt.BorderLayout; -import java.awt.Component; - - -import javax.swing.*; - -class CustomerCellRenderer extends DefaultListCellRenderer { - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (component instanceof JLabel && value instanceof Customer) { - JLabel label = (JLabel) component; - Customer customer = (Customer) value; - label.setText(customer.getName()); - } - return component; - } -} diff --git a/PR2 KI Projekt/src/EmploycallRenderer.java b/PR2 KI Projekt/src/EmploycallRenderer.java deleted file mode 100644 index 73ca4be..0000000 --- a/PR2 KI Projekt/src/EmploycallRenderer.java +++ /dev/null @@ -1,21 +0,0 @@ -import java.awt.*; - -import javax.swing.*; - - class EmployeeCellRenderer extends JLabel implements ListCellRenderer { - @Override - public Component getListCellRendererComponent(JList list, Employee value, int index, boolean isSelected, boolean cellHasFocus) { - setText(value.getName() + " - " + value.getPosition()); - if (isSelected) { - setBackground(list.getSelectionBackground()); - setForeground(list.getSelectionForeground()); - } else { - setBackground(list.getBackground()); - setForeground(list.getForeground()); - } - setEnabled(list.isEnabled()); - setFont(list.getFont()); - setOpaque(true); - return this; - } -} \ No newline at end of file diff --git a/PR2 KI Projekt/src/Employee.java b/PR2 KI Projekt/src/Employee.java deleted file mode 100644 index 78cd7df..0000000 --- a/PR2 KI Projekt/src/Employee.java +++ /dev/null @@ -1,81 +0,0 @@ -import java.util.List; -import java.util.ArrayList; - - -class Employee { - private int id; - private String name; - private String position; - private String department; - private double salary; - private String employmentStatus; - private List vacations; - private List transfers; - private List terminations; - - public Employee(int id, String name, String position, String department, double salary) { - this.id = id; - this.name = name; - this.position = position; - this.department = department; - this.salary = salary; - this.employmentStatus = "Active"; - this.vacations = new ArrayList<>(); - this.transfers = new ArrayList<>(); - this.terminations = new ArrayList<>(); - } - - // Getter und Setter - - public int getId() { - return id; - } - - public String getName() { - return name; - } - - public String getPosition() { - return position; - } - - public String getDepartment() { - return department; - } - - public double getSalary() { - return salary; - } - - public String getEmploymentStatus() { - return employmentStatus; - } - - public void setEmploymentStatus(String employmentStatus) { - this.employmentStatus = employmentStatus; - } - - public List getVacations() { - return vacations; - } - - public List getTransfers() { - return transfers; - } - - public List getTerminations() { - return terminations; - } - - public void addVacation(Vacation vacation) { - vacations.add(vacation); - } - - public void addTransfer(Transfer transfer) { - transfers.add(transfer); - } - - public void addTermination(Termination termination) { - terminations.add(termination); - } -} diff --git a/PR2 KI Projekt/src/FakturamaGUI.java b/PR2 KI Projekt/src/FakturamaGUI.java new file mode 100644 index 0000000..89cc3c6 --- /dev/null +++ b/PR2 KI Projekt/src/FakturamaGUI.java @@ -0,0 +1,350 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.util.ArrayList; +import java.util.List; + +public class FakturamaGUI { + private JFrame frame; + private JTextArea textArea; + + public FakturamaGUI() { + initialize(); + } + + private void initialize() { + frame = new JFrame("Fakturama"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(800, 600); + frame.setLayout(new BorderLayout()); + + // Menüleiste + JMenuBar menuBar = new JMenuBar(); + frame.setJMenuBar(menuBar); + + JMenu menu = new JMenu("Optionen"); + menuBar.add(menu); + + JMenuItem addCustomerItem = new JMenuItem("Kunde hinzufügen"); + menu.add(addCustomerItem); + addCustomerItem.addActionListener(e -> showAddCustomerPanel()); + + JMenuItem addArticleItem = new JMenuItem("Artikel hinzufügen"); + menu.add(addArticleItem); + addArticleItem.addActionListener(e -> showAddArticlePanel()); + + JMenuItem createOfferItem = new JMenuItem("Angebot erstellen"); + menu.add(createOfferItem); + createOfferItem.addActionListener(e -> showCreateOfferPanel()); + + JMenuItem createOrderConfirmationItem = new JMenuItem("Auftragsbestätigung erstellen"); + menu.add(createOrderConfirmationItem); + createOrderConfirmationItem.addActionListener(e -> showCreateOrderConfirmationPanel()); + + JMenuItem createDeliveryNoteItem = new JMenuItem("Lieferschein erstellen"); + menu.add(createDeliveryNoteItem); + createDeliveryNoteItem.addActionListener(e -> showCreateDeliveryNotePanel()); + + JMenuItem createInvoiceItem = new JMenuItem("Rechnung erstellen"); + menu.add(createInvoiceItem); + createInvoiceItem.addActionListener(e -> showCreateInvoicePanel()); + + JMenuItem saveDataItem = new JMenuItem("Daten speichern"); + menu.add(saveDataItem); + saveDataItem.addActionListener(e -> { + Main.saveData(); + updateTextArea(); + }); + + JMenuItem loadDataItem = new JMenuItem("Daten laden"); + menu.add(loadDataItem); + loadDataItem.addActionListener(e -> { + Main.loadData(); + updateTextArea(); + }); + + JMenuItem exitItem = new JMenuItem("Beenden"); + menu.add(exitItem); + exitItem.addActionListener(e -> System.exit(0)); + + textArea = new JTextArea(); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + frame.add(scrollPane, BorderLayout.CENTER); + + frame.setVisible(true); + updateTextArea(); + } + + private void showAddCustomerPanel() { + JPanel panel = new JPanel(new GridLayout(6, 2)); + JLabel nameLabel = new JLabel("Name:"); + JTextField nameField = new JTextField(); + JLabel addressLabel = new JLabel("Adresse:"); + JTextField addressField = new JTextField(); + JLabel contactLabel = new JLabel("Ansprechpartner:"); + JTextField contactField = new JTextField(); + JLabel taxExemptLabel = new JLabel("Unter § 4 UStG:"); + JCheckBox taxExemptBox = new JCheckBox(); + JLabel smallBusinessLabel = new JLabel("Kleinunternehmer:"); + JCheckBox smallBusinessBox = new JCheckBox(); + + JButton addButton = new JButton("Hinzufügen"); + addButton.setBackground(new Color(144, 238, 144)); // Hellgrün + addButton.addActionListener(e -> { + String name = nameField.getText(); + String address = addressField.getText(); + String contactPerson = contactField.getText(); + boolean taxExempt = taxExemptBox.isSelected(); + boolean smallBusiness = smallBusinessBox.isSelected(); + Main.customers.add(new Main.Customer(name, address, contactPerson, taxExempt, smallBusiness)); + updateTextArea(); + }); + + panel.add(nameLabel); + panel.add(nameField); + panel.add(addressLabel); + panel.add(addressField); + panel.add(contactLabel); + panel.add(contactField); + panel.add(taxExemptLabel); + panel.add(taxExemptBox); + panel.add(smallBusinessLabel); + panel.add(smallBusinessBox); + panel.add(new JLabel()); + panel.add(addButton); + + showPanel(panel); + } + + private void showAddArticlePanel() { + JPanel panel = new JPanel(new GridLayout(5, 2)); + JLabel unitLabel = new JLabel("Einheit:"); + JTextField unitField = new JTextField(); + JLabel descriptionLabel = new JLabel("Bezeichnung:"); + JTextField descriptionField = new JTextField(); + JLabel netPriceLabel = new JLabel("Nettopreis:"); + JTextField netPriceField = new JTextField(); + JLabel vatRateLabel = new JLabel("Mehrwertsteuersatz:"); + JTextField vatRateField = new JTextField(); + + JButton addButton = new JButton("Hinzufügen"); + addButton.setBackground(new Color(144, 238, 144)); // Hellgrün + addButton.addActionListener(e -> { + String unit = unitField.getText(); + String description = descriptionField.getText(); + double netPrice = Double.parseDouble(netPriceField.getText()); + double vatRate = Double.parseDouble(vatRateField.getText()); + Main.articles.add(new Main.Article(unit, description, netPrice, vatRate)); + updateTextArea(); + }); + + panel.add(unitLabel); + panel.add(unitField); + panel.add(descriptionLabel); + panel.add(descriptionField); + panel.add(netPriceLabel); + panel.add(netPriceField); + panel.add(vatRateLabel); + panel.add(vatRateField); + panel.add(new JLabel()); + panel.add(addButton); + + showPanel(panel); + } + + private void showCreateOfferPanel() { + JPanel panel = new JPanel(new BorderLayout()); + JPanel formPanel = new JPanel(new GridLayout(4, 2)); + + JLabel customerLabel = new JLabel("Kunde:"); + JComboBox customerBox = new JComboBox<>(); + for (Main.Customer customer : Main.customers) { + customerBox.addItem(customer.name); + } + + JLabel articlesLabel = new JLabel("Artikel:"); + JList articlesList = new JList<>(Main.articles.stream().map(a -> a.description).toArray(String[]::new)); + articlesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + JScrollPane articlesScrollPane = new JScrollPane(articlesList); + + JLabel dateLabel = new JLabel("Datum:"); + JTextField dateField = new JTextField(); + + formPanel.add(customerLabel); + formPanel.add(customerBox); + formPanel.add(dateLabel); + formPanel.add(dateField); + + JButton addButton = new JButton("Erstellen"); + addButton.setBackground(new Color(144, 238, 144)); // Hellgrün + addButton.addActionListener(e -> { + String customerName = (String) customerBox.getSelectedItem(); + Main.Customer customer = Main.customers.stream().filter(c -> c.name.equals(customerName)).findFirst().orElse(null); + List selectedArticles = new ArrayList<>(); + for (String articleDesc : articlesList.getSelectedValuesList()) { + Main.Article article = Main.articles.stream().filter(a -> a.description.equals(articleDesc)).findFirst().orElse(null); + selectedArticles.add(article); + } + String date = dateField.getText(); + Main.offers.add(new Main.Offer(Main.nextOfferId++, customer, selectedArticles, date, "Angebot erstellt")); + updateTextArea(); + }); + + panel.add(formPanel, BorderLayout.NORTH); + panel.add(new JLabel("Artikel auswählen:"), BorderLayout.CENTER); + panel.add(articlesScrollPane, BorderLayout.CENTER); + panel.add(addButton, BorderLayout.SOUTH); + + showPanel(panel); + } + + private void showCreateOrderConfirmationPanel() { + JPanel panel = new JPanel(new GridLayout(4, 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); + } + + JLabel dateLabel = new JLabel("Datum:"); + JTextField dateField = new JTextField(); + + JButton addButton = new JButton("Erstellen"); + addButton.setBackground(new Color(144, 238, 144)); // Hellgrün + addButton.addActionListener(e -> { + int offerIndex = offerBox.getSelectedIndex(); + Main.Offer selectedOffer = Main.offers.get(offerIndex); + String date = dateField.getText(); + Main.orderConfirmations.add(new Main.OrderConfirmation(Main.nextOrderConfirmationId++, selectedOffer, date, "Auftragsbestätigung erstellt")); + selectedOffer.status = "Auftragsbestätigung erstellt"; + updateTextArea(); + }); + + panel.add(offerLabel); + panel.add(offerBox); + panel.add(dateLabel); + panel.add(dateField); + panel.add(new JLabel()); + panel.add(addButton); + + showPanel(panel); + } + + private void showCreateDeliveryNotePanel() { + JPanel panel = new JPanel(new GridLayout(4, 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); + } + + JLabel dateLabel = new JLabel("Datum:"); + JTextField dateField = new JTextField(); + + JButton addButton = new JButton("Erstellen"); + addButton.setBackground(new Color(144, 238, 144)); // Hellgrün + addButton.addActionListener(e -> { + int orderConfirmationIndex = orderConfirmationBox.getSelectedIndex(); + Main.OrderConfirmation selectedOrderConfirmation = Main.orderConfirmations.get(orderConfirmationIndex); + String date = dateField.getText(); + Main.deliveryNotes.add(new Main.DeliveryNote(Main.nextDeliveryNoteId++, selectedOrderConfirmation, date, "Lieferschein erstellt")); + selectedOrderConfirmation.status = "Lieferschein erstellt"; + selectedOrderConfirmation.offer.status = "Lieferschein erstellt"; + updateTextArea(); + }); + + panel.add(orderConfirmationLabel); + panel.add(orderConfirmationBox); + panel.add(dateLabel); + panel.add(dateField); + panel.add(new JLabel()); + panel.add(addButton); + + showPanel(panel); + } + + private void showCreateInvoicePanel() { + JPanel panel = new JPanel(new GridLayout(4, 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); + } + + JLabel dateLabel = new JLabel("Datum:"); + JTextField dateField = new JTextField(); + + JButton addButton = new JButton("Erstellen"); + addButton.setBackground(new Color(144, 238, 144)); // Hellgrün + addButton.addActionListener(e -> { + int deliveryNoteIndex = deliveryNoteBox.getSelectedIndex(); + Main.DeliveryNote selectedDeliveryNote = Main.deliveryNotes.get(deliveryNoteIndex); + String date = dateField.getText(); + Main.invoices.add(new Main.Invoice(Main.nextInvoiceId++, selectedDeliveryNote, date, "Rechnung erstellt")); + selectedDeliveryNote.status = "Rechnung erstellt"; + selectedDeliveryNote.orderConfirmation.status = "Rechnung erstellt"; + selectedDeliveryNote.orderConfirmation.offer.status = "Rechnung erstellt"; + updateTextArea(); + }); + + panel.add(deliveryNoteLabel); + panel.add(deliveryNoteBox); + panel.add(dateLabel); + panel.add(dateField); + panel.add(new JLabel()); + panel.add(addButton); + + showPanel(panel); + } + + private void showPanel(JPanel panel) { + frame.getContentPane().removeAll(); + frame.getContentPane().add(panel, BorderLayout.NORTH); + frame.revalidate(); + frame.repaint(); + } + + 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"); + } + 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"); + } + 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 (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"); + } + 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"); + } + 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"); + } + textArea.setText(sb.toString()); + } + + public static void main(String[] args) { + EventQueue.invokeLater(() -> { + try { + FakturamaGUI window = new FakturamaGUI(); + window.frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + }); + } +} diff --git a/PR2 KI Projekt/src/Main.java b/PR2 KI Projekt/src/Main.java new file mode 100644 index 0000000..aa60b1d --- /dev/null +++ b/PR2 KI Projekt/src/Main.java @@ -0,0 +1,814 @@ +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +public class Main { + + static class Customer { + String name; + String address; + String contactPerson; + boolean taxExempt; + boolean smallBusiness; + + Customer(String name, String address, String contactPerson, boolean taxExempt, boolean smallBusiness) { + this.name = name; + this.address = address; + this.contactPerson = contactPerson; + this.taxExempt = taxExempt; + this.smallBusiness = smallBusiness; + } + } + + static class Article { + static int nextId = 1; + int id; + String unit; + String description; + double netPrice; + double vatRate; + + Article(String unit, String description, double netPrice, double vatRate) { + this.id = nextId++; + this.unit = unit; + this.description = description; + this.netPrice = netPrice; + this.vatRate = vatRate; + } + } + + static class Offer { + int id; + Customer customer; + List
articles; + String date; + String status; + + Offer(int id, Customer customer, List
articles, String date, String status) { + this.id = id; + this.customer = customer; + this.articles = articles; + this.date = date; + this.status = status; + } + } + + static class OrderConfirmation { + int id; + Offer offer; + String date; + String status; + + OrderConfirmation(int id, Offer offer, String date, String status) { + this.id = id; + this.offer = offer; + this.date = date; + this.status = status; + } + } + + static class DeliveryNote { + int id; + OrderConfirmation orderConfirmation; + String date; + String status; + + DeliveryNote(int id, OrderConfirmation orderConfirmation, String date, String status) { + this.id = id; + this.orderConfirmation = orderConfirmation; + this.date = date; + this.status = status; + } + } + + static class Invoice { + int id; + DeliveryNote deliveryNote; + String date; + String status; + + Invoice(int id, DeliveryNote deliveryNote, String date, String status) { + this.id = id; + this.deliveryNote = deliveryNote; + this.date = date; + this.status = status; + } + } + + static List customers = new ArrayList<>(); + static List
articles = new ArrayList<>(); + static List offers = new ArrayList<>(); + static List orderConfirmations = new ArrayList<>(); + static List deliveryNotes = new ArrayList<>(); + static List invoices = new ArrayList<>(); + private static Scanner scanner = new Scanner(System.in); + static int nextOfferId = 1; + static int nextOrderConfirmationId = 1; + static int nextDeliveryNoteId = 1; + static int nextInvoiceId = 1; + + public static void main(String[] args) { + while (true) { + System.out.println("1. Kunde hinzufügen"); + System.out.println("2. Kunden anzeigen"); + System.out.println("3. Artikel hinzufügen"); + System.out.println("4. Artikel anzeigen"); + System.out.println("5. Angebot erstellen"); + System.out.println("6. Angebote anzeigen"); + System.out.println("7. Auftragsbestätigung erstellen"); + System.out.println("8. Auftragsbestätigungen anzeigen"); + System.out.println("9. Lieferschein erstellen"); + System.out.println("10. Lieferscheine anzeigen"); + System.out.println("11. Rechnung erstellen"); + System.out.println("12. Rechnungen anzeigen"); + System.out.println("13. Daten speichern"); + System.out.println("14. Daten laden"); + System.out.println("15. Beenden"); + System.out.print("Wählen Sie eine Option: "); + int choice = scanner.nextInt(); + scanner.nextLine(); // consume newline + + switch (choice) { + case 1: + addCustomer(); + break; + case 2: + displayCustomers(); + break; + case 3: + addArticle(); + break; + case 4: + displayArticles(); + break; + case 5: + createOffer(); + break; + case 6: + displayOffers(); + break; + case 7: + createOrderConfirmation(); + break; + case 8: + displayOrderConfirmations(); + break; + case 9: + createDeliveryNote(); + break; + case 10: + displayDeliveryNotes(); + break; + case 11: + createInvoice(); + break; + case 12: + displayInvoices(); + break; + case 13: + saveData(); + break; + case 14: + loadData(); + break; + case 15: + System.exit(0); + break; + default: + System.out.println("Ungültige Option. Bitte versuchen Sie es erneut."); + } + } + } + + private static void addCustomer() { + System.out.print("Kundenname: "); + String name = scanner.nextLine(); + System.out.print("Adresse: "); + String address = scanner.nextLine(); + System.out.print("Ansprechpartner: "); + String contactPerson = scanner.nextLine(); + System.out.print("Fällt der Kunde unter § 4 Umsatzsteuergesetz (ja/nein): "); + boolean taxExempt = scanner.nextLine().equalsIgnoreCase("ja"); + System.out.print("Kleinunternehmer (ja/nein): "); + boolean smallBusiness = scanner.nextLine().equalsIgnoreCase("ja"); + + customers.add(new Customer(name, address, contactPerson, taxExempt, smallBusiness)); + } + + private static void displayCustomers() { + if (customers.isEmpty()) { + System.out.println("Keine Kunden vorhanden."); + } else { + for (Customer customer : customers) { + System.out.println("Name: " + customer.name); + System.out.println("Adresse: " + customer.address); + System.out.println("Ansprechpartner: " + customer.contactPerson); + System.out.println("Unter § 4 UStG: " + (customer.taxExempt ? "Ja" : "Nein")); + System.out.println("Kleinunternehmer: " + (customer.smallBusiness ? "Ja" : "Nein")); + System.out.println(); + } + } + } + + private static void addArticle() { + System.out.print("Einheit: "); + String unit = scanner.nextLine(); + System.out.print("Bezeichnung: "); + String description = scanner.nextLine(); + System.out.print("Nettopreis: "); + double netPrice = scanner.nextDouble(); + System.out.print("Mehrwertsteuersatz: "); + double vatRate = scanner.nextDouble(); + scanner.nextLine(); // consume newline + + articles.add(new Article(unit, description, netPrice, vatRate)); + } + + private static void displayArticles() { + if (articles.isEmpty()) { + System.out.println("Keine Artikel vorhanden."); + } else { + for (Article article : articles) { + System.out.println("Artikelnummer: " + article.id); + System.out.println("Einheit: " + article.unit); + System.out.println("Bezeichnung: " + article.description); + System.out.println("Nettopreis: " + article.netPrice); + System.out.println("Mehrwertsteuersatz: " + article.vatRate); + System.out.println(); + } + } + } + + private static void createOffer() { + if (customers.isEmpty() || articles.isEmpty()) { + System.out.println("Es müssen zuerst Kunden und Artikel angelegt werden."); + return; + } + + System.out.println("Wählen Sie einen Kunden aus:"); + for (int i = 0; i < customers.size(); i++) { + System.out.println((i + 1) + ". " + customers.get(i).name); + } + System.out.print("Kundennummer: "); + int customerIndex = scanner.nextInt() - 1; + scanner.nextLine(); // consume newline + + if (customerIndex < 0 || customerIndex >= customers.size()) { + System.out.println("Ungültige Kundennummer."); + return; + } + + Customer selectedCustomer = customers.get(customerIndex); + List
selectedArticles = new ArrayList<>(); + + while (true) { + System.out.println("Wählen Sie einen Artikel aus (0 zum Beenden):"); + for (int i = 0; i < articles.size(); i++) { + System.out.println((i + 1) + ". " + articles.get(i).description); + } + System.out.print("Artikelnummer: "); + int articleIndex = scanner.nextInt() - 1; + scanner.nextLine(); // consume newline + + if (articleIndex == -1) break; + if (articleIndex < 0 || articleIndex >= articles.size()) { + System.out.println("Ungültige Artikelnummer."); + continue; + } + + selectedArticles.add(articles.get(articleIndex)); + } + + System.out.print("Datum des Angebots (z.B. 2024-06-30): "); + String date = scanner.nextLine(); + + offers.add(new Offer(nextOfferId++, selectedCustomer, selectedArticles, date, "Angebot erstellt")); + System.out.println("Angebot erfolgreich erstellt."); + } + + private static void displayOffers() { + if (offers.isEmpty()) { + System.out.println("Keine Angebote vorhanden."); + } else { + for (Offer offer : offers) { + System.out.println("Angebotsnummer: " + offer.id); + System.out.println("Kunde: " + offer.customer.name); + System.out.println("Datum: " + offer.date); + System.out.println("Status: " + offer.status); + System.out.println("Artikel:"); + for (Article article : offer.articles) { + System.out.println("- " + article.description + " (Einheit: " + article.unit + ", Nettopreis: " + article.netPrice + ", MwSt.: " + article.vatRate + ")"); + } + System.out.println(); + } + } + } + + private static void createOrderConfirmation() { + if (offers.isEmpty()) { + System.out.println("Es müssen zuerst Angebote erstellt werden."); + return; + } + + System.out.println("Wählen Sie ein Angebot aus:"); + for (int i = 0; i < offers.size(); i++) { + System.out.println((i + 1) + ". Angebot #" + offers.get(i).id + " - Kunde: " + offers.get(i).customer.name); + } + System.out.print("Angebotsnummer: "); + int offerIndex = scanner.nextInt() - 1; + scanner.nextLine(); // consume newline + + if (offerIndex < 0 || offerIndex >= offers.size()) { + System.out.println("Ungültige Angebotsnummer."); + return; + } + + Offer selectedOffer = offers.get(offerIndex); + + System.out.print("Datum der Auftragsbestätigung (z.B. 2024-06-30): "); + String date = scanner.nextLine(); + + orderConfirmations.add(new OrderConfirmation(nextOrderConfirmationId++, selectedOffer, date, "Auftragsbestätigung erstellt")); + selectedOffer.status = "Auftragsbestätigung erstellt"; + System.out.println("Auftragsbestätigung erfolgreich erstellt."); + } + + private static void displayOrderConfirmations() { + if (orderConfirmations.isEmpty()) { + System.out.println("Keine Auftragsbestätigungen vorhanden."); + } else { + for (OrderConfirmation orderConfirmation : orderConfirmations) { + System.out.println("Auftragsbestätigungsnummer: " + orderConfirmation.id); + System.out.println("Angebotsnummer: " + orderConfirmation.offer.id); + System.out.println("Kunde: " + orderConfirmation.offer.customer.name); + System.out.println("Datum: " + orderConfirmation.date); + System.out.println("Status: " + orderConfirmation.status); + System.out.println(); + } + } + } + + private static void createDeliveryNote() { + if (orderConfirmations.isEmpty()) { + System.out.println("Es müssen zuerst Auftragsbestätigungen erstellt werden."); + return; + } + + System.out.println("Wählen Sie eine Auftragsbestätigung aus:"); + for (int i = 0; i < orderConfirmations.size(); i++) { + System.out.println((i + 1) + ". Auftragsbestätigung #" + orderConfirmations.get(i).id + " - Kunde: " + orderConfirmations.get(i).offer.customer.name); + } + System.out.print("Auftragsbestätigungsnummer: "); + int orderConfirmationIndex = scanner.nextInt() - 1; + scanner.nextLine(); // consume newline + + if (orderConfirmationIndex < 0 || orderConfirmationIndex >= orderConfirmations.size()) { + System.out.println("Ungültige Auftragsbestätigungsnummer."); + return; + } + + OrderConfirmation selectedOrderConfirmation = orderConfirmations.get(orderConfirmationIndex); + + System.out.print("Datum des Lieferscheins (z.B. 2024-06-30): "); + String date = scanner.nextLine(); + + deliveryNotes.add(new DeliveryNote(nextDeliveryNoteId++, selectedOrderConfirmation, date, "Lieferschein erstellt")); + selectedOrderConfirmation.status = "Lieferschein erstellt"; + selectedOrderConfirmation.offer.status = "Lieferschein erstellt"; + System.out.println("Lieferschein erfolgreich erstellt."); + } + + private static void displayDeliveryNotes() { + if (deliveryNotes.isEmpty()) { + System.out.println("Keine Lieferscheine vorhanden."); + } else { + for (DeliveryNote deliveryNote : deliveryNotes) { + System.out.println("Lieferscheinnummer: " + deliveryNote.id); + System.out.println("Auftragsbestätigungsnummer: " + deliveryNote.orderConfirmation.id); + System.out.println("Kunde: " + deliveryNote.orderConfirmation.offer.customer.name); + System.out.println("Datum: " + deliveryNote.date); + System.out.println("Status: " + deliveryNote.status); + System.out.println(); + } + } + } + + private static void createInvoice() { + if (deliveryNotes.isEmpty()) { + System.out.println("Es müssen zuerst Lieferscheine erstellt werden."); + return; + } + + System.out.println("Wählen Sie einen Lieferschein aus:"); + for (int i = 0; i < deliveryNotes.size(); i++) { + System.out.println((i + 1) + ". Lieferschein #" + deliveryNotes.get(i).id + " - Kunde: " + deliveryNotes.get(i).orderConfirmation.offer.customer.name); + } + System.out.print("Lieferscheinnummer: "); + int deliveryNoteIndex = scanner.nextInt() - 1; + scanner.nextLine(); // consume newline + + if (deliveryNoteIndex < 0 || deliveryNoteIndex >= deliveryNotes.size()) { + System.out.println("Ungültige Lieferscheinnummer."); + return; + } + + DeliveryNote selectedDeliveryNote = deliveryNotes.get(deliveryNoteIndex); + + System.out.print("Datum der Rechnung (z.B. 2024-06-30): "); + String date = scanner.nextLine(); + + invoices.add(new Invoice(nextInvoiceId++, selectedDeliveryNote, date, "Rechnung erstellt")); + selectedDeliveryNote.status = "Rechnung erstellt"; + selectedDeliveryNote.orderConfirmation.status = "Rechnung erstellt"; + selectedDeliveryNote.orderConfirmation.offer.status = "Rechnung erstellt"; + System.out.println("Rechnung erfolgreich erstellt."); + } + + private static void displayInvoices() { + if (invoices.isEmpty()) { + System.out.println("Keine Rechnungen vorhanden."); + } else { + for (Invoice invoice : invoices) { + System.out.println("Rechnungsnummer: " + invoice.id); + System.out.println("Lieferscheinnummer: " + invoice.deliveryNote.id); + System.out.println("Kunde: " + invoice.deliveryNote.orderConfirmation.offer.customer.name); + System.out.println("Datum: " + invoice.date); + System.out.println("Status: " + invoice.status); + System.out.println(); + } + } + } + + static void saveData() { + try { + DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder documentBuilder = documentFactory.newDocumentBuilder(); + Document document = documentBuilder.newDocument(); + + Element root = document.createElement("Fakturama"); + document.appendChild(root); + + Element customersElement = document.createElement("Customers"); + root.appendChild(customersElement); + + for (Customer customer : customers) { + Element customerElement = document.createElement("Customer"); + + Element name = document.createElement("Name"); + name.appendChild(document.createTextNode(customer.name)); + customerElement.appendChild(name); + + Element address = document.createElement("Address"); + address.appendChild(document.createTextNode(customer.address)); + customerElement.appendChild(address); + + Element contactPerson = document.createElement("ContactPerson"); + contactPerson.appendChild(document.createTextNode(customer.contactPerson)); + customerElement.appendChild(contactPerson); + + Element taxExempt = document.createElement("TaxExempt"); + taxExempt.appendChild(document.createTextNode(Boolean.toString(customer.taxExempt))); + customerElement.appendChild(taxExempt); + + Element smallBusiness = document.createElement("SmallBusiness"); + smallBusiness.appendChild(document.createTextNode(Boolean.toString(customer.smallBusiness))); + customerElement.appendChild(smallBusiness); + + customersElement.appendChild(customerElement); + } + + Element articlesElement = document.createElement("Articles"); + root.appendChild(articlesElement); + + for (Article article : articles) { + Element articleElement = document.createElement("Article"); + + Element id = document.createElement("ID"); + id.appendChild(document.createTextNode(Integer.toString(article.id))); + articleElement.appendChild(id); + + Element unit = document.createElement("Unit"); + unit.appendChild(document.createTextNode(article.unit)); + articleElement.appendChild(unit); + + Element description = document.createElement("Description"); + description.appendChild(document.createTextNode(article.description)); + articleElement.appendChild(description); + + Element netPrice = document.createElement("NetPrice"); + netPrice.appendChild(document.createTextNode(Double.toString(article.netPrice))); + articleElement.appendChild(netPrice); + + Element vatRate = document.createElement("VatRate"); + vatRate.appendChild(document.createTextNode(Double.toString(article.vatRate))); + articleElement.appendChild(vatRate); + + articlesElement.appendChild(articleElement); + } + + Element offersElement = document.createElement("Offers"); + root.appendChild(offersElement); + + for (Offer offer : offers) { + Element offerElement = document.createElement("Offer"); + + Element id = document.createElement("ID"); + id.appendChild(document.createTextNode(Integer.toString(offer.id))); + offerElement.appendChild(id); + + Element customerName = document.createElement("CustomerName"); + customerName.appendChild(document.createTextNode(offer.customer.name)); + offerElement.appendChild(customerName); + + Element date = document.createElement("Date"); + date.appendChild(document.createTextNode(offer.date)); + offerElement.appendChild(date); + + Element status = document.createElement("Status"); + status.appendChild(document.createTextNode(offer.status)); + offerElement.appendChild(status); + + Element offerArticles = document.createElement("Articles"); + offerElement.appendChild(offerArticles); + + for (Article article : offer.articles) { + Element articleElement = document.createElement("Article"); + + Element articleId = document.createElement("ID"); + articleId.appendChild(document.createTextNode(Integer.toString(article.id))); + articleElement.appendChild(articleId); + + offerArticles.appendChild(articleElement); + } + + offersElement.appendChild(offerElement); + } + + Element orderConfirmationsElement = document.createElement("OrderConfirmations"); + root.appendChild(orderConfirmationsElement); + + for (OrderConfirmation orderConfirmation : orderConfirmations) { + Element orderConfirmationElement = document.createElement("OrderConfirmation"); + + Element id = document.createElement("ID"); + id.appendChild(document.createTextNode(Integer.toString(orderConfirmation.id))); + orderConfirmationElement.appendChild(id); + + Element offerId = document.createElement("OfferID"); + offerId.appendChild(document.createTextNode(Integer.toString(orderConfirmation.offer.id))); + orderConfirmationElement.appendChild(offerId); + + Element date = document.createElement("Date"); + date.appendChild(document.createTextNode(orderConfirmation.date)); + orderConfirmationElement.appendChild(date); + + Element status = document.createElement("Status"); + status.appendChild(document.createTextNode(orderConfirmation.status)); + orderConfirmationElement.appendChild(status); + + orderConfirmationsElement.appendChild(orderConfirmationElement); + } + + Element deliveryNotesElement = document.createElement("DeliveryNotes"); + root.appendChild(deliveryNotesElement); + + for (DeliveryNote deliveryNote : deliveryNotes) { + Element deliveryNoteElement = document.createElement("DeliveryNote"); + + Element id = document.createElement("ID"); + id.appendChild(document.createTextNode(Integer.toString(deliveryNote.id))); + deliveryNoteElement.appendChild(id); + + Element orderConfirmationId = document.createElement("OrderConfirmationID"); + orderConfirmationId.appendChild(document.createTextNode(Integer.toString(deliveryNote.orderConfirmation.id))); + deliveryNoteElement.appendChild(orderConfirmationId); + + Element date = document.createElement("Date"); + date.appendChild(document.createTextNode(deliveryNote.date)); + deliveryNoteElement.appendChild(date); + + Element status = document.createElement("Status"); + status.appendChild(document.createTextNode(deliveryNote.status)); + deliveryNoteElement.appendChild(status); + + deliveryNotesElement.appendChild(deliveryNoteElement); + } + + Element invoicesElement = document.createElement("Invoices"); + root.appendChild(invoicesElement); + + for (Invoice invoice : invoices) { + Element invoiceElement = document.createElement("Invoice"); + + Element id = document.createElement("ID"); + id.appendChild(document.createTextNode(Integer.toString(invoice.id))); + invoiceElement.appendChild(id); + + Element deliveryNoteId = document.createElement("DeliveryNoteID"); + deliveryNoteId.appendChild(document.createTextNode(Integer.toString(invoice.deliveryNote.id))); + invoiceElement.appendChild(deliveryNoteId); + + Element date = document.createElement("Date"); + date.appendChild(document.createTextNode(invoice.date)); + invoiceElement.appendChild(date); + + Element status = document.createElement("Status"); + status.appendChild(document.createTextNode(invoice.status)); + invoiceElement.appendChild(status); + + invoicesElement.appendChild(invoiceElement); + } + + TransformerFactory transformerFactory = TransformerFactory.newInstance(); + Transformer transformer = transformerFactory.newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + DOMSource domSource = new DOMSource(document); + StreamResult streamResult = new StreamResult("fakturama_data.xml"); + + transformer.transform(domSource, streamResult); + + System.out.println("Daten erfolgreich gespeichert."); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + static void loadData() { + try { + File xmlFile = new File("fakturama_data.xml"); + if (!xmlFile.exists()) { + System.out.println("Keine Daten zum Laden vorhanden."); + return; + } + + DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder documentBuilder = documentFactory.newDocumentBuilder(); + Document document = documentBuilder.parse(xmlFile); + document.getDocumentElement().normalize(); + + NodeList customerList = document.getElementsByTagName("Customer"); + customers.clear(); // Vor dem Laden die aktuelle Liste leeren + + for (int i = 0; i < customerList.getLength(); i++) { + Node customerNode = customerList.item(i); + + if (customerNode.getNodeType() == Node.ELEMENT_NODE) { + Element customerElement = (Element) customerNode; + + String name = customerElement.getElementsByTagName("Name").item(0).getTextContent(); + String address = customerElement.getElementsByTagName("Address").item(0).getTextContent(); + String contactPerson = customerElement.getElementsByTagName("ContactPerson").item(0).getTextContent(); + boolean taxExempt = Boolean.parseBoolean(customerElement.getElementsByTagName("TaxExempt").item(0).getTextContent()); + boolean smallBusiness = Boolean.parseBoolean(customerElement.getElementsByTagName("SmallBusiness").item(0).getTextContent()); + + customers.add(new Customer(name, address, contactPerson, taxExempt, smallBusiness)); + } + } + + NodeList articleList = document.getElementsByTagName("Article"); + articles.clear(); // Vor dem Laden die aktuelle Liste leeren + + for (int i = 0; i < articleList.getLength(); i++) { + Node articleNode = articleList.item(i); + + if (articleNode.getNodeType() == Node.ELEMENT_NODE) { + Element articleElement = (Element) articleNode; + + int id = Integer.parseInt(articleElement.getElementsByTagName("ID").item(0).getTextContent()); + String unit = articleElement.getElementsByTagName("Unit").item(0).getTextContent(); + String description = articleElement.getElementsByTagName("Description").item(0).getTextContent(); + double netPrice = Double.parseDouble(articleElement.getElementsByTagName("NetPrice").item(0).getTextContent()); + double vatRate = Double.parseDouble(articleElement.getElementsByTagName("VatRate").item(0).getTextContent()); + + Article article = new Article(unit, description, netPrice, vatRate); + article.id = id; // Set the ID explicitly + articles.add(article); + } + } + + NodeList offerList = document.getElementsByTagName("Offer"); + offers.clear(); // Vor dem Laden die aktuelle Liste leeren + + for (int i = 0; i < offerList.getLength(); i++) { + Node offerNode = offerList.item(i); + + if (offerNode.getNodeType() == Node.ELEMENT_NODE) { + Element offerElement = (Element) offerNode; + + int id = Integer.parseInt(offerElement.getElementsByTagName("ID").item(0).getTextContent()); + String customerName = offerElement.getElementsByTagName("CustomerName").item(0).getTextContent(); + Customer offerCustomer = customers.stream().filter(c -> c.name.equals(customerName)).findFirst().orElse(null); + + String date = offerElement.getElementsByTagName("Date").item(0).getTextContent(); + String status = offerElement.getElementsByTagName("Status").item(0).getTextContent(); + + NodeList offerArticles = offerElement.getElementsByTagName("Article"); + List
offerArticleList = new ArrayList<>(); + + for (int j = 0; j < offerArticles.getLength(); j++) { + Node offerArticleNode = offerArticles.item(j); + + if (offerArticleNode.getNodeType() == Node.ELEMENT_NODE) { + Element offerArticleElement = (Element) offerArticleNode; + + int articleId = Integer.parseInt(offerArticleElement.getElementsByTagName("ID").item(0).getTextContent()); + Article offerArticle = articles.stream().filter(a -> a.id == articleId).findFirst().orElse(null); + + if (offerArticle != null) { + offerArticleList.add(offerArticle); + } + } + } + + if (offerCustomer != null) { + offers.add(new Offer(id, offerCustomer, offerArticleList, date, status)); + } + } + } + + NodeList orderConfirmationList = document.getElementsByTagName("OrderConfirmation"); + orderConfirmations.clear(); // Vor dem Laden die aktuelle Liste leeren + + for (int i = 0; i < orderConfirmationList.getLength(); i++) { + Node orderConfirmationNode = orderConfirmationList.item(i); + + if (orderConfirmationNode.getNodeType() == Node.ELEMENT_NODE) { + Element orderConfirmationElement = (Element) orderConfirmationNode; + + int id = Integer.parseInt(orderConfirmationElement.getElementsByTagName("ID").item(0).getTextContent()); + int offerId = Integer.parseInt(orderConfirmationElement.getElementsByTagName("OfferID").item(0).getTextContent()); + Offer orderConfirmationOffer = offers.stream().filter(o -> o.id == offerId).findFirst().orElse(null); + + String date = orderConfirmationElement.getElementsByTagName("Date").item(0).getTextContent(); + String status = orderConfirmationElement.getElementsByTagName("Status").item(0).getTextContent(); + + if (orderConfirmationOffer != null) { + orderConfirmations.add(new OrderConfirmation(id, orderConfirmationOffer, date, status)); + } + } + } + + NodeList deliveryNoteList = document.getElementsByTagName("DeliveryNote"); + deliveryNotes.clear(); // Vor dem Laden die aktuelle Liste leeren + + for (int i = 0; i < deliveryNoteList.getLength(); i++) { + Node deliveryNoteNode = deliveryNoteList.item(i); + + if (deliveryNoteNode.getNodeType() == Node.ELEMENT_NODE) { + Element deliveryNoteElement = (Element) deliveryNoteNode; + + int id = Integer.parseInt(deliveryNoteElement.getElementsByTagName("ID").item(0).getTextContent()); + int orderConfirmationId = Integer.parseInt(deliveryNoteElement.getElementsByTagName("OrderConfirmationID").item(0).getTextContent()); + OrderConfirmation deliveryNoteOrderConfirmation = orderConfirmations.stream().filter(oc -> oc.id == orderConfirmationId).findFirst().orElse(null); + + String date = deliveryNoteElement.getElementsByTagName("Date").item(0).getTextContent(); + String status = deliveryNoteElement.getElementsByTagName("Status").item(0).getTextContent(); + + if (deliveryNoteOrderConfirmation != null) { + deliveryNotes.add(new DeliveryNote(id, deliveryNoteOrderConfirmation, date, status)); + } + } + } + + NodeList invoiceList = document.getElementsByTagName("Invoice"); + invoices.clear(); // Vor dem Laden die aktuelle Liste leeren + + for (int i = 0; i < invoiceList.getLength(); i++) { + Node invoiceNode = invoiceList.item(i); + + if (invoiceNode.getNodeType() == Node.ELEMENT_NODE) { + Element invoiceElement = (Element) invoiceNode; + + int id = Integer.parseInt(invoiceElement.getElementsByTagName("ID").item(0).getTextContent()); + int deliveryNoteId = Integer.parseInt(invoiceElement.getElementsByTagName("DeliveryNoteID").item(0).getTextContent()); + DeliveryNote invoiceDeliveryNote = deliveryNotes.stream().filter(dn -> dn.id == deliveryNoteId).findFirst().orElse(null); + + String date = invoiceElement.getElementsByTagName("Date").item(0).getTextContent(); + String status = invoiceElement.getElementsByTagName("Status").item(0).getTextContent(); + + if (invoiceDeliveryNote != null) { + invoices.add(new Invoice(id, invoiceDeliveryNote, date, status)); + } + } + } + + System.out.println("Daten erfolgreich geladen."); + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/PR2 KI Projekt/src/MainTest.java b/PR2 KI Projekt/src/MainTest.java new file mode 100644 index 0000000..11e261d --- /dev/null +++ b/PR2 KI Projekt/src/MainTest.java @@ -0,0 +1,127 @@ +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import java.util.ArrayList; +import java.util.List; + +public class MainTest { + + @BeforeEach + public void setUp() { + Main.customers = new ArrayList<>(); + Main.articles = new ArrayList<>(); + Main.offers = new ArrayList<>(); + Main.orderConfirmations = new ArrayList<>(); + Main.deliveryNotes = new ArrayList<>(); + Main.invoices = new ArrayList<>(); + } + + @Test + public void testAddCustomer() { + Main.customers.add(new Main.Customer("Test Kunde", "Test Adresse", "Test Kontakt", true, false)); + assertEquals(1, Main.customers.size()); + assertEquals("Test Kunde", Main.customers.get(0).name); + assertEquals("Test Adresse", Main.customers.get(0).address); + assertEquals("Test Kontakt", Main.customers.get(0).contactPerson); + assertTrue(Main.customers.get(0).taxExempt); + assertFalse(Main.customers.get(0).smallBusiness); + } + + @Test + public void testAddArticle() { + Main.articles.add(new Main.Article("Stück", "Test Artikel", 100.0, 19.0)); + assertEquals(1, Main.articles.size()); + assertEquals("Stück", Main.articles.get(0).unit); + assertEquals("Test Artikel", Main.articles.get(0).description); + assertEquals(100.0, Main.articles.get(0).netPrice); + assertEquals(19.0, Main.articles.get(0).vatRate); + } + + @Test + public void testCreateOffer() { + Main.Customer customer = new Main.Customer("Test Kunde", "Test Adresse", "Test Kontakt", true, false); + Main.customers.add(customer); + Main.Article article = new Main.Article("Stück", "Test Artikel", 100.0, 19.0); + Main.articles.add(article); + + List articles = new ArrayList<>(); + articles.add(article); + Main.offers.add(new Main.Offer(1, customer, articles, "2024-06-30", "Angebot erstellt")); + + assertEquals(1, Main.offers.size()); + assertEquals(customer, Main.offers.get(0).customer); + assertEquals(1, Main.offers.get(0).articles.size()); + assertEquals(article, Main.offers.get(0).articles.get(0)); + assertEquals("2024-06-30", Main.offers.get(0).date); + assertEquals("Angebot erstellt", Main.offers.get(0).status); + } + + @Test + public void testCreateOrderConfirmation() { + Main.Customer customer = new Main.Customer("Test Kunde", "Test Adresse", "Test Kontakt", true, false); + Main.customers.add(customer); + Main.Article article = new Main.Article("Stück", "Test Artikel", 100.0, 19.0); + Main.articles.add(article); + + List articles = new ArrayList<>(); + articles.add(article); + Main.Offer offer = new Main.Offer(1, customer, articles, "2024-06-30", "Angebot erstellt"); + Main.offers.add(offer); + + Main.orderConfirmations.add(new Main.OrderConfirmation(1, offer, "2024-07-01", "Auftragsbestätigung erstellt")); + + assertEquals(1, Main.orderConfirmations.size()); + assertEquals(offer, Main.orderConfirmations.get(0).offer); + assertEquals("2024-07-01", Main.orderConfirmations.get(0).date); + assertEquals("Auftragsbestätigung erstellt", Main.orderConfirmations.get(0).status); + } + + @Test + public void testCreateDeliveryNote() { + Main.Customer customer = new Main.Customer("Test Kunde", "Test Adresse", "Test Kontakt", true, false); + Main.customers.add(customer); + Main.Article article = new Main.Article("Stück", "Test Artikel", 100.0, 19.0); + Main.articles.add(article); + + List articles = new ArrayList<>(); + articles.add(article); + Main.Offer offer = new Main.Offer(1, customer, articles, "2024-06-30", "Angebot erstellt"); + Main.offers.add(offer); + + Main.OrderConfirmation orderConfirmation = new Main.OrderConfirmation(1, offer, "2024-07-01", "Auftragsbestätigung erstellt"); + Main.orderConfirmations.add(orderConfirmation); + + Main.deliveryNotes.add(new Main.DeliveryNote(1, orderConfirmation, "2024-07-05", "Lieferschein erstellt")); + + assertEquals(1, Main.deliveryNotes.size()); + assertEquals(orderConfirmation, Main.deliveryNotes.get(0).orderConfirmation); + assertEquals("2024-07-05", Main.deliveryNotes.get(0).date); + assertEquals("Lieferschein erstellt", Main.deliveryNotes.get(0).status); + } + + @Test + public void testCreateInvoice() { + Main.Customer customer = new Main.Customer("Test Kunde", "Test Adresse", "Test Kontakt", true, false); + Main.customers.add(customer); + Main.Article article = new Main.Article("Stück", "Test Artikel", 100.0, 19.0); + Main.articles.add(article); + + List articles = new ArrayList<>(); + articles.add(article); + Main.Offer offer = new Main.Offer(1, customer, articles, "2024-06-30", "Angebot erstellt"); + Main.offers.add(offer); + + Main.OrderConfirmation orderConfirmation = new Main.OrderConfirmation(1, offer, "2024-07-01", "Auftragsbestätigung erstellt"); + Main.orderConfirmations.add(orderConfirmation); + + Main.DeliveryNote deliveryNote = new Main.DeliveryNote(1, orderConfirmation, "2024-07-05", "Lieferschein erstellt"); + Main.deliveryNotes.add(deliveryNote); + + Main.invoices.add(new Main.Invoice(1, deliveryNote, "2024-07-10", "Rechnung erstellt")); + + assertEquals(1, Main.invoices.size()); + assertEquals(deliveryNote, Main.invoices.get(0).deliveryNote); + assertEquals("2024-07-10", Main.invoices.get(0).date); + assertEquals("Rechnung erstellt", Main.invoices.get(0).status); + } +} diff --git a/PR2 KI Projekt/src/Order.java b/PR2 KI Projekt/src/Order.java deleted file mode 100644 index 3252e5c..0000000 --- a/PR2 KI Projekt/src/Order.java +++ /dev/null @@ -1,46 +0,0 @@ -class Order { - private int id; - private String product; - private int quantity; - private String date; - private String deliveryDate; - private String status; - - public Order(int id, String product, int quantity, String date, String deliveryDate, String status) { - this.id = id; - this.product = product; - this.quantity = quantity; - this.date = date; - this.deliveryDate = deliveryDate; - this.status = status; - } - - public int getId() { - return id; - } - - public String getProduct() { - return product; - } - - public int getQuantity() { - return quantity; - } - - public String getDate() { - return date; - } - - public String getDeliveryDate() { - return deliveryDate; - } - - public String getStatus() { - return status; - } - - @Override - public String toString() { - return "Order " + id + " - " + product; - } -} \ No newline at end of file diff --git a/PR2 KI Projekt/src/OrderCellRenderer.java b/PR2 KI Projekt/src/OrderCellRenderer.java deleted file mode 100644 index e701bdd..0000000 --- a/PR2 KI Projekt/src/OrderCellRenderer.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.awt.Component; -import javax.swing.*; - -class OrderCellRenderer extends DefaultListCellRenderer { - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (component instanceof JLabel && value instanceof Order) { - JLabel label = (JLabel) component; - Order order = (Order) value; - label.setText(order.getProduct()); - } - return component; - } -} \ No newline at end of file diff --git a/PR2 KI Projekt/src/Product.java b/PR2 KI Projekt/src/Product.java deleted file mode 100644 index ff447a9..0000000 --- a/PR2 KI Projekt/src/Product.java +++ /dev/null @@ -1,82 +0,0 @@ -class Product { - private int id; - private String itemNumber; - private String productName; - private String description; - private String category; - private int availableStock; - private int minimumStock; - private String storageLocation; - private double purchasePrice; - private double sellingPrice; - private String mainSupplier; - private String imagePath; - - public Product(int id, String itemNumber, String productName, String description, String category, int availableStock, int minimumStock, String storageLocation, double purchasePrice, double sellingPrice, String mainSupplier, String imagePath) { - this.id = id; - this.itemNumber = itemNumber; - this.productName = productName; - this.description = description; - this.category = category; - this.availableStock = availableStock; - this.minimumStock = minimumStock; - this.storageLocation = storageLocation; - this.purchasePrice = purchasePrice; - this.sellingPrice = sellingPrice; - this.mainSupplier = mainSupplier; - this.imagePath = imagePath; - } - - public int getId() { - return id; - } - - public String getItemNumber() { - return itemNumber; - } - - public String getProductName() { - return productName; - } - - public String getDescription() { - return description; - } - - public String getCategory() { - return category; - } - - public int getAvailableStock() { - return availableStock; - } - - public int getMinimumStock() { - return minimumStock; - } - - public String getStorageLocation() { - return storageLocation; - } - - public double getPurchasePrice() { - return purchasePrice; - } - - public double getSellingPrice() { - return sellingPrice; - } - - public String getMainSupplier() { - return mainSupplier; - } - - public String getImagePath() { - return imagePath; - } - - @Override - public String toString() { - return productName; - } -} \ No newline at end of file diff --git a/PR2 KI Projekt/src/ProductCellRenderer.java b/PR2 KI Projekt/src/ProductCellRenderer.java deleted file mode 100644 index dc5a724..0000000 --- a/PR2 KI Projekt/src/ProductCellRenderer.java +++ /dev/null @@ -1,19 +0,0 @@ -import java.awt.*; - -import javax.swing.*; - -class ProductCellRenderer extends JLabel implements ListCellRenderer { - @Override - public Component getListCellRendererComponent(JList list, Product product, int index, boolean isSelected, boolean cellHasFocus) { - setText(product.getProductName()); - setOpaque(true); - if (isSelected) { - setBackground(list.getSelectionBackground()); - setForeground(list.getSelectionForeground()); - } else { - setBackground(list.getBackground()); - setForeground(list.getForeground()); - } - return this; - } -} \ No newline at end of file diff --git a/PR2 KI Projekt/src/Supplier.java b/PR2 KI Projekt/src/Supplier.java deleted file mode 100644 index a4f537c..0000000 --- a/PR2 KI Projekt/src/Supplier.java +++ /dev/null @@ -1,52 +0,0 @@ -class Supplier { - private int id; - private String name; - private String address; - private String contact; - private String contractDetails; - private String orderHistory; - private String qualityRating; - - public Supplier(int id, String name, String address, String contact, String contractDetails, String orderHistory, String qualityRating) { - this.id = id; - this.name = name; - this.address = address; - this.contact = contact; - this.contractDetails = contractDetails; - this.orderHistory = orderHistory; - this.qualityRating = qualityRating; - } - - public int getId() { - return id; - } - - public String getName() { - return name; - } - - public String getAddress() { - return address; - } - - public String getContact() { - return contact; - } - - public String getContractDetails() { - return contractDetails; - } - - public String getOrderHistory() { - return orderHistory; - } - - public String getQualityRating() { - return qualityRating; - } - - @Override - public String toString() { - return name; - } -} \ No newline at end of file diff --git a/PR2 KI Projekt/src/SupplierCellRenderer.java b/PR2 KI Projekt/src/SupplierCellRenderer.java deleted file mode 100644 index 600b7bd..0000000 --- a/PR2 KI Projekt/src/SupplierCellRenderer.java +++ /dev/null @@ -1,18 +0,0 @@ -import java.awt.*; -import javax.swing.*; - -class SupplierCellRenderer extends JLabel implements ListCellRenderer { - @Override - public Component getListCellRendererComponent(JList list, Supplier supplier, int index, boolean isSelected, boolean cellHasFocus) { - setText(supplier.getName()); - setOpaque(true); - if (isSelected) { - setBackground(list.getSelectionBackground()); - setForeground(list.getSelectionForeground()); - } else { - setBackground(list.getBackground()); - setForeground(list.getForeground()); - } - return this; - } -} \ No newline at end of file diff --git a/PR2 KI Projekt/src/Termination.java b/PR2 KI Projekt/src/Termination.java deleted file mode 100644 index 1b278b1..0000000 --- a/PR2 KI Projekt/src/Termination.java +++ /dev/null @@ -1,25 +0,0 @@ -class Termination { - private String date; - private String type; - private String reason; - - public Termination(String date, String type, String reason) { - this.date = date; - this.type = type; - this.reason = reason; - } - - // Getter und Setter - - public String getDate() { - return date; - } - - public String getType() { - return type; - } - - public String getReason() { - return reason; - } -} diff --git a/PR2 KI Projekt/src/Transfer.java b/PR2 KI Projekt/src/Transfer.java deleted file mode 100644 index 63ddfb5..0000000 --- a/PR2 KI Projekt/src/Transfer.java +++ /dev/null @@ -1,31 +0,0 @@ -class Transfer { - private String date; - private String fromDepartment; - private String toDepartment; - private String reason; - - public Transfer(String date, String fromDepartment, String toDepartment, String reason) { - this.date = date; - this.fromDepartment = fromDepartment; - this.toDepartment = toDepartment; - this.reason = reason; - } - - // Getter und Setter - - public String getDate() { - return date; - } - - public String getFromDepartment() { - return fromDepartment; - } - - public String getToDepartment() { - return toDepartment; - } - - public String getReason() { - return reason; - } -} diff --git a/PR2 KI Projekt/src/User.java b/PR2 KI Projekt/src/User.java deleted file mode 100644 index 5d3f0d5..0000000 --- a/PR2 KI Projekt/src/User.java +++ /dev/null @@ -1,29 +0,0 @@ -class User { - private int id; - private String username; - private String password; - private String role; - - public User(int id, String username, String password, String role) { - this.id = id; - this.username = username; - this.password = password; - this.role = role; - } - - public int getId() { - return id; - } - - public String getUsername() { - return username; - } - - public String getPassword() { - return password; - } - - public String getRole() { - return role; - } -} \ No newline at end of file diff --git a/PR2 KI Projekt/src/Vacation.java b/PR2 KI Projekt/src/Vacation.java deleted file mode 100644 index 44bac22..0000000 --- a/PR2 KI Projekt/src/Vacation.java +++ /dev/null @@ -1,25 +0,0 @@ -class Vacation { - private String startDate; - private String endDate; - private String reason; - - public Vacation(String startDate, String endDate, String reason) { - this.startDate = startDate; - this.endDate = endDate; - this.reason = reason; - } - - // Getter und Setter - - public String getStartDate() { - return startDate; - } - - public String getEndDate() { - return endDate; - } - - public String getReason() { - return reason; - } -} diff --git a/PR2 KI Projekt/src/Warenwirtschaftssystem.java b/PR2 KI Projekt/src/Warenwirtschaftssystem.java deleted file mode 100644 index 2e89cf9..0000000 --- a/PR2 KI Projekt/src/Warenwirtschaftssystem.java +++ /dev/null @@ -1,2331 +0,0 @@ -import javax.swing.*; -import javax.swing.border.TitledBorder; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.table.DefaultTableModel; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.*; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -public class Warenwirtschaftssystem { - private JFrame frame; - private JPanel mainPanel; - private JMenuBar menuBar; - private JMenu menuDatei, menuVerwaltung, menuBerichte, menuProduktion, menuFinanzen, menuCRM, menuHR, menuIntegration, menuHilfe; - private JMenuItem menuItemExit, menuItemLogout, menuItemKunden, menuItemProdukte, menuItemBestellungen, menuItemLieferanten, menuItemBestandsbericht, menuItemExportBericht, menuItemHilfe; - private DefaultListModel productListModel; - private DefaultListModel supplierListModel; - private DefaultListModel orderListModel; - private DefaultListModel customerListModel; - private DefaultListModel employeeListModel; - private JList productList; - private JList supplierList; - private JList orderList; - private JList customerList; - private JList employeeList; - private List products; - private List suppliers; - private List orders; - private List customers; - private List employees; - private int productIdCounter = 1; - private int supplierIdCounter = 1; - private int orderIdCounter = 1; - private int customerIdCounter = 1; - private int employeeIdCounter = 1; - private User currentUser; - private List users; - - public Warenwirtschaftssystem() { - initializeUsers(); - showLoginDialog(); - initializeMainComponents(); - loadData(); - checkStockLevels(); - } - - private void initializeUsers() { - users = loadUsers(); - if (users.isEmpty()) { - users.add(new User(1, "admin", "admin123", "Administrator")); - users.add(new User(2, "manager", "manager123", "Manager")); - users.add(new User(3, "user", "user123", "User")); - saveUsers(users); - } - } - - private void showLoginDialog() { - JPanel loginPanel = new JPanel(new GridLayout(4, 2, 10, 10)); - loginPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Login", TitledBorder.CENTER, TitledBorder.TOP)); - - JTextField usernameField = new JTextField(); - JPasswordField passwordField = new JPasswordField(); - JButton createUserButton = new JButton("Neuen Benutzer erstellen"); - - loginPanel.add(new JLabel("Benutzername:")); - loginPanel.add(usernameField); - loginPanel.add(new JLabel("Passwort:")); - loginPanel.add(passwordField); - loginPanel.add(createUserButton); - - createUserButton.addActionListener(e -> showCreateUserDialog()); - - int option = JOptionPane.showConfirmDialog(frame, loginPanel, "Login", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); - - if (option == JOptionPane.OK_OPTION) { - String username = usernameField.getText(); - String password = new String(passwordField.getPassword()); - - Optional userOptional = users.stream().filter(user -> user.getUsername().equals(username) && user.getPassword().equals(password)).findFirst(); - - if (userOptional.isPresent()) { - currentUser = userOptional.get(); - JOptionPane.showMessageDialog(frame, "Login erfolgreich", "Erfolg", JOptionPane.INFORMATION_MESSAGE); - } else { - JOptionPane.showMessageDialog(frame, "Ungültige Anmeldeinformationen", "Fehler", JOptionPane.ERROR_MESSAGE); - showLoginDialog(); - } - } else { - System.exit(0); - } - } - - private void checkAndCreateFile(String fileName) { - File file = new File(fileName); - if (!file.exists()) { - try { - file.createNewFile(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - private void showCreateUserDialog() { - JPanel createUserPanel = new JPanel(new GridLayout(4, 2, 10, 10)); - createUserPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Neuen Benutzer erstellen", TitledBorder.CENTER, TitledBorder.TOP)); - - JTextField usernameField = new JTextField(); - JPasswordField passwordField = new JPasswordField(); - String[] roles = {"Administrator", "Manager", "User"}; - JComboBox roleComboBox = new JComboBox<>(roles); - - createUserPanel.add(new JLabel("Benutzername:")); - createUserPanel.add(usernameField); - createUserPanel.add(new JLabel("Passwort:")); - createUserPanel.add(passwordField); - createUserPanel.add(new JLabel("Rolle:")); - createUserPanel.add(roleComboBox); - - int option = JOptionPane.showConfirmDialog(frame, createUserPanel, "Neuen Benutzer erstellen", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); - - if (option == JOptionPane.OK_OPTION) { - String username = usernameField.getText(); - String password = new String(passwordField.getPassword()); - String role = (String) roleComboBox.getSelectedItem(); - - if (!username.isEmpty() && !password.isEmpty() && role != null) { - users.add(new User(users.size() + 1, username, password, role)); - saveUsers(users); - JOptionPane.showMessageDialog(frame, "Benutzer erfolgreich erstellt", "Erfolg", JOptionPane.INFORMATION_MESSAGE); - } else { - JOptionPane.showMessageDialog(frame, "Bitte alle Felder ausfüllen", "Fehler", JOptionPane.ERROR_MESSAGE); - showCreateUserDialog(); - } - } - } - - - private void initializeMainComponents() { - frame = new JFrame("Warenwirtschaftssystem"); - frame.setSize(1200, 800); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - - mainPanel = new JPanel(); - mainPanel.setLayout(new BorderLayout()); - mainPanel.setBackground(Color.decode("#F5F5F5")); - - // Überprüfen und Erstellen der Dateien - checkAndCreateFile("products.txt"); - checkAndCreateFile("suppliers.txt"); - checkAndCreateFile("orders.txt"); - checkAndCreateFile("customers.txt"); - checkAndCreateFile("employees.txt"); - checkAndCreateFile("users.txt"); - // Menüleiste erstellen - menuBar = new JMenuBar(); - - menuDatei = new JMenu("Datei"); - menuVerwaltung = new JMenu("Verwaltung"); - menuBerichte = new JMenu("Berichte"); - menuProduktion = new JMenu("Produktion"); - menuFinanzen = new JMenu("Finanzen"); - menuCRM = new JMenu("CRM"); - menuHR = new JMenu("HR"); - menuIntegration = new JMenu("Integration"); - menuHilfe = new JMenu("Hilfe"); - - menuItemExit = new JMenuItem("Beenden"); - menuItemLogout = new JMenuItem("Logout"); - menuItemKunden = new JMenuItem("Kundenverwaltung"); - menuItemProdukte = new JMenuItem("Produktverwaltung"); - menuItemBestellungen = new JMenuItem("Bestellverwaltung"); - menuItemLieferanten = new JMenuItem("Lieferantenverwaltung"); - menuItemBestandsbericht = new JMenuItem("Bestandsbericht"); - menuItemExportBericht = new JMenuItem("Bericht exportieren"); - menuItemHilfe = new JMenuItem("Hilfe"); - - menuItemExit.addActionListener(event -> System.exit(0)); - menuItemLogout.addActionListener(event -> { - currentUser = null; - showLoginDialog(); - }); - - // Menüstruktur aufbauen - menuDatei.add(menuItemLogout); - menuDatei.add(menuItemExit); - menuVerwaltung.add(menuItemKunden); - menuVerwaltung.add(menuItemProdukte); - menuVerwaltung.add(menuItemBestellungen); - menuVerwaltung.add(menuItemLieferanten); - menuBerichte.add(menuItemBestandsbericht); - menuBerichte.add(menuItemExportBericht); - menuHilfe.add(menuItemHilfe); - - menuBar.add(menuDatei); - menuBar.add(menuVerwaltung); - menuBar.add(menuBerichte); - menuBar.add(menuProduktion); - menuBar.add(menuFinanzen); - menuBar.add(menuCRM); - menuBar.add(menuHR); - menuBar.add(menuIntegration); - menuBar.add(menuHilfe); - - frame.setJMenuBar(menuBar); - - // Hauptfenster - JLabel welcomeLabel = new JLabel("Willkommen im Warenwirtschaftssystem", JLabel.CENTER); - welcomeLabel.setFont(new Font("Arial", Font.BOLD, 24)); - welcomeLabel.setForeground(Color.decode("#2C3E50")); - mainPanel.add(welcomeLabel, BorderLayout.CENTER); - - frame.add(mainPanel); - frame.setVisible(true); - - // Event-Handler für Menüelemente - menuItemKunden.addActionListener(e -> openKundenverwaltung()); - menuItemProdukte.addActionListener(e -> openProduktverwaltung()); - menuItemBestellungen.addActionListener(e -> openBestellverwaltung()); - menuItemLieferanten.addActionListener(e -> openLieferantenverwaltung()); - menuItemBestandsbericht.addActionListener(e -> openBestandsbericht()); - menuItemExportBericht.addActionListener(e -> exportBericht()); - menuItemHilfe.addActionListener(e -> showHelp()); - - // Weitere Menüpunkte - JMenuItem menuItemProduktionsplanung = new JMenuItem("Produktionsplanung"); - JMenuItem menuItemStuecklisten = new JMenuItem("Stücklisten"); - JMenuItem menuItemProduktionssteuerung = new JMenuItem("Produktionssteuerung"); - JMenuItem menuItemQualitaetskontrolle = new JMenuItem("Qualitätskontrolle"); - JMenuItem menuItemProduktionskosten = new JMenuItem("Produktionskosten"); - - menuProduktion.add(menuItemProduktionsplanung); - menuProduktion.add(menuItemStuecklisten); - menuProduktion.add(menuItemProduktionssteuerung); - menuProduktion.add(menuItemQualitaetskontrolle); - menuProduktion.add(menuItemProduktionskosten); - - JMenuItem menuItemBuchhaltung = new JMenuItem("Buchhaltung"); - JMenuItem menuItemRechnungswesen = new JMenuItem("Rechnungswesen"); - JMenuItem menuItemKostenrechnung = new JMenuItem("Kostenrechnung"); - JMenuItem menuItemBudgetierung = new JMenuItem("Budgetierung"); - JMenuItem menuItemFinanzberichte = new JMenuItem("Finanzberichte"); - - menuFinanzen.add(menuItemBuchhaltung); - menuFinanzen.add(menuItemRechnungswesen); - menuFinanzen.add(menuItemKostenrechnung); - menuFinanzen.add(menuItemBudgetierung); - menuFinanzen.add(menuItemFinanzberichte); - - JMenuItem menuItemKontaktmanagement = new JMenuItem("Kontaktmanagement"); - JMenuItem menuItemVertriebschancen = new JMenuItem("Vertriebschancen"); - JMenuItem menuItemMarketingkampagnen = new JMenuItem("Marketingkampagnen"); - JMenuItem menuItemKundendienst = new JMenuItem("Kundendienst"); - JMenuItem menuItemKundenzufriedenheit = new JMenuItem("Kundenzufriedenheit"); - - menuCRM.add(menuItemKontaktmanagement); - menuCRM.add(menuItemVertriebschancen); - menuCRM.add(menuItemMarketingkampagnen); - menuCRM.add(menuItemKundendienst); - menuCRM.add(menuItemKundenzufriedenheit); - - - - JMenuItem menuItemPersonalverwaltung = new JMenuItem("Personalverwaltung"); - JMenuItem menuItemRekrutierung = new JMenuItem("Rekrutierung"); - JMenuItem menuItemMitarbeiterentwicklung = new JMenuItem("Mitarbeiterentwicklung"); - JMenuItem menuItemZeitmanagement = new JMenuItem("Zeitmanagement"); - JMenuItem menuItemLeistungsbewertung = new JMenuItem("Leistungsbewertung"); - JMenuItem menuItemGehaltsabrechnung = new JMenuItem("Gehaltsabrechnung"); - JMenuItem menuItemUrlaub = new JMenuItem("Urlaub verwalten"); - JMenuItem menuItemTransfer = new JMenuItem("Transfer verwalten"); - JMenuItem menuItemKündigung = new JMenuItem("Kündigung verwalten"); - - menuHR.add(menuItemPersonalverwaltung); - menuHR.add(menuItemRekrutierung); - menuHR.add(menuItemMitarbeiterentwicklung); - menuHR.add(menuItemZeitmanagement); - menuHR.add(menuItemLeistungsbewertung); - menuHR.add(menuItemGehaltsabrechnung); - menuHR.add(menuItemUrlaub); - menuHR.add(menuItemTransfer); - menuHR.add(menuItemKündigung); - - JMenuItem menuItemSystemintegration = new JMenuItem("Systemintegration"); - JMenuItem menuItemDatenschnittstellen = new JMenuItem("Datenschnittstellen"); - JMenuItem menuItemEchtzeitDaten = new JMenuItem("Echtzeit-Daten"); - JMenuItem menuItemCloudServices = new JMenuItem("Cloud-Services"); - JMenuItem menuItemEDI = new JMenuItem("EDI"); - - menuIntegration.add(menuItemSystemintegration); - menuIntegration.add(menuItemDatenschnittstellen); - menuIntegration.add(menuItemEchtzeitDaten); - menuIntegration.add(menuItemCloudServices); - menuIntegration.add(menuItemEDI); - - menuItemProduktionsplanung.addActionListener(e -> openProduktionsplanung()); - menuItemStuecklisten.addActionListener(e -> openStuecklisten()); - menuItemProduktionssteuerung.addActionListener(e -> openProduktionssteuerung()); - menuItemQualitaetskontrolle.addActionListener(e -> openQualitaetskontrolle()); - menuItemProduktionskosten.addActionListener(e -> openProduktionskosten()); - - menuItemBuchhaltung.addActionListener(e -> openBuchhaltung()); - menuItemRechnungswesen.addActionListener(e -> openRechnungswesen()); - menuItemKostenrechnung.addActionListener(e -> openKostenrechnung()); - menuItemBudgetierung.addActionListener(e -> openBudgetierung()); - menuItemFinanzberichte.addActionListener(e -> openFinanzberichte()); - - menuItemKontaktmanagement.addActionListener(e -> openKontaktmanagement()); - menuItemVertriebschancen.addActionListener(e -> openVertriebschancen()); - menuItemMarketingkampagnen.addActionListener(e -> openMarketingkampagnen()); - menuItemKundendienst.addActionListener(e -> openKundendienst()); - menuItemKundenzufriedenheit.addActionListener(e -> openKundenzufriedenheit()); - - menuItemPersonalverwaltung.addActionListener(e -> openPersonalverwaltung()); - menuItemRekrutierung.addActionListener(e -> openRekrutierung()); - menuItemMitarbeiterentwicklung.addActionListener(e -> openMitarbeiterentwicklung()); - menuItemZeitmanagement.addActionListener(e -> openZeitmanagement()); - menuItemLeistungsbewertung.addActionListener(e -> openLeistungsbewertung()); - menuItemGehaltsabrechnung.addActionListener(e -> openGehaltsabrechnung()); - menuItemUrlaub.addActionListener(e -> openUrlaubVerwaltung()); - menuItemTransfer.addActionListener(e -> openTransferVerwaltung()); - menuItemKündigung.addActionListener(e -> openKündigungVerwaltung()); - - menuItemSystemintegration.addActionListener(e -> openSystemintegration()); - menuItemDatenschnittstellen.addActionListener(e -> openDatenschnittstellen()); - menuItemEchtzeitDaten.addActionListener(e -> openEchtzeitDaten()); - menuItemCloudServices.addActionListener(e -> openCloudServices()); - menuItemEDI.addActionListener(e -> openEDI()); - } - - private void loadData() { - products = loadProducts(); - suppliers = loadSuppliers(); - orders = loadOrders(); - customers = loadCustomers(); - employees = loadEmployees(); - - if (!products.isEmpty()) { - productIdCounter = products.stream().mapToInt(Product::getId).max().orElse(0) + 1; - } - if (!suppliers.isEmpty()) { - supplierIdCounter = suppliers.stream().mapToInt(Supplier::getId).max().orElse(0) + 1; - } - if (!orders.isEmpty()) { - orderIdCounter = orders.stream().mapToInt(Order::getId).max().orElse(0) + 1; - } - if (!customers.isEmpty()) { - customerIdCounter = customers.stream().mapToInt(Customer::getId).max().orElse(0) + 1; - } - if (!employees.isEmpty()) { - employeeIdCounter = employees.stream().mapToInt(Employee::getId).max().orElse(0) + 1; - } - } - - private void checkStockLevels() { - for (Product product : products) { - if (product.getAvailableStock() < product.getMinimumStock()) { - JOptionPane.showMessageDialog(frame, "Warnung: Der Mindestbestand für " + product.getProductName() + " wurde unterschritten!", "Mindestbestand Warnung", JOptionPane.WARNING_MESSAGE); - } - } - } - - private void openKundenverwaltung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Kundenverwaltung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Liste zur Anzeige der Kunden - customerListModel = new DefaultListModel<>(); - customerList = new JList<>(customerListModel); - customerList.setCellRenderer(new CustomerCellRenderer()); - customerList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - JScrollPane scrollPane = new JScrollPane(customerList); - mainPanel.add(scrollPane, BorderLayout.CENTER); - - // Panel zum Hinzufügen neuer Kunden - JPanel inputPanel = new JPanel(new GridLayout(6, 2, 10, 10)); - inputPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Kunde hinzufügen", TitledBorder.CENTER, TitledBorder.TOP)); - inputPanel.setBackground(Color.decode("#ECF0F1")); - - inputPanel.add(new JLabel("Name:")); - JTextField nameField = new JTextField(); - inputPanel.add(nameField); - - inputPanel.add(new JLabel("Adresse:")); - JTextField addressField = new JTextField(); - inputPanel.add(addressField); - - inputPanel.add(new JLabel("Kontaktinformationen:")); - JTextField contactField = new JTextField(); - inputPanel.add(contactField); - - inputPanel.add(new JLabel("Kundensegment:")); - JTextField segmentField = new JTextField(); - inputPanel.add(segmentField); - - JButton addButton = new JButton("Hinzufügen"); - addButton.setBackground(Color.decode("#2C3E50")); - addButton.setForeground(Color.WHITE); - JButton deleteButton = new JButton("Löschen"); - deleteButton.setBackground(Color.decode("#E74C3C")); - deleteButton.setForeground(Color.WHITE); - inputPanel.add(addButton); - inputPanel.add(deleteButton); - - mainPanel.add(inputPanel, BorderLayout.SOUTH); - - addButton.addActionListener(e -> { - String name = nameField.getText(); - String address = addressField.getText(); - String contact = contactField.getText(); - String segment = segmentField.getText(); - - if (name.isEmpty() || address.isEmpty() || contact.isEmpty() || segment.isEmpty()) { - JOptionPane.showMessageDialog(frame, "Bitte alle Felder ausfüllen", "Fehler", JOptionPane.ERROR_MESSAGE); - return; - } - - Customer customer = new Customer(customerIdCounter++, name, address, contact, segment); - customers.add(customer); - saveCustomers(customers); - - customerListModel.addElement(customer); - - // Felder leeren - nameField.setText(""); - addressField.setText(""); - contactField.setText(""); - segmentField.setText(""); - }); - - deleteButton.addActionListener(e -> { - Customer selectedCustomer = customerList.getSelectedValue(); - if (selectedCustomer != null) { - customers.removeIf(c -> c.getId() == selectedCustomer.getId()); - saveCustomers(customers); - customerListModel.removeElement(selectedCustomer); - } - }); - - customerList.addListSelectionListener(e -> { - Customer selectedCustomer = customerList.getSelectedValue(); - if (selectedCustomer != null) { - showCustomerDetails(selectedCustomer); - } - }); - - updateCustomerList(); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void showCustomerDetails(Customer customer) { - JPanel customerDetailsPanel = new JPanel(new GridLayout(5, 2, 10, 10)); - customerDetailsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Kundendetails", TitledBorder.CENTER, TitledBorder.TOP)); - customerDetailsPanel.setBackground(Color.decode("#ECF0F1")); - - customerDetailsPanel.add(new JLabel("Name:")); - customerDetailsPanel.add(new JLabel(customer.getName())); - - customerDetailsPanel.add(new JLabel("Adresse:")); - customerDetailsPanel.add(new JLabel(customer.getAddress())); - - customerDetailsPanel.add(new JLabel("Kontaktinformationen:")); - customerDetailsPanel.add(new JLabel(customer.getContact())); - - customerDetailsPanel.add(new JLabel("Kundensegment:")); - customerDetailsPanel.add(new JLabel(customer.getSegment())); - - JButton backButton = new JButton("Zurück"); - backButton.setBackground(Color.decode("#2C3E50")); - backButton.setForeground(Color.WHITE); - customerDetailsPanel.add(backButton); - - backButton.addActionListener(e -> openKundenverwaltung()); - - mainPanel.removeAll(); - mainPanel.add(customerDetailsPanel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void openProduktverwaltung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Produktverwaltung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Liste zur Anzeige der Produkte - productListModel = new DefaultListModel<>(); - productList = new JList<>(productListModel); - productList.setCellRenderer(new ProductCellRenderer()); - productList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - JScrollPane scrollPane = new JScrollPane(productList); - mainPanel.add(scrollPane, BorderLayout.CENTER); - - // Panel zum Hinzufügen neuer Produkte - JPanel inputPanel = new JPanel(new GridLayout(12, 2, 10, 10)); - inputPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Produkt hinzufügen", TitledBorder.CENTER, TitledBorder.TOP)); - inputPanel.setBackground(Color.decode("#ECF0F1")); - - inputPanel.add(new JLabel("Artikelnummer:")); - JTextField itemNumberField = new JTextField(); - inputPanel.add(itemNumberField); - - inputPanel.add(new JLabel("Produktname:")); - JTextField productNameField = new JTextField(); - inputPanel.add(productNameField); - - inputPanel.add(new JLabel("Beschreibung:")); - JTextField descriptionField = new JTextField(); - inputPanel.add(descriptionField); - - inputPanel.add(new JLabel("Kategorie:")); - JTextField categoryField = new JTextField(); - inputPanel.add(categoryField); - - inputPanel.add(new JLabel("Verfügbarer Bestand:")); - JTextField availableStockField = new JTextField(); - inputPanel.add(availableStockField); - - inputPanel.add(new JLabel("Mindestbestand:")); - JTextField minimumStockField = new JTextField(); - inputPanel.add(minimumStockField); - - inputPanel.add(new JLabel("Lagerort:")); - JTextField storageLocationField = new JTextField(); - inputPanel.add(storageLocationField); - - inputPanel.add(new JLabel("Einkaufspreis:")); - JTextField purchasePriceField = new JTextField(); - inputPanel.add(purchasePriceField); - - inputPanel.add(new JLabel("Verkaufspreis:")); - JTextField sellingPriceField = new JTextField(); - inputPanel.add(sellingPriceField); - - inputPanel.add(new JLabel("Hauptlieferant:")); - JTextField mainSupplierField = new JTextField(); - inputPanel.add(mainSupplierField); - - inputPanel.add(new JLabel("Bildpfad:")); - JTextField imagePathField = new JTextField(); - inputPanel.add(imagePathField); - - JButton addButton = new JButton("Hinzufügen"); - addButton.setBackground(Color.decode("#2C3E50")); - addButton.setForeground(Color.WHITE); - JButton deleteButton = new JButton("Löschen"); - deleteButton.setBackground(Color.decode("#E74C3C")); - deleteButton.setForeground(Color.WHITE); - inputPanel.add(addButton); - inputPanel.add(deleteButton); - - mainPanel.add(inputPanel, BorderLayout.SOUTH); - - addButton.addActionListener(e -> { - try { - String itemNumber = itemNumberField.getText(); - String productName = productNameField.getText(); - String description = descriptionField.getText(); - String category = categoryField.getText(); - int availableStock = Integer.parseInt(availableStockField.getText()); - int minimumStock = Integer.parseInt(minimumStockField.getText()); - String storageLocation = storageLocationField.getText(); - double purchasePrice = Double.parseDouble(purchasePriceField.getText()); - double sellingPrice = Double.parseDouble(sellingPriceField.getText()); - String mainSupplier = mainSupplierField.getText(); - String imagePath = imagePathField.getText(); - - Product product = new Product(productIdCounter++, itemNumber, productName, description, category, availableStock, minimumStock, storageLocation, purchasePrice, sellingPrice, mainSupplier, imagePath); - products.add(product); - saveProducts(products); - - productListModel.addElement(product); - - // Felder leeren - itemNumberField.setText(""); - productNameField.setText(""); - descriptionField.setText(""); - categoryField.setText(""); - availableStockField.setText(""); - minimumStockField.setText(""); - storageLocationField.setText(""); - purchasePriceField.setText(""); - sellingPriceField.setText(""); - mainSupplierField.setText(""); - imagePathField.setText(""); - } catch (NumberFormatException ex) { - JOptionPane.showMessageDialog(frame, "Bitte gültige Werte eingeben", "Fehler", JOptionPane.ERROR_MESSAGE); - } - }); - - deleteButton.addActionListener(e -> { - Product selectedProduct = productList.getSelectedValue(); - if (selectedProduct != null) { - products.removeIf(p -> p.getId() == selectedProduct.getId()); - saveProducts(products); - productListModel.removeElement(selectedProduct); - } - }); - - productList.addListSelectionListener(e -> { - Product selectedProduct = productList.getSelectedValue(); - if (selectedProduct != null) { - showProductDetails(selectedProduct); - } - }); - - updateProductList(); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void showProductDetails(Product product) { - JPanel productDetailsPanel = new JPanel(new GridLayout(12, 2, 10, 10)); - productDetailsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Produktdetails", TitledBorder.CENTER, TitledBorder.TOP)); - productDetailsPanel.setBackground(Color.decode("#ECF0F1")); - - productDetailsPanel.add(new JLabel("Artikelnummer:")); - productDetailsPanel.add(new JLabel(product.getItemNumber())); - - productDetailsPanel.add(new JLabel("Produktname:")); - productDetailsPanel.add(new JLabel(product.getProductName())); - - productDetailsPanel.add(new JLabel("Beschreibung:")); - productDetailsPanel.add(new JLabel(product.getDescription())); - - productDetailsPanel.add(new JLabel("Kategorie:")); - productDetailsPanel.add(new JLabel(product.getCategory())); - - productDetailsPanel.add(new JLabel("Verfügbarer Bestand:")); - productDetailsPanel.add(new JLabel(String.valueOf(product.getAvailableStock()))); - - productDetailsPanel.add(new JLabel("Mindestbestand:")); - productDetailsPanel.add(new JLabel(String.valueOf(product.getMinimumStock()))); - - productDetailsPanel.add(new JLabel("Lagerort:")); - productDetailsPanel.add(new JLabel(product.getStorageLocation())); - - productDetailsPanel.add(new JLabel("Einkaufspreis:")); - productDetailsPanel.add(new JLabel(String.valueOf(product.getPurchasePrice()))); - - productDetailsPanel.add(new JLabel("Verkaufspreis:")); - productDetailsPanel.add(new JLabel(String.valueOf(product.getSellingPrice()))); - - productDetailsPanel.add(new JLabel("Hauptlieferant:")); - productDetailsPanel.add(new JLabel(product.getMainSupplier())); - - productDetailsPanel.add(new JLabel("Bild:")); - if (!product.getImagePath().isEmpty()) { - ImageIcon productImage = new ImageIcon(product.getImagePath()); - JLabel imageLabel = new JLabel(productImage); - imageLabel.setPreferredSize(new Dimension(100, 100)); - imageLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); - productDetailsPanel.add(imageLabel); - } else { - productDetailsPanel.add(new JLabel("Kein Bild verfügbar")); - } - - JButton backButton = new JButton("Zurück"); - backButton.setBackground(Color.decode("#2C3E50")); - backButton.setForeground(Color.WHITE); - productDetailsPanel.add(backButton); - - backButton.addActionListener(e -> openProduktverwaltung()); - - mainPanel.removeAll(); - mainPanel.add(productDetailsPanel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void openBestellverwaltung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Bestellverwaltung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Liste zur Anzeige der Bestellungen - orderListModel = new DefaultListModel<>(); - orderList = new JList<>(orderListModel); - orderList.setCellRenderer(new OrderCellRenderer()); - orderList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - JScrollPane scrollPane = new JScrollPane(orderList); - mainPanel.add(scrollPane, BorderLayout.CENTER); - - // Panel zum Hinzufügen neuer Bestellungen - JPanel inputPanel = new JPanel(new GridLayout(7, 2, 10, 10)); - inputPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Bestellung hinzufügen", TitledBorder.CENTER, TitledBorder.TOP)); - inputPanel.setBackground(Color.decode("#ECF0F1")); - - inputPanel.add(new JLabel("Produkt:")); - JTextField productField = new JTextField(); - inputPanel.add(productField); - - inputPanel.add(new JLabel("Menge:")); - JTextField quantityField = new JTextField(); - inputPanel.add(quantityField); - - inputPanel.add(new JLabel("Datum:")); - JTextField dateField = new JTextField(); - inputPanel.add(dateField); - - inputPanel.add(new JLabel("Lieferdatum:")); - JTextField deliveryDateField = new JTextField(); - inputPanel.add(deliveryDateField); - - inputPanel.add(new JLabel("Status:")); - String[] statuses = {"Bestellt", "Versendet", "Geliefert"}; - JComboBox statusComboBox = new JComboBox<>(statuses); - inputPanel.add(statusComboBox); - - JButton addButton = new JButton("Hinzufügen"); - addButton.setBackground(Color.decode("#2C3E50")); - addButton.setForeground(Color.WHITE); - JButton deleteButton = new JButton("Löschen"); - deleteButton.setBackground(Color.decode("#E74C3C")); - deleteButton.setForeground(Color.WHITE); - inputPanel.add(addButton); - inputPanel.add(deleteButton); - - mainPanel.add(inputPanel, BorderLayout.SOUTH); - - addButton.addActionListener(e -> { - try { - String product = productField.getText(); - int quantity = Integer.parseInt(quantityField.getText()); - String date = dateField.getText(); - String deliveryDate = deliveryDateField.getText(); - String status = (String) statusComboBox.getSelectedItem(); - - Order order = new Order(orderIdCounter++, product, quantity, date, deliveryDate, status); - orders.add(order); - saveOrders(orders); - - orderListModel.addElement(order); - - // Felder leeren - productField.setText(""); - quantityField.setText(""); - dateField.setText(""); - deliveryDateField.setText(""); - } catch (NumberFormatException ex) { - JOptionPane.showMessageDialog(frame, "Bitte gültige Werte eingeben", "Fehler", JOptionPane.ERROR_MESSAGE); - } - }); - - deleteButton.addActionListener(e -> { - Order selectedOrder = orderList.getSelectedValue(); - if (selectedOrder != null) { - orders.removeIf(o -> o.getId() == selectedOrder.getId()); - saveOrders(orders); - orderListModel.removeElement(selectedOrder); - } - }); - - orderList.addListSelectionListener(e -> { - Order selectedOrder = orderList.getSelectedValue(); - if (selectedOrder != null) { - showOrderDetails(selectedOrder); - } - }); - - updateOrderList(); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void showOrderDetails(Order order) { - JPanel orderDetailsPanel = new JPanel(new GridLayout(6, 2, 10, 10)); - orderDetailsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Bestelldetails", TitledBorder.CENTER, TitledBorder.TOP)); - orderDetailsPanel.setBackground(Color.decode("#ECF0F1")); - - orderDetailsPanel.add(new JLabel("Bestellnummer:")); - orderDetailsPanel.add(new JLabel(String.valueOf(order.getId()))); - - orderDetailsPanel.add(new JLabel("Produkt:")); - orderDetailsPanel.add(new JLabel(order.getProduct())); - - orderDetailsPanel.add(new JLabel("Menge:")); - orderDetailsPanel.add(new JLabel(String.valueOf(order.getQuantity()))); - - orderDetailsPanel.add(new JLabel("Datum:")); - orderDetailsPanel.add(new JLabel(order.getDate())); - - orderDetailsPanel.add(new JLabel("Lieferdatum:")); - orderDetailsPanel.add(new JLabel(order.getDeliveryDate())); - - orderDetailsPanel.add(new JLabel("Status:")); - JLabel statusLabel = new JLabel(order.getStatus()); - switch (order.getStatus()) { - case "Bestellt": - statusLabel.setForeground(Color.RED); - break; - case "Versendet": - statusLabel.setForeground(Color.YELLOW); - break; - case "Geliefert": - statusLabel.setForeground(Color.GREEN); - break; - } - orderDetailsPanel.add(statusLabel); - - JButton backButton = new JButton("Zurück"); - backButton.setBackground(Color.decode("#2C3E50")); - backButton.setForeground(Color.WHITE); - orderDetailsPanel.add(backButton); - - backButton.addActionListener(e -> openBestellverwaltung()); - - mainPanel.removeAll(); - mainPanel.add(orderDetailsPanel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void openLieferantenverwaltung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Lieferantenverwaltung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Liste zur Anzeige der Lieferanten - supplierListModel = new DefaultListModel<>(); - supplierList = new JList<>(supplierListModel); - supplierList.setCellRenderer(new SupplierCellRenderer()); - supplierList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - JScrollPane scrollPane = new JScrollPane(supplierList); - mainPanel.add(scrollPane, BorderLayout.CENTER); - - // Panel zum Hinzufügen neuer Lieferanten - JPanel inputPanel = new JPanel(new GridLayout(7, 2, 10, 10)); - inputPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Lieferant hinzufügen", TitledBorder.CENTER, TitledBorder.TOP)); - inputPanel.setBackground(Color.decode("#ECF0F1")); - - inputPanel.add(new JLabel("Name:")); - JTextField nameField = new JTextField(); - inputPanel.add(nameField); - - inputPanel.add(new JLabel("Adresse:")); - JTextField addressField = new JTextField(); - inputPanel.add(addressField); - - inputPanel.add(new JLabel("Kontaktinformationen:")); - JTextField contactField = new JTextField(); - inputPanel.add(contactField); - - inputPanel.add(new JLabel("Vertragsdetails:")); - JTextField contractDetailsField = new JTextField(); - inputPanel.add(contractDetailsField); - - inputPanel.add(new JLabel("Bestellhistorie:")); - JTextField orderHistoryField = new JTextField(); - inputPanel.add(orderHistoryField); - - inputPanel.add(new JLabel("Qualitätsbewertung:")); - JTextField qualityRatingField = new JTextField(); - inputPanel.add(qualityRatingField); - - JButton addButton = new JButton("Hinzufügen"); - addButton.setBackground(Color.decode("#2C3E50")); - addButton.setForeground(Color.WHITE); - JButton deleteButton = new JButton("Löschen"); - deleteButton.setBackground(Color.decode("#E74C3C")); - deleteButton.setForeground(Color.WHITE); - inputPanel.add(addButton); - inputPanel.add(deleteButton); - - mainPanel.add(inputPanel, BorderLayout.SOUTH); - - addButton.addActionListener(e -> { - String name = nameField.getText(); - String address = addressField.getText(); - String contact = contactField.getText(); - String contractDetails = contractDetailsField.getText(); - String orderHistory = orderHistoryField.getText(); - String qualityRating = qualityRatingField.getText(); - - if (name.isEmpty() || address.isEmpty() || contact.isEmpty() || contractDetails.isEmpty() || orderHistory.isEmpty() || qualityRating.isEmpty()) { - JOptionPane.showMessageDialog(frame, "Bitte alle Felder ausfüllen", "Fehler", JOptionPane.ERROR_MESSAGE); - return; - } - - Supplier supplier = new Supplier(supplierIdCounter++, name, address, contact, contractDetails, orderHistory, qualityRating); - suppliers.add(supplier); - saveSuppliers(suppliers); - - supplierListModel.addElement(supplier); - - // Felder leeren - nameField.setText(""); - addressField.setText(""); - contactField.setText(""); - contractDetailsField.setText(""); - orderHistoryField.setText(""); - qualityRatingField.setText(""); - }); - - deleteButton.addActionListener(e -> { - Supplier selectedSupplier = supplierList.getSelectedValue(); - if (selectedSupplier != null) { - suppliers.removeIf(s -> s.getId() == selectedSupplier.getId()); - saveSuppliers(suppliers); - supplierListModel.removeElement(selectedSupplier); - } - }); - - supplierList.addListSelectionListener(e -> { - Supplier selectedSupplier = supplierList.getSelectedValue(); - if (selectedSupplier != null) { - showSupplierDetails(selectedSupplier); - } - }); - - updateSupplierList(); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void showSupplierDetails(Supplier supplier) { - JPanel supplierDetailsPanel = new JPanel(new GridLayout(7, 2, 10, 10)); - supplierDetailsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Lieferantendetails", TitledBorder.CENTER, TitledBorder.TOP)); - supplierDetailsPanel.setBackground(Color.decode("#ECF0F1")); - - supplierDetailsPanel.add(new JLabel("Lieferantennummer:")); - supplierDetailsPanel.add(new JLabel(String.valueOf(supplier.getId()))); - - supplierDetailsPanel.add(new JLabel("Name:")); - supplierDetailsPanel.add(new JLabel(supplier.getName())); - - supplierDetailsPanel.add(new JLabel("Adresse:")); - supplierDetailsPanel.add(new JLabel(supplier.getAddress())); - - supplierDetailsPanel.add(new JLabel("Kontaktinformationen:")); - supplierDetailsPanel.add(new JLabel(supplier.getContact())); - - supplierDetailsPanel.add(new JLabel("Vertragsdetails:")); - supplierDetailsPanel.add(new JLabel(supplier.getContractDetails())); - - supplierDetailsPanel.add(new JLabel("Bestellhistorie:")); - supplierDetailsPanel.add(new JLabel(supplier.getOrderHistory())); - - supplierDetailsPanel.add(new JLabel("Qualitätsbewertung:")); - supplierDetailsPanel.add(new JLabel(supplier.getQualityRating())); - - JButton backButton = new JButton("Zurück"); - backButton.setBackground(Color.decode("#2C3E50")); - backButton.setForeground(Color.WHITE); - supplierDetailsPanel.add(backButton); - - backButton.addActionListener(e -> openLieferantenverwaltung()); - - mainPanel.removeAll(); - mainPanel.add(supplierDetailsPanel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void openBestandsbericht() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Bestandsbericht", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Tabelle zur Anzeige der Bestände - String[] columns = {"Artikelnummer", "Produktname", "Verfügbarer Bestand", "Mindestbestand", "Lagerwert"}; - DefaultTableModel inventoryTableModel = new DefaultTableModel(columns, 0); - JTable table = new JTable(inventoryTableModel); - JScrollPane scrollPane = new JScrollPane(table); - mainPanel.add(scrollPane, BorderLayout.CENTER); - - for (Product product : products) { - Object[] row = {product.getItemNumber(), product.getProductName(), product.getAvailableStock(), product.getMinimumStock(), product.getAvailableStock() * product.getSellingPrice()}; - inventoryTableModel.addRow(row); - } - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void exportBericht() { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setDialogTitle("Bericht exportieren"); - int userSelection = fileChooser.showSaveDialog(frame); - - if (userSelection == JFileChooser.APPROVE_OPTION) { - File fileToSave = fileChooser.getSelectedFile(); - - try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileToSave))) { - StringBuilder sb = new StringBuilder(); - - for (Product product : products) { - sb.append(product.getItemNumber()).append(","); - sb.append(product.getProductName()).append(","); - sb.append(product.getAvailableStock()).append(","); - sb.append(product.getMinimumStock()).append(","); - sb.append(product.getAvailableStock() * product.getSellingPrice()).append("\n"); - } - - writer.write(sb.toString()); - JOptionPane.showMessageDialog(frame, "Bericht erfolgreich exportiert", "Erfolg", JOptionPane.INFORMATION_MESSAGE); - } catch (IOException e) { - JOptionPane.showMessageDialog(frame, "Fehler beim Exportieren des Berichts", "Fehler", JOptionPane.ERROR_MESSAGE); - } - } - } - - private void openProduktionsplanung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Produktionsplanung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - JPanel panel = new JPanel(new GridLayout(5, 2, 10, 10)); - panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Produktionsplanung", TitledBorder.CENTER, TitledBorder.TOP)); - panel.setBackground(Color.decode("#ECF0F1")); - - JButton createPlanButton = new JButton("Plan erstellen"); - JButton manageBOMButton = new JButton("Stückliste anzeigen"); - JButton productionControlButton = new JButton("Steuerung anzeigen"); - JButton qualityControlButton = new JButton("Kontrolle anzeigen"); - JButton productionCostsButton = new JButton("Kosten anzeigen"); - - panel.add(new JLabel("Plan erstellen")); - panel.add(createPlanButton); - - panel.add(new JLabel("Stückliste verwalten")); - panel.add(manageBOMButton); - - panel.add(new JLabel("Produktionssteuerung")); - panel.add(productionControlButton); - - panel.add(new JLabel("Qualitätskontrolle")); - panel.add(qualityControlButton); - - panel.add(new JLabel("Produktionskosten")); - panel.add(productionCostsButton); - - createPlanButton.addActionListener(e -> showCreatePlanDialog()); - manageBOMButton.addActionListener(e -> openStuecklisten()); - productionControlButton.addActionListener(e -> openProduktionssteuerung()); - qualityControlButton.addActionListener(e -> openQualitaetskontrolle()); - productionCostsButton.addActionListener(e -> openProduktionskosten()); - - mainPanel.add(panel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - private void showCreatePlanDialog() { - JDialog dialog = new JDialog(frame, "Produktionsplan erstellen", true); - dialog.setSize(400, 300); - dialog.setLocationRelativeTo(frame); - - JPanel panel = new JPanel(new GridLayout(6, 2, 10, 10)); - panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Produktionsplan", TitledBorder.CENTER, TitledBorder.TOP)); - panel.setBackground(Color.decode("#ECF0F1")); - - panel.add(new JLabel("Produkt:")); - JTextField productField = new JTextField(); - panel.add(productField); - - panel.add(new JLabel("Menge:")); - JTextField quantityField = new JTextField(); - panel.add(quantityField); - - panel.add(new JLabel("Startdatum:")); - JTextField startDateField = new JTextField(); - panel.add(startDateField); - - panel.add(new JLabel("Enddatum:")); - JTextField endDateField = new JTextField(); - panel.add(endDateField); - - JButton saveButton = new JButton("Speichern"); - panel.add(saveButton); - - saveButton.addActionListener(e -> { - String product = productField.getText(); - int quantity = Integer.parseInt(quantityField.getText()); - String startDate = startDateField.getText(); - String endDate = endDateField.getText(); - - // Speichern des Produktionsplans (Implementierung erforderlich) - saveProductionPlan(product, quantity, startDate, endDate); - - dialog.dispose(); - }); - - dialog.add(panel); - dialog.setVisible(true); - } - - private void saveProductionPlan(String product, int quantity, String startDate, String endDate) { - // Implementiere die Logik zum Speichern des Produktionsplans (z.B. in einer Datei oder Datenbank) - // Beispiel: Produktionsplan in eine Datei speichern - try (BufferedWriter writer = new BufferedWriter(new FileWriter("production_plans.txt", true))) { - writer.write(product + "," + quantity + "," + startDate + "," + endDate); - writer.newLine(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private void openStuecklisten() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Stücklisten", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Beispielhafte Implementierung zur Anzeige der Stücklisten - JPanel panel = new JPanel(new BorderLayout()); - DefaultTableModel bomModel = new DefaultTableModel(new Object[]{"Artikelnummer", "Komponente", "Menge"}, 0); - JTable bomTable = new JTable(bomModel); - JScrollPane scrollPane = new JScrollPane(bomTable); - panel.add(scrollPane, BorderLayout.CENTER); - - // Beispiel: Fügen Sie hier Stücklisten hinzu - bomModel.addRow(new Object[]{"P001", "K001", 5}); - bomModel.addRow(new Object[]{"P001", "K002", 3}); - - mainPanel.add(panel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void openProduktionssteuerung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Produktionssteuerung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Beispielhafte Implementierung zur Anzeige der Produktionssteuerung - JPanel panel = new JPanel(new BorderLayout()); - DefaultTableModel controlModel = new DefaultTableModel(new Object[]{"Produkt", "Status", "Fortschritt"}, 0); - JTable controlTable = new JTable(controlModel); - JScrollPane scrollPane = new JScrollPane(controlTable); - panel.add(scrollPane, BorderLayout.CENTER); - - // Beispiel: Fügen Sie hier Produktionssteuerungsdaten hinzu - controlModel.addRow(new Object[]{"Produkt A", "In Produktion", "50%"}); - controlModel.addRow(new Object[]{"Produkt B", "Geplant", "0%"}); - - mainPanel.add(panel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void openQualitaetskontrolle() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Qualitätskontrolle", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Beispielhafte Implementierung zur Anzeige der Qualitätskontrolle - JPanel panel = new JPanel(new BorderLayout()); - DefaultTableModel qualityModel = new DefaultTableModel(new Object[]{"Produkt", "Tester", "Ergebnis", "Datum"}, 0); - JTable qualityTable = new JTable(qualityModel); - JScrollPane scrollPane = new JScrollPane(qualityTable); - panel.add(scrollPane, BorderLayout.CENTER); - - // Beispiel: Fügen Sie hier Qualitätskontrolldaten hinzu - qualityModel.addRow(new Object[]{"Produkt A", "Tester 1", "Bestanden", "2024-01-01"}); - qualityModel.addRow(new Object[]{"Produkt B", "Tester 2", "Nicht bestanden", "2024-01-02"}); - - mainPanel.add(panel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - private void openProduktionskosten() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Produktionskosten", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Beispielhafte Implementierung zur Anzeige der Produktionskosten - JPanel panel = new JPanel(new BorderLayout()); - DefaultTableModel costsModel = new DefaultTableModel(new Object[]{"Produkt", "Materialkosten", "Arbeitskosten", "Gesamtkosten"}, 0); - JTable costsTable = new JTable(costsModel); - JScrollPane scrollPane = new JScrollPane(costsTable); - panel.add(scrollPane, BorderLayout.CENTER); - - // Beispiel: Fügen Sie hier Produktionskostendaten hinzu - costsModel.addRow(new Object[]{"Produkt A", 5000, 2000, 7000}); - costsModel.addRow(new Object[]{"Produkt B", 3000, 1500, 4500}); - - mainPanel.add(panel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - private void openBuchhaltung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Buchhaltung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Tabelle zur Anzeige der Buchhaltungsdaten - String[] columns = {"Kontonummer", "Beschreibung", "Saldo"}; - DefaultTableModel buchhaltungTableModel = new DefaultTableModel(columns, 0); - JTable table = new JTable(buchhaltungTableModel); - JScrollPane scrollPane = new JScrollPane(table); - mainPanel.add(scrollPane, BorderLayout.CENTER); - - // Beispielhafte Buchhaltungsdaten hinzufügen - buchhaltungTableModel.addRow(new Object[]{"1000", "Bankkonto", 50000}); - buchhaltungTableModel.addRow(new Object[]{"2000", "Verbindlichkeiten", -20000}); - buchhaltungTableModel.addRow(new Object[]{"3000", "Eigenkapital", 30000}); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - - private void openRechnungswesen() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Rechnungswesen", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Tabelle zur Anzeige der Rechnungswesen-Daten - String[] columns = {"Rechnungsnummer", "Datum", "Betrag", "Status"}; - DefaultTableModel rechnungswesenTableModel = new DefaultTableModel(columns, 0); - JTable table = new JTable(rechnungswesenTableModel); - JScrollPane scrollPane = new JScrollPane(table); - mainPanel.add(scrollPane, BorderLayout.CENTER); - - // Beispielhafte Rechnungswesen-Daten hinzufügen - rechnungswesenTableModel.addRow(new Object[]{"2024-01", "2024-01-10", 1500, "Bezahlt"}); - rechnungswesenTableModel.addRow(new Object[]{"2024-02", "2024-01-15", 3000, "Offen"}); - rechnungswesenTableModel.addRow(new Object[]{"2024-03", "2024-01-20", 4500, "Bezahlt"}); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - - private void openKostenrechnung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Kostenrechnung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Implementiere hier die Funktionalität zur Kostenrechnung - JTextArea textArea = new JTextArea("Hier können Sie Kostenrechnungsdaten einsehen und verwalten."); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - private void openBudgetierung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Budgetierung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Implementiere hier die Funktionalität zur Budgetierung - // Beispiel für ein Diagramm (Dummy-Daten) - JPanel panel = new JPanel(new BorderLayout()); - panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Budgetierung", TitledBorder.CENTER, TitledBorder.TOP)); - panel.setBackground(Color.decode("#ECF0F1")); - - String[] columnNames = {"Kategorie", "Geplant", "Aktuell"}; - Object[][] data = { - {"Marketing", 10000, 8000}, - {"Forschung & Entwicklung", 15000, 12000}, - {"Produktion", 20000, 18000} - }; - - JTable table = new JTable(data, columnNames); - JScrollPane scrollPane = new JScrollPane(table); - panel.add(scrollPane, BorderLayout.CENTER); - - mainPanel.add(panel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void openFinanzberichte() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Finanzberichte", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Implementiere hier die Funktionalität für Finanzberichte - JTextArea textArea = new JTextArea("Hier können Sie Finanzberichte einsehen und erstellen."); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - private void openKontaktmanagement() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Kontaktmanagement", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Implementiere hier die Funktionalität für Kontaktmanagement - JTextArea textArea = new JTextArea("Hier können Sie Kontakte einsehen und verwalten."); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - private void openVertriebschancen() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Vertriebschancen", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Implementiere hier die Funktionalität für Vertriebschancen - JTextArea textArea = new JTextArea("Hier können Sie Vertriebschancen einsehen und verwalten."); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - private void openMarketingkampagnen() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Marketingkampagnen", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Implementiere hier die Funktionalität für Marketingkampagnen - JTextArea textArea = new JTextArea("Hier können Sie Marketingkampagnen einsehen und verwalten."); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - private void openKundendienst() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Kundendienst", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Implementiere hier die Funktionalität für Kundendienst - JTextArea textArea = new JTextArea("Hier können Sie Kundendienst-Daten einsehen und verwalten."); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - private void openKundenzufriedenheit() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Kundenzufriedenheit", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Implementiere hier die Funktionalität für Kundenzufriedenheit - JTextArea textArea = new JTextArea("Hier können Sie Daten zur Kundenzufriedenheit einsehen und verwalten."); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - private void openPersonalverwaltung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Personalverwaltung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Liste zur Anzeige der Mitarbeiter - employeeListModel = new DefaultListModel<>(); - employeeList = new JList<>(employeeListModel); - employeeList.setCellRenderer(new EmployeeCellRenderer()); - employeeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - JScrollPane scrollPane = new JScrollPane(employeeList); - mainPanel.add(scrollPane, BorderLayout.CENTER); - - // Panel zum Hinzufügen neuer Mitarbeiter - JPanel inputPanel = new JPanel(new GridLayout(6, 2, 10, 10)); - inputPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Mitarbeiter hinzufügen", TitledBorder.CENTER, TitledBorder.TOP)); - inputPanel.setBackground(Color.decode("#ECF0F1")); - - inputPanel.add(new JLabel("Name:")); - JTextField nameField = new JTextField(); - inputPanel.add(nameField); - - inputPanel.add(new JLabel("Position:")); - JTextField positionField = new JTextField(); - inputPanel.add(positionField); - - inputPanel.add(new JLabel("Abteilung:")); - JTextField departmentField = new JTextField(); - inputPanel.add(departmentField); - - inputPanel.add(new JLabel("Gehalt:")); - JTextField salaryField = new JTextField(); - inputPanel.add(salaryField); - - JButton addButton = new JButton("Hinzufügen"); - addButton.setBackground(Color.decode("#2C3E50")); - addButton.setForeground(Color.WHITE); - JButton deleteButton = new JButton("Löschen"); - deleteButton.setBackground(Color.decode("#E74C3C")); - deleteButton.setForeground(Color.WHITE); - inputPanel.add(addButton); - inputPanel.add(deleteButton); - - mainPanel.add(inputPanel, BorderLayout.SOUTH); - - addButton.addActionListener(e -> { - String name = nameField.getText(); - String position = positionField.getText(); - String department = departmentField.getText(); - double salary = Double.parseDouble(salaryField.getText()); - - if (name.isEmpty() || position.isEmpty() || department.isEmpty() || salaryField.getText().isEmpty()) { - JOptionPane.showMessageDialog(frame, "Bitte alle Felder ausfüllen", "Fehler", JOptionPane.ERROR_MESSAGE); - return; - } - - Employee employee = new Employee(employeeIdCounter++, name, position, department, salary); - employees.add(employee); - saveEmployees(employees); - - employeeListModel.addElement(employee); - - // Felder leeren - nameField.setText(""); - positionField.setText(""); - departmentField.setText(""); - salaryField.setText(""); - }); - - deleteButton.addActionListener(e -> { - Employee selectedEmployee = employeeList.getSelectedValue(); - if (selectedEmployee != null) { - employees.removeIf(emp -> emp.getId() == selectedEmployee.getId()); - saveEmployees(employees); - employeeListModel.removeElement(selectedEmployee); - } - }); - - employeeList.addListSelectionListener(e -> { - Employee selectedEmployee = employeeList.getSelectedValue(); - if (selectedEmployee != null) { - showEmployeeDetails(selectedEmployee); - } - }); - - updateEmployeeList(); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void showEmployeeDetails(Employee employee) { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JPanel employeeDetailsPanel = new JPanel(new GridLayout(10, 2, 10, 10)); - employeeDetailsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Mitarbeiterdetails", TitledBorder.CENTER, TitledBorder.TOP)); - employeeDetailsPanel.setBackground(Color.decode("#ECF0F1")); - - employeeDetailsPanel.add(new JLabel("Name:")); - employeeDetailsPanel.add(new JLabel(employee.getName())); - - employeeDetailsPanel.add(new JLabel("Position:")); - employeeDetailsPanel.add(new JLabel(employee.getPosition())); - - employeeDetailsPanel.add(new JLabel("Abteilung:")); - employeeDetailsPanel.add(new JLabel(employee.getDepartment())); - - employeeDetailsPanel.add(new JLabel("Gehalt:")); - employeeDetailsPanel.add(new JLabel(String.valueOf(employee.getSalary()))); - - employeeDetailsPanel.add(new JLabel("Status:")); - employeeDetailsPanel.add(new JLabel(employee.getEmploymentStatus())); - - JButton backButton = new JButton("Zurück"); - backButton.setBackground(Color.decode("#2C3E50")); // Dunkelblau - backButton.setForeground(Color.WHITE); - employeeDetailsPanel.add(backButton); - - // Urlaub hinzufügen - JButton addVacationButton = new JButton("Urlaub hinzufügen"); - addVacationButton.setBackground(Color.decode("#3498DB")); // Hellblau - addVacationButton.setForeground(Color.WHITE); - employeeDetailsPanel.add(addVacationButton); - - addVacationButton.addActionListener(e -> showAddVacationDialog(employee)); - - // Transfer hinzufügen - JButton addTransferButton = new JButton("Transfer hinzufügen"); - addTransferButton.setBackground(Color.decode("#1ABC9C")); // Türkis - addTransferButton.setForeground(Color.WHITE); - employeeDetailsPanel.add(addTransferButton); - - addTransferButton.addActionListener(e -> showAddTransferDialog(employee)); - - // Kündigung hinzufügen - JButton addTerminationButton = new JButton("Kündigung hinzufügen"); - addTerminationButton.setBackground(Color.decode("#E74C3C")); // Rot - addTerminationButton.setForeground(Color.WHITE); - employeeDetailsPanel.add(addTerminationButton); - - addTerminationButton.addActionListener(e -> showAddTerminationDialog(employee)); - - backButton.addActionListener(e -> openPersonalverwaltung()); - - mainPanel.add(employeeDetailsPanel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - private void showAddVacationDialog(Employee employee) { - JPanel vacationPanel = new JPanel(new GridLayout(3, 2, 10, 10)); - vacationPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Urlaub hinzufügen", TitledBorder.CENTER, TitledBorder.TOP)); - - vacationPanel.add(new JLabel("Startdatum:")); - JTextField startDateField = new JTextField(); - vacationPanel.add(startDateField); - - vacationPanel.add(new JLabel("Enddatum:")); - JTextField endDateField = new JTextField(); - vacationPanel.add(endDateField); - - vacationPanel.add(new JLabel("Grund:")); - JTextField reasonField = new JTextField(); - vacationPanel.add(reasonField); - - int option = JOptionPane.showConfirmDialog(frame, vacationPanel, "Urlaub hinzufügen", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); - - if (option == JOptionPane.OK_OPTION) { - String startDate = startDateField.getText(); - String endDate = endDateField.getText(); - String reason = reasonField.getText(); - - Vacation vacation = new Vacation(startDate, endDate, reason); - employee.addVacation(vacation); - saveEmployees(employees); - - JOptionPane.showMessageDialog(frame, "Urlaub erfolgreich hinzugefügt", "Erfolg", JOptionPane.INFORMATION_MESSAGE); - } - } - - private void showAddTransferDialog(Employee employee) { - JPanel transferPanel = new JPanel(new GridLayout(4, 2, 10, 10)); - transferPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Transfer hinzufügen", TitledBorder.CENTER, TitledBorder.TOP)); - - transferPanel.add(new JLabel("Datum:")); - JTextField dateField = new JTextField(); - transferPanel.add(dateField); - - transferPanel.add(new JLabel("Von Abteilung:")); - JTextField fromDepartmentField = new JTextField(); - transferPanel.add(fromDepartmentField); - - transferPanel.add(new JLabel("Zu Abteilung:")); - JTextField toDepartmentField = new JTextField(); - transferPanel.add(toDepartmentField); - - transferPanel.add(new JLabel("Grund:")); - JTextField reasonField = new JTextField(); - transferPanel.add(reasonField); - - int option = JOptionPane.showConfirmDialog(frame, transferPanel, "Transfer hinzufügen", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); - - if (option == JOptionPane.OK_OPTION) { - String date = dateField.getText(); - String fromDepartment = fromDepartmentField.getText(); - String toDepartment = toDepartmentField.getText(); - String reason = reasonField.getText(); - - Transfer transfer = new Transfer(date, fromDepartment, toDepartment, reason); - employee.addTransfer(transfer); - saveEmployees(employees); - - JOptionPane.showMessageDialog(frame, "Transfer erfolgreich hinzugefügt", "Erfolg", JOptionPane.INFORMATION_MESSAGE); - } - } - - private void showAddTerminationDialog(Employee employee) { - JPanel terminationPanel = new JPanel(new GridLayout(3, 2, 10, 10)); - terminationPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Kündigung hinzufügen", TitledBorder.CENTER, TitledBorder.TOP)); - - terminationPanel.add(new JLabel("Datum:")); - JTextField dateField = new JTextField(); - terminationPanel.add(dateField); - - terminationPanel.add(new JLabel("Art:")); - String[] types = {"Freiwillig", "Unfreiwillig"}; - JComboBox typeComboBox = new JComboBox<>(types); - terminationPanel.add(typeComboBox); - - terminationPanel.add(new JLabel("Grund:")); - JTextField reasonField = new JTextField(); - terminationPanel.add(reasonField); - - int option = JOptionPane.showConfirmDialog(frame, terminationPanel, "Kündigung hinzufügen", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); - - if (option == JOptionPane.OK_OPTION) { - String date = dateField.getText(); - String type = (String) typeComboBox.getSelectedItem(); - String reason = reasonField.getText(); - - Termination termination = new Termination(date, type, reason); - employee.addTermination(termination); - employee.setEmploymentStatus("Terminated"); - saveEmployees(employees); - - JOptionPane.showMessageDialog(frame, "Kündigung erfolgreich hinzugefügt", "Erfolg", JOptionPane.INFORMATION_MESSAGE); - } - } - - - private void openRekrutierung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Rekrutierung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Implementiere hier die Funktionalität für Rekrutierung - JTextArea textArea = new JTextArea("Hier können Sie Rekrutierungsdaten einsehen und verwalten."); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - private void openMitarbeiterentwicklung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Mitarbeiterentwicklung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Implementiere hier die Funktionalität für Mitarbeiterentwicklung - JTextArea textArea = new JTextArea("Hier können Sie Daten zur Mitarbeiterentwicklung einsehen und verwalten."); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - private void openZeitmanagement() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Zeitmanagement", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Implementiere hier die Funktionalität für Zeitmanagement - JTextArea textArea = new JTextArea("Hier können Sie Zeitmanagement-Daten einsehen und verwalten."); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - private void openLeistungsbewertung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Leistungsbewertung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Implementiere hier die Funktionalität für Leistungsbewertung - JTextArea textArea = new JTextArea("Hier können Sie Leistungsbewertungsdaten einsehen und verwalten."); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - private void openGehaltsabrechnung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Gehaltsabrechnung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Liste zur Anzeige der Gehälter - String[] columns = {"Mitarbeiter", "Gehalt"}; - DefaultTableModel salaryTableModel = new DefaultTableModel(columns, 0); - JTable table = new JTable(salaryTableModel); - JScrollPane scrollPane = new JScrollPane(table); - mainPanel.add(scrollPane, BorderLayout.CENTER); - - for (Employee employee : employees) { - Object[] row = {employee.getName(), employee.getSalary()}; - salaryTableModel.addRow(row); - } - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void updateCustomerList() { - customerListModel.removeAllElements(); - for (Customer customer : customers) { - customerListModel.addElement(customer); - } - } - - private void updateProductList() { - productListModel.removeAllElements(); - for (Product product : products) { - productListModel.addElement(product); - } - } - - private void updateSupplierList() { - supplierListModel.removeAllElements(); - for (Supplier supplier : suppliers) { - supplierListModel.addElement(supplier); - } - } - - private void updateOrderList() { - orderListModel.removeAllElements(); - for (Order order : orders) { - orderListModel.addElement(order); - } - } - - private void updateEmployeeList() { - employeeListModel.removeAllElements(); - for (Employee employee : employees) { - employeeListModel.addElement(employee); - } - } - - private List loadProducts() { - List productList = new ArrayList<>(); - try (BufferedReader br = new BufferedReader(new FileReader("products.txt"))) { - String line; - while ((line = br.readLine()) != null) { - String[] data = line.split(","); - int id = Integer.parseInt(data[0]); - String itemNumber = data[1]; - String productName = data[2]; - String description = data[3]; - String category = data[4]; - int availableStock = Integer.parseInt(data[5]); - int minimumStock = Integer.parseInt(data[6]); - String storageLocation = data[7]; - double purchasePrice = Double.parseDouble(data[8]); - double sellingPrice = Double.parseDouble(data[9]); - String mainSupplier = data[10]; - String imagePath = data[11]; - productList.add(new Product(id, itemNumber, productName, description, category, availableStock, minimumStock, storageLocation, purchasePrice, sellingPrice, mainSupplier, imagePath)); - } - } catch (IOException e) { - e.printStackTrace(); - } - return productList; - } - - private List loadSuppliers() { - List supplierList = new ArrayList<>(); - try (BufferedReader br = new BufferedReader(new FileReader("suppliers.txt"))) { - String line; - while ((line = br.readLine()) != null) { - String[] data = line.split(","); - int id = Integer.parseInt(data[0]); - String name = data[1]; - String address = data[2]; - String contact = data[3]; - String contractDetails = data[4]; - String orderHistory = data[5]; - String qualityRating = data[6]; - supplierList.add(new Supplier(id, name, address, contact, contractDetails, orderHistory, qualityRating)); - } - } catch (IOException e) { - e.printStackTrace(); - } - return supplierList; - } - - private List loadOrders() { - List orderList = new ArrayList<>(); - try (BufferedReader br = new BufferedReader(new FileReader("orders.txt"))) { - String line; - while ((line = br.readLine()) != null) { - String[] data = line.split(","); - int id = Integer.parseInt(data[0]); - String product = data[1]; - int quantity = Integer.parseInt(data[2]); - String date = data[3]; - String deliveryDate = data[4]; - String status = data[5]; - orderList.add(new Order(id, product, quantity, date, deliveryDate, status)); - } - } catch (IOException e) { - e.printStackTrace(); - } - return orderList; - } - - private List loadCustomers() { - List customerList = new ArrayList<>(); - try (BufferedReader br = new BufferedReader(new FileReader("customers.txt"))) { - String line; - while ((line = br.readLine()) != null) { - String[] data = line.split(","); - int id = Integer.parseInt(data[0]); - String name = data[1]; - String address = data[2]; - String contact = data[3]; - String segment = data[4]; - customerList.add(new Customer(id, name, address, contact, segment)); - } - } catch (IOException e) { - e.printStackTrace(); - } - return customerList; - } - - private List loadEmployees() { - List employeeList = new ArrayList<>(); - try (BufferedReader br = new BufferedReader(new FileReader("employees.txt"))) { - String line; - while ((line = br.readLine()) != null) { - String[] data = line.split(","); - int id = Integer.parseInt(data[0]); - String name = data[1]; - String position = data[2]; - String department = data[3]; - double salary = Double.parseDouble(data[4]); - employeeList.add(new Employee(id, name, position, department, salary)); - } - } catch (IOException e) { - e.printStackTrace(); - } - return employeeList; - } - - private List loadUsers() { - List userList = new ArrayList<>(); - try (BufferedReader br = new BufferedReader(new FileReader("users.txt"))) { - String line; - while ((line = br.readLine()) != null) { - String[] data = line.split(","); - int id = Integer.parseInt(data[0]); - String username = data[1]; - String password = data[2]; - String role = data[3]; - userList.add(new User(id, username, password, role)); - } - } catch (IOException e) { - e.printStackTrace(); - } - return userList; - } - - private void saveProducts(List products) { - try (BufferedWriter bw = new BufferedWriter(new FileWriter("products.txt"))) { - for (Product product : products) { - bw.write(product.getId() + "," + product.getItemNumber() + "," + product.getProductName() + "," + product.getDescription() + "," + product.getCategory() + "," + product.getAvailableStock() + "," + product.getMinimumStock() + "," + product.getStorageLocation() + "," + product.getPurchasePrice() + "," + product.getSellingPrice() + "," + product.getMainSupplier() + "," + product.getImagePath()); - bw.newLine(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - private void saveSuppliers(List suppliers) { - try (BufferedWriter bw = new BufferedWriter(new FileWriter("suppliers.txt"))) { - for (Supplier supplier : suppliers) { - bw.write(supplier.getId() + "," + supplier.getName() + "," + supplier.getAddress() + "," + supplier.getContact() + "," + supplier.getContractDetails() + "," + supplier.getOrderHistory() + "," + supplier.getQualityRating()); - bw.newLine(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - private void saveOrders(List orders) { - try (BufferedWriter bw = new BufferedWriter(new FileWriter("orders.txt"))) { - for (Order order : orders) { - bw.write(order.getId() + "," + order.getProduct() + "," + order.getQuantity() + "," + order.getDate() + "," + order.getDeliveryDate() + "," + order.getStatus()); - bw.newLine(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - private void saveCustomers(List customers) { - try (BufferedWriter bw = new BufferedWriter(new FileWriter("customers.txt"))) { - for (Customer customer : customers) { - bw.write(customer.getId() + "," + customer.getName() + "," + customer.getAddress() + "," + customer.getContact() + "," + customer.getSegment()); - bw.newLine(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - private void saveEmployees(List employees) { - try (BufferedWriter bw = new BufferedWriter(new FileWriter("employees.txt"))) { - for (Employee employee : employees) { - bw.write(employee.getId() + "," + employee.getName() + "," + employee.getPosition() + "," + employee.getDepartment() + "," + employee.getSalary()); - bw.newLine(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - private void saveUsers(List users) { - try (BufferedWriter bw = new BufferedWriter(new FileWriter("users.txt"))) { - for (User user : users) { - bw.write(user.getId() + "," + user.getUsername() + "," + user.getPassword() + "," + user.getRole()); - bw.newLine(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - - private void openDatenschnittstellen() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Datenschnittstellen", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - JPanel dataInterfacePanel = new JPanel(new BorderLayout()); - DefaultTableModel interfaceModel = new DefaultTableModel(new Object[]{"Schnittstellen-ID", "Typ", "Status"}, 0); - JTable interfaceTable = new JTable(interfaceModel); - JScrollPane scrollPane = new JScrollPane(interfaceTable); - dataInterfacePanel.add(scrollPane, BorderLayout.CENTER); - - // Beispiel: Fügen Sie hier Datenschnittstellen hinzu - interfaceModel.addRow(new Object[]{1, "API", "Aktiv"}); - interfaceModel.addRow(new Object[]{2, "FTP", "Inaktiv"}); - - mainPanel.add(dataInterfacePanel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void showHelp() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Hilfe", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - JTextArea textArea = new JTextArea("Kontaktinformationen:\n\n" + - "Support: support@example.com\n" + - "Telefon: +49 123 456 789\n" + - "Adresse: Beispielstraße 1, 12345 Beispielstadt\n\n" + - "Dies ist das Warenwirtschaftssystem. Verwenden Sie die Menüs, um verschiedene Verwaltungsfunktionen auszuführen. " + - "Unter 'Produktverwaltung' können Sie Produkte hinzufügen, bearbeiten und löschen. " + - "Unter 'Bestandsbericht' können Sie den aktuellen Lagerbestand einsehen und feststellen, welche Produkte nachbestellt werden müssen."); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void openSystemintegration() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Systemintegration", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - JTextArea textArea = new JTextArea("Hier können Sie die Systemintegration verwalten.\n\n" + - "Optionen:\n" + - "1. Datenbankintegration\n" + - "2. API-Integration\n" + - "3. Externe Systeme einbinden"); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void openEchtzeitDaten() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Echtzeit-Daten", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - JTextArea textArea = new JTextArea("Hier können Sie Echtzeit-Daten einsehen und verwalten.\n\n" + - "Optionen:\n" + - "1. Echtzeit-Berichte\n" + - "2. Live-Dashboard\n" + - "3. Datenvisualisierung"); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void openCloudServices() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Cloud-Services", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - JTextArea textArea = new JTextArea("Hier können Sie Cloud-Services verwalten.\n\n" + - "Optionen:\n" + - "1. Cloud-Speicher\n" + - "2. Cloud-Computing\n" + - "3. Cloud-Sicherheit"); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void openEDI() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("EDI", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - JTextArea textArea = new JTextArea("Hier können Sie EDI (Electronic Data Interchange) verwalten.\n\n" + - "Optionen:\n" + - "1. EDI-Verbindungen\n" + - "2. EDI-Nachrichten\n" + - "3. EDI-Protokolle"); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - textArea.setEditable(false); - textArea.setFont(new Font("Arial", Font.PLAIN, 18)); - mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); - - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void openUrlaubVerwaltung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Urlaub Verwaltung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Panel zur Anzeige der Urlaube - JPanel urlaubPanel = new JPanel(new BorderLayout()); - DefaultTableModel urlaubTableModel = new DefaultTableModel(new Object[]{"Mitarbeiter", "Startdatum", "Enddatum"}, 0); - JTable urlaubTable = new JTable(urlaubTableModel); - JScrollPane scrollPane = new JScrollPane(urlaubTable); - urlaubPanel.add(scrollPane, BorderLayout.CENTER); - - for (Employee employee : employees) { - for (Vacation vacation : employee.getVacations()) { - urlaubTableModel.addRow(new Object[]{employee.getName(), vacation.getStartDate(), vacation.getEndDate()}); - } - } - - mainPanel.add(urlaubPanel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void openTransferVerwaltung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Transfer Verwaltung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Panel zur Anzeige der Transfers - JPanel transferPanel = new JPanel(new BorderLayout()); - DefaultTableModel transferTableModel = new DefaultTableModel(new Object[]{"Mitarbeiter", "Abteilung", "Neue Abteilung", "Datum"}, 0); - JTable transferTable = new JTable(transferTableModel); - JScrollPane scrollPane = new JScrollPane(transferTable); - transferPanel.add(scrollPane, BorderLayout.CENTER); - - for (Employee employee : employees) { - for (Transfer transfer : employee.getTransfers()) { - transferTableModel.addRow(new Object[]{employee.getName(), transfer.getFromDepartment(), transfer.getToDepartment(), transfer.getDate()}); - } - } - - mainPanel.add(transferPanel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - private void openKündigungVerwaltung() { - mainPanel.removeAll(); - mainPanel.repaint(); - mainPanel.revalidate(); - - JLabel label = new JLabel("Kündigung Verwaltung", JLabel.CENTER); - label.setFont(new Font("Arial", Font.BOLD, 20)); - label.setForeground(Color.decode("#2C3E50")); - mainPanel.add(label, BorderLayout.NORTH); - - // Panel zur Anzeige der Kündigungen - JPanel kündigungPanel = new JPanel(new BorderLayout()); - DefaultTableModel kündigungTableModel = new DefaultTableModel(new Object[]{"Mitarbeiter", "Datum", "Grund"}, 0); - JTable kündigungTable = new JTable(kündigungTableModel); - JScrollPane scrollPane = new JScrollPane(kündigungTable); - kündigungPanel.add(scrollPane, BorderLayout.CENTER); - - for (Employee employee : employees) { - for (Termination termination : employee.getTerminations()) { - kündigungTableModel.addRow(new Object[]{employee.getName(), termination.getDate(), termination.getReason()}); - } - } - - mainPanel.add(kündigungPanel, BorderLayout.CENTER); - mainPanel.repaint(); - mainPanel.revalidate(); - } - - - - - public static void main(String[] args) { - SwingUtilities.invokeLater(Warenwirtschaftssystem::new); - } -} \ No newline at end of file diff --git a/PR2 KI Projekt/src/pom.xml b/PR2 KI Projekt/src/pom.xml new file mode 100644 index 0000000..46bddc8 --- /dev/null +++ b/PR2 KI Projekt/src/pom.xml @@ -0,0 +1,69 @@ + + 4.0.0 + com.example + fakturama + 1.0-SNAPSHOT + + + + + org.junit.jupiter + junit-jupiter-api + 5.7.1 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.7.1 + test + + + + + org.junit.vintage + junit-vintage-engine + 5.7.1 + test + + + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.7 + + + + prepare-agent + + + + report + prepare-package + + report + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + **/MainTest.java + + + + + + diff --git a/PR2 KI Projekt/suppliers.txt b/PR2 KI Projekt/suppliers.txt deleted file mode 100644 index e69de29..0000000 diff --git a/PR2 KI Projekt/users.txt b/PR2 KI Projekt/users.txt deleted file mode 100644 index d88241e..0000000 --- a/PR2 KI Projekt/users.txt +++ /dev/null @@ -1,6 +0,0 @@ -1,admin,admin123,Administrator -2,manager,manager123,Manager -3,user,user123,User -4,Abbas,12,Administrator -5,Abbas,12,Administrator -6,Athar,A,Administrator