Inspection.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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Inspection extends JPanel implements ActionListener{

  GridBagConstraints gbc = 
new GridBagConstraints();
  String strQuery = 
new String();
  JLabel buildingLabel = 
new JLabel ("Building :");
  JLabel addressLabel = 
new JLabel ("Address :");
  JLabel departmentLabel = 
new JLabel ("Department :");
  JLabel contactLabel = 
new JLabel ("Contact :");
  JLabel directorLabel = 
new JLabel ("Director :");
  JLabel dateLabel = 
new JLabel ("Inspection Date :");
  JLabel rmLabel = 
new JLabel ("RM Control No. :");
  JLabel facmanLabel = 
new JLabel ("FACMAN WO No. :");
  JLabel obsLabel = 
new JLabel ("Are all exit routes clear of obstructions?");
  JLabel exitLabel = 
new JLabel ("Do all exit routes have lighted exit signs?");
  JLabel bulbLabel = 
new JLabel ("Are all exit signs working with no burned out light bulbs?");
  JLabel hallLabel = 
new JLabel ("Are all hallways and common areas illuminated?");
  JLabel escapeLabel = 
new JLabel ("Are all fire escapes cleared of objects and in good condition?");
  JLabel lockLabel = 
new JLabel ("Are all exit doors free of locking devices?");
  JLabel planLabel = 
new JLabel ("Is there an exit plan posted on each floor");
  JLabel smokeLabel = 
new JLabel ("When was the last time the smoke detectors were tested?");
  JLabel placeLabel = 
new JLabel ("Are all the fire extinguishers in place and full?");
  JLabel warnLabel = 
new JLabel ("Is the fire alarm system operating without warning sounds or lights?");
  JLabel sprinkLabel = 
new JLabel ("Is there a working sprinkler system?");
  JLabel inspectLabel = 
new JLabel ("When was the last time the kitchen suppression system was inspected?");
  JLabel appLabel = 
new JLabel ("Are all electrical appliances in good working condition?");
  JLabel cordLabel = 
new JLabel ("Are all electrical cords in good condition(no fraying or splices)?");
  JLabel liquidLabel = 
new JLabel ("Are there any flammable liquids stored in the building?");
  JLabel dryerLabel = 
new JLabel ("Is the laundry area kept clean and the dryer vents clear?");
  JLabel trashLabel = 
new JLabel ("How often is the trash removed from the building?");
  JLabel probLabel = 
new JLabel ("List problems found on self-inspection");
  JLabel actionLabel = 
new JLabel ("List actions taken to rectify the problems encountered");

  JComboBox dayBox = 
new JComboBox();
  JComboBox monthBox = 
new JComboBox();
  JComboBox yearBox = 
new JComboBox();

  JTextField building = 
new JTextField(30);
  JTextField address1 = 
new JTextField(30);
  JTextField address2 = 
new JTextField(30);
  JTextField address3 = 
new JTextField(30);
  JTextField department = 
new JTextField(30);
  JTextField contact = 
new JTextField(30);
  JTextField director = 
new JTextField(30);
  JTextField date = 
new JTextField(30);
  JTextField rm = 
new JTextField(30);
  JTextField facman = 
new JTextField(30);

  JCheckBox yes = 
new JCheckBox("Yes");
  JCheckBox no = 
new JCheckBox("No");
  JCheckBox yes1 = 
new JCheckBox("Yes");
  JCheckBox no1 = 
new JCheckBox("No");
  JCheckBox yes2 = 
new JCheckBox("Yes");
  JCheckBox no2 = 
new JCheckBox("No");
  JCheckBox yes3 = 
new JCheckBox("Yes");
  JCheckBox no3 = 
new JCheckBox("No");
  JCheckBox yes4 = 
new JCheckBox("Yes");
  JCheckBox no4 = 
new JCheckBox("No");
  JCheckBox yes5 = 
new JCheckBox("Yes");
  JCheckBox no5 = 
new JCheckBox("No");
  JCheckBox yes6 = 
new JCheckBox("Yes");
  JCheckBox no6 = 
new JCheckBox("No");
  JCheckBox yes8 = 
new JCheckBox("Yes");
  JCheckBox no8 = 
new JCheckBox("No");
  JCheckBox yes9 = 
new JCheckBox("Yes");
  JCheckBox no9 = 
new JCheckBox("No");
  JCheckBox yes10 = 
new JCheckBox("Yes");
  JCheckBox no10 = 
new JCheckBox("No");
  JCheckBox yes12 = 
new JCheckBox("Yes");
  JCheckBox no12 = 
new JCheckBox("No");
  JCheckBox yes13 = 
new JCheckBox("Yes");
  JCheckBox no13 = 
new JCheckBox("No");
  JCheckBox yes15 = 
new JCheckBox("Yes");
  JCheckBox no15 = 
new JCheckBox("No");
  JCheckBox yes17 = 
new JCheckBox("Yes");
  JCheckBox no17 = 
new JCheckBox("No");

  JTextArea smoke = 
new JTextArea();
  JTextArea kit = 
new JTextArea();
  JTextArea trash = 
new JTextArea();
  JTextArea prob = 
new JTextArea();
  JTextArea action = 
new JTextArea();

  Icon quitbug =  
new ImageIcon("door.gif");
  Icon submitbug =  
new ImageIcon("satelite.gif");
  Icon clearfieldsbug =  
new ImageIcon("trash.gif");
  Icon menubug =  
new ImageIcon("inventory.gif");

  JButton quit = 
new JButton ("Quit",quitbug);
  JButton submit = 
new JButton ("Submit",submitbug);
  JButton clearfields = 
new JButton ("ClearFields",clearfieldsbug);

  
public Inspection(){
    JPanel titleRow = 
new JPanel();
  titleRow.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder()));
  gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 
1.0;
    gbc.weighty = 
1.0;
  addGB(titleRow,buildingLabel, 
00);
  addGB(titleRow,building, 
10);
  addGB(titleRow,addressLabel, 
01);
  addGB(titleRow,address1, 
11);
  addGB(titleRow,address2, 
12);
  addGB(titleRow,address3, 
13);
  addGB(titleRow,departmentLabel, 
04);
  addGB(titleRow,department, 
14);
  addGB(titleRow,contactLabel, 
20);
  addGB(titleRow,contact, 
30);
  addGB(titleRow,directorLabel, 
21);
  addGB(titleRow,director, 
31);
  addGB(titleRow,dateLabel, 
22);
  addGB(titleRow,date, 
32);
  addGB(titleRow,rmLabel, 
23);
  addGB(titleRow,rm, 
33);
  addGB(titleRow,facmanLabel, 
24);
  addGB(titleRow,facman, 
34);
  addGB(this, titleRow, 
00);

    JPanel questionRow = 
new JPanel();
  questionRow.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder()));

  addGB(questionRow,obsLabel, 
00);
    addGB(questionRow,yes, 
01);
    addGB(questionRow,no, 
02);

  addGB(questionRow,exitLabel, 
10);
    addGB(questionRow,yes1, 
11);
    addGB(questionRow,no1, 
12);

  addGB(questionRow,bulbLabel, 
20);
    addGB(questionRow,yes2, 
21);
    addGB(questionRow,no2, 
22);

  addGB(questionRow,hallLabel, 
03);
    addGB(questionRow,yes3, 
04);
    addGB(questionRow,no3, 
05);

  addGB(questionRow,escapeLabel, 
13);
    addGB(questionRow,yes4, 
14);
    addGB(questionRow,no4, 
15);

  addGB(questionRow,lockLabel, 
23);
    addGB(questionRow,yes5, 
24);
    addGB(questionRow,no5, 
25);

  addGB(questionRow,planLabel, 
06);
    addGB(questionRow,yes6, 
07);
    addGB(questionRow,no6, 
08);

  addGB(questionRow,smokeLabel, 
16);
  JScrollPane locPane = 
new JScrollPane(smoke,
      JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
      JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  addGB(questionRow,locPane, 
17);

  addGB(questionRow,placeLabel, 
26);
    addGB(questionRow,yes8, 
27);
    addGB(questionRow,no8, 
28);

  addGB(this, questionRow, 
01);

    JPanel question1Row = 
new JPanel();
  question1Row.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder()));

  addGB(question1Row,warnLabel, 
00);
    addGB(question1Row,yes9, 
01);
    addGB(question1Row,no9, 
02);

  addGB(question1Row,sprinkLabel, 
10);
    addGB(question1Row,yes10, 
11);
    addGB(question1Row,no10, 
12);

  addGB(question1Row,inspectLabel, 
03);
  JScrollPane kitPane = 
new JScrollPane(kit,
      JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
      JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  addGB(question1Row,kitPane, 
04);

  addGB(question1Row,appLabel, 
13);
    addGB(question1Row,yes12, 
14);
    addGB(question1Row,no12, 
15);

  addGB(question1Row,cordLabel, 
06);
    addGB(question1Row,yes13, 
07);
    addGB(question1Row,no13, 
08);

  addGB(question1Row,liquidLabel, 
16);
    addGB(question1Row,yes15, 
17);
    addGB(question1Row,no15, 
18);

  addGB(this, question1Row, 
02);
  
    JPanel question2Row = 
new JPanel();
  question2Row.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder()));

  addGB(question2Row,dryerLabel, 
00);
    addGB(question2Row,yes17, 
01);
    addGB(question2Row,no17, 
02);

  addGB(question2Row,trashLabel, 
10);
  JScrollPane trashPane = 
new JScrollPane(trash,
      JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
      JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  addGB(question2Row,trashPane, 
11);

  addGB(question2Row,probLabel, 
03);
  JScrollPane probPane = 
new JScrollPane(prob,
      JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
      JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  addGB(question2Row,probPane, 
04);

  addGB(question2Row,actionLabel, 
13);
  JScrollPane actionPane = 
new JScrollPane(action,
      JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
      JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  addGB(question2Row,actionPane, 
14);

  addGB(this, question2Row, 
03);

  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(fifthRow, 
new JLabel(""), 50);
    addGB(fifthRow, clearfields, 
60);
  clearfields.addActionListener(
this);

  addGB(this, fifthRow, 
04);
  }

  
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 inspection_1(building,address,dept,contact,director,idate,rm,facman)";
        strQuery += 
"values ('" + building.getText() + "','" + address1.getText() + ",";
        strQuery += address2.getText() + 
"," + address3.getText() + "','" + department.getText();
        strQuery += 
"','" + contact.getText() + "','" + director.getText() + "','" + date.getText();
        strQuery += 
"','" + rm.getText() + "','" + facman.getText() + "')";

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

        strQuery = 
"INSERT INTO inspection_2(indate,obs,exit,bulb,hall,escape,locked,plan,smoke,place)";
        strQuery += 
"values ('" + date.getText() + "','";

        
if (yes.isSelected())
          strQuery += yes.getText() + 
"','";
        
if (no.isSelected())
          strQuery += no.getText() + 
"','";
        
if (yes1.isSelected())
          strQuery += yes1.getText() + 
"','";
        
if (no1.isSelected())
          strQuery += no1.getText() + 
"','";
        
if (yes2.isSelected())
          strQuery += yes2.getText() + 
"','";
        
if (no2.isSelected())
          strQuery += no2.getText() + 
"','";
        
if (yes3.isSelected())
          strQuery += yes3.getText() + 
"','";
        
if (no3.isSelected())
          strQuery += no3.getText() + 
"','";
        
if (yes4.isSelected())
          strQuery += yes4.getText() + 
"','";
        
if (no4.isSelected())
          strQuery += no4.getText() + 
"','";
        
if (yes5.isSelected())
          strQuery += yes5.getText() + 
"','";
        
if (no5.isSelected())
          strQuery += no5.getText() + 
"','";
        
if (yes6.isSelected())
          strQuery += yes6.getText() + 
"','";
        
if (no6.isSelected())
          strQuery += no6.getText() + 
"','";

        strQuery += smoke.getText() + 
"','";

        
if (yes8.isSelected())
          strQuery += yes8.getText();
        
if (no8.isSelected())
          strQuery += no8.getText();

              strQuery += 
"')";

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

        s.Close();
      }  
      
if ("ClearFields".equals(myEvent)) { 
        smoke.setText(
"");
        kit.setText(
"");
        trash.setText(
"");
        prob.setText(
"");
        action.setText(
"");

        building.setText(
"");
        address1.setText(
"");
        address2.setText(
"");
        address3.setText(
"");
        department.setText(
"");

        contact.setText(
"");
        director.setText(
"");
        date.setText(
"");
        rm.setText(
"");
        facman.setText(
"");
      } 
    } 
  } 
  
catch (Exception e) { 
    System.out.println(
"An Error has occured at ListenForButtonPress :"+e.toString()); 
  } 
  }

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