|
|
|
@ -18,19 +18,44 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
|
|
|
|
|
|
public BibliothekGUI() {
|
|
|
|
|
Bibliothek.makeEntries();
|
|
|
|
|
|
|
|
|
|
JPanel dateGrid = new JPanel(new GridLayout(1,4,10,10));
|
|
|
|
|
JLabel dateEntry = new JLabel("Datum eingeben: ");
|
|
|
|
|
String[] datumArray = {""};
|
|
|
|
|
JTextField dateInput = new JTextField(20);
|
|
|
|
|
JButton dateButton = new JButton("OK");
|
|
|
|
|
dateGrid.add(dateEntry);
|
|
|
|
|
dateGrid.add(dateInput);
|
|
|
|
|
dateGrid.add(dateButton);
|
|
|
|
|
JPanel loginPanel = new JPanel(new BorderLayout());
|
|
|
|
|
JLabel text1 = new JLabel("Login mit Kennnummer:");
|
|
|
|
|
loginPanel.add(text1, BorderLayout.NORTH);
|
|
|
|
|
dateButton.addActionListener(e -> {
|
|
|
|
|
if(datumArray[0] != "") {
|
|
|
|
|
dateGrid.remove(dateGrid.getComponentCount() -1);
|
|
|
|
|
String newDate1 = dateInput.getText().toString();
|
|
|
|
|
datumArray[0] = newDate1;
|
|
|
|
|
JLabel dateState1 = new JLabel("Datum: " + datumArray[0]);
|
|
|
|
|
dateGrid.add(dateState1);
|
|
|
|
|
dateGrid.revalidate();
|
|
|
|
|
} else {
|
|
|
|
|
String newDate = dateInput.getText().toString();
|
|
|
|
|
datumArray[0] = newDate;
|
|
|
|
|
JLabel dateState = new JLabel("Datum: " + datumArray[0]);
|
|
|
|
|
dateGrid.add(dateState);
|
|
|
|
|
dateGrid.revalidate();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
loginPanel.add(dateGrid, BorderLayout.NORTH);
|
|
|
|
|
|
|
|
|
|
JLabel text1 = new JLabel("Login mit Kennnummer: ");
|
|
|
|
|
JPanel loginGrid = new JPanel(new BorderLayout());
|
|
|
|
|
loginGrid.add(text1, BorderLayout.NORTH);
|
|
|
|
|
JTextField field1 = new JTextField(20);
|
|
|
|
|
loginGrid.add(field1);
|
|
|
|
|
loginPanel.add(loginGrid, BorderLayout.CENTER);
|
|
|
|
|
JButton b0 = new JButton("Registrieren");
|
|
|
|
|
b0.addActionListener(e -> { nutzerAnlegen();});
|
|
|
|
|
JButton b3 = new JButton("Ohne Anmeldung fortfahren");
|
|
|
|
|
b3.addActionListener(e -> {
|
|
|
|
|
browseMedia();
|
|
|
|
|
});
|
|
|
|
|
b3.addActionListener(e -> {browseMedia(datumArray[0]);});
|
|
|
|
|
JPanel buttonGrid = new JPanel(new GridLayout(1,2,10,10));
|
|
|
|
|
buttonGrid.add(b0);
|
|
|
|
|
buttonGrid.add(b3);
|
|
|
|
@ -47,7 +72,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
|
String text = k.getClass().toString();
|
|
|
|
|
int lastDotIndex = text.lastIndexOf(".");
|
|
|
|
|
String substring = text.substring(lastDotIndex + 1);
|
|
|
|
|
if(substring.equals("Kunde")) {openMainMenu(k);}
|
|
|
|
|
if(substring.equals("Kunde")) {openMainMenu(k, datumArray[0]);}
|
|
|
|
|
}});
|
|
|
|
|
bp.add(b1);
|
|
|
|
|
bp.add(b2);
|
|
|
|
@ -60,8 +85,53 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
|
cl.show(mainPanel, "loginPanel");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void browseMedia() {
|
|
|
|
|
JPanel browsePanel = new JPanel(new GridLayout(6, 1, 10, 10));
|
|
|
|
|
private static void openMainMenu(Kunde k, String datum) {
|
|
|
|
|
JPanel mediumPanel = new JPanel(new GridLayout(7, 1, 10, 10));
|
|
|
|
|
|
|
|
|
|
JPanel dateGrid = new JPanel(new GridLayout(1,4,10,10));
|
|
|
|
|
JLabel dateEntry = new JLabel("Datum eingeben: ");
|
|
|
|
|
String[] datumArray = {datum};
|
|
|
|
|
JTextField dateInput = new JTextField(20);
|
|
|
|
|
JButton dateButton = new JButton("OK");
|
|
|
|
|
dateGrid.add(dateEntry);
|
|
|
|
|
dateGrid.add(dateInput);
|
|
|
|
|
dateGrid.add(dateButton);
|
|
|
|
|
JLabel dateState1 = new JLabel("Datum: " + datumArray[0]);
|
|
|
|
|
dateGrid.add(dateState1);
|
|
|
|
|
dateButton.addActionListener(e -> {
|
|
|
|
|
String newDate = dateInput.getText().toString();
|
|
|
|
|
datumArray[0] = newDate;
|
|
|
|
|
JLabel dateState = new JLabel("Datum: " + datumArray[0]);
|
|
|
|
|
dateGrid.remove(dateState1);
|
|
|
|
|
dateGrid.add(dateState);
|
|
|
|
|
dateGrid.revalidate();
|
|
|
|
|
});
|
|
|
|
|
mediumPanel.add(dateGrid, BorderLayout.NORTH);
|
|
|
|
|
|
|
|
|
|
JButton b0 = new JButton("Medien durchsuchen");
|
|
|
|
|
b0.addActionListener(e -> { medienDurchsuchenMenu(k);});
|
|
|
|
|
JButton b1 = new JButton("Ausleihe");
|
|
|
|
|
b1.addActionListener(e -> ausleihenMenü(k, datumArray[0]));
|
|
|
|
|
JButton b2 = new JButton("Rückgabe");
|
|
|
|
|
b2.addActionListener(e -> rückgabeMenü(k, datumArray[0]));
|
|
|
|
|
JButton b3 = new JButton("Meine Ausgeliehenen Medien");
|
|
|
|
|
b3.addActionListener(e -> myBooks(k));
|
|
|
|
|
JButton b4 = new JButton("Verlängern");
|
|
|
|
|
b4.addActionListener(e -> verlängern(k, datumArray[0]));
|
|
|
|
|
JButton b5= new JButton("Ausloggen");
|
|
|
|
|
b5.addActionListener(e -> cl.show(mainPanel, "loginPanel"));
|
|
|
|
|
mediumPanel.add(b0);
|
|
|
|
|
mediumPanel.add(b1);
|
|
|
|
|
mediumPanel.add(b2);
|
|
|
|
|
mediumPanel.add(b3);
|
|
|
|
|
mediumPanel.add(b4);
|
|
|
|
|
mediumPanel.add(b5);
|
|
|
|
|
mainPanel.add(mediumPanel, "mediumPanel");
|
|
|
|
|
cl.show(mainPanel, "mediumPanel");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void browseMedia(String datum) {
|
|
|
|
|
JPanel browsePanel = new JPanel(new GridLayout(7, 1, 10, 10));
|
|
|
|
|
JButton b1 = new JButton("Bücher");
|
|
|
|
|
Kunde k = null;
|
|
|
|
|
b1.addActionListener(e -> bookMenu(k));
|
|
|
|
@ -73,18 +143,67 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
|
b4.addActionListener(e -> bsMenu(k));
|
|
|
|
|
JButton b5 = new JButton("Videospiele");
|
|
|
|
|
b5.addActionListener(e -> vsMenu(k));
|
|
|
|
|
JButton b6 = new JButton("OK");
|
|
|
|
|
b6.addActionListener(e -> cl.show(mainPanel, "loginPanel"));
|
|
|
|
|
JButton b6 = new JButton("Rückgabe");
|
|
|
|
|
b6.addActionListener(e -> { rückgabeOhneUserID(datum);});
|
|
|
|
|
JButton b7 = new JButton("Zurück");
|
|
|
|
|
b7.addActionListener(e -> cl.show(mainPanel, "loginPanel"));
|
|
|
|
|
browsePanel.add(b1);
|
|
|
|
|
browsePanel.add(b2);
|
|
|
|
|
browsePanel.add(b3);
|
|
|
|
|
browsePanel.add(b4);
|
|
|
|
|
browsePanel.add(b5);
|
|
|
|
|
browsePanel.add(b6);
|
|
|
|
|
browsePanel.add(b7);
|
|
|
|
|
mainPanel.add(browsePanel, "browsePanel");
|
|
|
|
|
cl.show(mainPanel, "browsePanel");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rückgabeOhneUserID(String datum) {
|
|
|
|
|
JPanel rückgabeOhneIdMenü = new JPanel(new BorderLayout());
|
|
|
|
|
//NORTH
|
|
|
|
|
JPanel dateGrid = new JPanel(new GridLayout(1,4,10,10));
|
|
|
|
|
JLabel dateEntry = new JLabel("Datum eingeben: ");
|
|
|
|
|
String[] datumArray = {datum};
|
|
|
|
|
JTextField dateInput = new JTextField(20);
|
|
|
|
|
JButton dateButton = new JButton("OK");
|
|
|
|
|
dateGrid.add(dateEntry);
|
|
|
|
|
dateGrid.add(dateInput);
|
|
|
|
|
dateGrid.add(dateButton);
|
|
|
|
|
JLabel dateState1 = new JLabel("Datum: " + datumArray[0]);
|
|
|
|
|
dateGrid.add(dateState1);
|
|
|
|
|
dateButton.addActionListener(e -> {
|
|
|
|
|
String newDate = dateInput.getText().toString();
|
|
|
|
|
datumArray[0] = newDate;
|
|
|
|
|
JLabel dateState = new JLabel("Datum: " + datumArray[0]);
|
|
|
|
|
dateGrid.remove(dateState1);
|
|
|
|
|
dateGrid.add(dateState);
|
|
|
|
|
dateGrid.revalidate();
|
|
|
|
|
});
|
|
|
|
|
rückgabeOhneIdMenü.add(dateGrid, BorderLayout.NORTH);
|
|
|
|
|
//CENTER
|
|
|
|
|
JPanel inputMenu = new JPanel(new GridLayout(2, 1, 10, 10));
|
|
|
|
|
JLabel text1 = new JLabel("Zu ausleihende Kennnummer des Mediums eingeben:");
|
|
|
|
|
JTextField inputField1 = new JTextField(20);
|
|
|
|
|
inputMenu.add(text1);
|
|
|
|
|
inputMenu.add(inputField1);
|
|
|
|
|
rückgabeOhneIdMenü.add(inputMenu, BorderLayout.CENTER);
|
|
|
|
|
//SOUTH
|
|
|
|
|
JPanel buttonGrid = new JPanel(new GridLayout(1, 2, 10,10));
|
|
|
|
|
JButton b1 = new JButton("Abbrechen");
|
|
|
|
|
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
|
|
|
|
JButton b2 = new JButton("OK");
|
|
|
|
|
buttonGrid.add(b1);
|
|
|
|
|
buttonGrid.add(b2);
|
|
|
|
|
rückgabeOhneIdMenü.add(buttonGrid, BorderLayout.SOUTH);
|
|
|
|
|
b2.addActionListener(e -> {
|
|
|
|
|
int kennnummer = Integer.parseInt(inputField1.getText());
|
|
|
|
|
Kunde k = Bibliothek.findKunde(kennnummer);
|
|
|
|
|
Bibliothek.rückgabe2(kennnummer, datumArray[0], k);
|
|
|
|
|
});
|
|
|
|
|
mainPanel.add(rückgabeOhneIdMenü, "Rückgabe1");
|
|
|
|
|
cl.show(mainPanel, "Rückgabe1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void nutzerAnlegen() {
|
|
|
|
|
JPanel registerMenu = new JPanel(new BorderLayout());
|
|
|
|
|
int newKennnummer = Bibliothek.getNewKennnummer();
|
|
|
|
@ -195,10 +314,10 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
|
cl.show(mainPanel, "changeOwed");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void openMainMenu(Kunde k) {
|
|
|
|
|
JPanel mediumPanel = new JPanel(new GridLayout(12, 1, 10, 10));
|
|
|
|
|
JLabel text1 = new JLabel("Ihre Kennnnummer: " + k.getKennnummer());
|
|
|
|
|
mediumPanel.add(text1);
|
|
|
|
|
private static void medienDurchsuchenMenu(Kunde k) {
|
|
|
|
|
JPanel suchenPanel = new JPanel(new GridLayout(7,1,10,10));
|
|
|
|
|
JButton b0 = new JButton("Stichwortsuche");
|
|
|
|
|
b0.addActionListener(e -> searchMenu(k));
|
|
|
|
|
JButton b1 = new JButton("Bücher");
|
|
|
|
|
b1.addActionListener(e -> bookMenu(k));
|
|
|
|
|
JButton b2 = new JButton("DVDs");
|
|
|
|
@ -209,34 +328,59 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
|
b4.addActionListener(e -> bsMenu(k));
|
|
|
|
|
JButton b5 = new JButton("Videospiele");
|
|
|
|
|
b5.addActionListener(e -> vsMenu(k));
|
|
|
|
|
JButton b6 = new JButton("Ausleihe");
|
|
|
|
|
b6.addActionListener(e -> ausleihenMenü(k));
|
|
|
|
|
JButton b7 = new JButton("Rückgabe");
|
|
|
|
|
b7.addActionListener(e -> rückgabeMenü(k));
|
|
|
|
|
JButton b8 = new JButton("Meine Ausgeliehenen Medien");
|
|
|
|
|
b8.addActionListener(e -> myBooks(k));
|
|
|
|
|
JButton b9 = new JButton("Verlängern");
|
|
|
|
|
b9.addActionListener(e -> verlängern(k));
|
|
|
|
|
JButton b10 = new JButton("Meine Schulden abbezahlen");
|
|
|
|
|
b10.addActionListener(e -> schuldenBegleichen(k));
|
|
|
|
|
JButton b11 = new JButton("Ausloggen");
|
|
|
|
|
b11.addActionListener(e -> cl.show(mainPanel, "loginPanel"));
|
|
|
|
|
mediumPanel.add(b1);
|
|
|
|
|
mediumPanel.add(b2);
|
|
|
|
|
mediumPanel.add(b3);
|
|
|
|
|
mediumPanel.add(b4);
|
|
|
|
|
mediumPanel.add(b5);
|
|
|
|
|
mediumPanel.add(b6);
|
|
|
|
|
mediumPanel.add(b7);
|
|
|
|
|
mediumPanel.add(b8);
|
|
|
|
|
mediumPanel.add(b9);
|
|
|
|
|
mediumPanel.add(b10);
|
|
|
|
|
mediumPanel.add(b11);
|
|
|
|
|
mainPanel.add(mediumPanel, "mediumPanel");
|
|
|
|
|
cl.show(mainPanel, "mediumPanel");
|
|
|
|
|
JButton b6 = new JButton("Zurück");
|
|
|
|
|
b6.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
|
|
|
|
suchenPanel.add(b0);
|
|
|
|
|
suchenPanel.add(b1);
|
|
|
|
|
suchenPanel.add(b2);
|
|
|
|
|
suchenPanel.add(b3);
|
|
|
|
|
suchenPanel.add(b4);
|
|
|
|
|
suchenPanel.add(b5);
|
|
|
|
|
suchenPanel.add(b6);
|
|
|
|
|
mainPanel.add(suchenPanel, "suchenMenu");
|
|
|
|
|
cl.show(mainPanel, "suchenMenu");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void verlängern(Kunde k) {
|
|
|
|
|
private static void searchMenu(Kunde k) {
|
|
|
|
|
JPanel mainSearch = new JPanel(new BorderLayout());
|
|
|
|
|
//NORTH: Search bar
|
|
|
|
|
JPanel enterSearch = new JPanel(new GridLayout(1,3,10,10));
|
|
|
|
|
JLabel text0 = new JLabel("Geben Sie einen Suchbegriff ein:");
|
|
|
|
|
JTextField enterSearchTerm = new JTextField(20);
|
|
|
|
|
JButton b0 = new JButton("Suchen");
|
|
|
|
|
enterSearch.add(text0);
|
|
|
|
|
enterSearch.add(enterSearchTerm);
|
|
|
|
|
enterSearch.add(b0);
|
|
|
|
|
mainSearch.add(enterSearch, BorderLayout.NORTH);
|
|
|
|
|
//CENTER: Matched media
|
|
|
|
|
b0.addActionListener(e -> {
|
|
|
|
|
String searchTerm = enterSearchTerm.getText().toString();
|
|
|
|
|
ArrayList<JLabel> matchedMedia = Bibliothek.findMatches(searchTerm);
|
|
|
|
|
int i = matchedMedia.size();
|
|
|
|
|
if(i == 0) {
|
|
|
|
|
JLabel text1 = new JLabel("Nichts passendes zu dem Suchbegriff " + searchTerm + " gefunden.");
|
|
|
|
|
mainSearch.add(text0, BorderLayout.CENTER);
|
|
|
|
|
} else if (i > 0){
|
|
|
|
|
JPanel ergebnisPanel = new JPanel(new GridLayout(i, 1, 10,10));
|
|
|
|
|
for(JLabel j: matchedMedia) {
|
|
|
|
|
ergebnisPanel.add(j);
|
|
|
|
|
}
|
|
|
|
|
mainSearch.revalidate();
|
|
|
|
|
mainSearch.add(ergebnisPanel, BorderLayout.CENTER);
|
|
|
|
|
mainSearch.revalidate();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
//SOUTH: OK Button to return
|
|
|
|
|
JButton b1 = new JButton("OK");
|
|
|
|
|
b1.addActionListener(e -> cl.show(mainPanel, "suchenMenu"));
|
|
|
|
|
mainSearch.add(b1, BorderLayout.SOUTH);
|
|
|
|
|
|
|
|
|
|
mainPanel.add(mainSearch, "Stichwort");
|
|
|
|
|
cl.show(mainPanel, "Stichwort");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void verlängern(Kunde k, String datumArray) {
|
|
|
|
|
|
|
|
|
|
JPanel verlängerungPanel = new JPanel(new BorderLayout());
|
|
|
|
|
JLabel text0 = new JLabel("Geben Sie die Kennnumer des Mediums ein, dessen Rückgabezeit sie verlängern möchten.");
|
|
|
|
|
JTextField inputField = new JTextField(20);
|
|
|
|
@ -313,95 +457,95 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
|
cl.show(mainPanel, "Verlängerung2");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void schuldenBegleichen(Kunde k) {
|
|
|
|
|
JPanel schuldenMenü = new JPanel(new BorderLayout());
|
|
|
|
|
double schulden = k.getSchulden();
|
|
|
|
|
if(schulden > 0) {
|
|
|
|
|
JLabel text0 = new JLabel("Sie haben " + schulden + "€ Schulden. Geben Sie unten ein, wie viel Sie zahlen möchten.");
|
|
|
|
|
JTextField inputField1 = new JTextField(20);
|
|
|
|
|
JButton b1 = new JButton("OK");
|
|
|
|
|
schuldenMenü.add(text0, BorderLayout.NORTH);
|
|
|
|
|
schuldenMenü.add(inputField1, BorderLayout.CENTER);
|
|
|
|
|
JPanel buttonGrid = new JPanel(new GridLayout(1,2,10,10));
|
|
|
|
|
JButton b2 = new JButton("Abbrechen");
|
|
|
|
|
b2.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
|
|
|
|
buttonGrid.add(b2);
|
|
|
|
|
buttonGrid.add(b1);
|
|
|
|
|
schuldenMenü.add(buttonGrid, BorderLayout.SOUTH);
|
|
|
|
|
b1.addActionListener(e -> {
|
|
|
|
|
int einzahlung = Integer.parseInt(inputField1.getText());
|
|
|
|
|
double newSchulden = schulden - einzahlung;
|
|
|
|
|
k.setSchulden(newSchulden);
|
|
|
|
|
cl.show(mainPanel, "mediumPanel");
|
|
|
|
|
});
|
|
|
|
|
} else if(schulden <= 0){
|
|
|
|
|
JLabel text0 = new JLabel("Sie haben keine Schulden.");
|
|
|
|
|
JLabel text1 = new JLabel("Ihr Guthaben beträgt " + schulden*(-1) + "€.");
|
|
|
|
|
JButton b1 = new JButton("OK");
|
|
|
|
|
schuldenMenü.add(text0, BorderLayout.NORTH);
|
|
|
|
|
schuldenMenü.add(text1, BorderLayout.CENTER);
|
|
|
|
|
schuldenMenü.add(b1, BorderLayout.SOUTH);
|
|
|
|
|
b1.addActionListener(e -> {
|
|
|
|
|
cl.show(mainPanel, "mediumPanel");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
mainPanel.add(schuldenMenü, "Schulden");
|
|
|
|
|
cl.show(mainPanel, "Schulden");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ausleihenMenü(Kunde k) {
|
|
|
|
|
|
|
|
|
|
private static void ausleihenMenü(Kunde k, String datum) {
|
|
|
|
|
JPanel ausleihMenü = new JPanel(new BorderLayout());
|
|
|
|
|
JPanel inputMenu = new JPanel(new GridLayout(4, 1, 10, 10));
|
|
|
|
|
//NORTH
|
|
|
|
|
JPanel dateGrid = new JPanel(new GridLayout(1,4,10,10));
|
|
|
|
|
JLabel dateEntry = new JLabel("Datum eingeben: ");
|
|
|
|
|
String[] datumArray = {datum};
|
|
|
|
|
JTextField dateInput = new JTextField(20);
|
|
|
|
|
JButton dateButton = new JButton("OK");
|
|
|
|
|
dateGrid.add(dateEntry);
|
|
|
|
|
dateGrid.add(dateInput);
|
|
|
|
|
dateGrid.add(dateButton);
|
|
|
|
|
JLabel dateState1 = new JLabel("Datum: " + datumArray[0]);
|
|
|
|
|
dateGrid.add(dateState1);
|
|
|
|
|
dateButton.addActionListener(e -> {
|
|
|
|
|
String newDate = dateInput.getText().toString();
|
|
|
|
|
datumArray[0] = newDate;
|
|
|
|
|
JLabel dateState = new JLabel("Datum: " + datumArray[0]);
|
|
|
|
|
dateGrid.remove(dateState1);
|
|
|
|
|
dateGrid.add(dateState);
|
|
|
|
|
dateGrid.revalidate();
|
|
|
|
|
});
|
|
|
|
|
ausleihMenü.add(dateGrid, BorderLayout.NORTH);
|
|
|
|
|
//CENTER
|
|
|
|
|
JPanel inputMenu = new JPanel(new GridLayout(2, 1, 10, 10));
|
|
|
|
|
JLabel text1 = new JLabel("Zu ausleihende Kennnummer des Mediums eingeben:");
|
|
|
|
|
JTextField inputField1 = new JTextField(20);
|
|
|
|
|
JLabel text2 = new JLabel("Datum eingeben:");
|
|
|
|
|
JTextField inputField2 = new JTextField(20);
|
|
|
|
|
inputMenu.add(text1);
|
|
|
|
|
inputMenu.add(inputField1);
|
|
|
|
|
inputMenu.add(text2);
|
|
|
|
|
inputMenu.add(inputField2);
|
|
|
|
|
ausleihMenü.add(inputMenu, BorderLayout.CENTER);
|
|
|
|
|
//SOUTH
|
|
|
|
|
JPanel buttonGrid = new JPanel(new GridLayout(1, 2, 10,10));
|
|
|
|
|
JButton b1 = new JButton("Abbrechen");
|
|
|
|
|
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
|
|
|
|
JButton b2 = new JButton("OK");
|
|
|
|
|
b2.addActionListener(e -> {
|
|
|
|
|
int kennnummer = Integer.parseInt(inputField1.getText());
|
|
|
|
|
String ausleihDatum = inputField2.getText().toString();
|
|
|
|
|
Bibliothek.ausleihe(kennnummer, ausleihDatum, k);
|
|
|
|
|
cl.show(mainPanel, "mediumPanel");
|
|
|
|
|
});
|
|
|
|
|
buttonGrid.add(b1);
|
|
|
|
|
buttonGrid.add(b2);
|
|
|
|
|
ausleihMenü.add(buttonGrid, BorderLayout.SOUTH);
|
|
|
|
|
b2.addActionListener(e -> {
|
|
|
|
|
int kennnummer = Integer.parseInt(inputField1.getText());
|
|
|
|
|
Bibliothek.ausleihe(kennnummer, datumArray[0], k);
|
|
|
|
|
cl.show(mainPanel, "mediumPanel");
|
|
|
|
|
});
|
|
|
|
|
mainPanel.add(ausleihMenü, "Ausleihen");
|
|
|
|
|
cl.show(mainPanel, "Ausleihen");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void rückgabeMenü(Kunde k) {
|
|
|
|
|
private static void rückgabeMenü(Kunde k, String datum) {
|
|
|
|
|
JPanel rückgabeMenü = new JPanel(new BorderLayout());
|
|
|
|
|
JPanel inputMenu = new JPanel(new GridLayout(4,1,10,10));
|
|
|
|
|
JLabel text1 = new JLabel("Kennnummer des Mediums zur Rückgabe eingeben:");
|
|
|
|
|
//NORTH
|
|
|
|
|
JPanel dateGrid = new JPanel(new GridLayout(1,4,10,10));
|
|
|
|
|
JLabel dateEntry = new JLabel("Datum eingeben: ");
|
|
|
|
|
String[] datumArray = {datum};
|
|
|
|
|
JTextField dateInput = new JTextField(20);
|
|
|
|
|
JButton dateButton = new JButton("OK");
|
|
|
|
|
dateGrid.add(dateEntry);
|
|
|
|
|
dateGrid.add(dateInput);
|
|
|
|
|
dateGrid.add(dateButton);
|
|
|
|
|
JLabel dateState1 = new JLabel("Datum: " + datumArray[0]);
|
|
|
|
|
dateGrid.add(dateState1);
|
|
|
|
|
dateButton.addActionListener(e -> {
|
|
|
|
|
String newDate = dateInput.getText().toString();
|
|
|
|
|
datumArray[0] = newDate;
|
|
|
|
|
JLabel dateState = new JLabel("Datum: " + datumArray[0]);
|
|
|
|
|
dateGrid.remove(dateState1);
|
|
|
|
|
dateGrid.add(dateState);
|
|
|
|
|
dateGrid.revalidate();
|
|
|
|
|
});
|
|
|
|
|
rückgabeMenü.add(dateGrid, BorderLayout.NORTH);
|
|
|
|
|
//CENTER
|
|
|
|
|
JPanel inputMenu = new JPanel(new GridLayout(2, 1, 10, 10));
|
|
|
|
|
JLabel text1 = new JLabel("Zu ausleihende Kennnummer des Mediums eingeben:");
|
|
|
|
|
JTextField inputField1 = new JTextField(20);
|
|
|
|
|
JLabel text2 = new JLabel("Datum eingeben:");
|
|
|
|
|
JTextField inputField2 = new JTextField(20);
|
|
|
|
|
inputMenu.add(text1);
|
|
|
|
|
inputMenu.add(inputField1);
|
|
|
|
|
inputMenu.add(text2);
|
|
|
|
|
inputMenu.add(inputField2);
|
|
|
|
|
rückgabeMenü.add(inputMenu, BorderLayout.CENTER);;
|
|
|
|
|
rückgabeMenü.add(inputMenu, BorderLayout.CENTER);
|
|
|
|
|
//SOUTH
|
|
|
|
|
JPanel buttonGrid = new JPanel(new GridLayout(1, 2, 10,10));
|
|
|
|
|
JButton b1 = new JButton("Abbrechen");
|
|
|
|
|
b1.addActionListener(e -> cl.show(mainPanel, "mediumPanel"));
|
|
|
|
|
JButton b2 = new JButton("OK");
|
|
|
|
|
b2.addActionListener(e -> {
|
|
|
|
|
int kennnummer = Integer.parseInt(inputField1.getText());
|
|
|
|
|
String rückgabeDatum = inputField2.getText().toString();
|
|
|
|
|
Bibliothek.rückgabe(kennnummer, rückgabeDatum, k);
|
|
|
|
|
});
|
|
|
|
|
buttonGrid.add(b1);
|
|
|
|
|
buttonGrid.add(b2);
|
|
|
|
|
rückgabeMenü.add(buttonGrid, BorderLayout.SOUTH);
|
|
|
|
|
b2.addActionListener(e -> {
|
|
|
|
|
int kennnummer = Integer.parseInt(inputField1.getText());
|
|
|
|
|
Bibliothek.rückgabe(kennnummer, datumArray[0], k);
|
|
|
|
|
});
|
|
|
|
|
mainPanel.add(rückgabeMenü, "Rückgabe");
|
|
|
|
|
cl.show(mainPanel, "Rückgabe");
|
|
|
|
|
}
|
|
|
|
@ -420,7 +564,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
|
if(k == null) {
|
|
|
|
|
cl.show(mainPanel, "browsePanel");
|
|
|
|
|
} else {
|
|
|
|
|
cl.show(mainPanel, "mediumPanel");}
|
|
|
|
|
cl.show(mainPanel, "suchenMenu");}
|
|
|
|
|
});
|
|
|
|
|
buchMenü.add(b1, BorderLayout.SOUTH);
|
|
|
|
|
mainPanel.add(buchMenü, "Bücher");
|
|
|
|
@ -441,7 +585,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
|
if(k == null) {
|
|
|
|
|
cl.show(mainPanel, "browsePanel");
|
|
|
|
|
} else {
|
|
|
|
|
cl.show(mainPanel, "mediumPanel");}
|
|
|
|
|
cl.show(mainPanel, "suchenMenu");}
|
|
|
|
|
});
|
|
|
|
|
dvdMenü.add(b1, BorderLayout.SOUTH);
|
|
|
|
|
mainPanel.add(dvdMenü, "DVDs");
|
|
|
|
@ -462,7 +606,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
|
if(k == null) {
|
|
|
|
|
cl.show(mainPanel, "browsePanel");
|
|
|
|
|
} else {
|
|
|
|
|
cl.show(mainPanel, "mediumPanel");}
|
|
|
|
|
cl.show(mainPanel, "suchenMenu");}
|
|
|
|
|
}); cdMenü.add(b1, BorderLayout.SOUTH);
|
|
|
|
|
mainPanel.add(cdMenü, "CDs");
|
|
|
|
|
cl.show(mainPanel, "CDs");
|
|
|
|
@ -482,7 +626,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
|
if(k == null) {
|
|
|
|
|
cl.show(mainPanel, "browsePanel");
|
|
|
|
|
} else {
|
|
|
|
|
cl.show(mainPanel, "mediumPanel");}
|
|
|
|
|
cl.show(mainPanel, "suchenMenu");}
|
|
|
|
|
}); bsMenü.add(b1, BorderLayout.SOUTH);
|
|
|
|
|
mainPanel.add(bsMenü, "Brettspiele");
|
|
|
|
|
cl.show(mainPanel, "Brettspiele");
|
|
|
|
@ -502,7 +646,7 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
|
if(k == null) {
|
|
|
|
|
cl.show(mainPanel, "browsePanel");
|
|
|
|
|
} else {
|
|
|
|
|
cl.show(mainPanel, "mediumPanel");}
|
|
|
|
|
cl.show(mainPanel, "suchenMenu");}
|
|
|
|
|
}); vsMenü.add(b1, BorderLayout.SOUTH);
|
|
|
|
|
mainPanel.add(vsMenü, "Videospiele");
|
|
|
|
|
cl.show(mainPanel, "Videospiele");
|
|
|
|
@ -532,52 +676,37 @@ public class BibliothekGUI extends JFrame implements ActionListener{
|
|
|
|
|
|
|
|
|
|
public static void zahlungsFenster(double kosten, String titel, int kennnummer, Kunde k) {
|
|
|
|
|
JPanel zahlungPanel = new JPanel(new BorderLayout());
|
|
|
|
|
JLabel text1 = new JLabel("Sie schulden für das Buch " + titel + " mit der Kennnummer " + kennnummer + " " + kosten + "€.");
|
|
|
|
|
zahlungPanel.add(text1, BorderLayout.NORTH);
|
|
|
|
|
JPanel zahlungPanelMitte = new JPanel(new GridLayout(2,1,10,10));
|
|
|
|
|
JLabel text3 = new JLabel("Geben Sie ein wieviel sie zahlen:");
|
|
|
|
|
zahlungPanelMitte.add(text3);
|
|
|
|
|
JTextField inputField1 = new JTextField(20);
|
|
|
|
|
zahlungPanelMitte.add(inputField1);
|
|
|
|
|
zahlungPanel.add(zahlungPanelMitte, BorderLayout.CENTER);
|
|
|
|
|
//CENTER
|
|
|
|
|
JLabel text1 = new JLabel("Sie schulden für das Buch " + titel + " mit der Kennnummer " + kennnummer + " " + kosten + "€. Bitte zahlen Sie die Gebühren an der Kasse.");
|
|
|
|
|
zahlungPanel.add(text1, BorderLayout.CENTER);
|
|
|
|
|
//SOUTH
|
|
|
|
|
JButton b1 = new JButton("OK");
|
|
|
|
|
zahlungPanel.add(b1, BorderLayout.SOUTH);
|
|
|
|
|
mainPanel.add(zahlungPanel,"Zahlung1");
|
|
|
|
|
cl.show(mainPanel, "Zahlung1");
|
|
|
|
|
b1.addActionListener(e -> {
|
|
|
|
|
String paymentString = inputField1.getText().toString();
|
|
|
|
|
zahlungStatus(paymentString, kosten, k);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void zahlungStatus(String zahlungStr, double kosten, Kunde k) {
|
|
|
|
|
int zahlung = Integer.parseInt(zahlungStr);
|
|
|
|
|
boolean zahlungErfolgreich = Bibliothek.zahlungRegistrieren(zahlung, kosten);
|
|
|
|
|
JPanel zahlungStatusPanel = new JPanel(new BorderLayout());
|
|
|
|
|
JLabel text2 = new JLabel("Zahlungsstatus:");
|
|
|
|
|
zahlungStatusPanel.add(text2, BorderLayout.NORTH);
|
|
|
|
|
JButton b2 = new JButton("OK");
|
|
|
|
|
zahlungStatusPanel.add(b2, BorderLayout.SOUTH);
|
|
|
|
|
if(zahlungErfolgreich == true) {
|
|
|
|
|
JLabel text4 = new JLabel("Zahlung war erfolgreich!");
|
|
|
|
|
zahlungStatusPanel.add(text4, BorderLayout.CENTER);
|
|
|
|
|
k.setSchulden(kosten - zahlung);
|
|
|
|
|
} else {
|
|
|
|
|
k.setSchulden(kosten - zahlung);
|
|
|
|
|
double schulden = k.getSchulden();
|
|
|
|
|
JLabel text4 = new JLabel("Zahlung fehlgeschlagen! Ihnen wurden " + schulden + "€ Schulden zugeschrieben.");
|
|
|
|
|
zahlungStatusPanel.add(text4, BorderLayout.CENTER);
|
|
|
|
|
}
|
|
|
|
|
mainPanel.add(zahlungStatusPanel, "Zahlung2");
|
|
|
|
|
cl.show(mainPanel, "Zahlung2");
|
|
|
|
|
b2.addActionListener(e -> {
|
|
|
|
|
cl.show(mainPanel, "mediumPanel");
|
|
|
|
|
myBooks(k);
|
|
|
|
|
});
|
|
|
|
|
mainPanel.add(zahlungPanel,"Zahlung");
|
|
|
|
|
cl.show(mainPanel, "Zahlung");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void noMoneyOwed() {
|
|
|
|
|
cl.show(mainPanel, "mediumPanel");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void zahlungsFenster2(double kosten, String titel, int kennnummer, Kunde k) {
|
|
|
|
|
JPanel zahlungPanel = new JPanel(new BorderLayout());
|
|
|
|
|
//CENTER
|
|
|
|
|
JLabel text1 = new JLabel("Sie schulden für das Buch " + titel + " mit der Kennnummer " + kennnummer + " " + kosten + "€. Bitte zahlen Sie die Gebühren an der Kasse.");
|
|
|
|
|
zahlungPanel.add(text1, BorderLayout.CENTER);
|
|
|
|
|
//SOUTH
|
|
|
|
|
JButton b1 = new JButton("OK");
|
|
|
|
|
zahlungPanel.add(b1, BorderLayout.SOUTH);
|
|
|
|
|
b1.addActionListener(e -> {
|
|
|
|
|
cl.show(mainPanel, "browsePanel");
|
|
|
|
|
});
|
|
|
|
|
mainPanel.add(zahlungPanel,"Zahlung2");
|
|
|
|
|
cl.show(mainPanel, "Zahlung2");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|