From 69ba157b30d5dc51bc62d6aba28ab55adce8d248 Mon Sep 17 00:00:00 2001 From: Abbas Date: Sat, 29 Jun 2024 16:08:09 +0200 Subject: [PATCH] Grundlegende Funktionen von Athar erstellt --- PR2 KI Projekt/.classpath | 10 + PR2 KI Projekt/.gitignore | 1 + PR2 KI Projekt/.project | 17 + .../org.eclipse.core.resources.prefs | 2 + 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 | 35 + 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/User.java | 29 + .../src/Warenwirtschaftssystem.java | 1885 +++++++++++++++++ PR2 KI Projekt/users.txt | 4 + 17 files changed, 2294 insertions(+) create mode 100644 PR2 KI Projekt/.classpath create mode 100644 PR2 KI Projekt/.gitignore create mode 100644 PR2 KI Projekt/.project create mode 100644 PR2 KI Projekt/.settings/org.eclipse.core.resources.prefs create mode 100644 PR2 KI Projekt/src/Customer.java create mode 100644 PR2 KI Projekt/src/CustomerCellRenderer.java create mode 100644 PR2 KI Projekt/src/EmploycallRenderer.java create mode 100644 PR2 KI Projekt/src/Employee.java create mode 100644 PR2 KI Projekt/src/Order.java create mode 100644 PR2 KI Projekt/src/OrderCellRenderer.java create mode 100644 PR2 KI Projekt/src/Product.java create mode 100644 PR2 KI Projekt/src/ProductCellRenderer.java create mode 100644 PR2 KI Projekt/src/Supplier.java create mode 100644 PR2 KI Projekt/src/SupplierCellRenderer.java create mode 100644 PR2 KI Projekt/src/User.java create mode 100644 PR2 KI Projekt/src/Warenwirtschaftssystem.java create mode 100644 PR2 KI Projekt/users.txt diff --git a/PR2 KI Projekt/.classpath b/PR2 KI Projekt/.classpath new file mode 100644 index 0000000..c8b8bcc --- /dev/null +++ b/PR2 KI Projekt/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/PR2 KI Projekt/.gitignore b/PR2 KI Projekt/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/PR2 KI Projekt/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/PR2 KI Projekt/.project b/PR2 KI Projekt/.project new file mode 100644 index 0000000..973f437 --- /dev/null +++ b/PR2 KI Projekt/.project @@ -0,0 +1,17 @@ + + + PR2 KI Projekt + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/PR2 KI Projekt/.settings/org.eclipse.core.resources.prefs b/PR2 KI Projekt/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..4824b80 --- /dev/null +++ b/PR2 KI Projekt/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/PR2 KI Projekt/src/Customer.java b/PR2 KI Projekt/src/Customer.java new file mode 100644 index 0000000..c4026fd --- /dev/null +++ b/PR2 KI Projekt/src/Customer.java @@ -0,0 +1,40 @@ +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 new file mode 100644 index 0000000..ccebc99 --- /dev/null +++ b/PR2 KI Projekt/src/CustomerCellRenderer.java @@ -0,0 +1,18 @@ +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 new file mode 100644 index 0000000..73ca4be --- /dev/null +++ b/PR2 KI Projekt/src/EmploycallRenderer.java @@ -0,0 +1,21 @@ +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 new file mode 100644 index 0000000..a22dc0e --- /dev/null +++ b/PR2 KI Projekt/src/Employee.java @@ -0,0 +1,35 @@ +class Employee { + private int id; + private String name; + private String position; + private String department; + private double salary; + + 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; + } + + 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; + } +} \ No newline at end of file diff --git a/PR2 KI Projekt/src/Order.java b/PR2 KI Projekt/src/Order.java new file mode 100644 index 0000000..3252e5c --- /dev/null +++ b/PR2 KI Projekt/src/Order.java @@ -0,0 +1,46 @@ +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 new file mode 100644 index 0000000..e701bdd --- /dev/null +++ b/PR2 KI Projekt/src/OrderCellRenderer.java @@ -0,0 +1,15 @@ +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 new file mode 100644 index 0000000..ff447a9 --- /dev/null +++ b/PR2 KI Projekt/src/Product.java @@ -0,0 +1,82 @@ +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 new file mode 100644 index 0000000..dc5a724 --- /dev/null +++ b/PR2 KI Projekt/src/ProductCellRenderer.java @@ -0,0 +1,19 @@ +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 new file mode 100644 index 0000000..a4f537c --- /dev/null +++ b/PR2 KI Projekt/src/Supplier.java @@ -0,0 +1,52 @@ +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 new file mode 100644 index 0000000..600b7bd --- /dev/null +++ b/PR2 KI Projekt/src/SupplierCellRenderer.java @@ -0,0 +1,18 @@ +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/User.java b/PR2 KI Projekt/src/User.java new file mode 100644 index 0000000..5d3f0d5 --- /dev/null +++ b/PR2 KI Projekt/src/User.java @@ -0,0 +1,29 @@ +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/Warenwirtschaftssystem.java b/PR2 KI Projekt/src/Warenwirtschaftssystem.java new file mode 100644 index 0000000..b99564d --- /dev/null +++ b/PR2 KI Projekt/src/Warenwirtschaftssystem.java @@ -0,0 +1,1885 @@ +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 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")); + + // 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"); + + menuHR.add(menuItemPersonalverwaltung); + menuHR.add(menuItemRekrutierung); + menuHR.add(menuItemMitarbeiterentwicklung); + menuHR.add(menuItemZeitmanagement); + menuHR.add(menuItemLeistungsbewertung); + menuHR.add(menuItemGehaltsabrechnung); + + 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()); + + //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")); + + panel.add(new JLabel("Plan erstellen")); + JButton createPlanButton = new JButton("Plan erstellen"); + panel.add(createPlanButton); + + panel.add(new JLabel("Stückliste verwalten")); + JButton manageBOMButton = new JButton("Stückliste anzeigen"); + panel.add(manageBOMButton); + + panel.add(new JLabel("Produktionssteuerung")); + JButton productionControlButton = new JButton("Steuerung anzeigen"); + panel.add(productionControlButton); + + panel.add(new JLabel("Qualitätskontrolle")); + JButton qualityControlButton = new JButton("Kontrolle anzeigen"); + panel.add(qualityControlButton); + + panel.add(new JLabel("Produktionskosten")); + JButton productionCostsButton = new JButton("Kosten anzeigen"); + panel.add(productionCostsButton); + + createPlanButton.addActionListener(e -> JOptionPane.showMessageDialog(frame, "Produktionsplan erstellt", "Erfolg", JOptionPane.INFORMATION_MESSAGE)); + manageBOMButton.addActionListener(e -> JOptionPane.showMessageDialog(frame, "Stückliste verwaltet", "Erfolg", JOptionPane.INFORMATION_MESSAGE)); + productionControlButton.addActionListener(e -> JOptionPane.showMessageDialog(frame, "Produktionssteuerung angezeigt", "Erfolg", JOptionPane.INFORMATION_MESSAGE)); + qualityControlButton.addActionListener(e -> JOptionPane.showMessageDialog(frame, "Qualitätskontrolle durchgeführt", "Erfolg", JOptionPane.INFORMATION_MESSAGE)); + productionCostsButton.addActionListener(e -> JOptionPane.showMessageDialog(frame, "Produktionskosten berechnet", "Erfolg", JOptionPane.INFORMATION_MESSAGE)); + + mainPanel.add(panel, BorderLayout.CENTER); + mainPanel.repaint(); + mainPanel.revalidate(); + } + + 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); + + // Implementiere hier die Funktionalität zur Verwaltung von Stücklisten + + 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); + + // Implementiere hier die Funktionalität zur Produktionssteuerung + + 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); + + // Implementiere hier die Funktionalität zur Qualitätskontrolle + + 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); + + // Implementiere hier die Funktionalität zur Produktionskosten + + 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); + + // Implementiere hier die Funktionalität zur Buchhaltung + + 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); + + // Implementiere hier die Funktionalität zum Rechnungswesen + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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) { + JPanel employeeDetailsPanel = new JPanel(new GridLayout(5, 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()))); + + JButton backButton = new JButton("Zurück"); + backButton.setBackground(Color.decode("#2C3E50")); + backButton.setForeground(Color.WHITE); + employeeDetailsPanel.add(backButton); + + backButton.addActionListener(e -> openPersonalverwaltung()); + + mainPanel.removeAll(); + mainPanel.add(employeeDetailsPanel, BorderLayout.CENTER); + mainPanel.repaint(); + mainPanel.revalidate(); + } + + 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 + + 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 + + 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 + + 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 + + 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(); + } + + + public static void main(String[] args) { + SwingUtilities.invokeLater(Warenwirtschaftssystem::new); + } +} \ No newline at end of file diff --git a/PR2 KI Projekt/users.txt b/PR2 KI Projekt/users.txt new file mode 100644 index 0000000..1c82057 --- /dev/null +++ b/PR2 KI Projekt/users.txt @@ -0,0 +1,4 @@ +1,admin,admin123,Administrator +2,manager,manager123,Manager +3,user,user123,User +4,Abbas,12,Administrator