Skip to content

Commit 39d3afd

Browse files
committed
aufträge
1 parent 874a9db commit 39d3afd

9 files changed

Lines changed: 385 additions & 40 deletions

File tree

src/gui/Auftraege.java

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package gui;
2+
3+
import java.awt.EventQueue;
4+
import java.awt.Toolkit;
5+
import java.sql.ResultSet;
6+
import java.sql.SQLException;
7+
8+
import javax.swing.JDialog;
9+
import javax.swing.JScrollPane;
10+
import java.awt.BorderLayout;
11+
import javax.swing.JTable;
12+
import javax.swing.table.DefaultTableModel;
13+
14+
import extern.ButtonColumn;
15+
import fachklasse.DBManager;
16+
17+
public class Auftraege extends JDialog {
18+
private JTable table;
19+
20+
public Auftraege(DBManager dbm) {
21+
setTitle("Aufträge");
22+
setBounds(100, 100, 699, 320);
23+
setModal(true);
24+
setIconImage(Toolkit.getDefaultToolkit().getImage(AnmeldungGui.class.getResource("/img/icon.png")));
25+
26+
JScrollPane scrollPane = new JScrollPane();
27+
getContentPane().add(scrollPane, BorderLayout.CENTER);
28+
29+
table = new JTable();
30+
table.setModel(new DefaultTableModel(
31+
new Object[][] {
32+
},
33+
new String[] {
34+
"Auftragsname", "Kunde", "Start", "ende", "Status", "Notizen"
35+
}
36+
) {
37+
Class[] columnTypes = new Class[] {
38+
String.class, String.class, String.class, String.class, String.class, String.class
39+
};
40+
public Class getColumnClass(int columnIndex) {
41+
return columnTypes[columnIndex];
42+
}
43+
boolean[] columnEditables = new boolean[] {
44+
false, false, false, false, false, false
45+
};
46+
public boolean isCellEditable(int row, int column) {
47+
return columnEditables[column];
48+
}
49+
});
50+
scrollPane.setViewportView(table);
51+
52+
dbm.startConnect("crm");
53+
try {
54+
ResultSet rs = dbm.getStatement().executeQuery("SELECT auftraege.*, kunden.name, vorname FROM crm.auftraege, crm.kunden where auftraege.kundenNr = kunden.kundenNr;");
55+
while(rs.next()){
56+
String kunde = rs.getString(8)+ "; " +rs.getString(9);
57+
String data[] = {rs.getString(2),kunde, rs.getString(3),rs.getString(4),rs.getString(6),rs.getString(5)};
58+
DefaultTableModel tbm = (DefaultTableModel) table.getModel();
59+
tbm.addRow(data);
60+
}
61+
62+
} catch (SQLException e) {
63+
e.printStackTrace();
64+
}
65+
dbm.closeConnection();
66+
}
67+
68+
}

src/gui/Benutzervewaltung.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ public boolean isCellEditable(int row, int column) {
155155
contentPanel.setLayout(gl_contentPanel);
156156

157157
//Button action event Löschen
158-
Action delete = new AbstractAction()
159-
{
158+
Action deleteAction = new AbstractAction() {
160159
public void actionPerformed(ActionEvent e)
161160
{
162161
//Tabelle suche (quelle + reihe)
@@ -186,10 +185,9 @@ public void actionPerformed(ActionEvent e)
186185
dbm.startConnect("");
187186
ResultSet rs = dbm.getStatement().executeQuery("select User, Host from mysql.user where not User=\"root\" and not User=\"mysql.infoschema\" and not User=\"mysql.session\" and not User=\"mysql.sys\" and not User='"+dbm.getUser()+"';");
188187
while(rs.next()){
189-
new ButtonColumn(table, delete, 2);
188+
new ButtonColumn(table, deleteAction, 2);
190189
String data[] = {rs.getString(1),rs.getString(2),"Löschen"};
191190
DefaultTableModel tbm = (DefaultTableModel) table.getModel();
192-
193191
tbm.addRow(data);
194192
}
195193
dbm.closeConnection();

src/gui/Kunden.java

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,23 @@ public void actionPerformed(ActionEvent e) {
183183
textFieldKundenNr = new JTextField();
184184
textFieldKundenNr.setEditable(false);
185185
textFieldKundenNr.setColumns(10);
186+
187+
JLabel lblNewLabel_2 = new JLabel("Aufträge");
188+
189+
JLabel lblNewLabel_3 = new JLabel("Termine");
186190
GroupLayout groupLayout = new GroupLayout(getContentPane());
187191
groupLayout.setHorizontalGroup(
188192
groupLayout.createParallelGroup(Alignment.LEADING)
189193
.addGroup(groupLayout.createSequentialGroup()
190194
.addContainerGap()
191195
.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
192-
.addComponent(lblInteressen, GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
193-
.addComponent(lblBemerkung, GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
196+
.addComponent(lblInteressen, GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
197+
.addComponent(lblBemerkung, GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
194198
.addComponent(separator_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
195-
.addComponent(lblEmail, GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
196-
.addComponent(lblTelefonnummer, GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
199+
.addComponent(lblEmail, GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
200+
.addComponent(lblTelefonnummer, GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
197201
.addComponent(separator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
198-
.addComponent(lblGeburtsdatum, GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
202+
.addComponent(lblGeburtsdatum, GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
199203
.addGroup(groupLayout.createSequentialGroup()
200204
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
201205
.addComponent(comboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
@@ -215,38 +219,40 @@ public void actionPerformed(ActionEvent e) {
215219
.addPreferredGap(ComponentPlacement.RELATED)
216220
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
217221
.addComponent(lblFirma, GroupLayout.PREFERRED_SIZE, 176, GroupLayout.PREFERRED_SIZE)
218-
.addComponent(textFieldFirma, GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)))
219-
.addComponent(textFieldStrasse, GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
222+
.addComponent(textFieldFirma, GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE)))
223+
.addComponent(textFieldStrasse, GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
220224
.addGroup(groupLayout.createSequentialGroup()
221-
.addComponent(comboBox_1, 0, 267, Short.MAX_VALUE)
225+
.addComponent(comboBox_1, 0, 268, Short.MAX_VALUE)
222226
.addPreferredGap(ComponentPlacement.RELATED)
223227
.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 98, GroupLayout.PREFERRED_SIZE)
224228
.addPreferredGap(ComponentPlacement.RELATED))
225-
.addComponent(lblOrt, GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
226-
.addComponent(lblStrasse, GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
227-
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
228-
.addComponent(scrollPane_1, GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
229+
.addComponent(lblOrt, GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
230+
.addComponent(lblStrasse, GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
231+
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
232+
.addComponent(scrollPane_1, GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
229233
.addGroup(groupLayout.createSequentialGroup()
230-
.addComponent(btnAktualisieren, GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
234+
.addComponent(btnAktualisieren, GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
231235
.addPreferredGap(ComponentPlacement.UNRELATED)
232236
.addComponent(btnLoeschen, GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE))
233-
.addComponent(textFieldGeburtsdatum, GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
234-
.addComponent(textFieldTelefonnummer, GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
235-
.addComponent(textFieldEmail, GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE))
237+
.addComponent(textFieldGeburtsdatum, GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
238+
.addComponent(textFieldTelefonnummer, GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
239+
.addComponent(textFieldEmail, GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE))
236240
.addGap(18)
237241
.addComponent(separator_2, GroupLayout.PREFERRED_SIZE, 9, GroupLayout.PREFERRED_SIZE)
238242
.addPreferredGap(ComponentPlacement.RELATED)
239243
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
240-
.addComponent(scrollPane_2, GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
241-
.addComponent(scrollPane_3, GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE))
244+
.addComponent(scrollPane_3, GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)
245+
.addComponent(scrollPane_2, GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)
246+
.addComponent(lblNewLabel_2)
247+
.addComponent(lblNewLabel_3))
242248
.addContainerGap())
243249
);
244250
groupLayout.setVerticalGroup(
245251
groupLayout.createParallelGroup(Alignment.LEADING)
246252
.addGroup(groupLayout.createSequentialGroup()
247253
.addContainerGap()
248254
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
249-
.addComponent(separator_2, GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE)
255+
.addComponent(separator_2, GroupLayout.DEFAULT_SIZE, 593, Short.MAX_VALUE)
250256
.addGroup(groupLayout.createSequentialGroup()
251257
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
252258
.addComponent(lblNewLabel)
@@ -294,21 +300,25 @@ public void actionPerformed(ActionEvent e) {
294300
.addPreferredGap(ComponentPlacement.RELATED)
295301
.addComponent(lblBemerkung)
296302
.addPreferredGap(ComponentPlacement.RELATED)
297-
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
303+
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
298304
.addPreferredGap(ComponentPlacement.UNRELATED)
299305
.addComponent(lblInteressen)
300306
.addPreferredGap(ComponentPlacement.RELATED)
301-
.addComponent(scrollPane_1, GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
307+
.addComponent(scrollPane_1, GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
302308
.addGap(18)
303309
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
304310
.addComponent(btnAktualisieren)
305311
.addComponent(btnLoeschen))
306312
.addGap(1))
307313
.addGroup(groupLayout.createSequentialGroup()
308-
.addComponent(scrollPane_2, GroupLayout.PREFERRED_SIZE, 288, GroupLayout.PREFERRED_SIZE)
309-
.addPreferredGap(ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
310-
.addComponent(scrollPane_3, GroupLayout.PREFERRED_SIZE, 294, GroupLayout.PREFERRED_SIZE)))
311-
.addContainerGap())
314+
.addComponent(lblNewLabel_2)
315+
.addGap(2)
316+
.addComponent(scrollPane_2, GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)
317+
.addPreferredGap(ComponentPlacement.UNRELATED)
318+
.addComponent(lblNewLabel_3)
319+
.addPreferredGap(ComponentPlacement.RELATED)
320+
.addComponent(scrollPane_3, GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE)))
321+
.addGap(7))
312322
);
313323

314324
tableTermin = new JTable();
@@ -333,7 +343,7 @@ public Class getColumnClass(int columnIndex) {
333343
new Object[][] {
334344
},
335345
new String[] {
336-
"Auftragname", "Kunde"
346+
"Auftragname", "Status"
337347
}
338348
) {
339349
Class[] columnTypes = new Class[] {
@@ -384,19 +394,40 @@ public boolean isCellEditable(int row, int column) {
384394
btnAktualisieren.addActionListener(new ActionListener() {
385395
public void actionPerformed(ActionEvent e) {
386396
dbm.startConnect("crm");
397+
String ortNr = null;
387398
try {
388399
ResultSet rs = dbm.getStatement().executeQuery("select ortNr from crm.ort where ortName = '"+comboBox_1.getSelectedItem().toString()+"';");
389400
while (rs.next()) {
401+
ortNr = rs.getString(1);
402+
}
403+
String gebTag = textFieldGeburtsdatum.getText().isEmpty()? "0000-00-00":textFieldGeburtsdatum.getText();
390404
dbm.getStatement().executeUpdate("update crm.kunden set name = '"+textFieldName.getText()+"', vorname ='"+textFieldVorname.getText()+
391405
"', firma ='"+textFieldFirma.getText()+"', email ='"+textFieldEmail.getText()+"', tel ='"+textFieldTelefonnummer.getText()+
392406
"', strasse ='"+textFieldStrasse.getText()+"', bemerkungen ='"+textAreaBemerkung.getText()+"', interessen ='"+textAreaInteresse.getText()+
393-
"', geburtsdatum ='"+textFieldGeburtsdatum.getText()+"', geschlecht ='"+comboBox.getSelectedItem()+"',ortNr ='"+
394-
rs.getString(1)+"'");}
407+
"', geburtsdatum ='"+gebTag+"', geschlecht ='"+comboBox.getSelectedItem()+"',ortNr ='"+
408+
ortNr+"' where kundenNr = "+textFieldKundenNr.getText()+";");
409+
rs.close();
395410
} catch (SQLException e1) {
396411
e1.printStackTrace();
412+
JOptionPane.showMessageDialog(null, e1, "Fehler", JOptionPane.ERROR_MESSAGE);
413+
397414
}
398415
dbm.closeConnection();
399416
}
400417
});
418+
419+
dbm.startConnect("crm");
420+
try {
421+
ResultSet rs = dbm.getStatement().executeQuery("SELECT auftraege.name, status FROM crm.auftraege where auftraege.kundenNr = '"+textFieldKundenNr.getText()+"';");
422+
while(rs.next()){
423+
String data[] = {rs.getString(1), rs.getString(2)};
424+
DefaultTableModel tbm = (DefaultTableModel) tableAuftrag.getModel();
425+
tbm.addRow(data);
426+
}
427+
428+
} catch (SQLException e) {
429+
e.printStackTrace();
430+
}
431+
dbm.closeConnection();
401432
}
402433
}

src/gui/MainView.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,18 @@ public void actionPerformed(ActionEvent e) {
9393
});
9494

9595
JButton btnAuftrag = new JButton("Auftäge anzeigen");
96+
btnAuftrag.addActionListener(new ActionListener() {
97+
public void actionPerformed(ActionEvent e) {
98+
new Auftraege(dbm).setVisible(true);;
99+
}
100+
});
96101

97102
JButton btnNewButton = new JButton("Neuer Aufttrag erstellen");
103+
btnNewButton.addActionListener(new ActionListener() {
104+
public void actionPerformed(ActionEvent e) {
105+
new NeueAuftraege(dbm).setVisible(true);
106+
}
107+
});
98108
GroupLayout gl_contentPane = new GroupLayout(contentPane);
99109
gl_contentPane.setHorizontalGroup(
100110
gl_contentPane.createParallelGroup(Alignment.LEADING)
@@ -199,6 +209,7 @@ public void windowGainedFocus(WindowEvent e) {
199209

200210
tbm.addRow(data);
201211
}
212+
rs.close();
202213
dbm.closeConnection();
203214
} catch (SQLException e1) {
204215
e1.printStackTrace();

0 commit comments

Comments
 (0)