|
@@ -54,12 +54,12 @@ |
54 |
54 |
|
private int row; |
55 |
55 |
|
private JLabel labelPhone; |
56 |
56 |
|
|
57 |
|
- |
|
58 |
57 |
|
/** |
59 |
58 |
|
* Create the frame. |
60 |
59 |
|
*/ |
61 |
60 |
|
|
62 |
|
- |
public HouseFeaturesGUI(RuralHouse RH, final Date FirstDay, final Date LastDay) { |
|
61 |
+ |
public HouseFeaturesGUI(RuralHouse RH, final Date FirstDay, |
|
62 |
+ |
final Date LastDay) { |
63 |
63 |
|
this.rh = RH; |
64 |
64 |
|
this.getContentPane().setLayout(null); |
65 |
65 |
|
setBounds(100, 100, 500, 583); |
|
@@ -187,11 +187,11 @@ |
187 |
187 |
|
lblNewLabel.setEnabled(false); |
188 |
188 |
|
lblNewLabel.setBounds(170, 282, 261, 23); |
189 |
189 |
|
contentPane.add(lblNewLabel); |
190 |
|
- |
|
|
190 |
+ |
|
191 |
191 |
|
JLabel lblNewLabel_1 = new JLabel("Telephone num:"); |
192 |
192 |
|
lblNewLabel_1.setBounds(10, 509, 83, 14); |
193 |
193 |
|
contentPane.add(lblNewLabel_1); |
194 |
|
- |
|
|
194 |
+ |
|
195 |
195 |
|
telIn = new JTextField(); |
196 |
196 |
|
telIn.setBounds(99, 505, 129, 20); |
197 |
197 |
|
contentPane.add(telIn); |
|
@@ -201,7 +201,7 @@ |
201 |
201 |
|
labelPhone.setBounds(238, 252, 178, 14); |
202 |
202 |
|
contentPane.add(labelPhone); |
203 |
203 |
|
|
204 |
|
- |
table.addMouseListener( new MouseAdapter(){ |
|
204 |
+ |
table.addMouseListener(new MouseAdapter() { |
205 |
205 |
|
@Override |
206 |
206 |
|
public void mouseClicked(MouseEvent arg0) { |
207 |
207 |
|
row = table.getSelectedRow(); |
|
@@ -210,13 +210,14 @@ |
210 |
210 |
|
Enumeration<Offer> rhs = rh.getAllOffers().elements(); |
211 |
211 |
|
while (rhs.hasMoreElements()) { |
212 |
212 |
|
Offer of = rhs.nextElement(); |
213 |
|
- |
Vector<Object> row = new Vector<Object>(); |
214 |
|
- |
row.add(of.getOfferNumber()); |
215 |
|
- |
row.add(of.getFirstDay()); |
216 |
|
- |
row.add(of.getLastDay()); |
217 |
|
- |
row.add(of.getPrice()); |
218 |
|
- |
tableModel.addRow(row); |
219 |
|
- |
|
|
213 |
+ |
if (of.getBooking() == null) { |
|
214 |
+ |
Vector<Object> row = new Vector<Object>(); |
|
215 |
+ |
row.add(of.getOfferNumber()); |
|
216 |
+ |
row.add(of.getFirstDay()); |
|
217 |
+ |
row.add(of.getLastDay()); |
|
218 |
+ |
row.add(of.getPrice()); |
|
219 |
+ |
tableModel.addRow(row); |
|
220 |
+ |
} |
220 |
221 |
|
} |
221 |
222 |
|
table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() { |
222 |
223 |
|
/** |
|
@@ -235,7 +236,7 @@ |
235 |
236 |
|
Date firstDay = (Date) table.getModel().getValueAt(row, 1); |
236 |
237 |
|
Date lastDay = (Date) table.getModel().getValueAt(row, 2); |
237 |
238 |
|
if (FirstDay != null && LastDay != null) { |
238 |
|
- |
if (LastDay.before(lastDay) || FirstDay.after(firstDay)) { |
|
239 |
+ |
if (LastDay.before(lastDay) || FirstDay.after(firstDay)) { |
239 |
240 |
|
setBackground(Color.RED); |
240 |
241 |
|
setForeground(Color.BLACK); |
241 |
242 |
|
} else { |
|
@@ -250,16 +251,18 @@ |
250 |
251 |
|
|
251 |
252 |
|
private void jButton_ActionPerformed(ActionEvent arg0) { |
252 |
253 |
|
BookingManager bookingM = new BookingManager(); |
253 |
|
- |
//RegExp to see if telephone number is correct??TODO |
|
254 |
+ |
// RegExp to see if telephone number is correct??TODO |
254 |
255 |
|
if (telIn.getText().matches("[976]\\d{2}[.\\- ]?\\d{3}[.\\- ]?\\d{3}")) { |
255 |
256 |
|
labelPhone.setText(""); |
256 |
257 |
|
Booking book = null; |
257 |
258 |
|
try { |
258 |
|
- |
if (table.getRowCount()!=0) |
259 |
|
- |
book = bookingM.createBooking(rh, rh.offers.get(row).getFirstDay(), rh.offers.get(row).getLastDay(), telIn.getText()); |
|
259 |
+ |
if (table.getRowCount() != 0) |
|
260 |
+ |
book = bookingM.createBooking(rh, rh.offers.get(row) |
|
261 |
+ |
.getFirstDay(), rh.offers.get(row).getLastDay(), |
|
262 |
+ |
telIn.getText()); |
260 |
263 |
|
} catch (Exception e) { |
261 |
264 |
|
e.printStackTrace(); |
262 |
|
- |
} |
|
265 |
+ |
} |
263 |
266 |
|
if (book != null) { |
264 |
267 |
|
BookRuralHouseConfirmationWindow confirmWindow = new BookRuralHouseConfirmationWindow( |
265 |
268 |
|
book); |
|
@@ -268,7 +271,6 @@ |
268 |
271 |
|
} else { |
269 |
272 |
|
labelPhone.setText("Phone format is wrong"); |
270 |
273 |
|
|
271 |
|
- |
|
272 |
274 |
|
} |
273 |
275 |
|
} |
274 |
276 |
|
} |