Name anzeigen anstatt ID bei Angeboterstellung

master
athar 2024-06-30 21:09:43 +02:00
parent 42453b825f
commit df97979002
1 changed files with 21 additions and 27 deletions

View File

@ -6,9 +6,9 @@ import java.util.List;
public class FakturamaGUI {
private JFrame frame;
private JTextArea textArea;
private JPanel mainPanel;
private CardLayout cardLayout;
private JTextArea textArea;
public FakturamaGUI() {
initialize();
@ -18,17 +18,11 @@ public class FakturamaGUI {
frame = new JFrame("Fakturama");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 600);
frame.setLayout(new BorderLayout());
cardLayout = new CardLayout();
mainPanel = new JPanel(cardLayout);
// Startseite
JPanel homePanel = new JPanel(new BorderLayout());
textArea = new JTextArea();
textArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(textArea);
homePanel.add(scrollPane, BorderLayout.CENTER);
mainPanel.add(homePanel, "Home");
frame.add(mainPanel, BorderLayout.CENTER);
// Menüleiste
JMenuBar menuBar = new JMenuBar();
@ -66,7 +60,6 @@ public class FakturamaGUI {
saveDataItem.addActionListener(e -> {
Main.saveData();
updateTextArea();
cardLayout.show(mainPanel, "Home");
});
JMenuItem loadDataItem = new JMenuItem("Daten laden");
@ -74,20 +67,28 @@ public class FakturamaGUI {
loadDataItem.addActionListener(e -> {
Main.loadData();
updateTextArea();
cardLayout.show(mainPanel, "Home");
});
JMenuItem exitItem = new JMenuItem("Beenden");
menu.add(exitItem);
exitItem.addActionListener(e -> System.exit(0));
frame.add(mainPanel);
textArea = new JTextArea();
textArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(textArea);
JPanel homePanel = new JPanel(new BorderLayout());
homePanel.add(scrollPane, BorderLayout.CENTER);
mainPanel.add(homePanel, "Home");
cardLayout.show(mainPanel, "Home");
frame.setVisible(true);
updateTextArea();
}
private void showAddCustomerPanel() {
JPanel panel = new JPanel(new GridLayout(7, 2));
JPanel panel = new JPanel(new GridLayout(6, 2));
JLabel nameLabel = new JLabel("Name:");
JTextField nameField = new JTextField();
JLabel addressLabel = new JLabel("Adresse:");
@ -141,7 +142,7 @@ public class FakturamaGUI {
JLabel netPriceLabel = new JLabel("Nettopreis:");
JTextField netPriceField = new JTextField();
JLabel vatRateLabel = new JLabel("Mehrwertsteuersatz:");
JComboBox<Double> vatRateBox = new JComboBox<>(new Double[]{7.0, 19.0});
JComboBox<String> vatRateBox = new JComboBox<>(new String[]{"19%", "7%"});
JButton addButton = new JButton("Hinzufügen");
addButton.setBackground(new Color(144, 238, 144)); // Hellgrün
@ -149,7 +150,7 @@ public class FakturamaGUI {
String unit = unitField.getText();
String description = descriptionField.getText();
double netPrice = Double.parseDouble(netPriceField.getText());
double vatRate = (Double) vatRateBox.getSelectedItem();
double vatRate = vatRateBox.getSelectedIndex() == 0 ? 19.0 : 7.0;
Main.articles.add(new Main.Article(unit, description, netPrice, vatRate));
updateTextArea();
cardLayout.show(mainPanel, "Home");
@ -176,7 +177,7 @@ public class FakturamaGUI {
private void showCreateOfferPanel() {
JPanel panel = new JPanel(new BorderLayout());
JPanel formPanel = new JPanel(new GridLayout(4, 2));
JPanel formPanel = new JPanel(new GridLayout(2, 2));
JLabel customerLabel = new JLabel("Kunde:");
JComboBox<String> customerBox = new JComboBox<>();
for (Main.Customer customer : Main.customers) {
@ -229,9 +230,8 @@ public class FakturamaGUI {
cardLayout.show(mainPanel, "CreateOffer");
}
private void showCreateOrderConfirmationPanel() {
JPanel panel = new JPanel(new GridLayout(6, 2));
JPanel panel = new JPanel(new GridLayout(4, 2));
JLabel offerLabel = new JLabel("Angebot:");
JComboBox<String> offerBox = new JComboBox<>();
for (Main.Offer offer : Main.offers) {
@ -260,8 +260,6 @@ public class FakturamaGUI {
panel.add(offerBox);
panel.add(dateLabel);
panel.add(dateField);
panel.add(new JLabel());
panel.add(new JLabel());
panel.add(backButton);
panel.add(addButton);
@ -270,7 +268,7 @@ public class FakturamaGUI {
}
private void showCreateDeliveryNotePanel() {
JPanel panel = new JPanel(new GridLayout(6, 2));
JPanel panel = new JPanel(new GridLayout(4, 2));
JLabel orderConfirmationLabel = new JLabel("Auftragsbestätigung:");
JComboBox<String> orderConfirmationBox = new JComboBox<>();
for (Main.OrderConfirmation orderConfirmation : Main.orderConfirmations) {
@ -300,8 +298,6 @@ public class FakturamaGUI {
panel.add(orderConfirmationBox);
panel.add(dateLabel);
panel.add(dateField);
panel.add(new JLabel());
panel.add(new JLabel());
panel.add(backButton);
panel.add(addButton);
@ -310,7 +306,7 @@ public class FakturamaGUI {
}
private void showCreateInvoicePanel() {
JPanel panel = new JPanel(new GridLayout(6, 2));
JPanel panel = new JPanel(new GridLayout(4, 2));
JLabel deliveryNoteLabel = new JLabel("Lieferschein:");
JComboBox<String> deliveryNoteBox = new JComboBox<>();
for (Main.DeliveryNote deliveryNote : Main.deliveryNotes) {
@ -341,8 +337,6 @@ public class FakturamaGUI {
panel.add(deliveryNoteBox);
panel.add(dateLabel);
panel.add(dateField);
panel.add(new JLabel());
panel.add(new JLabel());
panel.add(backButton);
panel.add(addButton);
@ -358,7 +352,7 @@ public class FakturamaGUI {
}
sb.append("\nArtikel:\n");
for (Main.Article article : Main.articles) {
sb.append(article.id).append(": ").append(article.description).append(" - ").append(article.unit).append(" - ").append(article.netPrice).append(" € - ").append(article.vatRate).append(" %").append("\n");
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) {