diff options
Diffstat (limited to 'dozentenmodul/src/main/java/gui/lecture')
| -rw-r--r-- | dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java | 194 |
1 files changed, 97 insertions, 97 deletions
diff --git a/dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java b/dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java index 38d29620..49a2c7a0 100644 --- a/dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java +++ b/dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java @@ -342,6 +342,103 @@ public class DeleteLecture_GUI extends JFrame { tablemyLectures.setRowSorter(rowSorterMyLectures); scrollPaneMyImage.setViewportView(tablemyLectures); + + button = new JButton("Löschen"); + button.setBounds(442, 495, 118, 23); + contentPanel.add(button); + button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + + String lectureID = ""; + int eingabe; + String username = person.verantwortlicher.getName() + " " + + person.verantwortlicher.getVorname(); + // check if a row is selected + if (tablemyLectures.getSelectedRowCount() != 0) { + // a row is selected + // ask for confirmation + eingabe = JOptionPane.showConfirmDialog(c, + "Wollen Sie diese Daten löschen?", "Löschen?", + JOptionPane.YES_NO_OPTION); + + if (eingabe == JOptionPane.YES_OPTION) { + // user has confirmed deletion, now get the ID of the + // selected lecture + lectureID = modelMyLectures + .getValueAt( + tablemyLectures + .convertColumnIndexToModel(tablemyLectures + .getSelectedRow()), 8) + .toString(); + LOGGER.info("Lösche Veranstaltung: " + lectureID); + try { + if (client.deleteLecture(lectureID, + person.verantwortlicher.getHochschule(), + person.verantwortlicher.getUsername())) { + LOGGER.info("Löschen erfolgreich."); + // delete successful + + DeleteLecture_GUI dl = new DeleteLecture_GUI(c); + dl.setVisible(true); + dispose(); + } else { + // delete not successful + LOGGER.error("Konnte Veranstaltung '" + + lectureID + + "' nicht aus der Datenbank löschen!"); + JOptionPane + .showMessageDialog( + c, + "Löschen der Veranstaltung aus der Datenbank fehlgeschlagen.", + "Fehler", + JOptionPane.INFORMATION_MESSAGE); + } + } catch (TException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + }// end delete + }// end ask for confirmation + + }// end check if a row is selected + /* + * else if (tableAllLectures.getSelectedRowCount() !=0 && + * tableAllLectures + * .getValueAt(tableAllLectures.getSelectedRow(), + * 5).toString().equals(username)){ //a row is selected //ask + * for confirmation eingabe = + * JOptionPane.showConfirmDialog(null, + * "Wollen Sie diese Daten löschen?", "Löschen?", + * JOptionPane.YES_NO_OPTION); + * + * if (eingabe == JOptionPane.YES_OPTION) { //user has confirmed + * deletion, now get the ID of the selected lecture lectureID = + * tableAllLectures + * .getValueAt(tableAllLectures.convertColumnIndexToModel + * (tableAllLectures.getSelectedRow()), 8).toString(); + * LOGGER.info("Lösche Veranstaltung: "+lectureID); try { + * if(client.deleteLecture(lectureID, + * person.verantwortlicher.getHochschule + * (),person.verantwortlicher.getUsername())){ + * LOGGER.info("Löschen erfolgreich."); //delete successful + * + * DeleteLecture_GUI dl = new DeleteLecture_GUI(); + * dl.setVisible(true); dispose(); } else { //delete not + * successful LOGGER.error("Konnte Veranstaltung '" + lectureID + * + "' nicht aus der Datenbank löschen!"); JOptionPane + * .showMessageDialog( null, + * "Löschen aus Datenbank fehlgeschlagen.", "Fehler", + * JOptionPane.INFORMATION_MESSAGE); } } catch (TException e1) { + * // TODO Auto-generated catch block e1.printStackTrace(); + * }//end delete }//end ask for confirmation + * + * } else { //end check if a row is selected JOptionPane + * .showMessageDialog( null, + * "Bitte wählen Sie ein eigenes Image aus.", "Message", + * JOptionPane.INFORMATION_MESSAGE); } + */ + + } + }); { JPanel buttonPane = new JPanel(); buttonPane.setBounds(0, 640, 826, 33); @@ -464,103 +561,6 @@ public class DeleteLecture_GUI extends JFrame { scrollPaneName.setBounds(10, 40, 218, 55); panel.add(scrollPaneName); - button = new JButton("Löschen"); - button.setBounds(469, 606, 118, 23); - getContentPane().add(button); - button.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - - String lectureID = ""; - int eingabe; - String username = person.verantwortlicher.getName() + " " - + person.verantwortlicher.getVorname(); - // check if a row is selected - if (tablemyLectures.getSelectedRowCount() != 0) { - // a row is selected - // ask for confirmation - eingabe = JOptionPane.showConfirmDialog(c, - "Wollen Sie diese Daten löschen?", "Löschen?", - JOptionPane.YES_NO_OPTION); - - if (eingabe == JOptionPane.YES_OPTION) { - // user has confirmed deletion, now get the ID of the - // selected lecture - lectureID = modelMyLectures - .getValueAt( - tablemyLectures - .convertColumnIndexToModel(tablemyLectures - .getSelectedRow()), 8) - .toString(); - LOGGER.info("Lösche Veranstaltung: " + lectureID); - try { - if (client.deleteLecture(lectureID, - person.verantwortlicher.getHochschule(), - person.verantwortlicher.getUsername())) { - LOGGER.info("Löschen erfolgreich."); - // delete successful - - DeleteLecture_GUI dl = new DeleteLecture_GUI(c); - dl.setVisible(true); - dispose(); - } else { - // delete not successful - LOGGER.error("Konnte Veranstaltung '" - + lectureID - + "' nicht aus der Datenbank löschen!"); - JOptionPane - .showMessageDialog( - c, - "Löschen der Veranstaltung aus der Datenbank fehlgeschlagen.", - "Fehler", - JOptionPane.INFORMATION_MESSAGE); - } - } catch (TException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - }// end delete - }// end ask for confirmation - - }// end check if a row is selected - /* - * else if (tableAllLectures.getSelectedRowCount() !=0 && - * tableAllLectures - * .getValueAt(tableAllLectures.getSelectedRow(), - * 5).toString().equals(username)){ //a row is selected //ask - * for confirmation eingabe = - * JOptionPane.showConfirmDialog(null, - * "Wollen Sie diese Daten löschen?", "Löschen?", - * JOptionPane.YES_NO_OPTION); - * - * if (eingabe == JOptionPane.YES_OPTION) { //user has confirmed - * deletion, now get the ID of the selected lecture lectureID = - * tableAllLectures - * .getValueAt(tableAllLectures.convertColumnIndexToModel - * (tableAllLectures.getSelectedRow()), 8).toString(); - * LOGGER.info("Lösche Veranstaltung: "+lectureID); try { - * if(client.deleteLecture(lectureID, - * person.verantwortlicher.getHochschule - * (),person.verantwortlicher.getUsername())){ - * LOGGER.info("Löschen erfolgreich."); //delete successful - * - * DeleteLecture_GUI dl = new DeleteLecture_GUI(); - * dl.setVisible(true); dispose(); } else { //delete not - * successful LOGGER.error("Konnte Veranstaltung '" + lectureID - * + "' nicht aus der Datenbank löschen!"); JOptionPane - * .showMessageDialog( null, - * "Löschen aus Datenbank fehlgeschlagen.", "Fehler", - * JOptionPane.INFORMATION_MESSAGE); } } catch (TException e1) { - * // TODO Auto-generated catch block e1.printStackTrace(); - * }//end delete }//end ask for confirmation - * - * } else { //end check if a row is selected JOptionPane - * .showMessageDialog( null, - * "Bitte wählen Sie ein eigenes Image aus.", "Message", - * JOptionPane.INFORMATION_MESSAGE); } - */ - - } - }); - JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); |
