Registration_Tenant.java Source code

Java tutorial

Introduction

Here is the source code for Registration_Tenant.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Image;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
import com.itextpdf.text.pdf.PdfWriter;
import java.awt.Toolkit;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.rmi.RemoteException;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;

/**
 *
 * @author Mark Herbert Cabuang
 */
public class Registration_Tenant extends javax.swing.JFrame {
    private String file = null;
    private ArrayList<String> registrationDetails;
    private String user;
    private final MessageDialog md = new MessageDialog();
    private Connection connection;
    private String roomNo;
    private String reservationIdnum;

    /**
     * Creates new form Registration
     *
     */
    public Registration_Tenant() {
        initComponents();
        this.setIconImage(
                Toolkit.getDefaultToolkit().getImage(getClass().getResource("icons/Backup and Recovery.png")));
        try {
            Class.forName("com.mysql.jdbc.Driver");
            connection = DriverManager.getConnection("jdbc:mysql://localhost/181nprdb", "root", "");
        } catch (ClassNotFoundException | SQLException ex) {
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        }
        setRooms();
        setReservations();
    }

    /**
     * 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">//GEN-BEGIN:initComponents
    private void initComponents() {

        gender = new javax.swing.ButtonGroup();
        occupation = new javax.swing.ButtonGroup();
        mainPanel = new javax.swing.JPanel();
        basicInfoPanel = new javax.swing.JPanel();
        nameLabel = new javax.swing.JLabel();
        lastNameTextField = new javax.swing.JTextField();
        firstNameTextField = new javax.swing.JTextField();
        firstNameLabel = new javax.swing.JLabel();
        middleNameLabel = new javax.swing.JLabel();
        lastNameLabel = new javax.swing.JLabel();
        collegeLabel = new javax.swing.JLabel();
        collegeTextField = new javax.swing.JTextField();
        departmentTextField = new javax.swing.JTextField();
        departmentLabel = new javax.swing.JLabel();
        courseLabel = new javax.swing.JLabel();
        courseTextField = new javax.swing.JTextField();
        yearLabel = new javax.swing.JLabel();
        yearTextField = new javax.swing.JTextField();
        genderLabel = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        homeAddressTextArea = new javax.swing.JTextArea();
        uploadPictureButton = new javax.swing.JButton();
        pictureFileNameLabel = new javax.swing.JLabel();
        homeAddressLabel = new javax.swing.JLabel();
        birthDateLabel = new javax.swing.JLabel();
        birthDateChooser = new datechooser.beans.DateChooserCombo();
        middleNameTextField = new javax.swing.JTextField();
        male = new javax.swing.JRadioButton();
        female = new javax.swing.JRadioButton();
        othersPanel = new javax.swing.JPanel();
        roomNumberLabel = new javax.swing.JLabel();
        roomTypeLabel = new javax.swing.JLabel();
        applianceAndInventoryFormButton = new javax.swing.JButton();
        roomTypeTextField = new javax.swing.JTextField();
        roomNumberTextField = new javax.swing.JComboBox();
        saveButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();
        contactDetailsPanel = new javax.swing.JPanel();
        jLabel135 = new javax.swing.JLabel();
        mobileNumberLabel = new javax.swing.JLabel();
        emailLabel = new javax.swing.JLabel();
        email = new javax.swing.JTextField();
        jSeparator16 = new javax.swing.JSeparator();
        fatherNameTextField = new javax.swing.JTextField();
        flandlineLabel = new javax.swing.JLabel();
        fACodeTextField = new javax.swing.JTextField();
        fphoneNumberTextField = new javax.swing.JTextField();
        fPhoneNumberLabel = new javax.swing.JLabel();
        fareaCodeLabel = new javax.swing.JLabel();
        fatherNameLabel = new javax.swing.JLabel();
        fMobileNumberLabel = new javax.swing.JLabel();
        fMobileNumberTextField = new javax.swing.JTextField();
        fEmailTextField = new javax.swing.JTextField();
        fEmailLabel = new javax.swing.JLabel();
        jSeparator17 = new javax.swing.JSeparator();
        mACodeTextField = new javax.swing.JTextField();
        mphoneNumberTextField = new javax.swing.JTextField();
        mphoneNumberLabel = new javax.swing.JLabel();
        mareaCodeLabel = new javax.swing.JLabel();
        mlandlineLabel = new javax.swing.JLabel();
        motherNameTextField = new javax.swing.JTextField();
        motherNameLabel = new javax.swing.JLabel();
        mMobileNumberTextField = new javax.swing.JTextField();
        mEmailLabel = new javax.swing.JLabel();
        mMobileNumberLabel = new javax.swing.JLabel();
        jSeparator18 = new javax.swing.JSeparator();
        emergencyContactLabel = new javax.swing.JLabel();
        guardianNameLabel = new javax.swing.JLabel();
        guardianNameTextField = new javax.swing.JTextField();
        relationToGuardianLabel = new javax.swing.JLabel();
        gContactNumbersLabel = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        guardianAddress = new javax.swing.JTextArea();
        MobileNumber1 = new javax.swing.JTextField();
        MobileNumber2 = new javax.swing.JTextField();
        gContactNumber1 = new javax.swing.JTextField();
        mEmailTextField = new javax.swing.JTextField();
        relationToGuardian = new javax.swing.JTextField();
        clearButton1 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        reservations = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        registrationDate = new datechooser.beans.DateChooserCombo();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Registration");
        setIconImages(null);
        setUndecorated(true);
        setResizable(false);

        mainPanel.setBackground(new java.awt.Color(255, 255, 255));
        mainPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        basicInfoPanel.setBackground(new java.awt.Color(255, 255, 255));
        basicInfoPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Basic Information",
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Rondalo", 0, 12))); // NOI18N

        nameLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        nameLabel.setText("Name:");

        lastNameTextField.setBackground(new java.awt.Color(255, 255, 204));
        lastNameTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N

        firstNameTextField.setBackground(new java.awt.Color(255, 255, 204));
        firstNameTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N

        firstNameLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        firstNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        firstNameLabel.setText("First Name");

        middleNameLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        middleNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        middleNameLabel.setText("Middle Name");

        lastNameLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        lastNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lastNameLabel.setText("Last Name");

        collegeLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        collegeLabel.setText("College/University Attending:");

        collegeTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        collegeTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                collegeTextFieldKeyTyped(evt);
            }
        });

        departmentTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        departmentTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                departmentTextFieldKeyTyped(evt);
            }
        });

        departmentLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        departmentLabel.setText("School/Department:");

        courseLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        courseLabel.setText("Course:");

        courseTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        courseTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                courseTextFieldKeyTyped(evt);
            }
        });

        yearLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        yearLabel.setText("Year:");

        yearTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        yearTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                yearTextFieldKeyTyped(evt);
            }
        });

        genderLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        genderLabel.setText("Gender:");

        homeAddressTextArea.setBackground(new java.awt.Color(255, 255, 204));
        homeAddressTextArea.setColumns(20);
        homeAddressTextArea.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        homeAddressTextArea.setLineWrap(true);
        homeAddressTextArea.setRows(5);
        homeAddressTextArea.setWrapStyleWord(true);
        jScrollPane6.setViewportView(homeAddressTextArea);

        uploadPictureButton.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        uploadPictureButton.setText("Upload Picture");
        uploadPictureButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        uploadPictureButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                uploadPictureButtonActionPerformed(evt);
            }
        });

        pictureFileNameLabel.setFont(new java.awt.Font("Rondalo", 2, 12)); // NOI18N
        pictureFileNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        pictureFileNameLabel.setText("picture.jpg");

        homeAddressLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        homeAddressLabel.setText("Home Address:");

        birthDateLabel.setText("Birth date:");

        birthDateChooser.setCurrentView(new datechooser.view.appearance.AppearancesList("Light",
                new datechooser.view.appearance.ViewAppearance("custom",
                        new datechooser.view.appearance.swing.SwingCellAppearance(
                                new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11), new java.awt.Color(0, 0, 0),
                                new java.awt.Color(0, 0, 255), false, true,
                                new datechooser.view.appearance.swing.ButtonPainter()),
                        new datechooser.view.appearance.swing.SwingCellAppearance(
                                new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11), new java.awt.Color(0, 0, 0),
                                new java.awt.Color(0, 0, 255), true, true,
                                new datechooser.view.appearance.swing.ButtonPainter()),
                        new datechooser.view.appearance.swing.SwingCellAppearance(
                                new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11), new java.awt.Color(0, 0, 255),
                                new java.awt.Color(0, 0, 255), false, true,
                                new datechooser.view.appearance.swing.ButtonPainter()),
                        new datechooser.view.appearance.swing.SwingCellAppearance(
                                new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11),
                                new java.awt.Color(128, 128, 128), new java.awt.Color(0, 0, 255), false, true,
                                new datechooser.view.appearance.swing.LabelPainter()),
                        new datechooser.view.appearance.swing.SwingCellAppearance(
                                new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11), new java.awt.Color(0, 0, 0),
                                new java.awt.Color(0, 0, 255), false, true,
                                new datechooser.view.appearance.swing.LabelPainter()),
                        new datechooser.view.appearance.swing.SwingCellAppearance(
                                new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11), new java.awt.Color(0, 0, 0),
                                new java.awt.Color(255, 0, 0), false, false,
                                new datechooser.view.appearance.swing.ButtonPainter()),
                        (datechooser.view.BackRenderer) null, false, true)));
        birthDateChooser.setCalendarBackground(new java.awt.Color(255, 255, 255));
        birthDateChooser.setNothingAllowed(false);
        try {
            birthDateChooser.setDefaultPeriods(new datechooser.model.multiple.PeriodSet(
                    new datechooser.model.multiple.Period(new java.util.GregorianCalendar(1995, 0, 1),
                            new java.util.GregorianCalendar(1995, 0, 1))));
        } catch (datechooser.model.exeptions.IncompatibleDataExeption e1) {
            e1.printStackTrace();
        }

        middleNameTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N

        male.setBackground(new java.awt.Color(255, 255, 255));
        gender.add(male);
        male.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        male.setSelected(true);
        male.setText("Male");
        male.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        male.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                maleMouseClicked(evt);
            }
        });

        female.setBackground(new java.awt.Color(255, 255, 255));
        gender.add(female);
        female.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        female.setText("Female");
        female.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        female.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                femaleMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout basicInfoPanelLayout = new javax.swing.GroupLayout(basicInfoPanel);
        basicInfoPanel.setLayout(basicInfoPanelLayout);
        basicInfoPanelLayout.setHorizontalGroup(
                basicInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                        javax.swing.GroupLayout.Alignment.TRAILING,
                        basicInfoPanelLayout.createSequentialGroup().addContainerGap().addGroup(basicInfoPanelLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jScrollPane6)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                        basicInfoPanelLayout.createSequentialGroup().addComponent(collegeLabel)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(collegeTextField))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                        basicInfoPanelLayout.createSequentialGroup().addGap(45, 45, 45)
                                                .addComponent(departmentLabel)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(departmentTextField))
                                .addGroup(basicInfoPanelLayout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                        .addComponent(pictureFileNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                182, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(uploadPictureButton))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, basicInfoPanelLayout
                                        .createSequentialGroup().addGap(12, 12, 12).addComponent(nameLabel)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(basicInfoPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        false)
                                                .addComponent(lastNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        148, Short.MAX_VALUE)
                                                .addComponent(lastNameTextField))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(basicInfoPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(firstNameTextField,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 172,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(firstNameLabel,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 160,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(basicInfoPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(middleNameTextField).addComponent(middleNameLabel,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                        basicInfoPanelLayout.createSequentialGroup().addComponent(homeAddressLabel)
                                                .addGap(0, 0, Short.MAX_VALUE))
                                .addGroup(basicInfoPanelLayout.createSequentialGroup().addComponent(courseLabel)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(courseTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 60,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(yearLabel)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(yearTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(birthDateLabel)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(birthDateChooser, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18).addComponent(genderLabel)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(male).addGap(12, 12, 12).addComponent(female,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                .addContainerGap()));
        basicInfoPanelLayout.setVerticalGroup(
                basicInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(basicInfoPanelLayout.createSequentialGroup().addContainerGap()
                                .addGroup(basicInfoPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(nameLabel)
                                        .addComponent(lastNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(firstNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(middleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(basicInfoPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lastNameLabel).addComponent(firstNameLabel)
                                        .addComponent(middleNameLabel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(basicInfoPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(collegeLabel).addComponent(collegeTextField,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(basicInfoPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(departmentLabel).addComponent(departmentTextField,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(basicInfoPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(basicInfoPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(genderLabel).addComponent(male).addComponent(female))
                                        .addGroup(basicInfoPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(birthDateChooser,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGroup(basicInfoPanelLayout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(courseLabel)
                                                        .addComponent(courseTextField,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(yearLabel)
                                                        .addComponent(yearTextField,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(birthDateLabel))))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(homeAddressLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 53,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(basicInfoPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(uploadPictureButton).addComponent(pictureFileNameLabel))
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        othersPanel.setBackground(new java.awt.Color(255, 255, 255));
        othersPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Others",
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Rondalo", 0, 12))); // NOI18N

        roomNumberLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        roomNumberLabel.setText("Room Number:");

        roomTypeLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        roomTypeLabel.setText("Room Type:");

        applianceAndInventoryFormButton.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        applianceAndInventoryFormButton.setText("Inventory Form");
        applianceAndInventoryFormButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        applianceAndInventoryFormButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                applianceAndInventoryFormButtonActionPerformed(evt);
            }
        });

        roomTypeTextField.setEditable(false);
        roomTypeTextField.setBackground(new java.awt.Color(255, 255, 204));
        roomTypeTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        roomTypeTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        roomTypeTextField.setText("Double Sharing Room");

        roomNumberTextField.setBackground(new java.awt.Color(255, 255, 204));
        roomNumberTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        roomNumberTextField.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                roomNumberTextFieldItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout othersPanelLayout = new javax.swing.GroupLayout(othersPanel);
        othersPanel.setLayout(othersPanelLayout);
        othersPanelLayout.setHorizontalGroup(othersPanelLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(othersPanelLayout.createSequentialGroup().addContainerGap().addComponent(roomNumberLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(roomNumberTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 93,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(roomTypeLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(roomTypeTextField)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(applianceAndInventoryFormButton, javax.swing.GroupLayout.PREFERRED_SIZE, 177,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap()));
        othersPanelLayout.setVerticalGroup(othersPanelLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(othersPanelLayout.createSequentialGroup().addContainerGap().addGroup(othersPanelLayout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(roomNumberLabel).addComponent(roomTypeLabel)
                        .addComponent(applianceAndInventoryFormButton)
                        .addComponent(roomTypeTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(roomNumberTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(52, Short.MAX_VALUE)));

        saveButton.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        saveButton.setText("Save");
        saveButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        saveButton.setEnabled(false);
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });

        cancelButton.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        cancelButton.setText("Cancel");
        cancelButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });

        contactDetailsPanel.setBackground(new java.awt.Color(255, 255, 255));
        contactDetailsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Contact Details",
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Rondalo", 0, 12))); // NOI18N

        jLabel135.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel135.setText("/");

        mobileNumberLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        mobileNumberLabel.setText("Mobile Number:");

        emailLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        emailLabel.setText("Email:");

        email.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N

        fatherNameTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        fatherNameTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                fatherNameTextFieldKeyTyped(evt);
            }
        });

        flandlineLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        flandlineLabel.setText("Landline:");

        fACodeTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        fACodeTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                fACodeTextFieldKeyTyped(evt);
            }
        });

        fphoneNumberTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        fphoneNumberTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                fphoneNumberTextFieldKeyTyped(evt);
            }
        });

        fPhoneNumberLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        fPhoneNumberLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        fPhoneNumberLabel.setText("Phone No.");

        fareaCodeLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        fareaCodeLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        fareaCodeLabel.setText("Area Code");

        fatherNameLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        fatherNameLabel.setText("Father's Name:");

        fMobileNumberLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        fMobileNumberLabel.setText("Mobile Number:");

        fMobileNumberTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        fMobileNumberTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                fMobileNumberTextFieldKeyTyped(evt);
            }
        });

        fEmailTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        fEmailTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                fEmailTextFieldKeyTyped(evt);
            }
        });

        fEmailLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        fEmailLabel.setText("Email:");

        mACodeTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        mACodeTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                mACodeTextFieldKeyTyped(evt);
            }
        });

        mphoneNumberTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        mphoneNumberTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                mphoneNumberTextFieldKeyTyped(evt);
            }
        });

        mphoneNumberLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        mphoneNumberLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        mphoneNumberLabel.setText("Phone No.");

        mareaCodeLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        mareaCodeLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        mareaCodeLabel.setText("Area Code");

        mlandlineLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        mlandlineLabel.setText("Landline:");

        motherNameTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        motherNameTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                motherNameTextFieldKeyTyped(evt);
            }
        });

        motherNameLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        motherNameLabel.setText("Mother's Name:");

        mMobileNumberTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        mMobileNumberTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                mMobileNumberTextFieldKeyTyped(evt);
            }
        });

        mEmailLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        mEmailLabel.setText("Email:");

        mMobileNumberLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        mMobileNumberLabel.setText("Mobile Number:");

        emergencyContactLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        emergencyContactLabel.setText("Emergency Contacts:");

        guardianNameLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        guardianNameLabel.setText("Guardian Name:");

        guardianNameTextField.setBackground(new java.awt.Color(255, 255, 204));
        guardianNameTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        guardianNameTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                guardianNameTextFieldKeyTyped(evt);
            }
        });

        relationToGuardianLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        relationToGuardianLabel.setText("Relation to Guardian:");

        gContactNumbersLabel.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        gContactNumbersLabel.setText("Contact Number:");

        jLabel1.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        jLabel1.setText("Address:");

        guardianAddress.setBackground(new java.awt.Color(255, 255, 204));
        guardianAddress.setColumns(20);
        guardianAddress.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        guardianAddress.setLineWrap(true);
        guardianAddress.setRows(5);
        guardianAddress.setWrapStyleWord(true);
        guardianAddress.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                guardianAddressKeyTyped(evt);
            }
        });
        jScrollPane1.setViewportView(guardianAddress);

        MobileNumber1.setBackground(new java.awt.Color(255, 255, 204));
        MobileNumber1.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N

        MobileNumber2.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        MobileNumber2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                MobileNumber2KeyTyped(evt);
            }
        });

        gContactNumber1.setBackground(new java.awt.Color(255, 255, 204));
        gContactNumber1.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        gContactNumber1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                gContactNumber1KeyTyped(evt);
            }
        });

        mEmailTextField.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        mEmailTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                mEmailTextFieldKeyTyped(evt);
            }
        });

        relationToGuardian.setBackground(new java.awt.Color(255, 255, 204));
        relationToGuardian.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        relationToGuardian.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                relationToGuardianKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout contactDetailsPanelLayout = new javax.swing.GroupLayout(contactDetailsPanel);
        contactDetailsPanel.setLayout(contactDetailsPanelLayout);
        contactDetailsPanelLayout.setHorizontalGroup(contactDetailsPanelLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(contactDetailsPanelLayout.createSequentialGroup().addContainerGap()
                        .addGroup(contactDetailsPanelLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(contactDetailsPanelLayout.createSequentialGroup()
                                        .addComponent(jSeparator18).addContainerGap())
                                .addGroup(contactDetailsPanelLayout.createSequentialGroup()
                                        .addGroup(contactDetailsPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        contactDetailsPanelLayout.createSequentialGroup()
                                                                .addGap(8, 8, 8).addComponent(fMobileNumberLabel)
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                                .addComponent(fMobileNumberTextField,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 201,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        contactDetailsPanelLayout.createSequentialGroup()
                                                                .addGap(14, 14, 14).addComponent(fatherNameLabel)
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(fatherNameTextField,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 209,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(contactDetailsPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(contactDetailsPanelLayout.createSequentialGroup()
                                                        .addComponent(flandlineLabel)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addGroup(contactDetailsPanelLayout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(fareaCodeLabel,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE)
                                                                .addComponent(fACodeTextField))
                                                        .addGap(18, 18, 18)
                                                        .addGroup(contactDetailsPanelLayout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(fphoneNumberTextField,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 90,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addComponent(fPhoneNumberLabel,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 90,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                                .addGroup(contactDetailsPanelLayout.createSequentialGroup()
                                                        .addGap(2, 2, 2).addComponent(mlandlineLabel)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addGroup(contactDetailsPanelLayout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(mareaCodeLabel,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE)
                                                                .addComponent(mACodeTextField))
                                                        .addGap(18, 18, 18)
                                                        .addGroup(contactDetailsPanelLayout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(mphoneNumberTextField,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 90,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addComponent(mphoneNumberLabel,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 90,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                                .addGroup(contactDetailsPanelLayout.createSequentialGroup()
                                                        .addGap(8, 8, 8).addComponent(fEmailLabel)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(fEmailTextField,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 200,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addGap(0, 0, Short.MAX_VALUE)))
                                        .addContainerGap())
                                .addGroup(contactDetailsPanelLayout.createSequentialGroup()
                                        .addGroup(contactDetailsPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jSeparator16)
                                                .addGroup(contactDetailsPanelLayout.createSequentialGroup()
                                                        .addGap(12, 12, 12)
                                                        .addGroup(contactDetailsPanelLayout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.TRAILING)
                                                                .addComponent(mobileNumberLabel)
                                                                .addComponent(emailLabel))
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addGroup(contactDetailsPanelLayout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.TRAILING)
                                                                .addComponent(MobileNumber1,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 208,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addComponent(email,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 208,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(jLabel135)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(MobileNumber2)))
                                        .addGap(5, 5, 5))
                                .addGroup(contactDetailsPanelLayout.createSequentialGroup()
                                        .addGroup(contactDetailsPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jSeparator17)
                                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                        contactDetailsPanelLayout.createSequentialGroup()
                                                                .addGap(0, 0, Short.MAX_VALUE)
                                                                .addGroup(contactDetailsPanelLayout
                                                                        .createParallelGroup(
                                                                                javax.swing.GroupLayout.Alignment.TRAILING,
                                                                                false)
                                                                        .addGroup(
                                                                                javax.swing.GroupLayout.Alignment.LEADING,
                                                                                contactDetailsPanelLayout
                                                                                        .createSequentialGroup()
                                                                                        .addComponent(
                                                                                                mMobileNumberLabel)
                                                                                        .addPreferredGap(
                                                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                                        .addComponent(
                                                                                                mMobileNumberTextField))
                                                                        .addGroup(
                                                                                javax.swing.GroupLayout.Alignment.LEADING,
                                                                                contactDetailsPanelLayout
                                                                                        .createSequentialGroup()
                                                                                        .addComponent(
                                                                                                motherNameLabel)
                                                                                        .addPreferredGap(
                                                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                                Short.MAX_VALUE)
                                                                                        .addComponent(
                                                                                                motherNameTextField,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                195,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                        .addGap(14, 14, 14)))
                                                                .addGap(10, 10, 10).addComponent(mEmailLabel)
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(mEmailTextField,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 200,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addGap(10, 10, 10))
                                                .addGroup(contactDetailsPanelLayout.createSequentialGroup()
                                                        .addGroup(contactDetailsPanelLayout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addGroup(contactDetailsPanelLayout
                                                                        .createSequentialGroup().addGap(12, 12, 12)
                                                                        .addGroup(contactDetailsPanelLayout
                                                                                .createParallelGroup(
                                                                                        javax.swing.GroupLayout.Alignment.TRAILING)
                                                                                .addComponent(jLabel1)
                                                                                .addComponent(gContactNumbersLabel))
                                                                        .addPreferredGap(
                                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                        .addGroup(contactDetailsPanelLayout
                                                                                .createParallelGroup(
                                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                                .addGroup(contactDetailsPanelLayout
                                                                                        .createSequentialGroup()
                                                                                        .addComponent(
                                                                                                gContactNumber1)
                                                                                        .addGap(252, 252, 252))
                                                                                .addComponent(jScrollPane1)))
                                                                .addGroup(contactDetailsPanelLayout
                                                                        .createSequentialGroup()
                                                                        .addComponent(emergencyContactLabel)
                                                                        .addGap(0, 0, Short.MAX_VALUE))
                                                                .addGroup(contactDetailsPanelLayout
                                                                        .createSequentialGroup().addGap(8, 8, 8)
                                                                        .addComponent(guardianNameLabel,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                78,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addPreferredGap(
                                                                                javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                                        .addComponent(guardianNameTextField,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                195,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addPreferredGap(
                                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                        .addComponent(relationToGuardianLabel)
                                                                        .addPreferredGap(
                                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                        .addComponent(relationToGuardian)))
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                5, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addContainerGap()))));
        contactDetailsPanelLayout.setVerticalGroup(contactDetailsPanelLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(contactDetailsPanelLayout.createSequentialGroup().addContainerGap()
                        .addGroup(contactDetailsPanelLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(mobileNumberLabel).addComponent(jLabel135)
                                .addComponent(MobileNumber1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(MobileNumber2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(contactDetailsPanelLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(emailLabel).addComponent(email,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jSeparator16, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(1, 1, 1)
                        .addGroup(contactDetailsPanelLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(contactDetailsPanelLayout.createSequentialGroup()
                                        .addComponent(fphoneNumberTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(fPhoneNumberLabel)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(contactDetailsPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(fMobileNumberLabel)
                                                .addComponent(fMobileNumberTextField,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(fEmailLabel).addComponent(fEmailTextField,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jSeparator17, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addGroup(contactDetailsPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(motherNameLabel).addComponent(motherNameTextField,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(26, 26, 26)
                                        .addGroup(contactDetailsPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(mMobileNumberLabel)
                                                .addComponent(mMobileNumberTextField,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(mEmailLabel).addComponent(mEmailTextField,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(18, 18, 18)
                                        .addComponent(jSeparator18, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(emergencyContactLabel)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(contactDetailsPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(guardianNameLabel)
                                                .addComponent(guardianNameTextField,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(relationToGuardianLabel).addComponent(
                                                        relationToGuardian, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(contactDetailsPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(gContactNumbersLabel).addComponent(gContactNumber1,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(contactDetailsPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel1).addComponent(jScrollPane1,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 46,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(contactDetailsPanelLayout.createSequentialGroup()
                                        .addGroup(contactDetailsPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(flandlineLabel)
                                                .addComponent(fACodeTextField,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(fatherNameTextField,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(fatherNameLabel))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(fareaCodeLabel).addGap(65, 65, 65)
                                        .addGroup(contactDetailsPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(mlandlineLabel)
                                                .addComponent(mACodeTextField,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(mphoneNumberTextField,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(contactDetailsPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(mareaCodeLabel).addComponent(mphoneNumberLabel))))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        clearButton1.setFont(new java.awt.Font("Rondalo", 0, 12)); // NOI18N
        clearButton1.setText("Clear");
        clearButton1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        clearButton1.setEnabled(false);
        clearButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearButton1ActionPerformed(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel2.setFont(new java.awt.Font("Rondalo", 0, 14)); // NOI18N
        jLabel2.setText("Reservations:");

        reservations.setFont(new java.awt.Font("Rondalo", 0, 14)); // NOI18N
        reservations.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                reservationsItemStateChanged(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Rondalo", 0, 14)); // NOI18N
        jLabel3.setText("Date Registered:");

        registrationDate.setCurrentView(new datechooser.view.appearance.AppearancesList("Light",
                new datechooser.view.appearance.ViewAppearance("custom",
                        new datechooser.view.appearance.swing.SwingCellAppearance(
                                new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11), new java.awt.Color(0, 0, 0),
                                new java.awt.Color(0, 0, 255), false, true,
                                new datechooser.view.appearance.swing.ButtonPainter()),
                        new datechooser.view.appearance.swing.SwingCellAppearance(
                                new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11), new java.awt.Color(0, 0, 0),
                                new java.awt.Color(0, 0, 255), true, true,
                                new datechooser.view.appearance.swing.ButtonPainter()),
                        new datechooser.view.appearance.swing.SwingCellAppearance(
                                new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11), new java.awt.Color(0, 0, 255),
                                new java.awt.Color(0, 0, 255), false, true,
                                new datechooser.view.appearance.swing.ButtonPainter()),
                        new datechooser.view.appearance.swing.SwingCellAppearance(
                                new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11),
                                new java.awt.Color(128, 128, 128), new java.awt.Color(0, 0, 255), false, true,
                                new datechooser.view.appearance.swing.LabelPainter()),
                        new datechooser.view.appearance.swing.SwingCellAppearance(
                                new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11), new java.awt.Color(0, 0, 0),
                                new java.awt.Color(0, 0, 255), false, true,
                                new datechooser.view.appearance.swing.LabelPainter()),
                        new datechooser.view.appearance.swing.SwingCellAppearance(
                                new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11), new java.awt.Color(0, 0, 0),
                                new java.awt.Color(255, 0, 0), false, false,
                                new datechooser.view.appearance.swing.ButtonPainter()),
                        (datechooser.view.BackRenderer) null, false, true)));
        registrationDate.setNothingAllowed(false);
        registrationDate.setFieldFont(new java.awt.Font("Rondalo", java.awt.Font.PLAIN, 14));
        registrationDate.setBehavior(datechooser.model.multiple.MultyModelBehavior.SELECT_SINGLE);

        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, false)
                                        .addComponent(jLabel3, 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))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(reservations, javax.swing.GroupLayout.PREFERRED_SIZE, 283,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(registrationDate, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel2)
                        .addComponent(reservations, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel3).addComponent(registrationDate,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(mainPanelLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(mainPanelLayout.createSequentialGroup().addContainerGap().addGroup(mainPanelLayout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(basicInfoPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(othersPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(contactDetailsPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout
                                        .createSequentialGroup().addGap(325, 325, 325)
                                        .addComponent(clearButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 79,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(saveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 79,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap()));
        mainPanelLayout
                .setVerticalGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(mainPanelLayout.createSequentialGroup().addContainerGap().addGroup(mainPanelLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(mainPanelLayout.createSequentialGroup()
                                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(basicInfoPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(othersPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(contactDetailsPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(mainPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(saveButton).addComponent(cancelButton)
                                        .addComponent(clearButton1))
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, 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()
                        .addComponent(mainPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                Short.MAX_VALUE));

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private boolean insertIntoDatabase() {
        boolean status;
        try {
            registrationDetails = new ArrayList<>();
            registrationDetails.add(roomNo);//0
            registrationDetails.add(collegeTextField.getText().trim());//1
            registrationDetails.add(courseTextField.getText().trim());//2
            registrationDetails.add(yearTextField.getText().trim());//3
            registrationDetails.add(departmentTextField.getText().trim());//4

            DateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd");
            String formattedDate = targetFormat
                    .format(birthDateChooser.getDateFormat().parse(birthDateChooser.getText()));

            registrationDetails.add(formattedDate);//5

            if (male.isSelected()) {
                registrationDetails.add("Male");//6
            } else {
                registrationDetails.add("Female");//6
            }
            registrationDetails.add(MobileNumber1.getText().trim());//7
            registrationDetails.add(MobileNumber2.getText().trim());//8
            registrationDetails.add(fatherNameTextField.getText().trim());//9
            registrationDetails.add(fACodeTextField.getText().trim() + fphoneNumberTextField.getText().trim());//10
            registrationDetails.add(fMobileNumberTextField.getText().trim());//11
            registrationDetails.add(fEmailTextField.getText().trim());//12
            registrationDetails.add(motherNameTextField.getText());//13
            registrationDetails.add(mACodeTextField.getText().trim() + mphoneNumberTextField.getText().trim());//14
            registrationDetails.add(mMobileNumberTextField.getText().trim());//15
            registrationDetails.add(mEmailTextField.getText().trim());//16
            registrationDetails.add(guardianNameTextField.getText().trim());//17
            registrationDetails.add(guardianAddress.getText().trim());//18
            registrationDetails.add(gContactNumber1.getText());//19
            registrationDetails.add(relationToGuardian.getText());//20
            registrationDetails.add(file);//21
            registrationDetails.add(reservationIdnum);//22
            byte[] cc = null;
            if (file != null) {
                File thisFile = new File(file);
                cc = Files.readAllBytes(thisFile.toPath());
            }
            if (insertRegistration(registrationDetails, cc)) {
                if (!roomNumberTextField.getSelectedItem().equals(roomNo)) {
                    if (!updateRoomStatus(roomNo.trim(), roomNumberTextField.getSelectedItem().toString().trim())
                            && !updateFurnitureTosNull()) {
                        md.warning(this, "Room Status not Updated");
                    }
                }
                insertBilling();
                md.successful(this);
                saveButton.setEnabled(false);
                status = true;
                clearAll();
            } else {
                md.unsuccessful(this);
                status = false;
            }

        } catch (ParseException | RemoteException ex) {
            status = false;
            md.error(this, ex.getMessage());
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            status = false;
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
        }
        return status;
    }

    private boolean checker() {
        boolean tester = false;
        //
        if (mobileNumber1Checker() & emailAddress1Checker() & mobileNumber2Checker() & mobileNumber3Checker()
                & emailAddress2Checker() & mobileNumber4Checker() & emailAddress3Checker() & mobileNumber5Checker()
                & yearChecker() & phoneNumber1Checker() & phoneNumber2Checker()) {
            tester = true;
        } else {
            tester = false;
        }
        return tester;
    }

    private boolean pictureChecker() {
        boolean tester = true;
        if (pictureFileNameLabel.getText().trim().equals("picture.jpg") || file == null) {
            tester = false;
        }
        return tester;
    }

    //mobile number of student
    private boolean mobileNumber1Checker() {
        String str = MobileNumber1.getText().trim();
        char[] chars = str.toCharArray();
        boolean tester = false;
        //if it is null
        if (!str.equals("")) {
            //checks if the number is alphanumeric
            for (int i = 0; i < chars.length; i++) {
                try {
                    Integer.parseInt(String.valueOf(chars[i]));
                } catch (NumberFormatException nfe) {
                    md.error(this, "Not a number");
                    MobileNumber1.setText("");
                }
            }
            //checks if the number is 11 digits.
            if (str.length() == 11) {
                tester = true;
            } else {
                md.error(this, "The mobile number must be 11 digits.");
                MobileNumber1.setText("");
            }
        }
        return tester;
    }

    //mobile number of student
    private boolean mobileNumber2Checker() {
        String str = MobileNumber2.getText().trim();
        char[] chars = str.toCharArray();
        boolean tester = true;
        //if it is null                
        if (!str.equals("")) {
            //checks if the number is alphanumeric
            for (int i = 0; i < chars.length; i++) {
                try {
                    Integer.parseInt(String.valueOf(chars[i]));
                } catch (NumberFormatException nfe) {
                    md.error(this, "Not a number");
                    MobileNumber2.setText("");
                    tester = false;
                    break;
                }
            }
            //checks if the number is 11 digits.
            if (str.length() != 11) {
                md.error(this, "The mobile number must be 11 digits.");
                MobileNumber2.setText("");
                tester = false;
            }
        }
        return tester;
    }

    //email add of the student
    private boolean emailAddress1Checker() {
        char atSymbol = '@';
        String dotCom = ".com";
        String emailAddress = email.getText().trim();
        boolean tester = true;
        //find the @ symbol
        int atpos = emailAddress.indexOf(atSymbol);
        //find the .com
        int emadd = emailAddress.indexOf(dotCom, atpos);
        //if it is null                
        if (!emailAddress.equals("")) {
            if (emadd == -1) {
                md.error(this, "Invalid email address.");
                tester = false;
            }
        }
        return tester;
    }

    //mobile number of father
    private boolean mobileNumber3Checker() {
        String str = fMobileNumberTextField.getText().trim();
        char[] chars = str.toCharArray();
        boolean tester = true;
        //if it is null                
        if (!str.equals("")) {
            //checks if the number is alphanumeric
            for (int i = 0; i < chars.length; i++) {
                try {
                    Integer.parseInt(String.valueOf(chars[i]));
                } catch (NumberFormatException nfe) {
                    md.error(this, "Not a number");
                    fMobileNumberTextField.setText("");
                    tester = false;
                    break;
                }
            }
            //checks if the number is 11 digits.
            if (str.length() != 11) {
                md.error(this, "The mobile number must be 11 digits.");
                fMobileNumberTextField.setText("");
                tester = false;
            }
        }
        return tester;
    }

    //email add of the father
    private boolean emailAddress2Checker() {
        char atSymbol = '@';
        String dotCom = ".com";
        String emailAddress = fEmailTextField.getText().trim();
        boolean tester = true;
        //find the @ symbol
        int atpos = emailAddress.indexOf(atSymbol);
        //find the .com
        int emadd = emailAddress.indexOf(dotCom, atpos);
        //if it is null                
        if (!emailAddress.equals("")) {
            if (emadd == -1) {
                md.error(this, "Invalid email address.");
                tester = false;
            }
        }
        return tester;
    }

    //mobile number of mother
    private boolean mobileNumber4Checker() {
        String str = mMobileNumberTextField.getText().trim();
        char[] chars = str.toCharArray();
        boolean tester = true;
        //if it is null                
        if (!str.equals("")) {
            //checks if the number is alphanumeric
            for (int i = 0; i < chars.length; i++) {
                try {
                    Integer.parseInt(String.valueOf(chars[i]));
                } catch (NumberFormatException nfe) {
                    md.error(this, "Not a number");
                    mMobileNumberTextField.setText("");
                    tester = false;
                    break;
                }
            }
            //checks if the number is 11 digits.
            if (str.length() != 11) {
                md.error(this, "The mobile number must be 11 digits.");
                mMobileNumberTextField.setText("");
                tester = false;
            }
        }
        return tester;
    }

    //email add of the mother
    private boolean emailAddress3Checker() {
        char atSymbol = '@';
        String dotCom = ".com";
        String emailAddress = mEmailTextField.getText().trim();
        boolean tester = true;
        //find the @ symbol
        int atpos = emailAddress.indexOf(atSymbol);
        //find the .com
        int emadd = emailAddress.indexOf(dotCom, atpos);
        //if it is null                
        if (!emailAddress.equals("")) {
            if (emadd == -1) {
                md.error(this, "Invalid email address.");
                tester = false;
            }
        }
        return tester;
    }

    //mobile number of guardian
    private boolean mobileNumber5Checker() {
        String str = gContactNumber1.getText().trim();
        char[] chars = str.toCharArray();
        boolean tester = true;
        //if it is null                
        if (!str.equals("")) {
            //checks if the number is alphanumeric
            for (int i = 0; i < chars.length; i++) {
                try {
                    Integer.parseInt(String.valueOf(chars[i]));
                } catch (NumberFormatException nfe) {
                    md.error(this, "Not a number");
                    gContactNumber1.setText("");
                    tester = false;
                    break;
                }
            }
            //checks if the number is 11 digits.
            if (str.length() != 11) {
                md.error(this, "The mobile number must be 11 digits.");
                gContactNumber1.setText("");

            }
        }
        return tester;
    }

    //year of the student
    private boolean yearChecker() {
        String str = yearTextField.getText().trim();
        char[] chars = str.toCharArray();
        boolean tester = true;
        //if it is null
        if (!str.equals("")) {
            //checks if the Year is alphanummeric
            for (int i = 0; i < chars.length; i++) {
                try {
                    Integer.parseInt(String.valueOf(chars[i]));
                } catch (NumberFormatException nfe) {
                    md.error(this, "You've entered an alphanumeric, please try again.");
                    yearTextField.setText("");
                    tester = false;
                }
            }
            //checks if the Year is 4 digits.
            if (str.length() != 1) {
                md.error(this, "The number you've enter is more than 1 digits.");
                yearTextField.setText("");

            }
        }
        return tester;
    }

    //phone number for father
    private boolean phoneNumber1Checker() {
        String str = fphoneNumberTextField.getText().trim();
        char[] chars = str.toCharArray();
        boolean tester = true;
        //if it is null
        if (!str.equals("")) {
            //checks if the phone number is alphanummeric
            for (int i = 0; i < chars.length; i++) {
                try {
                    Integer.parseInt(String.valueOf(chars[i]));
                } catch (NumberFormatException nfe) {
                    md.error(this, "You've entered an alphanumeric, please try again.");
                    fphoneNumberTextField.setText("");
                    tester = false;
                    break;
                }
            }
            //checks if the phone number is 7 digits.
            if (str.length() != 7) {
                md.error(this, "The number you've enter is more than 7 digits.");
                fphoneNumberTextField.setText("");
                tester = false;
            }
        }
        return tester;
    }

    //phone number for mother
    private boolean phoneNumber2Checker() {
        String str = mphoneNumberTextField.getText().trim();
        char[] chars = str.toCharArray();
        boolean tester = true;
        //if it is null
        if (!str.equals("")) {
            //checks if the phone number is alphanummeric
            for (int i = 0; i < chars.length; i++) {
                try {
                    Integer.parseInt(String.valueOf(chars[i]));
                } catch (NumberFormatException nfe) {
                    md.error(this, "You've entered an alphanumeric, please try again.");
                    mphoneNumberTextField.setText("");
                    tester = false;
                    break;
                }
            }
            //checks if the phone number is 7 digits.
            if (str.length() != 7) {
                md.error(this, "The number you've enter is more than 7 digits.");
                mphoneNumberTextField.setText("");
                tester = false;
            }
        }
        return tester;
    }

    private void enableClearButton() {
        // TODO add your handling code here:
        if (!collegeTextField.getText().isEmpty() || !departmentTextField.getText().isEmpty()
                || !courseTextField.getText().isEmpty() || !MobileNumber2.getText().isEmpty()
                || !fatherNameTextField.getText().isEmpty() || !fACodeTextField.getText().isEmpty()
                || !fphoneNumberTextField.getText().isEmpty() || !fMobileNumberTextField.getText().isEmpty()
                || !fEmailTextField.getText().isEmpty() || !motherNameTextField.getText().isEmpty()
                || !mACodeTextField.getText().isEmpty() || !mphoneNumberTextField.getText().isEmpty()
                || !mMobileNumberTextField.getText().isEmpty() || !mEmailTextField.getText().isEmpty()
                || !guardianNameTextField.getText().isEmpty() || !gContactNumber1.getText().isEmpty()
                || !relationToGuardian.getText().isEmpty() || !guardianAddress.getText().isEmpty()) {
            clearButton1.setEnabled(true);
        } else
            clearButton1.setEnabled(false);
    }

    private void enableButton() {
        // TODO add your handling code here:
        if ((male.isSelected() | female.isSelected()) && !lastNameTextField.getText().trim().isEmpty()
                && !firstNameTextField.getText().trim().isEmpty() && !MobileNumber1.getText().trim().isEmpty()
                && !homeAddressTextArea.getText().trim().isEmpty()
                && !guardianNameTextField.getText().trim().isEmpty()
                && !relationToGuardian.getText().trim().isEmpty() && !gContactNumber1.getText().trim().isEmpty()
                && !guardianAddress.getText().trim().isEmpty()) {
            saveButton.setEnabled(true);
        } else {
            saveButton.setEnabled(false);
        }
    }

    private void clearAll() {
        collegeTextField.setText("");
        departmentTextField.setText("");
        courseTextField.setText("");
        fatherNameTextField.setText("");
        fACodeTextField.setText("");
        fphoneNumberTextField.setText("");
        fMobileNumberTextField.setText("");
        fEmailTextField.setText("");
        MobileNumber2.setText("");
        motherNameTextField.setText("");
        mACodeTextField.setText("");
        mphoneNumberTextField.setText("");
        mMobileNumberTextField.setText("");
        mEmailTextField.setText("");
        guardianNameTextField.setText("");
        gContactNumber1.setText("");
        relationToGuardian.setText("");
        guardianAddress.setText("");
    }

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        if (md.confirmationSave(this) == md.YES) {
            if (checker()) {
                saveToPdf();
                insertIntoDatabase();
                setReservations();
            }
        }
    }//GEN-LAST:event_saveButtonActionPerformed

    private void collegeTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_collegeTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_collegeTextFieldKeyTyped

    private void departmentTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_departmentTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_departmentTextFieldKeyTyped

    private void courseTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_courseTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_courseTextFieldKeyTyped

    private void yearTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_yearTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_yearTextFieldKeyTyped

    private void fatherNameTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_fatherNameTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_fatherNameTextFieldKeyTyped

    private void fACodeTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_fACodeTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_fACodeTextFieldKeyTyped

    private void fphoneNumberTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_fphoneNumberTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_fphoneNumberTextFieldKeyTyped

    private void fMobileNumberTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_fMobileNumberTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_fMobileNumberTextFieldKeyTyped

    private void fEmailTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_fEmailTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_fEmailTextFieldKeyTyped

    private void clearButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearButton1ActionPerformed
        // TODO add your handling code here:
        clearAll();
        saveButton.setEnabled(false);
        clearButton1.setEnabled(false);
    }//GEN-LAST:event_clearButton1ActionPerformed

    private void applianceAndInventoryFormButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applianceAndInventoryFormButtonActionPerformed
        inventoryFormButton();
    }//GEN-LAST:event_applianceAndInventoryFormButtonActionPerformed

    private void inventoryFormButton() {
        // TODO add your handling code here:
        String fullName;
        String roomNumber;
        String roomTypes;
        fullName = lastNameTextField.getText().trim() + ", " + firstNameTextField.getText().trim() + " "
                + middleNameTextField.getText().charAt(0) + ".";
        roomNumber = roomNumberTextField.getSelectedItem().toString().trim();
        roomTypes = roomTypeTextField.getText().trim();
        new InventoryForm(reservationIdnum, fullName, roomNumber, roomTypes).setVisible(true);
    }

    private void uploadPictureButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uploadPictureButtonActionPerformed
        FileFilter filter = new FileNameExtensionFilter("jpg and png files", "jpg", "png");
        chooser.setFileFilter(filter);
        chooser.showOpenDialog(null);
        if (chooser.getSelectedFile() != null) {
            pictureFileNameLabel.setText(chooser.getSelectedFile().getName() + " ");
            file = chooser.getSelectedFile().toString();
        }
    }//GEN-LAST:event_uploadPictureButtonActionPerformed

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        String buttonName = cancelButton.getText();
        if (buttonName.contains("Cancel")) {
            if (md.confirmationCancel(this) == md.YES) {
                if (removeFurniture()) {
                    JOptionPane.showMessageDialog(null, "Furniture(s) update failed!", "Failed",
                            JOptionPane.ERROR_MESSAGE);
                }

                if (removeGadget()) {
                    JOptionPane.showMessageDialog(null, "Gadget(s) delete failed!", "Failed",
                            JOptionPane.ERROR_MESSAGE);
                }
                new Home().setVisible(true);
                dispose();
            }
        } else {
            if (md.confirmationBack(this) == md.YES) {
            }
        }
    }//GEN-LAST:event_cancelButtonActionPerformed

    private void MobileNumber2KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_MobileNumber2KeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_MobileNumber2KeyTyped

    private void motherNameTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_motherNameTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_motherNameTextFieldKeyTyped

    private void mACodeTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_mACodeTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_mACodeTextFieldKeyTyped

    private void mphoneNumberTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_mphoneNumberTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_mphoneNumberTextFieldKeyTyped

    private void mMobileNumberTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_mMobileNumberTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_mMobileNumberTextFieldKeyTyped

    private void mEmailTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_mEmailTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_mEmailTextFieldKeyTyped

    private void guardianNameTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_guardianNameTextFieldKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_guardianNameTextFieldKeyTyped

    private void relationToGuardianKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_relationToGuardianKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_relationToGuardianKeyTyped

    private void gContactNumber1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_gContactNumber1KeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_gContactNumber1KeyTyped

    private void guardianAddressKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_guardianAddressKeyTyped
        // TODO add your handling code here:
        enableClearButton();
        enableButton();
    }//GEN-LAST:event_guardianAddressKeyTyped

    private void maleMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_maleMouseClicked
        enableButton();
    }//GEN-LAST:event_maleMouseClicked

    private void femaleMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_femaleMouseClicked
        enableButton();
    }//GEN-LAST:event_femaleMouseClicked

    private void reservationsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_reservationsItemStateChanged
        try {
            if (reservations.getItemCount() > 0) {
                // TODO add your handling code here:
                reservationIdnum = null;
                roomNo = null;
                PreparedStatement preparedStatement = connection.prepareStatement(
                        "SELECT * FROM reservation WHERE CONCAT(reservationLname,', ',reservationFname) LIKE ?");
                preparedStatement.setString(1, reservations.getSelectedItem().toString());
                ResultSet rs = preparedStatement.executeQuery();
                while (rs.next()) {
                    reservationIdnum = rs.getString("reservationIdnum");
                    roomNo = rs.getString("roomIdnum");
                    lastNameTextField.setText(rs.getString("reservationLname"));
                    firstNameTextField.setText(rs.getString("reservationFname"));
                    middleNameTextField.setText(rs.getString("reservationMname"));
                    MobileNumber1.setText(rs.getString("reservationMobileNo"));
                    homeAddressTextArea.setText(rs.getString("reservationHomeaddress"));
                    email.setText(rs.getString("reservationEmail"));
                }
                if (roomNo != null) {
                    preparedStatement = connection
                            .prepareStatement("SELECT roomNumber, roomType FROM room WHERE roomIdnum = ?");
                    preparedStatement.setInt(1, Integer.parseInt(roomNo));
                    rs = preparedStatement.executeQuery();
                    boolean b = true;
                    String roomNum = "";
                    while (rs.next()) {
                        roomNum = rs.getString("roomNumber");
                        roomNumberTextField.addItem(roomNum);
                        roomNumberTextField.setSelectedItem(roomNum);
                        for (int i = 0; i < roomNumberTextField.getItemCount(); i++) {
                            if (roomNumberTextField.getItemAt(i).equals(roomNum)) {
                                b = false;
                            }
                        }
                    }
                    if (b) {
                        roomNumberTextField.setSelectedItem(roomNum);
                    }
                }
            }
        } catch (SQLException ex) {
            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        }

    }//GEN-LAST:event_reservationsItemStateChanged

    private void roomNumberTextFieldItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_roomNumberTextFieldItemStateChanged
        try {
            // TODO add your handling code here:
            PreparedStatement preparedStatement = connection
                    .prepareStatement("SELECT roomType FROM room WHERE roomNumber LIKE ?");
            preparedStatement.setString(1, roomNumberTextField.getSelectedItem().toString().trim());
            ResultSet rs = preparedStatement.executeQuery();
            while (rs.next()) {
                roomTypeTextField.setText(type(rs.getString("roomType").trim()));
            }
        } catch (SQLException ex) {
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        }
    }//GEN-LAST:event_roomNumberTextFieldItemStateChanged

    private void saveToPdf() {
        try {
            String gend = "";
            Document doc = new Document();
            BufferedReader br = new BufferedReader(new FileReader("dir\\defaults.txt"));
            String path = "";
            try {
                StringBuilder sb = new StringBuilder();
                String line = br.readLine();

                while (line != null) {
                    sb.append(line);
                    sb.append(System.lineSeparator());
                    line = br.readLine();
                }
                path = sb.toString().trim();
            } finally {
                br.close();
            }
            FileOutputStream fos = new FileOutputStream(
                    path + "\\registration\\" + lastNameTextField.getText().trim() + ", "
                            + firstNameTextField.getText().trim() + "RegistrationResidentForm.pdf");
            PdfWriter pdfWriter = PdfWriter.getInstance(doc, fos);

            PdfReader pdfReader = new PdfReader("RegistrationResidentForm.pdf");

            PdfStamper pdfStamper = new PdfStamper(pdfReader, fos);

            for (int i = 1; i <= pdfReader.getNumberOfPages(); i++) {
                PdfContentByte content = pdfStamper.getOverContent(i);

                byte[] cc = null;
                if (file != null) {
                    File thisFile = new File(file);
                    cc = Files.readAllBytes(thisFile.toPath());
                }
                if (cc != null) {
                    Image image1 = Image.getInstance(cc);
                    image1.scaleAbsolute(95, 105);
                    image1.setAbsolutePosition(465f, 635f);
                    content.addImage(image1);
                }

                //Text over the existing page
                BaseFont bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.WINANSI, BaseFont.EMBEDDED);
                content.beginText();
                content.setFontAndSize(bf, 10);
                //last name
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, lastNameTextField.getText().trim(), 175, 610, 0);
                //first name
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, firstNameTextField.getText().trim(), 325, 610,
                        0);
                //middle name
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, middleNameTextField.getText().trim(), 470, 610,
                        0);
                //college
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, collegeTextField.getText().trim(), 180, 582, 0);
                //Course and year
                content.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        courseTextField.getText().trim() + " - " + yearTextField.getText().trim(), 180, 568, 0);
                //department
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, departmentTextField.getText().trim(), 400, 582,
                        0);
                String g;
                if (male.isSelected()) {
                    g = "Male";//6
                } else {
                    g = "Female";//6
                }
                //Sex
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, g, 400, 568, 0);
                //Home address
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, homeAddressTextArea.getText(), 110, 540, 0);
                //resident mobile no1
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, MobileNumber1.getText().trim(), 187, 485, 0);
                //resident mobile no2
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, MobileNumber2.getText().trim(), 187, 470, 0);
                //student email
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, email.getText().trim(), 397, 485, 0);
                //fathers name
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, fatherNameTextField.getText().trim(), 110, 443,
                        0);
                //fathers area code
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, fACodeTextField.getText().trim(), 300, 443, 0);
                //father landline
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, fphoneNumberTextField.getText().trim(), 355, 443,
                        0);
                //father mobile
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, fMobileNumberTextField.getText().trim(), 490,
                        443, 0);
                //father email
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, fEmailTextField.getText().trim(), 110, 430, 0);
                //mother name
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, motherNameTextField.getText().trim(), 110, 402,
                        0);
                //mother area code
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, mACodeTextField.getText().trim(), 300, 402, 0);
                //mother landline
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, mphoneNumberTextField.getText().trim(), 355, 402,
                        0);
                //mother mobile
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, mMobileNumberTextField.getText().trim(), 490,
                        402, 0);
                //mother email
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, mEmailTextField.getText().trim(), 110, 387, 0);
                //guardian name
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, guardianNameTextField.getText().trim(), 170, 335,
                        0);
                //guardian contact number
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, gContactNumber1.getText().trim(), 470, 335, 0);
                //guardian address
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, guardianAddress.getText().trim(), 125, 322, 0);
                //guardian relation
                content.showTextAligned(PdfContentByte.ALIGN_LEFT, relationToGuardian.getText().trim(), 170, 307,
                        0);
                content.setFontAndSize(bf, 12);
                //room details
                content.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Room No.: " + roomNumberTextField.getSelectedItem().toString().trim() + " - "
                                + roomTypeTextField.getText().trim(),
                        355, 235, 0);
                content.endText();

            }
            pdfStamper.close();
            pdfReader.close();
            fos.close();
            pdfWriter.close();
        } catch (DocumentException ex) {
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        } catch (FileNotFoundException ex) {
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        } catch (IOException ex) {
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        }
    }

    private void setReservations() {
        try {
            Statement statement = connection.createStatement();
            ResultSet rs = statement.executeQuery(
                    "SELECT CONCAT(reservationLname,', ',reservationFname) AS names FROM reservation WHERE reservationStatus LIKE 'Pending'");
            reservations.removeAllItems();
            while (rs.next()) {
                reservations.addItem(rs.getString("names"));
            }

            if (reservations.getItemCount() <= 0) {
                dispose();
                new Home().setVisible(true);
            }
        } catch (SQLException ex) {
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        }

    }

    private boolean insertRegistration(ArrayList<String> registrationDetails, byte[] pic) {
        try {
            String roomId = "";
            String id = "";
            PreparedStatement preparedStatement = connection
                    .prepareStatement("SELECT `roomIdnum` FROM room WHERE roomNumber = ?");
            preparedStatement.setInt(1, Integer.parseInt(registrationDetails.get(0).trim()));
            ResultSet resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                roomId = resultSet.getString("roomIdnum");
            }
            resultSet = preparedStatement.executeQuery("SELECT * FROM registration");
            int c1 = 0;
            while (resultSet.next()) {
                c1++;
            }

            preparedStatement = connection.prepareStatement(
                    " insert into registration (registrationResidentCollege, registrationResidentCourse,"
                            + " registrationResidentYear, registrationResidentDept, registrationResidentBirthdate, registrationResidentGender,"
                            + " registrationResidentMobileNo, registrationResidentMobileNo2, registrationFatherName, registrationFatherLandline,"
                            + " registrationFatherMobileNo, registrationFatherEmail, registrationMotherName, registrationMotherLandline, "
                            + "registrationMotherMobileNo, registrationMotherEmail, registrationGuardianName, registrationGuardianAddress,"
                            + "registrationGuardianMobileNo, registrationGuardianRelation, registrationPicture, "
                            + "registrationStatus, reservationIdnum, roomIdnum, registrationDate)"
                            + " values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");

            if (registrationDetails.get(1).length() != 0) {
                preparedStatement.setString(1, registrationDetails.get(1));
            } else {
                preparedStatement.setNull(1, Types.VARCHAR);
            }
            if (registrationDetails.get(2).length() != 0) {
                preparedStatement.setString(2, registrationDetails.get(2));
            } else {
                preparedStatement.setNull(2, Types.VARCHAR);
            }
            if (registrationDetails.get(3).length() != 0) {
                preparedStatement.setString(3, registrationDetails.get(3));
            } else {
                preparedStatement.setNull(3, Types.VARCHAR);
            }
            if (registrationDetails.get(4).length() != 0) {
                preparedStatement.setString(4, registrationDetails.get(4));
            } else {
                preparedStatement.setNull(4, Types.VARCHAR);
            }

            DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            java.util.Date utilDate = df.parse(registrationDetails.get(5));
            java.sql.Date sDate = new java.sql.Date(utilDate.getTime());

            preparedStatement.setDate(5, sDate);
            if (registrationDetails.get(6).length() != 0) {
                preparedStatement.setString(6, registrationDetails.get(6));
            } else {
                preparedStatement.setNull(6, Types.VARCHAR);
            }
            if (registrationDetails.get(7).length() != 0) {
                preparedStatement.setString(7, registrationDetails.get(7));
            } else {
                preparedStatement.setNull(7, Types.VARCHAR);
            }
            if (registrationDetails.get(8).length() != 0) {
                preparedStatement.setString(8, registrationDetails.get(8));
            } else {
                preparedStatement.setNull(8, Types.VARCHAR);
            }
            if (registrationDetails.get(9).length() != 0) {
                preparedStatement.setString(9, registrationDetails.get(9));
            } else {
                preparedStatement.setNull(9, Types.VARCHAR);
            }
            if (registrationDetails.get(10).length() != 0) {
                preparedStatement.setString(10, registrationDetails.get(10));
            } else {
                preparedStatement.setNull(10, Types.VARCHAR);
            }
            if (registrationDetails.get(11).length() != 0) {
                preparedStatement.setString(11, registrationDetails.get(11));
            } else {
                preparedStatement.setNull(11, Types.VARCHAR);
            }
            if (registrationDetails.get(12).length() != 0) {
                preparedStatement.setString(12, registrationDetails.get(12));
            } else {
                preparedStatement.setNull(12, Types.VARCHAR);
            }
            if (registrationDetails.get(13).length() != 0) {
                preparedStatement.setString(13, registrationDetails.get(13));
            } else {
                preparedStatement.setNull(13, Types.VARCHAR);
            }
            if (registrationDetails.get(14).length() != 0) {
                preparedStatement.setString(14, registrationDetails.get(14));
            } else {
                preparedStatement.setNull(14, Types.VARCHAR);
            }
            if (registrationDetails.get(15).length() != 0) {
                preparedStatement.setString(15, registrationDetails.get(15));
            } else {
                preparedStatement.setNull(15, Types.VARCHAR);
            }
            if (registrationDetails.get(16).length() != 0) {
                preparedStatement.setString(16, registrationDetails.get(16));
            } else {
                preparedStatement.setNull(16, Types.VARCHAR);
            }
            if (registrationDetails.get(17).length() != 0) {
                preparedStatement.setString(17, registrationDetails.get(17));
            } else {
                preparedStatement.setNull(17, Types.VARCHAR);
            }
            if (registrationDetails.get(18).length() != 0) {
                preparedStatement.setString(18, registrationDetails.get(18));
            } else {
                preparedStatement.setNull(18, Types.VARCHAR);
            }
            if (registrationDetails.get(19).length() != 0) {
                preparedStatement.setString(19, registrationDetails.get(19));
            } else {
                preparedStatement.setNull(19, Types.VARCHAR);
            }
            if (registrationDetails.get(20).length() != 0) {
                preparedStatement.setString(20, registrationDetails.get(20));
            } else {
                preparedStatement.setNull(20, Types.VARCHAR);
            }

            Blob blobContainer = connection.createBlob();
            if (pic != null) {
                blobContainer.setBytes(1, pic);
                preparedStatement.setBlob(21, blobContainer);
            } else {
                preparedStatement.setNull(21, Types.BLOB);
            }

            preparedStatement.setString(22, "Not Active");
            id = registrationDetails.get(22);
            preparedStatement.setString(23, id);
            preparedStatement.setInt(24, Integer.parseInt(registrationDetails.get(0).trim()));

            utilDate = df.parse(df.format(registrationDate.getDateFormat().parse(registrationDate.getText())));
            sDate = new java.sql.Date(utilDate.getTime());

            preparedStatement.setDate(25, sDate);
            preparedStatement.execute();

            resultSet = preparedStatement.executeQuery("SELECT * FROM registration");
            int c2 = 0;
            while (resultSet.next()) {
                c2++;
            }
            if (c1 == (c2 - 1)) {
                preparedStatement = connection.prepareStatement(
                        "UPDATE reservation set reservationStatus = 'Registered' where reservationIdnum = ?");
                preparedStatement.setInt(1, Integer.parseInt(registrationDetails.get(22).trim()));
                preparedStatement.executeUpdate();
            } else {
                return false;
            }

            resultSet = preparedStatement.executeQuery("SELECT * FROM resident");
            int c3 = 0;
            while (resultSet.next()) {
                c3++;
            }

            preparedStatement = connection
                    .prepareStatement("SELECT `reservationLname`, `reservationFname`, `reservationMname`, "
                            + "`registrationResidentGender`, `reservationZipCode`, `registrationResidentMobileNo`,"
                            + "`reservationEmail`, `registrationResidentBirthdate`, `reservationHomeaddress`,"
                            + "`registrationPicture`, `registrationIdnum`, `roomIdnum` "
                            + "FROM registration NATURAL JOIN reservation WHERE reservationIdnum = ?");
            preparedStatement.setInt(1, Integer.parseInt(registrationDetails.get(22).trim()));
            resultSet = preparedStatement.executeQuery();

            String lname = "";
            String fname = "";
            while (resultSet.next()) {
                preparedStatement = connection.prepareStatement(
                        "INSERT INTO resident(residentLname, residentFname, residentMname, residentGender,"
                                + "residentZipCode, residentMobileNo, residentEmail, residentBirthdate,"
                                + "residentHomeAddress, picture, status, registrationIdnum, roomIdnum) "
                                + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
                preparedStatement.setString(1, resultSet.getString("reservationLname"));
                lname = resultSet.getString("reservationLname");
                preparedStatement.setString(2, resultSet.getString("reservationFname"));
                fname = resultSet.getString("reservationFname");
                preparedStatement.setString(3, resultSet.getString("reservationMname"));
                preparedStatement.setString(4, resultSet.getString("registrationResidentGender"));
                if (resultSet.getString("reservationZipCode") != null) {
                    preparedStatement.setString(5, resultSet.getString("reservationZipCode"));
                } else {
                    preparedStatement.setNull(5, Types.VARCHAR);
                }
                if (resultSet.getString("registrationResidentMobileNo") != null) {
                    preparedStatement.setString(6, resultSet.getString("registrationResidentMobileNo"));
                } else {
                    preparedStatement.setNull(6, Types.VARCHAR);
                }
                if (resultSet.getString("reservationEmail") != null) {
                    preparedStatement.setString(7, resultSet.getString("reservationEmail"));
                } else {
                    preparedStatement.setNull(7, Types.VARCHAR);
                }
                if (resultSet.getString("registrationResidentBirthdate") != null) {
                    preparedStatement.setString(8, resultSet.getString("registrationResidentBirthdate"));
                } else {
                    preparedStatement.setNull(8, Types.VARCHAR);
                }
                if (resultSet.getString("reservationHomeaddress") != null) {
                    preparedStatement.setString(9, resultSet.getString("reservationHomeaddress"));
                } else {
                    preparedStatement.setNull(9, Types.VARCHAR);
                }
                if (resultSet.getBlob("registrationPicture") != null) {
                    preparedStatement.setBlob(10, resultSet.getBlob("registrationPicture"));
                } else {
                    preparedStatement.setNull(10, Types.BLOB);
                }

                preparedStatement.setString(11, "Not Active");
                preparedStatement.setString(12, resultSet.getString("registrationIdnum"));
                preparedStatement.setString(13, resultSet.getString("roomIdnum"));
                preparedStatement.execute();
            }
            int registrationId = 0;
            preparedStatement = connection.prepareStatement(
                    "SELECT `registrationIdnum` FROM registration NATURAL JOIN reservation WHERE reservationIdnum = ?");
            preparedStatement.setInt(1, Integer.parseInt(id.trim()));
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                registrationId = resultSet.getInt("registrationIdnum");
            }
            int residentId = 0;
            preparedStatement = connection
                    .prepareStatement("SELECT `residentIdnum` FROM resident WHERE registrationIdnum = ?");
            preparedStatement.setInt(1, registrationId);
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                residentId = resultSet.getInt("residentIdnum");
            }
            preparedStatement = connection
                    .prepareStatement("SELECT * FROM furniture WHERE residentIdnum = '99999999'");
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                preparedStatement = connection.prepareStatement(
                        "UPDATE furniture SET furnitureStatus = 'Taken' WHERE residentIdnum = '99999999'");
                preparedStatement.executeUpdate();
                preparedStatement = connection.prepareStatement(
                        "UPDATE furniture SET residentIdnum = ? WHERE residentIdnum = '99999999'");
                preparedStatement.setInt(1, residentId);
                preparedStatement.executeUpdate();
            }

            preparedStatement = connection
                    .prepareStatement("SELECT * FROM gadget WHERE residentIdnum = '99999999'");
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                preparedStatement = connection
                        .prepareStatement("UPDATE gadget SET residentIdnum = ? WHERE residentIdnum = '99999999'");
                preparedStatement.setInt(1, residentId);
                preparedStatement.executeUpdate();
            }

            resultSet = preparedStatement.executeQuery("SELECT * FROM registration");
            int c4 = 0;
            while (resultSet.next()) {
                c4++;
            }
            if (c3 == (c4 - 1)) {
                preparedStatement = connection.prepareStatement(
                        "SELECT * FROM resident WHERE residentLname LIKE ? AND residentFname LIKE ?");
                preparedStatement.setString(1, lname);
                preparedStatement.setString(2, fname);
                resultSet = preparedStatement.executeQuery();
                int c = 0;
                while (resultSet.next()) {
                    c++;
                }
                if (c == 0) {
                    return false;
                }
            }
        } catch (SQLException | ParseException ex) {
            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
            return false;
        }
        return true;
    }

    private boolean removeFurniture() {
        boolean status = false;
        try {
            PreparedStatement preparedStatement = connection.prepareStatement(
                    "UPDATE furniture SET residentIdnum = ?, transientIdnum = ?, furnitureStatus = 'Available' "
                            + "WHERE residentIdnum = '99999999' OR transientIdnum = '99999999'");
            preparedStatement.setNull(1, Types.INTEGER);
            preparedStatement.setNull(2, Types.INTEGER);
            status = preparedStatement.execute();
        } catch (SQLException ex) {
            status = false;
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        }
        return status;
    }

    private boolean removeGadget() {
        boolean status = false;
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement("DELETE FROM gadget WHERE residentIdnum = '99999999'");
            status = preparedStatement.execute();
        } catch (SQLException ex) {
            status = false;
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        }
        return status;
    }

    private void setRooms() {
        try {
            PreparedStatement preparedStatement = connection.prepareStatement("SELECT roomNumber FROM room WHERE "
                    + "(roomStatus LIKE 'unoccupied' OR roomStatus LIKE 'partially occupied') AND roomType NOT LIKE 'SU'");
            ResultSet rs = preparedStatement.executeQuery();
            roomNumberTextField.removeAllItems();
            while (rs.next()) {
                roomNumberTextField.addItem(rs.getString("roomNumber"));
            }
        } catch (SQLException ex) {
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        }
    }

    private String type(String type) {
        switch (type) {
        case "S":
            return "Single Room";
        case "D":
            return "Double Sharing Room";
        case "T":
            return "Triple Sharing Room";
        default:
            return "Master Suite";
        }
    }

    private boolean insertBilling() {
        boolean status = true;
        try {
            int c = 0;
            PreparedStatement preparedStatement;
            ResultSet resultSet;
            preparedStatement = connection.prepareStatement("SELECT * FROM billing");
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                c++;
            }

            preparedStatement = connection
                    .prepareStatement("INSERT INTO billing (billingDatePaid, billingDateIn, billingDateOut, "
                            + "billingRateType, billingNoofDays, billingRoomrate, billingShuttleRatetype, "
                            + "billingShuttleRate, billingGadgetRate, billingRemarks, residentIdnum, "
                            + "roomIdnum, billingTotalAmount, billingBalance, billingTotalRoomrate, "
                            + "billingTotalShuttlerate, billingTotalGadgetrate, billingAdditionalfee, billingStatus) "
                            + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
            preparedStatement.setString(1, new SimpleDateFormat("yyyy-MM-dd")
                    .format(registrationDate.getDateFormat().parse(registrationDate.getText()))); // 0
            Calendar cal = Calendar.getInstance();
            cal.setTime(registrationDate.getDateFormat().parse(registrationDate.getText()));
            cal.add(Calendar.DATE, -1);
            preparedStatement.setString(2, new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()));

            preparedStatement.setString(3, new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime())); // 2
            preparedStatement.setString(4, "Daily"); // 3
            preparedStatement.setInt(5, 1); // 4

            double roomRate = 0.0;
            switch (roomTypeTextField.getText()) {
            case "Triple-Sharing Room":
                roomRate = getRoomRate("Triple-Sharing Room");
                break;
            case "Double-Sharing Room":
                roomRate = getRoomRate("Double-Sharing Room");
                break;
            case "Single Room":
                roomRate = getRoomRate("Single Room");
                break;
            default:
                roomRate = getRoomRate("Single Room");
            }

            preparedStatement.setDouble(6, roomRate); // 5
            preparedStatement.setNull(7, Types.VARCHAR); // 6
            preparedStatement.setNull(8, Types.VARCHAR); // 7

            String residentId = getResidentId(
                    lastNameTextField.getText().trim() + ", " + firstNameTextField.getText().trim());
            String roomId = getRoomIdFromResidentId(residentId.trim());

            preparedStatement.setString(9, "0.00"); // 8
            preparedStatement.setNull(10, Types.VARCHAR); // 9
            preparedStatement.setString(11, residentId); // 10
            preparedStatement.setString(12, roomId); // 11
            preparedStatement.setString(13, roomRate + "");// 12
            preparedStatement.setString(14, "0.00"); // 13
            preparedStatement.setString(15, roomRate + ""); // 14
            preparedStatement.setString(16, "0.00"); // 15
            preparedStatement.setString(17, "0.00"); // 16
            preparedStatement.setString(18, "0.00"); // 17
            preparedStatement.setString(19, "Paid"); // 17

            preparedStatement.execute();
            int c1 = 0;
            preparedStatement = connection.prepareStatement("SELECT * FROM billing");
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                c1++;
            }
            if (c != (c1 - 1)) {
                status = false;
            }
        } catch (SQLException ex) {
            status = false;
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        } catch (ParseException ex) {
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        }
        return status;
    }

    private String getResidentId(String name) {
        String id = "";
        try {
            String[] ResidentName = name.split(",");
            PreparedStatement preparedStatement = connection.prepareStatement(
                    "SELECT residentIdnum FROM resident WHERE residentLname LIKE ? AND residentFname LIKE ?");
            preparedStatement.setString(1, ResidentName[0].trim());
            preparedStatement.setString(2, ResidentName[1].trim());
            ResultSet resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                id = resultSet.getString("residentIdnum");
            }
        } catch (SQLException ex) {
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        }
        return id;
    }

    private double getRoomRate(String roomType) {
        double rate = 0.0;
        try {
            PreparedStatement preparedStatement;
            ResultSet resultSet;
            switch (roomType) {
            case "Single Room":
                preparedStatement = connection.prepareStatement("SELECT `rentRoomSingleSharing`  FROM rate");
                resultSet = preparedStatement.executeQuery();
                while (resultSet.next()) {
                    rate = resultSet.getDouble("rentRoomSingleSharing");
                }
                break;

            case "Double-Sharing Room":
                preparedStatement = connection.prepareStatement("SELECT `rentRoomDoubleSharing`  FROM rate");
                resultSet = preparedStatement.executeQuery();
                while (resultSet.next()) {
                    rate = resultSet.getDouble("rentRoomDoubleSharing");
                }
                break;

            case "Triple-Sharing Room":
                preparedStatement = connection.prepareStatement("SELECT `rentRoomTripleSharing`  FROM rate");
                resultSet = preparedStatement.executeQuery();
                while (resultSet.next()) {
                    rate = resultSet.getDouble("rentRoomTripleSharing");
                }
                break;

            default:
                preparedStatement = connection.prepareStatement("SELECT `rentRoomMasterSuite`  FROM rate");
                resultSet = preparedStatement.executeQuery();
                while (resultSet.next()) {
                    rate = resultSet.getDouble("rentRoomMasterSuite");
                }
                break;
            }
        } catch (SQLException ex) {
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        }
        return rate;
    }

    private String getRoomIdFromResidentId(String residentId) {
        String id = "";
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement("SELECT `roomIdnum` FROM resident WHERE residentIdnum = ?");
            preparedStatement.setInt(1, Integer.parseInt(residentId.trim()));
            ResultSet resultSet = preparedStatement.executeQuery();

            while (resultSet.next()) {
                id = resultSet.getString("roomIdnum");
            }
        } catch (SQLException ex) {
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        }
        return id;
    }

    private boolean updateRoomStatus(String oldRomm, String newRoom) {

        try {
            //update old room
            String roomId = null;
            String query = "UPDATE room SET roomStatus = 'unoccupied' WHERE roomIdnum = ?";
            PreparedStatement preparedStatement = connection
                    .prepareStatement("SELECT roomIdnum FROM room WHERE roomNumber LIKE ?");
            preparedStatement.setString(1, oldRomm.trim());
            ResultSet resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                roomId = resultSet.getString("roomIdnum").trim();
            }
            int count = 0;
            preparedStatement = connection.prepareStatement("SELECT " + "(SELECT DISTINCT COUNT(reservationIdnum) "
                    + "FROM  room  JOIN reservation ON room.roomIdnum = reservation.roomIdnum "
                    + "WHERE room.roomIdnum = ? AND reservationStatus = 'Pending') + "
                    + "(SELECT DISTINCT COUNT(residentIdnum) "
                    + "FROM  room  JOIN resident ON room.roomIdnum = resident.roomIdnum "
                    + "WHERE room.roomIdnum = ?) AS count");
            preparedStatement.setString(1, roomId);
            preparedStatement.setString(2, roomId);
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                count = resultSet.getInt("count");
            }

            preparedStatement = connection.prepareStatement("SELECT * FROM room " + "WHERE roomIdnum = ?");
            preparedStatement.setString(1, roomId);
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                switch (resultSet.getString("roomType")) {
                case "S":
                    switch (count) {
                    case 1:
                        query = "UPDATE room set roomStatus = 'fully occupied' WHERE roomIdnum = ?";
                        break;

                    default:
                        query = "UPDATE room set roomStatus = 'unoccupied' WHERE roomIdnum = ?";
                        break;
                    }
                    break;

                case "D":
                    switch (count) {
                    case 2:
                        query = "UPDATE room set roomStatus = 'fully occupied' WHERE roomIdnum = ?";
                        break;

                    case 1:
                        query = "UPDATE room set roomStatus = 'partially occupied' WHERE roomIdnum = ?";
                        break;

                    default:
                        query = "UPDATE room set roomStatus = 'unoccupied' WHERE roomIdnum = ?";
                        break;
                    }
                    break;

                case "T":
                    switch (count) {
                    case 3:
                        query = "UPDATE room set roomStatus = 'fully occupied' WHERE roomIdnum = ?";
                        break;

                    case 1:
                    case 2:
                        query = "UPDATE room set roomStatus = 'partially occupied' WHERE roomIdnum = ?";
                        break;

                    default:
                        query = "UPDATE room set roomStatus = 'unoccupied' WHERE roomIdnum = ?";
                        break;
                    }
                    break;
                }
                preparedStatement = connection.prepareStatement(query);
                preparedStatement.setString(1, roomId);
                preparedStatement.executeUpdate();
            }

            //update new room
            preparedStatement = connection.prepareStatement("SELECT roomIdnum FROM room WHERE roomNumber LIKE ?");
            preparedStatement.setString(1, newRoom.trim());
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                roomId = resultSet.getString("roomIdnum").trim();
            }
            count = 0;
            preparedStatement = connection.prepareStatement("SELECT " + "(SELECT DISTINCT COUNT(reservationIdnum) "
                    + "FROM  room  JOIN reservation ON room.roomIdnum = reservation.roomIdnum "
                    + "WHERE room.roomIdnum = ? AND reservationStatus = 'Pending') + "
                    + "(SELECT DISTINCT COUNT(residentIdnum) "
                    + "FROM  room  JOIN resident ON room.roomIdnum = resident.roomIdnum "
                    + "WHERE room.roomIdnum = ?) AS count");
            preparedStatement.setString(1, roomId);
            preparedStatement.setString(2, roomId);
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                count = resultSet.getInt("count");
            }
            preparedStatement = connection.prepareStatement("SELECT * FROM room " + "WHERE roomIdnum = ?");
            preparedStatement.setString(1, roomId);
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                switch (resultSet.getString("roomType")) {
                case "S":
                    switch (count) {
                    case 1:
                        query = "UPDATE room set roomStatus = 'fully occupied' WHERE roomIdnum = ?";
                        break;
                    default:
                        query = "UPDATE room set roomStatus = 'unoccupied' WHERE roomIdnum = ?";
                        break;
                    }
                    break;

                case "D":
                    switch (count) {
                    case 2:
                        query = "UPDATE room set roomStatus = 'fully occupied' WHERE roomIdnum = ?";
                        break;

                    case 1:
                        query = "UPDATE room set roomStatus = 'partially occupied' WHERE roomIdnum = ?";
                        break;

                    default:
                        query = "UPDATE room set roomStatus = 'unoccupied' WHERE roomIdnum = ?";
                        break;
                    }
                    break;

                case "T":
                    switch (count) {
                    case 3:
                        query = "UPDATE room set roomStatus = 'fully occupied' WHERE roomIdnum = ?";
                        break;
                    case 1:
                    case 2:
                        query = "UPDATE room set roomStatus = 'partially occupied' WHERE roomIdnum = ?";
                        break;

                    default:
                        query = "UPDATE room set roomStatus = 'unoccupied' WHERE roomIdnum = ?";
                        break;
                    }
                    break;
                }
                preparedStatement = connection.prepareStatement(query);
                preparedStatement.setString(1, roomId);
                preparedStatement.executeUpdate();
            }
        } catch (SQLException ex) {
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
            return false;
        }
        return true;
    }

    private boolean updateFurnitureTosNull() {
        boolean status = false;
        try {
            PreparedStatement preparedStatement = connection.prepareStatement(
                    "UPDATE furniture SET residentIdnum = ?, furnitureStatus = 'Available' WHERE residentIdnum = ?");
            preparedStatement.setNull(1, Types.INTEGER);
            preparedStatement.setInt(2, Integer.parseInt("99999999"));
            status = !preparedStatement.execute();

        } catch (SQLException ex) {
            status = false;
            //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
            new MessageDialog().error(this, ex.getMessage());
        }
        return status;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Registration_Tenant.class.getName())
                    .log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Registration_Tenant.class.getName())
                    .log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Registration_Tenant.class.getName())
                    .log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Registration_Tenant.class.getName())
                    .log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Registration_Tenant().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField MobileNumber1;
    private javax.swing.JTextField MobileNumber2;
    private javax.swing.JButton applianceAndInventoryFormButton;
    private javax.swing.JPanel basicInfoPanel;
    private datechooser.beans.DateChooserCombo birthDateChooser;
    private javax.swing.JLabel birthDateLabel;
    private javax.swing.JButton cancelButton;
    private javax.swing.JButton clearButton1;
    private javax.swing.JLabel collegeLabel;
    private javax.swing.JTextField collegeTextField;
    private javax.swing.JPanel contactDetailsPanel;
    private javax.swing.JLabel courseLabel;
    private javax.swing.JTextField courseTextField;
    private javax.swing.JLabel departmentLabel;
    private javax.swing.JTextField departmentTextField;
    private javax.swing.JTextField email;
    private javax.swing.JLabel emailLabel;
    private javax.swing.JLabel emergencyContactLabel;
    private javax.swing.JTextField fACodeTextField;
    private javax.swing.JLabel fEmailLabel;
    private javax.swing.JTextField fEmailTextField;
    private javax.swing.JLabel fMobileNumberLabel;
    private javax.swing.JTextField fMobileNumberTextField;
    private javax.swing.JLabel fPhoneNumberLabel;
    private javax.swing.JLabel fareaCodeLabel;
    private javax.swing.JLabel fatherNameLabel;
    private javax.swing.JTextField fatherNameTextField;
    private javax.swing.JRadioButton female;
    private javax.swing.JLabel firstNameLabel;
    private javax.swing.JTextField firstNameTextField;
    private javax.swing.JLabel flandlineLabel;
    private javax.swing.JTextField fphoneNumberTextField;
    private javax.swing.JTextField gContactNumber1;
    private javax.swing.JLabel gContactNumbersLabel;
    private javax.swing.ButtonGroup gender;
    private javax.swing.JLabel genderLabel;
    private javax.swing.JTextArea guardianAddress;
    private javax.swing.JLabel guardianNameLabel;
    private javax.swing.JTextField guardianNameTextField;
    private javax.swing.JLabel homeAddressLabel;
    private javax.swing.JTextArea homeAddressTextArea;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel135;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JSeparator jSeparator16;
    private javax.swing.JSeparator jSeparator17;
    private javax.swing.JSeparator jSeparator18;
    private javax.swing.JLabel lastNameLabel;
    private javax.swing.JTextField lastNameTextField;
    private javax.swing.JTextField mACodeTextField;
    private javax.swing.JLabel mEmailLabel;
    private javax.swing.JTextField mEmailTextField;
    private javax.swing.JLabel mMobileNumberLabel;
    private javax.swing.JTextField mMobileNumberTextField;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JRadioButton male;
    private javax.swing.JLabel mareaCodeLabel;
    private javax.swing.JLabel middleNameLabel;
    private javax.swing.JTextField middleNameTextField;
    private javax.swing.JLabel mlandlineLabel;
    private javax.swing.JLabel mobileNumberLabel;
    private javax.swing.JLabel motherNameLabel;
    private javax.swing.JTextField motherNameTextField;
    private javax.swing.JLabel mphoneNumberLabel;
    private javax.swing.JTextField mphoneNumberTextField;
    private javax.swing.JLabel nameLabel;
    private javax.swing.ButtonGroup occupation;
    private javax.swing.JPanel othersPanel;
    private javax.swing.JLabel pictureFileNameLabel;
    private datechooser.beans.DateChooserCombo registrationDate;
    private javax.swing.JTextField relationToGuardian;
    private javax.swing.JLabel relationToGuardianLabel;
    private javax.swing.JComboBox reservations;
    private javax.swing.JLabel roomNumberLabel;
    private javax.swing.JComboBox roomNumberTextField;
    private javax.swing.JLabel roomTypeLabel;
    private javax.swing.JTextField roomTypeTextField;
    private javax.swing.JButton saveButton;
    private javax.swing.JButton uploadPictureButton;
    private javax.swing.JLabel yearLabel;
    private javax.swing.JTextField yearTextField;
    // End of variables declaration//GEN-END:variables
    private javax.swing.JFileChooser chooser = new javax.swing.JFileChooser();

}