Hotel Management System Java With Source Code
The Hotel Management System Java is developed using Java Programming Language, This Hotel Management System Project In Java is a free and open source project. This application is pretty simple and easy to use.

A Hotel Management System Java is built in Java programming language with the help of NetBeans IDE. Also to make records available for future use it’s back-end is Sqlite database. This is simple yet complete hotel management system. This system performs all the necessary tasks that a hotel software application performs.
List of Modules
- Customer Information
- Rooms
- Booking
- Food
- Other Items
- Check Out and Payments
By the way I have here a list of Best Java Projects With Source Code For Beginners Free Download 2021 maybe this can help a lot.
This Hotel Management System also includes a downloadable Hotel Management System Java Source Code for free, just find the downloadable source code below and click to start downloading.
Watch the video here to see the full running Hotel Management System Java With Source Code
To start creating a Hotel Management System Java, makes sure that you have NeatBeans IDE or any platform of Java installed in your computer.
Hotel Management System Java With Source Code steps on how to create the project
Time needed: 5 minutes.
These are the steps on how to create Hotel Management System Java With Source Code
- Step 1: Create project.
First, open file and then click “project” to create.
- Step 2: Create project name.
Second, name your project.
- Step 3: Create JFrame.
Third, create “JFrame” form.
- Step 4: Create JFrame name.
Fourth, name your JFrame form.
- Step 5: Project Design.
Fifth, The actual design of the project.
The Code Given Below Is For The Customer Info Module
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 348 349 |
package I3.UI; import I3.Classes.UserInfo; import I3.DatabaseOperation.CustomerDb; import I3.DatabaseOperation.DatabaseOperation; import java.awt.Color; import java.awt.event.KeyEvent; import java.sql.ResultSet; import java.sql.SQLException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import net.proteanit.sql.DbUtils; /** * * @author Angel Jude Suarez */ public class CustomerPanel extends javax.swing.JFrame { UserInfo user = new UserInfo(); CustomerDb db = new CustomerDb(); ResultSet result = null; //int choice = ADD; public CustomerPanel() { // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); initComponents(); this.getContentPane().setBackground(new Color(241,241,242)); setTitle("All About Customers"); populateWithCustomerData(); } private void populateWithCustomerData() { result = db.getAllCustomer(); table_customer.setModel(DbUtils.resultSetToTableModel(result)); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); table_customer = new javax.swing.JTable(); jPanel3 = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); tf_type = new javax.swing.JTextField(); tf_address = new javax.swing.JTextField(); tf_phone = new javax.swing.JTextField(); tf_name = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); tf_id = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); btn_addCustomer = new javax.swing.JButton(); btn_editCustomer = new javax.swing.JButton(); btn_deleteCustomer = new javax.swing.JButton(); btn_reset = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); table_customer.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); table_customer.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { table_customerMouseClicked(evt); } }); jScrollPane1.setViewportView(table_customer); jPanel3.setBackground(new java.awt.Color(230, 231, 232)); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Customer Info", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Californian FB", 0, 18), new java.awt.Color(0, 153, 204))); // NOI18N jLabel3.setText("Phone No."); jLabel1.setText("Name"); tf_phone.setToolTipText("Digits Only"); tf_phone.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { tf_phoneKeyTyped(evt); } }); jLabel2.setText("Address"); jLabel4.setText("Type"); tf_id.setEditable(false); jLabel5.setText("ID"); btn_addCustomer.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N btn_addCustomer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/DefaultButton.png"))); // NOI18N btn_addCustomer.setBorder(null); btn_addCustomer.setBorderPainted(false); btn_addCustomer.setFocusPainted(false); btn_addCustomer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btn_addCustomerActionPerformed(evt); } }); btn_editCustomer.setForeground(new java.awt.Color(255, 255, 255)); btn_editCustomer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/EditButton.png"))); // NOI18N btn_editCustomer.setToolTipText(""); btn_editCustomer.setBorder(null); btn_editCustomer.setBorderPainted(false); btn_editCustomer.setEnabled(false); btn_editCustomer.setFocusPainted(false); btn_editCustomer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btn_editCustomerActionPerformed(evt); } }); btn_deleteCustomer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/DeleteButton.png"))); // NOI18N btn_deleteCustomer.setEnabled(false); btn_deleteCustomer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btn_deleteCustomerActionPerformed(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(btn_deleteCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(btn_editCustomer, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel3) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(tf_id, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(tf_address) .addComponent(tf_phone) .addComponent(tf_name, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE) .addComponent(tf_type)))) .addComponent(btn_addCustomer, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap(42, Short.MAX_VALUE)) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(tf_name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(tf_address, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(tf_phone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel4) .addComponent(tf_type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(tf_id, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btn_addCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btn_editCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btn_deleteCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(21, Short.MAX_VALUE)) ); btn_reset.setBackground(new java.awt.Color(204, 204, 255)); btn_reset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/reset.png"))); // NOI18N btn_reset.setToolTipText("Reset everything"); btn_reset.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btn_resetActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(btn_reset, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(54, 54, 54) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 461, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(0, 28, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(45, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGap(147, 147, 147) .addComponent(btn_reset) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGap(55, 55, 55) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void btn_addCustomerActionPerformed(java.awt.event.ActionEvent evt) { ObjectCreation(); db.insertCustomer(user); populateWithCustomerData(); emptyField(); } private void ObjectCreation() { user = new UserInfo(); user.setName(tf_name.getText()); user.setAddress(tf_address.getText()); user.setPhone_no(tf_phone.getText()); user.setType(tf_type.getText()); try{ user.setCustomer_id(Integer.parseInt(tf_id.getText())); } catch(Exception ex) { user.setCustomer_id(0); } } private void table_customerMouseClicked(java.awt.event.MouseEvent evt) { user = new UserInfo(); int row = table_customer.getSelectedRow(); displayToTextField(row); //ObjectCreation(); btn_editCustomer.setEnabled(true); btn_deleteCustomer.setEnabled(true); btn_addCustomer.setEnabled(false); } private void btn_resetActionPerformed(java.awt.event.ActionEvent evt) { emptyField(); } private void btn_editCustomerActionPerformed(java.awt.event.ActionEvent evt) { ObjectCreation(); db.updateCustomer(user); populateWithCustomerData(); emptyField(); } private void btn_deleteCustomerActionPerformed(java.awt.event.ActionEvent evt) { int row = table_customer.getSelectedRow(); int selectedUserId = (int) table_customer.getModel().getValueAt(row, 0); try { db.deleteCustomer(selectedUserId); } catch (SQLException ex) { Logger.getLogger(CustomerPanel.class.getName()).log(Level.SEVERE, null, ex); } populateWithCustomerData(); emptyField(); } private void tf_phoneKeyTyped(java.awt.event.KeyEvent evt) { char c = evt.getKeyChar(); if(!(Character.isDigit(c) || c== KeyEvent.VK_BACK_SPACE || c == KeyEvent.VK_DELETE )) { evt.consume(); } } private void emptyField() { btn_addCustomer.setEnabled(true); btn_editCustomer.setEnabled(false); btn_deleteCustomer.setEnabled(false); user = new UserInfo(); tf_address.setText(""); tf_id.setText(""); tf_name.setText(""); tf_phone.setText(""); tf_type.setText(""); table_customer.clearSelection(); } private void displayToTextField(int row) { //System.out.println(table_customer.getModel().getValueAt(row, 0)+ " >>>>>>>>> "); tf_id.setText(table_customer.getModel().getValueAt(row, 0)+""); tf_name.setText((String) table_customer.getModel().getValueAt(row, 1)); tf_address.setText((String) table_customer.getModel().getValueAt(row, 2)); tf_phone.setText((String) table_customer.getModel().getValueAt(row, 3)); tf_type.setText((String) table_customer.getModel().getValueAt(row, 4)); } |
In this module is for the customer information module.
The Code Given Below Is For The Rooms Module
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 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
package I3.UI; import I3.DatabaseOperation.DatabaseOperation; import I3.Classes.Room; import I3.Classes.RoomFare; import I3.DatabaseOperation.RoomDb; import java.awt.Color; import java.awt.event.KeyEvent; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JComboBox; import javax.swing.JOptionPane; import net.proteanit.sql.DbUtils; /** * * @author Angel Jude Suarez */ public class RoomPanel extends javax.swing.JDialog { /** * Creates new form RoomPanel */ RoomFare roomType = new RoomFare(); Room room = new Room(""); ResultSet result; ArrayList<String> roomClass = new ArrayList<>(); //DatabaseOperation db = new DatabaseOperation(); RoomDb roomdb = new RoomDb(); public RoomPanel(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); this.getContentPane().setBackground(new Color(241,241,242)); populateCombo(); populateRoomTable(); populateRoomTypeTable(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { tabbedPane = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); table_rooms = new javax.swing.JTable(); jPanel4 = new javax.swing.JPanel(); check_phone = new javax.swing.JCheckBox(); jLabel3 = new javax.swing.JLabel(); tf_roomNo = new javax.swing.JTextField(); combo_roomType = new javax.swing.JComboBox(); jLabel1 = new javax.swing.JLabel(); btn_edit = new javax.swing.JButton(); jLabel6 = new javax.swing.JLabel(); check_tv = new javax.swing.JCheckBox(); check_wifi = new javax.swing.JCheckBox(); jLabel2 = new javax.swing.JLabel(); check_gizer = new javax.swing.JCheckBox(); tf_roomID = new javax.swing.JTextField(); btn_delete = new javax.swing.JButton(); btn_add = new javax.swing.JButton(); tf_beds = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); btn_addRoomType = new javax.swing.JButton(); jLabel5 = new javax.swing.JLabel(); btn_deleteRoomType = new javax.swing.JButton(); tf_roomType = new javax.swing.JTextField(); tf_price = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); btn_editRoomType = new javax.swing.JButton(); jScrollPane2 = new javax.swing.JScrollPane(); table_roomType = new javax.swing.JTable(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); table_rooms.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); table_rooms.setToolTipText(""); table_rooms.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { table_roomsMouseClicked(evt); } }); jScrollPane1.setViewportView(table_rooms); jPanel4.setBackground(new java.awt.Color(230, 231, 232)); check_phone.setText("Phone Service"); jLabel3.setText("Beds"); jLabel1.setText("Room ID"); btn_edit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/EditButton.png"))); // NOI18N btn_edit.setEnabled(false); btn_edit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btn_editActionPerformed(evt); } }); jLabel6.setText("Category"); check_tv.setText("TV"); check_wifi.setText("WIFI"); check_wifi.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { check_wifiActionPerformed(evt); } }); jLabel2.setText("Room No"); check_gizer.setText("Gizer"); tf_roomID.setEditable(false); tf_roomID.setBackground(new java.awt.Color(204, 204, 255)); btn_delete.setBackground(new java.awt.Color(255, 0, 0)); btn_delete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/DeleteButton.png"))); // NOI18N btn_delete.setEnabled(false); btn_delete.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btn_deleteActionPerformed(evt); } }); btn_add.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/DefaultButton.png"))); // NOI18N btn_add.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btn_addActionPerformed(evt); } }); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(combo_roomType, 0, 100, Short.MAX_VALUE) .addComponent(tf_roomID) .addComponent(tf_roomNo) .addComponent(tf_beds))) .addGroup(jPanel4Layout.createSequentialGroup() .addGap(40, 40, 40) .addComponent(check_tv, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(check_phone)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(btn_add, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel4Layout.createSequentialGroup() .addComponent(check_wifi, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(check_gizer, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(btn_edit, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(btn_delete, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))) .addContainerGap(76, Short.MAX_VALUE)) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(tf_roomID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(tf_roomNo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(tf_beds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6) .addComponent(combo_roomType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 66, Short.MAX_VALUE) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(check_tv) .addComponent(check_phone)) .addGap(18, 18, 18) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(check_gizer) .addComponent(check_wifi)) .addGap(18, 18, 18) .addComponent(btn_add, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(btn_edit, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(btn_delete, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(106, 106, 106)) ); jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/reset.png"))); // NOI18N jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGap(25, 25, 25) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(53, 53, 53) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 677, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1)) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(29, 29, 29) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(191, 191, 191) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); tabbedPane.addTab("Room Information", jPanel1); jPanel3.setBackground(new java.awt.Color(230, 231, 232)); btn_addRoomType.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/DefaultButton.png"))); // NOI18N btn_addRoomType.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btn_addRoomTypeActionPerformed(evt); } }); jLabel5.setText("Price"); btn_deleteRoomType.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/DeleteButton.png"))); // NOI18N btn_deleteRoomType.setEnabled(false); btn_deleteRoomType.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btn_deleteRoomTypeActionPerformed(evt); } }); tf_price.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { tf_priceKeyTyped(evt); } }); jLabel4.setText("Room Type"); btn_editRoomType.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/EditButton.png"))); // NOI18N btn_editRoomType.setEnabled(false); btn_editRoomType.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btn_editRoomTypeActionPerformed(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(tf_roomType, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(tf_price, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(99, 99, 99) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(btn_editRoomType, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btn_addRoomType, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btn_deleteRoomType, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(123, Short.MAX_VALUE)) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(55, 55, 55) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(tf_roomType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4)) .addGap(29, 29, 29) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel5) .addComponent(tf_price, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(31, 31, 31) .addComponent(btn_addRoomType, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(btn_editRoomType, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(btn_deleteRoomType, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(56, Short.MAX_VALUE)) ); table_roomType.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); table_roomType.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { table_roomTypeMouseClicked(evt); } }); jScrollPane2.setViewportView(table_roomType); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(256, 256, 256) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 417, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(87, 87, 87)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(31, 31, 31) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 402, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(85, 85, 85) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(128, Short.MAX_VALUE)) ); tabbedPane.addTab("Room Class", jPanel2); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(tabbedPane) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(tabbedPane) ); pack(); }// </editor-fold> private void btn_addRoomTypeActionPerformed(java.awt.event.ActionEvent evt) { roomTypeObjectCreation(); roomdb.insertRoomType(roomType); //populateRoomTable(); populateRoomTypeTable(); } private void populateCombo() { try { ResultSet rs = roomdb.getRoomType(); while(rs.next()) { roomClass.add(rs.getString("type")); combo_roomType.addItem(rs.getString("type")); } } catch (SQLException ex) { JOptionPane.showMessageDialog(this, "Combo Fillup failed"); } } private void populateRoomTypeTable() { //System.out.println(tabbedPane.getSelectedIndex()); result = roomdb.getRoomType(); table_roomType.setModel(DbUtils.resultSetToTableModel(result)); roomdb.flushAll(); } private void populateRoomTable() { result = roomdb.getRooms(); table_rooms.setModel(DbUtils.resultSetToTableModel(result)); roomdb.flushAll(); } private void tf_priceKeyTyped(java.awt.event.KeyEvent evt) { char c = evt.getKeyChar(); if(!(Character.isDigit(c) || c== KeyEvent.VK_BACK_SPACE || c == KeyEvent.VK_DELETE )) { evt.consume(); } } private void btn_addActionPerformed(java.awt.event.ActionEvent evt) { roomObjectCreation(); roomdb.insertRoom(room); populateRoomTable(); clearRoomPanel(); //System.out.println(combo_roomType.getSelectedItem().toString()); } private void btn_editRoomTypeActionPerformed(java.awt.event.ActionEvent evt) { roomTypeObjectCreation(); roomdb.updateRoomType(roomType); populateRoomTypeTable(); btn_editRoomType.setEnabled(false); btn_addRoomType.setEnabled(true); } private void table_roomTypeMouseClicked(java.awt.event.MouseEvent evt) { roomType = new RoomFare(); int row = table_roomType.getSelectedRow(); displayToTextField(row); btn_addRoomType.setEnabled(false); btn_editRoomType.setEnabled(true); btn_deleteRoomType.setEnabled(true); } private void table_roomsMouseClicked(java.awt.event.MouseEvent evt) { room = new Room(null); btn_edit.setEnabled(true); btn_delete.setEnabled(true); btn_add.setEnabled(false); int row = table_rooms.getSelectedRow(); displayToRoomTextField(row); // System.out.println(table_rooms.getValueAt(row, 1)+""); //System.out.println(">>>>>>> "+row ); } private void btn_editActionPerformed(java.awt.event.ActionEvent evt) { roomObjectCreation(); roomdb.updateRoom(room); populateRoomTable(); clearRoomPanel(); btn_add.setEnabled(true); } private void btn_deleteActionPerformed(java.awt.event.ActionEvent evt) { int roomId =Integer.parseInt( tf_roomID.getText() ); roomdb.deleteRoom(roomId); populateRoomTable(); clearRoomPanel(); btn_add.setEnabled(true); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { clearRoomPanel(); } private void btn_deleteRoomTypeActionPerformed(java.awt.event.ActionEvent evt) { //int roomId =Integer.parseInt( tf_roomType.getText() ); JOptionPane.showMessageDialog(null, "no method written yet"); } private void check_wifiActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void clearRoomPanel() { room = new Room(null); tf_beds.setText(""); tf_price.setText(""); tf_roomID.setText(""); tf_roomNo.setText(""); tf_roomType.setText(""); table_rooms.clearSelection(); check_gizer.setSelected(false); check_phone.setSelected(false); check_tv.setSelected(false); check_wifi.setSelected(false); combo_roomType.setSelectedIndex(0); btn_add.setEnabled(true); btn_edit.setEnabled(false); btn_delete.setEnabled(false); } private void clearRoomTypePanel() { roomType = new RoomFare(); tf_roomType.setText(""); tf_price.setText(""); btn_addRoomType.setEnabled(true); btn_editRoomType.setEnabled(false); btn_deleteRoomType.setEnabled(false); } private void displayToRoomTextField(int row) { // for(int i=0; combo_roomType.) tf_roomID.setText(table_rooms.getModel().getValueAt(row, 0)+""); tf_roomNo.setText(table_rooms.getModel().getValueAt(row, 1)+""); tf_beds.setText(table_rooms.getModel().getValueAt(row, 2)+""); check_tv.setSelected((table_rooms.getModel().getValueAt(row, 3)+"").equals("true") ? true:false); check_wifi.setSelected((table_rooms.getModel().getValueAt(row, 4)+"").equals("true") ? true:false); check_gizer.setSelected((table_rooms.getModel().getValueAt(row, 5)+"").equals("true") ? true:false); check_phone.setSelected((table_rooms.getModel().getValueAt(row, 6)+"").equals("true") ? true:false); int selectedIndex = getComboSearchIndex(table_rooms.getModel().getValueAt(row, 7)+""); combo_roomType.setSelectedIndex(selectedIndex); //tv,wifi,gizer,phone //value ? "true" : "false"; } private void displayToTextField(int row) { tf_roomType.setText(table_roomType.getModel().getValueAt(row, 0)+""); tf_price.setText(table_roomType.getModel().getValueAt(row, 1)+""); } private int getComboSearchIndex(String item) { for( int i=0;i<roomClass.size() ; i++) { if(item.equals(roomClass.get(i))) { return i; } } return -1; } private void roomObjectCreation() { // ************************************** null add korsi "" er jaygay ********************* room = new Room(null); room.setRoom_no(tf_roomNo.getText()); room.setBed_number(Integer.parseInt(tf_beds.getText())); room.setHasTV(check_tv.isSelected()); room.setHasWIFI(check_wifi.isSelected()); room.setHasGizer(check_gizer.isSelected()); room.setHasPhone(check_phone.isSelected()); // setting the inner object of RoomType room.setRoom_class(new RoomFare()); room.getRoom_class().setRoom_type(combo_roomType.getSelectedItem().toString()); try { room.setRoom_id(Integer.parseInt(tf_roomID.getText())); } catch(Exception ex) { room.setRoom_id(-1); } } private void roomTypeObjectCreation() { roomType = new RoomFare(); roomType.setRoom_type(tf_roomType.getText()); roomType.setPricePerDay(Integer.parseInt(tf_price.getText())); } |
In this module which is the room module of the system.
The Code Given Below Is For The Order Module
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 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
package I3.UI; import I3.Classes.Order; import I3.DatabaseOperation.BookingDb; import I3.DatabaseOperation.DatabaseOperation; import I3.DatabaseOperation.FoodDb; import I3.DatabaseOperation.ItemDb; import I3.DatabaseOperation.OrderDb; import java.awt.Color; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.print.Book; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Vector; import javax.swing.DefaultComboBoxModel; import javax.swing.JOptionPane; import javax.swing.text.JTextComponent; import net.proteanit.sql.DbUtils; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; /** * * @author Angel Jude Suarez */ public class OrderPanel extends javax.swing.JDialog { /** * Creates new form OrderPanel */ Vector<String> bookingList = new Vector(); BookingDb db = new BookingDb(); ResultSet result; FoodDb foodDb = new FoodDb(); ItemDb itemDb = new ItemDb(); // OrderDb orderDb = new OrderDb(); public OrderPanel(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); this.getContentPane().setBackground(new Color(241,241,242)); searchHelper(); populateFoodTable(); populateItemTable(); AutoCompleteDecorator.decorate(combo_booking); } public void searchHelper() { final DefaultComboBoxModel model = new DefaultComboBoxModel(bookingList); combo_booking.setModel(model); JTextComponent editor = (JTextComponent) combo_booking.getEditor().getEditorComponent(); editor.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent evt) { if(evt.getKeyChar() == KeyEvent.VK_ENTER) { String details = (String) combo_booking.getSelectedItem(); //System.out.println(details); if(!details.contains(",")) { JOptionPane.showMessageDialog(null, "no booking found, try adding a new booking"); } else { int bookinId = Integer.parseInt(details.substring(details.lastIndexOf(",")+1)); tf_bookingId.setText(bookinId+""); // A if condition should be here, but not required as the last line has no chance of returning -1. } } /// suggestion generation String value = ""; try { value = combo_booking.getEditor().getItem().toString(); // System.out.println(value +" <<<<<<<<<<<<<"); } catch (Exception ex) { } if (value.length() >= 2) { // System.out.println("working"); bookingComboFill(db.bookingsReadyForOrder(value)); db.flushAll(); } } }); } public void bookingComboFill(ResultSet result) { bookingList.clear(); try { while (result.next()) { // System.out.println(">>>>>> "+result.getString("name")); bookingList.add(result.getString("booking_room") + ", " + result.getString("name") + "," + result.getString("booking_id")); } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "bookingCombo fill error"); } } private void populateFoodTable() { result = foodDb.getFoods(); table_food.setModel(DbUtils.resultSetToTableModel(result)); foodDb.flushAll(); } private void populateItemTable() { result = itemDb.getItems(); table_item.setModel(DbUtils.resultSetToTableModel(result)); itemDb.flushAll(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); table_food = new javax.swing.JTable(); jScrollPane2 = new javax.swing.JScrollPane(); table_item = new javax.swing.JTable(); jPanel1 = new javax.swing.JPanel(); tf_foodItem = new javax.swing.JTextField(); tf_quantity = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); tf_price = new javax.swing.JTextField(); tf_total = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); tf_bookingId = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); combo_booking = new javax.swing.JComboBox(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); table_food.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); table_food.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { table_foodMouseClicked(evt); } }); jScrollPane1.setViewportView(table_food); table_item.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); table_item.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { table_itemMouseClicked(evt); } }); jScrollPane2.setViewportView(table_item); jPanel1.setBackground(new java.awt.Color(230, 231, 232)); tf_quantity.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { tf_quantityKeyReleased(evt); } public void keyTyped(java.awt.event.KeyEvent evt) { tf_quantityKeyTyped(evt); } }); jLabel1.setText("Item/Food"); jLabel2.setText("Quantity"); tf_price.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { tf_priceKeyTyped(evt); } }); jLabel3.setText("Total"); tf_bookingId.setBackground(new java.awt.Color(204, 255, 0)); jLabel4.setText("Price"); combo_booking.setEditable(true); jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/SaveButton.png"))); // NOI18N jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(combo_booking, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(tf_bookingId) .addComponent(tf_foodItem) .addComponent(tf_quantity) .addComponent(tf_total) .addComponent(tf_price, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(114, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(combo_booking, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(tf_bookingId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(19, 19, 19) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(tf_foodItem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(10, 10, 10) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(tf_price, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(tf_quantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(tf_total, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(91, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap(71, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(47, 47, 47) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(45, 45, 45) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 284, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(55, 55, 55) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addContainerGap(66, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void table_foodMouseClicked(java.awt.event.MouseEvent evt) { int row = table_food.getSelectedRow(); displayToTextField(row); } private void tf_quantityKeyReleased(java.awt.event.KeyEvent evt) { int price = Integer.parseInt(tf_price.getText()); try{ int quantity = Integer.parseInt(tf_quantity.getText()); tf_total.setText(quantity*price+""); }catch(Exception ex) { } } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { db.insertOrder(new Order( Integer.parseInt(tf_bookingId.getText()), tf_foodItem.getText(), Integer.parseInt(tf_price.getText()), Integer.parseInt(tf_quantity.getText()), Integer.parseInt(tf_total.getText()) )); } private void table_itemMouseClicked(java.awt.event.MouseEvent evt) { int row = table_item.getSelectedRow(); displayToTextFieldFromItem(row); } private void tf_priceKeyTyped(java.awt.event.KeyEvent evt) { char c = evt.getKeyChar(); if(!(Character.isDigit(c) || c== KeyEvent.VK_BACK_SPACE || c == KeyEvent.VK_DELETE )) { evt.consume(); } } private void tf_quantityKeyTyped(java.awt.event.KeyEvent evt) { char c = evt.getKeyChar(); if(!(Character.isDigit(c) || c== KeyEvent.VK_BACK_SPACE || c == KeyEvent.VK_DELETE )) { evt.consume(); } } private void displayToTextField(int row) { tf_foodItem.setText(table_food.getModel().getValueAt(row, 1)+""); tf_price.setText(table_food.getModel().getValueAt(row, 2)+""); } private void displayToTextFieldFromItem(int row) { tf_foodItem.setText(table_item.getModel().getValueAt(row, 1)+""); tf_price.setText(table_item.getModel().getValueAt(row, 2)+""); } |
In this module which is the module for the ordering of foods.
The Code Given Below Is For The Payment Module
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 |
package I3.UI; import I3.Classes.Order; import I3.DatabaseOperation.BookingDb; import I3.DatabaseOperation.OrderDb; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.print.PrinterException; import java.sql.ResultSet; import java.sql.SQLException; import java.text.MessageFormat; import java.util.Date; import java.util.Vector; import java.util.concurrent.TimeUnit; import javax.swing.DefaultComboBoxModel; import javax.swing.JOptionPane; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; import javax.swing.text.JTextComponent; import net.proteanit.sql.DbUtils; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; import org.joda.time.Interval; /** * * @author Angel Jude Suarez */ public class PaymentPanel extends javax.swing.JDialog { /** * Creates new form PaymentPanel */ BookingDb bookingdB = new BookingDb(); Vector<String> bookingList = new Vector(); //OrderDb orderDb = new OrderDb(); int bookingId = -1; ResultSet result; public PaymentPanel(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); searchHelper(); AutoCompleteDecorator.decorate(combo_booking); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { combo_booking = new javax.swing.JComboBox(); btn_checkOut = new javax.swing.JButton(); jButton1 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); table_payment = new javax.swing.JTable(); jButton2 = new javax.swing.JButton(); tf_total = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); combo_booking.setEditable(true); btn_checkOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/checkout.png"))); // NOI18N btn_checkOut.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btn_checkOutActionPerformed(evt); } }); jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/generate.png"))); // NOI18N jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); table_payment.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent evt) { table_paymentPropertyChange(evt); } }); jScrollPane1.setViewportView(table_payment); jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/meme.png"))); // NOI18N jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jLabel1.setForeground(new java.awt.Color(64, 64, 65)); jLabel1.setText("Total :"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(138, 138, 138) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(54, 54, 54) .addComponent(combo_booking, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(btn_checkOut, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addGap(373, 373, 373) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(tf_total, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)))) .addContainerGap(348, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(37, 37, 37) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(btn_checkOut, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(combo_booking, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(56, 56, 56) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(tf_total, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(47, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void btn_checkOutActionPerformed(java.awt.event.ActionEvent evt) { //System.out.println("faysal .... "+ bookingId); if (bookingId != 1) { bookingdB.updateCheckOut(bookingId, new Date().getTime() / 1000); result = bookingdB.getABooking(bookingId); // bookingdB.flushAll(); try { int duration = 1; int checkIn = result.getInt("check_in"); int checkOut = result.getInt("check_out"); String roomName = result.getString("booking_room"); long diff = Math.abs((checkOut * 1000) - (checkIn * 1000)); // System.out.println(">>>>>>>>>>xxxxxxxxxxx "+ diff.toDuration().toStandardDays().toString()); int durationDays = (int) TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS); int roomFare = bookingdB.getRoomPrice(bookingId); bookingdB.flushAll(); // orderDb.flushAll(); if (roomFare != -1) { System.out.println("working as expected " + roomFare); bookingdB.insertOrder(new Order( bookingId, roomName, roomFare, durationDays, (roomFare * durationDays) )); } // System.out.println ("Days: " + days); } catch (Exception ex) { JOptionPane.showMessageDialog(null, "no booking result found\n " + ex.toString()); } } else { JOptionPane.showMessageDialog(null, "no booking selected, try to select one hitting enter from suggestion box"); } } |