Vehicle.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Vehicle extends JPanel implements ActionListener{
  GridBagConstraints gbc = 
new GridBagConstraints();
  String strQuery = 
new String();
  Icon quitbug =  
new ImageIcon("door.gif");
  Icon submitbug =  
new ImageIcon("satelite.gif");

  
  JTextField date = 
new JTextField (20);
  JLabel dateLabel = 
new JLabel("Date");
  JButton quit = 
new JButton ("Quit",quitbug);
  JButton submit = 
new JButton ("Submit",submitbug);
  JCheckBox coolant = 
new JCheckBox("Radiator Coolant Level"); 
  JCheckBox oil = 
new JCheckBox("Oil Level");
  JCheckBox brake = 
new JCheckBox("Hand Brake");
  JCheckBox side = 
new JCheckBox("Side Lights F/R");
  JCheckBox plate = 
new JCheckBox("No. Plate Lights");
  JCheckBox head = 
new JCheckBox("Head Lights H/D");
  JCheckBox fog = 
new JCheckBox("Fog Lights");
  JCheckBox indicators = 
new JCheckBox("Indicators F/R");
  JCheckBox hazard = 
new JCheckBox("Hazard Lights F/R");
  JCheckBox brakelight = 
new JCheckBox("Brake Lights");
  JCheckBox reverse = 
new JCheckBox("Reversing Lights");
  JCheckBox cab = 
new JCheckBox("Cab Lights");
  JCheckBox locker = 
new JCheckBox("Locker Lights");
  JCheckBox search = 
new JCheckBox("Search Lights");
  JCheckBox step = 
new JCheckBox("Step Lights");
  JCheckBox stem = 
new JCheckBox("Stem Lights");
  JCheckBox handspot = 
new JCheckBox("Cab Mounted Hand Spot");
  JCheckBox pumpbay = 
new JCheckBox("Pump Bay Lights");
  JCheckBox waterlevel = 
new JCheckBox("Water Level Indicator Lights");
  JCheckBox speedo = 
new JCheckBox("Speedometer");
  JCheckBox wipers = 
new JCheckBox("Wipers/Washers");
  JCheckBox drylock = 
new JCheckBox("Door Locks");
  JCheckBox windowreg = 
new JCheckBox("Window Regulators");
  JCheckBox seatbelt = 
new JCheckBox("Seat Belts/Mountings");
  JCheckBox glass = 
new JCheckBox("All Cab Glass");
  JCheckBox mounting = 
new JCheckBox("Ladder Mounting/Release Mechanism");
  JCheckBox tyrecheck = 
new JCheckBox("Visual Tyre Check");
  JCheckBox gauge = 
new JCheckBox("P.T.O. Pump Gauges");
  JCheckBox coolantlevel = 
new JCheckBox("Coolant Level");
  JCheckBox waterindicator = 
new JCheckBox("Water Level Indicator");
  JCheckBox test = 
new JCheckBox("Test Main Pump & F/A");
  JCheckBox mirror = 
new JCheckBox("Mirror");
  JCheckBox radio = 
new JCheckBox("Radio");
  JCheckBox resus = 
new JCheckBox("Resuscitation Box - Sealed (1)");
  JCheckBox maternity = 
new JCheckBox("Maternity Box - Sealed (1)");
  JCheckBox burns = 
new JCheckBox("Burns Box - Sealed (1)");
  JCheckBox dressings = 
new JCheckBox("Dressings Box - Sealed (1)");
  JCheckBox doctor = 
new JCheckBox("Doctors Kit - Sealed (1)");
  JCheckBox infection = 
new JCheckBox("Infection Control - Sealed (1)");
  JCheckBox als = 
new JCheckBox("A.L.S. Solutions - Sealed (1)");
  JCheckBox defib = 
new JCheckBox("De - Fibrillator (1)");
  JCheckBox mains = 
new JCheckBox("Mains Charger (1)");
  JCheckBox trickle = 
new JCheckBox("Trickle Charger (1)");
  JCheckBox spo2 = 
new JCheckBox("SPO2 (1)");
  JCheckBox resusbag = 
new JCheckBox("Resusitation Bag (1)");
  JCheckBox argo = 
new JCheckBox("Argo Bag (1)");
  JCheckBox suction = 
new JCheckBox("Suction (1)");
  JCheckBox spinal = 
new JCheckBox("Spinal Board (1)");
  JCheckBox ked = 
new JCheckBox("K.E.D. (1)");
  JCheckBox collars = 
new JCheckBox("Set of Collars (1)");
  JCheckBox traction = 
new JCheckBox("Traction Splint (1)");
  JCheckBox vacuum = 
new JCheckBox("Vacuum Splint (1)");
  JCheckBox ortho = 
new JCheckBox("Orthpedic Stretcher (1)");
  JCheckBox frac = 
new JCheckBox("Frac Straps (1)");
  JCheckBox chair = 
new JCheckBox("Chair (1)");
  JCheckBox carrying = 
new JCheckBox("Carrying Sheet (1)");
  JCheckBox blankets = 
new JCheckBox("Blankets (8 min)");
  JCheckBox o2l = 
new JCheckBox("O2 D Size (2)");
  JCheckBox o2s = 
new JCheckBox("O2 F Size (1)");
  JCheckBox entonox = 
new JCheckBox("Entonox (2)");

  
public Vehicle(){

    JPanel dateRow = 
new JPanel(); 
  gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 
1.0;
    gbc.weighty = 
1.0;
  addGB(dateRow,dateLabel,
0,0);
  addGB(dateRow,date,
1,0);
  addGB(this,dateRow,
0,0);

    JPanel titleRow = 
new JPanel();
  titleRow.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
"Driver"));
  gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 
1.0;
    gbc.weighty = 
1.0;
  addGB(titleRow,coolant, 
00);
  addGB(titleRow,oil, 
01);
  addGB(titleRow,brake, 
02);
  addGB(titleRow,side, 
03);
  addGB(titleRow,plate, 
04);
  addGB(titleRow,head, 
05);
  addGB(titleRow,fog, 
06);
  addGB(titleRow,indicators, 
07);
  addGB(titleRow,hazard, 
08);
  addGB(titleRow,brakelight, 
09);
  addGB(titleRow,reverse, 
010);

  addGB(titleRow,cab, 
10);
  addGB(titleRow,locker, 
11);
  addGB(titleRow,search, 
12);
  addGB(titleRow,step, 
13);
  addGB(titleRow,stem, 
14);
  addGB(titleRow,handspot, 
15);
  addGB(titleRow,pumpbay, 
16);
  addGB(titleRow,waterlevel, 
17);
  addGB(titleRow,speedo, 
18);
  addGB(titleRow,wipers, 
19);
  addGB(titleRow,drylock, 
110);

  addGB(titleRow,windowreg, 
20);
  addGB(titleRow,seatbelt, 
21);
  addGB(titleRow,glass, 
22);
  addGB(titleRow,mounting, 
23);
  addGB(titleRow,tyrecheck, 
24);
  addGB(titleRow,gauge, 
25);
  addGB(titleRow,coolantlevel, 
26);
  addGB(titleRow,waterindicator, 
27);
  addGB(titleRow,test, 
28);
  addGB(titleRow,mirror, 
29);
  addGB(titleRow,radio, 
210);

  addGB(this, titleRow, 
01);

    JPanel title1Row = 
new JPanel();
  title1Row.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
"Attendant"));
  addGB(title1Row,resus, 
00);
  addGB(title1Row,maternity, 
01);
  addGB(title1Row,burns, 
02);
  addGB(title1Row,dressings, 
03);
  addGB(title1Row,doctor, 
04);
  addGB(title1Row,infection, 
05);
  addGB(title1Row,als, 
06);
  addGB(title1Row,defib, 
07);
  addGB(title1Row,mains, 
08);

  addGB(title1Row,trickle, 
10);
  addGB(title1Row,spo2, 
11);
  addGB(title1Row,resusbag, 
12);
  addGB(title1Row,argo, 
13);
  addGB(title1Row,suction, 
14);
  addGB(title1Row,spinal, 
15);
  addGB(title1Row,ked, 
16);
  addGB(title1Row,collars, 
17);
  addGB(title1Row,traction, 
18);

  addGB(title1Row,vacuum, 
20);
  addGB(title1Row,ortho, 
21);
  addGB(title1Row,frac, 
22);
  addGB(title1Row,chair, 
23);
  addGB(title1Row,carrying, 
24);
  addGB(title1Row,blankets, 
25);
  addGB(title1Row,o2l, 
26);
  addGB(title1Row,o2s, 
27);
  addGB(title1Row,entonox, 
28);

  addGB(this, title1Row, 
02);
  
  JPanel fifthRow = 
new JPanel();
  gbc.fill = GridBagConstraints.HORIZONTAL;
  addGB(fifthRow, quit, 
00);
  quit.addActionListener(
this);
  addGB(fifthRow, 
new JLabel(""), 30);
    addGB(fifthRow, submit, 
40);
  submit.addActionListener(
this);

  addGB(this, fifthRow, 
03);
  }


  
void addGB(Container cont, Component comp, int x, int y) {
    
if ((cont.getLayout(  ) instanceof GridBagLayout) == false)
      cont.setLayout(
new GridBagLayout(  ));
    gbc.gridx = x; gbc.gridy = y;
    cont.add(comp, gbc);
  }

  
public void actionPerformed(ActionEvent event) {
    
try 
    String myEvent = event.getActionCommand(); 
    
if ( event.getSource() instanceof JButton) { 
      
if "Quit".equals(myEvent)) { 
        System.exit(
0); 
      }  
      
if "Submit".equals(myEvent)) { 
              Submit s = 
new Submit();
        s.Open();

        strQuery = 
"INSERT INTO driver(ddate,fault)";
        strQuery += 
"values (" + date.getText() + ",'";
        
if (coolant.isSelected())
          strQuery += coolant.getText();
        
if (oil.isSelected())
          strQuery += 
"," + oil.getText();
        
if (brake.isSelected())
          strQuery += 
"," + brake.getText();
        
if (side.isSelected())
          strQuery += 
"," + side.getText();
        
if (plate.isSelected())
          strQuery += 
"," + plate.getText();
        
if (head.isSelected())
          strQuery += 
"," + head.getText();
        
if (fog.isSelected())
          strQuery += 
"," + fog.getText();
        
if (indicators.isSelected())
          strQuery += 
"," + indicators.getText();
        
if (hazard.isSelected())
          strQuery += 
"," + hazard.getText();
        
if (brakelight.isSelected())
          strQuery += 
"," + brakelight.getText();
        
if (reverse.isSelected())
          strQuery += 
"," + reverse.getText();
        
if (cab.isSelected())
          strQuery += 
"," + cab.getText();
        
if (locker.isSelected())
          strQuery += 
"," + locker.getText();
        
if (search.isSelected())
          strQuery += 
"," + search.getText();
        
if (step.isSelected())
          strQuery += 
"," + step.getText();
        
if (stem.isSelected())
          strQuery += 
"," + stem.getText();
        
if (handspot.isSelected())
          strQuery += 
"," + handspot.getText();
        
if (pumpbay.isSelected())
          strQuery += 
"," + pumpbay.getText();
        
if (waterlevel.isSelected())
          strQuery += 
"," + waterlevel.getText();
        
if (speedo.isSelected())
          strQuery += 
"," + speedo.getText();
        
if (wipers.isSelected())
          strQuery += 
"," + wipers.getText();
        
if (drylock.isSelected())
          strQuery += 
"," + drylock.getText();
        
if (windowreg.isSelected())
          strQuery += 
"," + windowreg.getText();
        
if (seatbelt.isSelected())
          strQuery += 
"," + seatbelt.getText();
        
if (glass.isSelected())
          strQuery += 
"," + glass.getText();
        
if (mounting.isSelected())
          strQuery += 
"," + mounting.getText();
        
if (tyrecheck.isSelected())
          strQuery += 
"," + tyrecheck.getText();
        
if (gauge.isSelected())
          strQuery += 
"," + gauge.getText();
        
if (coolantlevel.isSelected())
          strQuery += 
"," + coolantlevel.getText();
        
if (waterindicator.isSelected())
          strQuery += 
"," + waterindicator.getText();
        
if (test.isSelected())
          strQuery += 
"," + test.getText();
        
if (mirror.isSelected())
          strQuery += 
"," + mirror.getText();
        
if (radio.isSelected())
          strQuery += 
"," + radio.getText();
        strQuery += 
"')";        
        System.out.println(strQuery);
        s.Select(strQuery);

        strQuery = 
"INSERT INTO attendant(adate,fault)";
        strQuery += 
"values (" + date.getText() + ",'";

        
if (resus.isSelected())
          strQuery += resus.getText();
        
if (maternity.isSelected())
          strQuery += 
"," + maternity.getText();
        
if (burns.isSelected())
          strQuery += 
"," + burns.getText();
        
if (dressings.isSelected())
          strQuery += 
"," + dressings.getText();
        
if (doctor.isSelected())
          strQuery += 
"," + doctor.getText();
        
if (infection.isSelected())
          strQuery += 
"," + infection.getText();
        
if (als.isSelected())
          strQuery += 
"," + als.getText();
        
if (defib.isSelected())
          strQuery += 
"," + defib.getText();
        
if (mains.isSelected())
          strQuery += 
"," + mains.getText();
        
if (trickle.isSelected())
          strQuery += 
"," + trickle.getText();
        
if (spo2.isSelected())
          strQuery += 
"," + spo2.getText();
        
if (resusbag.isSelected())
          strQuery += 
"," + resusbag.getText();
        
if (argo.isSelected())
          strQuery += 
"," + argo.getText();
        
if (suction.isSelected())
          strQuery += 
"," + suction.getText();
        
if (spinal.isSelected())
          strQuery += 
"," + spinal.getText();
        
if (ked.isSelected())
          strQuery += 
"," + ked.getText();
        
if (collars.isSelected())
          strQuery += 
"," + collars.getText();
        
if (traction.isSelected())
          strQuery += 
"," + traction.getText();
        
if (vacuum.isSelected())
          strQuery += 
"," + vacuum.getText();
        
if (ortho.isSelected())
          strQuery += 
"," + ortho.getText();
        
if (frac.isSelected())
          strQuery += 
"," + frac.getText();
        
if (chair.isSelected())
          strQuery += 
"," + chair.getText();
        
if (carrying.isSelected())
          strQuery += 
"," + carrying.getText();
        
if (blankets.isSelected())
          strQuery += 
"," + blankets.getText();
        
if (o2l.isSelected())
          strQuery += 
"," + o2l.getText();
        
if (o2s.isSelected())
          strQuery += 
"," + o2s.getText();
        
if (entonox.isSelected())
          strQuery += 
"," + entonox.getText();
        strQuery += 
"')";        

        System.out.println(strQuery);
        s.Select(strQuery);

        s.Close();
      }  
    } 
  } 
  
catch (Exception e) { 
    System.out.println(
"An Error has occured at ListenForButtonPress :"+e.toString()); 
  } 
  }

  
public static void main(String[] args) {
    JFrame f = 
new JFrame("Ambulance Asset Maintenance Form");
    f.addWindowListener(
new WindowAdapter() {
      
public void windowClosing(WindowEvent e) { System.exit(0); }
    });
    f.setSize(
1024,768);
    f.setLocation(
0,0);
    f.setContentPane(
new Vehicle());
    f.setVisible(
true);
  }
}
Java2html