Skip to content

Commit ed9abe9

Browse files
committed
acc manager delete function, added country's
Changed stuff in the acc manager where u delete usernames. Added a lot of country's by alfabet
1 parent e18045e commit ed9abe9

File tree

4 files changed

+118
-29
lines changed

4 files changed

+118
-29
lines changed

LuggageTrackerTool2/src/view/AccountManagement.form

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
</Group>
8282
</Group>
8383
</Group>
84-
<EmptySpace pref="125" max="32767" attributes="0"/>
84+
<EmptySpace pref="191" max="32767" attributes="0"/>
8585
</Group>
8686
</Group>
8787
</DimensionLayout>
@@ -235,15 +235,13 @@
235235
</Component>
236236
<Component class="javax.swing.JComboBox" name="jComboBox1">
237237
<Properties>
238-
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
239-
<StringArray count="4">
240-
<StringItem index="0" value="User 1"/>
241-
<StringItem index="1" value="User 2"/>
242-
<StringItem index="2" value="User 3"/>
243-
<StringItem index="3" value="User 4"/>
244-
</StringArray>
238+
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
239+
<Connection code="new javax.swing.DefaultComboBoxModel(usernames)" type="code"/>
245240
</Property>
246241
</Properties>
242+
<Events>
243+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jComboBox1ActionPerformed"/>
244+
</Events>
247245
</Component>
248246
<Component class="javax.swing.JLabel" name="jLabel2">
249247
<Properties>

LuggageTrackerTool2/src/view/AccountManagement.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
155155
}
156156
});
157157

158-
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "User 1", "User 2", "User 3", "User 4" }));
158+
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(usernames));
159+
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
160+
public void actionPerformed(java.awt.event.ActionEvent evt) {
161+
jComboBox1ActionPerformed(evt);
162+
}
163+
});
159164

160165
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
161166
jLabel2.setText("Delete user");
@@ -206,7 +211,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
206211
.addComponent(USER, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
207212
.addComponent(jComboBox2, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
208213
.addComponent(jComboBox1, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
209-
.addContainerGap(125, Short.MAX_VALUE))
214+
.addContainerGap(191, Short.MAX_VALUE))
210215
);
211216
ACCOUNT_MANAGEMENTLayout.setVerticalGroup(
212217
ACCOUNT_MANAGEMENTLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -378,12 +383,20 @@ private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
378383
"Are you sure you want to delete the user?", "Question",
379384
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
380385
if (result == JOptionPane.YES_OPTION) {
381-
// Actually delete the user in here
382-
//
383-
//
386+
try {
387+
model.User user = model.UserDAO.readByUsername(USER.getSelectedItem().toString());
388+
user.getUserid();
389+
model.UserDAO.delete(user.getUserid());
390+
} catch (SQLException ex) {
391+
Logger.getLogger(AccountManagement.class.getName()).log(Level.SEVERE, null, ex);
392+
}
384393
}
385394
}//GEN-LAST:event_jButton2ActionPerformed
386395

396+
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
397+
// TODO add your handling code here:
398+
}//GEN-LAST:event_jComboBox1ActionPerformed
399+
387400
// Variables declaration - do not modify//GEN-BEGIN:variables
388401
private javax.swing.JPanel ACCOUNT_MANAGEMENT;
389402
private javax.swing.JButton CHANGE_CONFIRM;

LuggageTrackerTool2/src/view/RegistrationPassenger.form

Lines changed: 71 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@
228228
<EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
229229
<Component id="PAIR_PASSENGER_LUGGAGE" min="-2" max="-2" attributes="0"/>
230230
<EmptySpace type="unrelated" max="-2" attributes="0"/>
231-
<Group type="103" groupAlignment="3" attributes="0">
231+
<Group type="103" groupAlignment="0" attributes="0">
232232
<Component id="PRINT" alignment="0" min="-2" max="-2" attributes="0"/>
233-
<Component id="REGISTER" alignment="3" min="-2" max="-2" attributes="0"/>
233+
<Component id="REGISTER" min="-2" max="-2" attributes="0"/>
234234
</Group>
235235
<EmptySpace max="-2" attributes="0"/>
236236
</Group>
@@ -322,11 +322,40 @@
322322
<Component class="javax.swing.JComboBox" name="HOME_COUNTRY_INPUT">
323323
<Properties>
324324
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
325-
<StringArray count="4">
325+
<StringArray count="33">
326326
<StringItem index="0" value="Please select your country .."/>
327-
<StringItem index="1" value="The Netherlands"/>
328-
<StringItem index="2" value="Germany"/>
329-
<StringItem index="3" value="Belgium"/>
327+
<StringItem index="1" value="Belgium"/>
328+
<StringItem index="2" value="Albania"/>
329+
<StringItem index="3" value="Bosnia &amp; Herzegovina"/>
330+
<StringItem index="4" value="Bulgaria"/>
331+
<StringItem index="5" value="Croatia"/>
332+
<StringItem index="6" value="Cyprus"/>
333+
<StringItem index="7" value="Czech Republic"/>
334+
<StringItem index="8" value="Denmark"/>
335+
<StringItem index="9" value="Estonia"/>
336+
<StringItem index="10" value="Finland"/>
337+
<StringItem index="11" value="France"/>
338+
<StringItem index="12" value="Georgia"/>
339+
<StringItem index="13" value="Germany"/>
340+
<StringItem index="14" value="Greece"/>
341+
<StringItem index="15" value="Hungary"/>
342+
<StringItem index="16" value="Ireland"/>
343+
<StringItem index="17" value="Italy"/>
344+
<StringItem index="18" value="The Netherlands"/>
345+
<StringItem index="19" value="Norway"/>
346+
<StringItem index="20" value="Poland"/>
347+
<StringItem index="21" value="Portugal"/>
348+
<StringItem index="22" value="Russia"/>
349+
<StringItem index="23" value="San Marino"/>
350+
<StringItem index="24" value="Serbia"/>
351+
<StringItem index="25" value="Slovakia"/>
352+
<StringItem index="26" value="Slovenia"/>
353+
<StringItem index="27" value="Spain"/>
354+
<StringItem index="28" value="Sweden"/>
355+
<StringItem index="29" value="Switzerland"/>
356+
<StringItem index="30" value="Turkey"/>
357+
<StringItem index="31" value="Ukraine"/>
358+
<StringItem index="32" value="United Kingdom"/>
330359
</StringArray>
331360
</Property>
332361
</Properties>
@@ -371,17 +400,49 @@
371400
<Component class="javax.swing.JComboBox" name="TEMP_COUNTRY_INPUT">
372401
<Properties>
373402
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
374-
<StringArray count="4">
403+
<StringArray count="33">
375404
<StringItem index="0" value="Please select your country .."/>
376-
<StringItem index="1" value="The Netherlands"/>
377-
<StringItem index="2" value="Germany"/>
378-
<StringItem index="3" value="Belgium"/>
405+
<StringItem index="1" value="Belgium"/>
406+
<StringItem index="2" value="Albania"/>
407+
<StringItem index="3" value="Bosnia &amp; Herzegovina"/>
408+
<StringItem index="4" value="Bulgaria"/>
409+
<StringItem index="5" value="Croatia"/>
410+
<StringItem index="6" value="Cyprus"/>
411+
<StringItem index="7" value="Czech Republic"/>
412+
<StringItem index="8" value="Denmark"/>
413+
<StringItem index="9" value="Estonia"/>
414+
<StringItem index="10" value="Finland"/>
415+
<StringItem index="11" value="France"/>
416+
<StringItem index="12" value="Georgia"/>
417+
<StringItem index="13" value="Germany"/>
418+
<StringItem index="14" value="Greece"/>
419+
<StringItem index="15" value="Hungary"/>
420+
<StringItem index="16" value="Ireland"/>
421+
<StringItem index="17" value="Italy"/>
422+
<StringItem index="18" value="The Netherlands"/>
423+
<StringItem index="19" value="Norway"/>
424+
<StringItem index="20" value="Poland"/>
425+
<StringItem index="21" value="Portugal"/>
426+
<StringItem index="22" value="Russia"/>
427+
<StringItem index="23" value="San Marino"/>
428+
<StringItem index="24" value="Serbia"/>
429+
<StringItem index="25" value="Slovakia"/>
430+
<StringItem index="26" value="Slovenia"/>
431+
<StringItem index="27" value="Spain"/>
432+
<StringItem index="28" value="Sweden"/>
433+
<StringItem index="29" value="Switzerland"/>
434+
<StringItem index="30" value="Turkey"/>
435+
<StringItem index="31" value="Ukraine"/>
436+
<StringItem index="32" value="United Kingdom"/>
379437
</StringArray>
380438
</Property>
381439
</Properties>
382440
<BindingProperties>
383441
<BindingProperty name="enabled" source="EQUALCHECKBOX" sourcePath="${!selected}" target="TEMP_COUNTRY_INPUT" targetPath="enabled" updateStrategy="0" immediately="false"/>
384442
</BindingProperties>
443+
<Events>
444+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="TEMP_COUNTRY_INPUTActionPerformed"/>
445+
</Events>
385446
</Component>
386447
<Component class="javax.swing.JLabel" name="TEMP_CITY">
387448
<Properties>

LuggageTrackerTool2/src/view/RegistrationPassenger.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
2-
* To change this template, choose Tools | Templates
3-
* and open the template in the editor.
2+
*
3+
*
4+
*
45
*/
56
package view;
67

@@ -515,7 +516,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
515516

516517
HOME_COUNTRY.setText("Country");
517518

518-
HOME_COUNTRY_INPUT.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Please select your country ..", "The Netherlands", "Germany", "Belgium" }));
519+
HOME_COUNTRY_INPUT.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Please select your country ..", "Belgium", "Albania", "Bosnia & Herzegovina", "Bulgaria", "Croatia", "Cyprus", "Czech Republic", "Denmark", "Estonia", "Finland", "France", "Georgia", "Germany", "Greece", "Hungary", "Ireland", "Italy", "The Netherlands", "Norway", "Poland", "Portugal", "Russia", "San Marino", "Serbia", "Slovakia", "Slovenia", "Spain", "Sweden", "Switzerland", "Turkey", "Ukraine", "United Kingdom" }));
519520
HOME_COUNTRY_INPUT.addActionListener(new java.awt.event.ActionListener() {
520521
public void actionPerformed(java.awt.event.ActionEvent evt) {
521522
HOME_COUNTRY_INPUTActionPerformed(evt);
@@ -533,11 +534,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
533534

534535
TEMP_COUNTRY.setText("Country");
535536

536-
TEMP_COUNTRY_INPUT.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Please select your country ..", "The Netherlands", "Germany", "Belgium" }));
537+
TEMP_COUNTRY_INPUT.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Please select your country ..", "Belgium", "Albania", "Bosnia & Herzegovina", "Bulgaria", "Croatia", "Cyprus", "Czech Republic", "Denmark", "Estonia", "Finland", "France", "Georgia", "Germany", "Greece", "Hungary", "Ireland", "Italy", "The Netherlands", "Norway", "Poland", "Portugal", "Russia", "San Marino", "Serbia", "Slovakia", "Slovenia", "Spain", "Sweden", "Switzerland", "Turkey", "Ukraine", "United Kingdom" }));
537538

538539
org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, EQUALCHECKBOX, org.jdesktop.beansbinding.ELProperty.create("${!selected}"), TEMP_COUNTRY_INPUT, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
539540
bindingGroup.addBinding(binding);
540541

542+
TEMP_COUNTRY_INPUT.addActionListener(new java.awt.event.ActionListener() {
543+
public void actionPerformed(java.awt.event.ActionEvent evt) {
544+
TEMP_COUNTRY_INPUTActionPerformed(evt);
545+
}
546+
});
547+
541548
TEMP_CITY.setText("City");
542549

543550
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, EQUALCHECKBOX, org.jdesktop.beansbinding.ELProperty.create("${!selected}"), TEMP_CITY_INPUT, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
@@ -753,7 +760,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
753760
.addGap(29, 29, 29)
754761
.addComponent(PAIR_PASSENGER_LUGGAGE)
755762
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
756-
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
763+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
757764
.addComponent(PRINT)
758765
.addComponent(REGISTER))
759766
.addContainerGap())
@@ -911,21 +918,31 @@ private void YEAROFBIRTHActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
911918
this.DAYOFBIRTH.setSelectedIndex(daySelectedIndex);
912919
}
913920
}//GEN-LAST:event_YEAROFBIRTHActionPerformed
914-
921+
// This is the print button.
915922
private void PRINTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PRINTActionPerformed
916923

924+
int result = JOptionPane.showConfirmDialog(null,
925+
"Are you sure you want to print the information?", "Question",
926+
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
927+
if (result == JOptionPane.YES_OPTION){
917928

918929
model.Passenger selectedPassenger = main.LuggageTrackerTool2.getInstance().getSelectedPassenger();
919930
model.Luggage selectedLuggage = main.LuggageTrackerTool2.getInstance().getSelectedLuggage();
920931

921932
PDFGenerator pdf = new PDFGenerator();
922933
pdf.generate(selectedPassenger, selectedLuggage);
923934
pdf.save("Informatie.pdf");
935+
}
936+
924937

925938

926939

927940
}//GEN-LAST:event_PRINTActionPerformed
928941

942+
private void TEMP_COUNTRY_INPUTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TEMP_COUNTRY_INPUTActionPerformed
943+
// TODO add your handling code here:
944+
}//GEN-LAST:event_TEMP_COUNTRY_INPUTActionPerformed
945+
929946
// Variables declaration - do not modify//GEN-BEGIN:variables
930947
private javax.swing.JLabel BASIC_INFORMATION_TITLE;
931948
private javax.swing.JLabel DATE_OF_BIRTH;

0 commit comments

Comments
 (0)