start
This commit is contained in:
parent
9e6ae9604a
commit
c5a033403b
@ -14,9 +14,8 @@ public class Datail {
|
||||
|
||||
}
|
||||
|
||||
public static DefaultTableModel detailmodel(int verein, String url) {
|
||||
public static DefaultTableModel detailmodel(DefaultTableModel t,int verein, String url) {
|
||||
String[][] temp = {{""}};
|
||||
DefaultTableModel t = new DefaultTableModel();
|
||||
System.out.println("test = "+verein);
|
||||
|
||||
try (Connection conn = DriverManager.getConnection(url, "root", "")) {
|
||||
|
@ -36,10 +36,10 @@ public class Einzelansicht extends JFrame implements TableModelListener, ActionL
|
||||
JMenu adm = null;
|
||||
JMenuItem i1, i2, i3, i4, i5, i6, i7;
|
||||
|
||||
static JTable detail;
|
||||
static DefaultTableModel dtm = new DefaultTableModel();
|
||||
static JTable detail = new JTable(dtm);
|
||||
static JScrollPane dsc;
|
||||
static int vid = 1;
|
||||
static DefaultTableModel dtm = new DefaultTableModel();
|
||||
|
||||
|
||||
public Einzelansicht(String ta) {
|
||||
@ -73,6 +73,9 @@ public class Einzelansicht extends JFrame implements TableModelListener, ActionL
|
||||
i4 = new JMenuItem("Suchen");
|
||||
i4.addActionListener(e -> {
|
||||
s.setText(JOptionPane.showInputDialog("Wonach wollen Sie suchen?"));
|
||||
r = Suchen.search(s.getText(), r);
|
||||
s.setText("");
|
||||
einfügen(r);
|
||||
});
|
||||
|
||||
i5 = new JMenuItem("Einfügen");
|
||||
@ -102,12 +105,11 @@ public class Einzelansicht extends JFrame implements TableModelListener, ActionL
|
||||
|
||||
try (Connection conn = DriverManager.getConnection(url, "root", "")) {
|
||||
Statement s = conn.createStatement();
|
||||
r = s.executeQuery("Select * FROM " + tab);
|
||||
rm = r.getMetaData();
|
||||
sql = "Select * From " + tab;
|
||||
r = s.executeQuery(sql);
|
||||
rm = r.getMetaData();
|
||||
r.first();
|
||||
einfügen(r);
|
||||
detailtab(vid);
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
@ -176,7 +178,7 @@ public class Einzelansicht extends JFrame implements TableModelListener, ActionL
|
||||
|
||||
t.addTableModelListener(this);
|
||||
|
||||
detail = new JTable(dtm);
|
||||
|
||||
detail.setAutoCreateRowSorter(true);
|
||||
dsc = new JScrollPane(detail);
|
||||
dsc.setBounds(20, 250, 550, 400);
|
||||
@ -206,9 +208,10 @@ public class Einzelansicht extends JFrame implements TableModelListener, ActionL
|
||||
}
|
||||
t.addRow(rows);
|
||||
t.fireTableDataChanged();
|
||||
|
||||
vid = r.getInt(1);
|
||||
detailtab(vid);
|
||||
dtm.fireTableDataChanged();
|
||||
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
@ -222,16 +225,9 @@ public class Einzelansicht extends JFrame implements TableModelListener, ActionL
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
|
||||
try {
|
||||
r = Suchen.search(s.getText(), r);
|
||||
s.setText("");
|
||||
einfügen(r);
|
||||
vid = r.getInt("V_ID");
|
||||
detailtab(vid);
|
||||
} catch (SQLException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,26 +313,7 @@ public class Einzelansicht extends JFrame implements TableModelListener, ActionL
|
||||
case "änd":
|
||||
break;
|
||||
case "lösch":
|
||||
System.out.println(t.getValueAt(0, 0));
|
||||
String wh = t.getValueAt(0, 0).toString();
|
||||
int response = JOptionPane.showConfirmDialog(null, "Wollen Sie den Eintrag löschen?", "Bestätigen", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||
if (response == 0) {
|
||||
try (Connection conn = DriverManager.getConnection(url, "root", "")) {
|
||||
Statement s = conn.createStatement();
|
||||
ResultSet r = s.executeQuery("DELETE From " + tab + " WHERE " + t.getColumnName(0) + "=" + wh);
|
||||
ResultSet r2 = s.executeQuery("Select * from " + tab);
|
||||
r2.previous();
|
||||
einfügen(r2);
|
||||
} catch (SQLException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
table.clearSelection();
|
||||
t.removeRow(0);
|
||||
t.fireTableDataChanged();
|
||||
Löschen l = new Löschen(tab,t,table);
|
||||
break;
|
||||
case "close":
|
||||
this.dispose();
|
||||
@ -349,7 +326,7 @@ public class Einzelansicht extends JFrame implements TableModelListener, ActionL
|
||||
}
|
||||
|
||||
public static void detailtab(int vid) {
|
||||
dtm = Datail.detailmodel(vid, url);
|
||||
Datail.detailmodel(dtm, vid, url);
|
||||
dtm.fireTableDataChanged();
|
||||
|
||||
|
||||
|
@ -9,19 +9,19 @@ public class Löschen {
|
||||
String url = "jdbc:mariadb://127.0.0.1:3306/bundesliga";
|
||||
|
||||
public Löschen(String tab, DefaultTableModel model, JTable table) {
|
||||
int zeile = table.getSelectedRow();
|
||||
|
||||
String wh = model.getValueAt(zeile, 0).toString();
|
||||
int response = JOptionPane.showConfirmDialog(null, "Wollen Sie dein Eintrag in Zeile " + (zeile+1) + " löschen?", "Bestätigen", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||
int response = JOptionPane.showConfirmDialog(null, "Wollen Sie dein Eintrag löschen?", "Bestätigen", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||
if (response == 0) {
|
||||
try (Connection conn = DriverManager.getConnection(url, "root", "")) {
|
||||
Statement s = conn.createStatement();
|
||||
ResultSet r = s.executeQuery("DELETE From " + tab + " WHERE " + model.getColumnName(0) + "=" + wh);
|
||||
ResultSet r = s.executeQuery("INSERT into bundesliga_archiv.verein SELECT * ,CURRENT_TIMESTAMP FROM `verein` WHERE V_ID = " + Einzelansicht.vid);
|
||||
r = s.executeQuery("DELETE From " + tab + " WHERE " + model.getColumnName(0) + "=" + Einzelansicht.vid);
|
||||
|
||||
Einzelansicht.r.next();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Tabellen.einfügen(tab);
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user