Results 1 to 16 of 16
  1. #1
    RickAintree is offline Member
    Join Date
    Dec 2010
    Posts
    22
    Rep Power
    0

    Default SQL not runnings after if statement

    //Set Names to Proper Case
    txtFname.setText(pc.toProperCase(txtFname.getText( )));
    txtMname.setText(pc.toProperCase(txtMname.getText( )));
    txtLname.setText(pc.toProperCase(txtLname.getText( )));
    txtAdd1.setText(pc.toProperCase(txtAdd1.getText()) );
    txtAdd2.setText(pc.toProperCase(txtAdd2.getText()) );
    //Validate Fields
    //Save Data////////////////////////////////////////////////////////////

    if ((validateNRN(txtNRN.getText())) & (validateNIS(txtNIS.getText()) )
    & (validateFname(txtFname.getText())) & (validateMname(txtMname.getText()))
    & (validateLname(txtLname.getText())) & (validateAdd1(txtAdd1.getText()))
    & (validateAdd2(txtAdd2.getText())) & (validateEmail(txtEmail.getText()))
    & (verifyEmailAdd(txtEmail.getText())) & (validatePnum(txtHnumber.getText()))
    & (validateHdate(txtHdate.getText())) ){
    //SQL INSERT statements using stringbuffer
    try {
    StringBuffer SQLQuery = new StringBuffer();
    SQLQuery.append("INSERT INTO EmployeeDetails (NRN,NIS,FirstName,MiddleName,LastName,MaritalStat us,Address1,Address2,Parish,Email,HomeNumber,CellN umber,HiredDate,JobTitle) VALUES (");
    SQLQuery.append(txtNRN.getText().replaceAll("-", ""));
    SQLQuery.append(",");
    SQLQuery.append(txtNIS.getText());
    SQLQuery.append(",'");
    SQLQuery.append(txtFname.getText().toString());
    SQLQuery.append("','");
    SQLQuery.append(txtMname.getText().toString());
    SQLQuery.append("','");
    SQLQuery.append(txtLname.getText().toString());
    SQLQuery.append("','");
    SQLQuery.append(cboMaritalStatusLnk.getSelectedIte m().toString());
    SQLQuery.append("','");
    SQLQuery.append(txtAdd1.getText().toString());
    SQLQuery.append("','");
    SQLQuery.append(txtAdd2.getText().toString());
    SQLQuery.append("','");
    SQLQuery.append(cboParishLnk.getSelectedItem().toS tring());
    SQLQuery.append("','");
    SQLQuery.append(txtEmail.getText().toString());
    SQLQuery.append("',");
    SQLQuery.append(txtHnumber.getText().replaceAll("-", ""));
    SQLQuery.append(",");
    SQLQuery.append(txtCnumber.getText().replaceAll("-", ""));
    SQLQuery.append(",'");
    SQLQuery.append(txtHdate.getText().toString());
    SQLQuery.append("','");
    SQLQuery.append(cboJtitleLnk.getSelectedItem().toS tring());
    SQLQuery.append("');");
    //Transmit data to database
    System.out.println(SQLQuery);

    dataconnect.querySQLINSERT(SQLQuery.toString());

    }catch(SQLException sqle){
    this.dispose();
    }
    }

    else{

    JOptionPane.showMessageDialog(opnErrorMessage,errM sg);
    errMsg.delete(0, errMsg.length());

    }

  2. #2
    RickAintree is offline Member
    Join Date
    Dec 2010
    Posts
    22
    Rep Power
    0

    Default

    A blank message box is coming up after the fields have passed validation, while it is suppose to save the data to the database. can someone help me.

  3. #3
    RickAintree is offline Member
    Join Date
    Dec 2010
    Posts
    22
    Rep Power
    0

    Default

    If the validation returns false an error message is stored in a string buffer which will be outputted if and error was found in any of the fields

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    Can you post that code in code tags?
    There's a # button that'll do it.

    That aside, I would bet that your concatenation of strings for your query is causing an error. Since you don't log any possible SQLExceptions thrown you are not seeing that problem. You should at the very least do a printStackTrace() on the exception.

    As for the INSERT, use a PreparedStatement. Do not do this sort of thing via string concatenation.

  5. #5
    RickAintree is offline Member
    Join Date
    Dec 2010
    Posts
    22
    Rep Power
    0

    Default The code is running, trying to settext of either Cont.Num to 0000000 but not wrking

    //Set Names to Proper Case
    txtFname.setText(pc.toProperCase(txtFname.getText( )));
    txtMname.setText(pc.toProperCase(txtMname.getText( )));
    txtLname.setText(pc.toProperCase(txtLname.getText( )));
    txtAdd1.setText(pc.toProperCase(txtAdd1.getText()) );
    txtAdd2.setText(pc.toProperCase(txtAdd2.getText()) );
    //Validate Fields
    //Save Data////////////////////////////////////////////////////////////
    if ((validateNRN(txtNRN.getText())) & (validateNIS(txtNIS.getText()) )
    || (validateFname(txtFname.getText())) & (validateMname(txtMname.getText()))
    || (validateLname(txtLname.getText())) & (validateAdd1(txtAdd1.getText()))
    || (validateAdd2(txtAdd2.getText())) & (validateEmail(txtEmail.getText()))
    || (verifyEmailAdd(txtEmail.getText())) & (validatePnum(txtHnumber.getText()))
    || (validateHdate(txtHdate.getText())) ){



    try {
    StringBuffer SQLQuery = new StringBuffer();
    SQLQuery.append("INSERT INTO EmployeeDetails (NRN,NIS,FirstName,MiddleName,LastName,MaritalStat us,Address1,Address2,Parish,Email,HomeNumber,CellN umber,HiredDate,JobTitle) VALUES (");
    SQLQuery.append(txtNRN.getText().replaceAll("-", ""));
    SQLQuery.append(",");
    SQLQuery.append(txtNIS.getText());
    SQLQuery.append(",'");
    SQLQuery.append(txtFname.getText().toString());
    SQLQuery.append("','");
    SQLQuery.append(txtMname.getText().toString());
    SQLQuery.append("','");
    SQLQuery.append(txtLname.getText().toString());
    SQLQuery.append("','");
    SQLQuery.append(cboMaritalStatusLnk.getSelectedIte m().toString());
    SQLQuery.append("','");
    SQLQuery.append(txtAdd1.getText().toString());
    SQLQuery.append("','");
    SQLQuery.append(txtAdd2.getText().toString());
    SQLQuery.append("','");
    SQLQuery.append(cboParishLnk.getSelectedItem().toS tring());
    SQLQuery.append("','");
    SQLQuery.append(txtEmail.getText().toString());
    SQLQuery.append("',");
    SQLQuery.append(txtHnumber.getText().replaceAll("-", ""));
    SQLQuery.append(",");
    SQLQuery.append(txtCnumber.getText().replaceAll("-", ""));
    SQLQuery.append(",'");
    SQLQuery.append(txtHdate.getText().toString());
    SQLQuery.append("','");
    SQLQuery.append(cboJtitleLnk.getSelectedItem().toS tring());
    SQLQuery.append("');");
    //Transmit data to database
    System.out.println(SQLQuery);
    dataconnect.querySQLINSERT(SQLQuery.toString());
    }catch(SQLException sqle){
    this.dispose();
    }
    }

    else{

    JOptionPane.showMessageDialog(opnErrorMessage,errM sg);
    errMsg.delete(0, errMsg.length());

    }

  6. #6
    RickAintree is offline Member
    Join Date
    Dec 2010
    Posts
    22
    Rep Power
    0

    Default

    I am a newbie at java im just trying to do a simple employee record system to rediscover my programming skills. i am at the point that when i have to code if either the h number or the c number is empty setText to 0000000 so it would enter in the database. but so far its not setting it. maybe i was thinking because im using a formattedtextfield

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    Quote Originally Posted by RickAintree View Post
    Java Code:
    //Set Names to Proper Case
          txtFname.setText(pc.toProperCase(txtFname.getText()));
          txtMname.setText(pc.toProperCase(txtMname.getText()));
          txtLname.setText(pc.toProperCase(txtLname.getText()));
          txtAdd1.setText(pc.toProperCase(txtAdd1.getText()));
          txtAdd2.setText(pc.toProperCase(txtAdd2.getText()));
          //Validate Fields
          //Save Data////////////////////////////////////////////////////////////
         if ((validateNRN(txtNRN.getText())) & (validateNIS(txtNIS.getText()) )
              || (validateFname(txtFname.getText())) & (validateMname(txtMname.getText()))
              || (validateLname(txtLname.getText())) & (validateAdd1(txtAdd1.getText()))
              || (validateAdd2(txtAdd2.getText())) & (validateEmail(txtEmail.getText()))
              || (verifyEmailAdd(txtEmail.getText())) & (validatePnum(txtHnumber.getText()))
              || (validateHdate(txtHdate.getText())) ){
    
           
             
            try {
                    StringBuffer SQLQuery = new StringBuffer();
                    SQLQuery.append("INSERT INTO EmployeeDetails (NRN,NIS,FirstName,MiddleName,LastName,MaritalStatus,Address1,Address2,Parish,Email,HomeNumber,CellNumber,HiredDate,JobTitle) VALUES (");
                    SQLQuery.append(txtNRN.getText().replaceAll("-", ""));
                    SQLQuery.append(",");
                    SQLQuery.append(txtNIS.getText());
                    SQLQuery.append(",'");
                    SQLQuery.append(txtFname.getText().toString());
                    SQLQuery.append("','");
                    SQLQuery.append(txtMname.getText().toString());
                    SQLQuery.append("','");
                    SQLQuery.append(txtLname.getText().toString());
                    SQLQuery.append("','");
                    SQLQuery.append(cboMaritalStatusLnk.getSelectedItem().toString());
                    SQLQuery.append("','");
                    SQLQuery.append(txtAdd1.getText().toString());
                    SQLQuery.append("','");
                    SQLQuery.append(txtAdd2.getText().toString());
                    SQLQuery.append("','");
                    SQLQuery.append(cboParishLnk.getSelectedItem().toString());
                    SQLQuery.append("','");
                    SQLQuery.append(txtEmail.getText().toString());
                    SQLQuery.append("',");
                    SQLQuery.append(txtHnumber.getText().replaceAll("-", ""));
                    SQLQuery.append(",");
                    SQLQuery.append(txtCnumber.getText().replaceAll("-", ""));
                    SQLQuery.append(",'");
                    SQLQuery.append(txtHdate.getText().toString());
                    SQLQuery.append("','");
                    SQLQuery.append(cboJtitleLnk.getSelectedItem().toString());
                    SQLQuery.append("');");               
                    //Transmit data to database
                    System.out.println(SQLQuery);
                    dataconnect.querySQLINSERT(SQLQuery.toString());
            }catch(SQLException sqle){
                   this.dispose();
                                     }
                                                      }
    
        else{
    
              JOptionPane.showMessageDialog(opnErrorMessage,errMsg);
              errMsg.delete(0, errMsg.length());
    
            }
    Sorry, I should have said "highlight the code and then click the # button"...:)

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    Anyway, first off change the catch block to:
    Java Code:
    catch(SQLException sqle){
        sqle.printStackTrace();
        this.dispose();
    }
    This will tell you if there's an exception coming, and what the exception is, along with where it was thrown. This is very important information.

    Next, I would really suggest reading up on JDBC, and PreparedStatements in particular. I expect a sizeable chunk of your problem is that string concatenation.

  9. #9
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    well, maybe its not even getting to the sql statement, because one or more of the input fields are not valid. what if you did some kind of validate each field and append to error message list as you go, and then if no error messgages, do the sql insert.

    Java Code:
    List<String> errorMessages = new ArrayList<String>();
    
    if (!validateNRN(txtNRN.getText())) {
      errorMessages.add("invalid NRN");
    }
    
    if (!validateNIS(txtNIS.getText()) ) {
      errorMessages.add("invalid NIS");
    }
    
    if (!validateFname(txtFname.getText())) {
      errorMessages.add("invlaid first name");
    }
    if (validateMname(txtMname.getText())) {
      errorMessages.add("invalid middle name");
    }
    
    if (!validateLname(txtLname.getText())) {
      errorMessages.add("invalid last name");
    }
    
    
    if (!validateAdd1(txtAdd1.getText())) {
      errorMessages.add("invalud address1");
    }
    
    if (!validateAdd2(txtAdd2.getText())) {
      errorMessages.add("invalid address2");
    }
    
    if (!verifyEmailAdd(txtEmail.getText())) {
      errorMessages.add("invalid email");
    }
    
    if (!validatePnum(txtHnumber.getText())) {
      errorMessages.add("invalid hnumber");
    }
    
    if (!validateHdate(txtHdate.getText())) {
      errorMessages.add("invalid hdate");
    }
    
    if (errorMessages.size() > 0) {
      for (String message: errorMessages) {
        System.err.printn(message); 
      }
      // or show some alert here.
    }
    else {
     ..// that mess about building the sql query string instead of using prepared statements like you should be using.
    }

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    For some reason I thought the OP knew it had got as far as building the SQL, but now I look at it it's quite possible you're correct.

    Now to wait and see if they use your code to try and debug their problem.

  11. #11
    RickAintree is offline Member
    Join Date
    Dec 2010
    Posts
    22
    Rep Power
    0

    Default

    Thanks a lot i will try implementing it asap

  12. #12
    RickAintree is offline Member
    Join Date
    Dec 2010
    Posts
    22
    Rep Power
    0

    Default These are the validations. i thought u might find this useful

    Java Code:
    //Verify Email Address
     private boolean verifyEmailMatch() {
            if (new String(txtEmail.getText()).equals(new String(txtEmailVer.getText())) == true) {
                return true;
            } else {
                return false;
            }
        }
     //Validate Name
         public static boolean validateName(String strName) {
            return strName.matches("[a-zA-z]+([ '-][a-zA-Z]+)*");
        }
    //Validate Address
         public static boolean validateAddress(String strName) {
            return  strName.matches("[A-Za-z0-9# '-\\./\"]+[A-Za-z0-9# '-\\./\"]");
    
        }
    //Validate Email Address
         public static boolean verifyEmail(String strName) {
            return strName.matches("[A-Za-z0-9#!$_\\.-]+.[A-Za-z0-9#!$_\\.-]*+@[A-Za-z0-9]*+.[A-Za-z0-9]*");
        }
    
         public  boolean validateEmail (String emailFields){
              //Validate Email
         if (txtEmail.getText().isEmpty() == false & verifyEmail(txtEmail.getText()) == false) {
            errMsg.append ("\nV3 - Invalid Email, ");
            
            
        } return false;
         }
    
          public  boolean verifyEmailAdd (String emailFields){
          if (verifyEmailMatch() == false){
              
            errMsg.append ("\nEU4 The Emails you typed do not match");
            txtEmail.setBackground(Color.PINK);
            txtEmailVer.setBackground(Color.PINK);
            return false;
          }
          else {
              txtEmail.setBackground(Color.WHITE);
              txtEmailVer.setBackground(Color.WHITE);
              return true;
          }
    
         }
         public  boolean validateFname (String FnameField){
          //Validate Names
          //First Name______________________________________
          if (txtFname.getText().equals("")) {
    
            errMsg.append ("\nV4 - Enter First Name");
            txtFname.setBackground(Color.PINK);
              return false;
        }
        else if (txtFname.getText().length() == 1){
            errMsg.append ("\nV1 - First Name must be greater than 1 character");
              txtFname.setBackground(Color.PINK);
              return false;
        }
       else  if  (validateName(txtFname.getText()) == false){
            errMsg.append("\nV7 - Invalid Character in First Name");
              txtFname.setBackground(Color.PINK);
              return false;
        }
        else {
              txtFname.setBackground(Color.WHITE);
              return true;
        }
         }
         public  boolean validateMname (String MnameField){
        //Middle Name______________________________________
    
        if (txtMname.getText().length() == 1){
            errMsg.append ("\nV1 - Middle Name must be greater than 1 character");
              txtMname.setBackground(Color.PINK);
              return false;
        }
         else if  (txtMname.getText().isEmpty() == false & validateName(txtMname.getText()) == false){
            errMsg.append ("\nV7 - Invalid Character in Middle Name");
            txtMname.setBackground(Color.PINK);
              return false;
        }
         else
              txtMname.setBackground(Color.WHITE);
              return true;
        
         }
         public  boolean validateLname (String LnameField){
        //Last Name________________________________________
          if (txtLname.getText().equals("") ) {
            errMsg.append ("\nV4 - Enter Last Name");
            txtLname.setBackground(Color.PINK);
              return false;
             }
        else if (txtLname.getText().length() == 1){
            errMsg.append("\nV1 - Last Name must be greater than 1 character");
            txtLname.setBackground(Color.PINK);
              return false;
        }
         else if  (validateName(txtLname.getText()) == false){
            errMsg.append("\nV7 - Invalid Character in Last Name");
            txtLname.setBackground(Color.PINK);
              return false;
        }
        else {
              txtLname.setBackground(Color.WHITE);
        }return true;
         }
         public  boolean validateNRN (String nrnField){
        //Validate NRN
        if (txtNRN.getText().equals("      -    ")){
           errMsg.append ("V4 - Enter NRN");
           txtNRN.setBackground(Color.PINK);
           return false;
        }
          else if (txtNRN.getText().length() < 10){
            errMsg.append ("V2 - NRN out of range");
            txtNRN.setBackground(Color.PINK);
            return false;
        }
          else if (verifyNRNuniqueness(txtNRN.getText().replaceAll("-", "")) == false ){
    
              errMsg.append ("IO4 - NRN already exist");
              txtNRN.setBackground(Color.PINK);
            return false;
    
          }
          else {
                txtNRN.setBackground(Color.WHITE);
              return true;
          }
         }
         public  boolean validateNIS (String nisField){
        //Validate NIS
          if (txtNIS.getText().equals("      ")){
           errMsg.append ("\nV4 - Enter NIS");
           txtNIS.setBackground(Color.PINK);
           return false;
        }
          else if (txtNIS.getText().length() < 6){
            errMsg.append("\nV2 - NIS out of range");
            txtNIS.setBackground(Color.PINK);
            return false;
        }
          else if (verifyNISuniqueness(txtNIS.getText().replaceAll("-", "")) == false ){
    
              errMsg.append ("\nIO4 - NIS already exist");
              txtNIS.setBackground(Color.PINK);
            return false;
          }
          else {
              txtNIS.setBackground(Color.WHITE);
              return true;
          }
         }
         public  boolean validateAdd1 (String add1Field){
        //Validate Addresses
        //Address Line 1
        if (txtAdd1.getText().equals("")){
             errMsg.append ("\nV4 - Enter Address Line 1");
              txtAdd1.setBackground(Color.PINK);
              return false;
        }
        else if (validateAddress(txtAdd1.getText()) == false) {
            errMsg.append ("\nV7 - Invalid Character in Address Line 1");
            txtAdd1.setBackground(Color.PINK);
            return false;
        }
        else {
              txtAdd1.setBackground(Color.WHITE);
              return true;
        }
         }
         public  boolean validateAdd2 (String add2Field){
        //Address Line 2
        if (txtAdd2.getText().equals("")){
             errMsg.append ("\nV4 - Enter Address Line 2");
              txtAdd2.setBackground(Color.PINK);
              return false;
        }
              else if (validateAddress(txtAdd2.getText()) == false) {
            errMsg.append("\nV7 - Invalid Character in Address Line 2");
            txtAdd2.setBackground(Color.PINK);
            return false;
        }
        else {
              txtAdd2.setBackground(Color.WHITE);
              return true;
        }
         }
         public  boolean validatePnum (String hNumField){
         //Validate Phone Numbers
        if (txtHnumber.getText().equals("   -    ") & txtCnumber.getText().equals("   -    ")){
            errMsg.append ("\nV4 - Enter Contact Number");
            txtHnumber.setBackground(Color.PINK);
            txtCnumber.setBackground(Color.PINK);
            return false;
        }
        
        else {
            
            txtHnumber.setBackground(Color.WHITE);
            txtCnumber.setBackground(Color.WHITE);
            
            return true;
        }
    
                
            
    
         }
         public  boolean validateHdate (String hDateField){
        //Validate Hired Date
         if (txtHdate.getText().equals("    /  /  ")){
             errMsg.append ("\nV4 - Enter Hired Date");
            txtHdate.setBackground(Color.PINK);
            return false;
         }
         else {
            txtHdate.setBackground(Color.WHITE);
            return true;
         }
        
        }
    private boolean verifyNRNuniqueness(String strNRN) {
            try {
                dataconnect.openSQLSELECT("SELECT COUNT(*) AS Amount FROM EmployeeDetails WHERE NRN = " + strNRN.replaceAll("-", "") + "");
                if (dataconnect.rs.next()) {
                    if (dataconnect.rs.getInt("Amount") == 0) {
                        dataconnect.closeSQLSELECT();
                        return true;
                    }
                }
                dataconnect.closeSQLSELECT();
            } catch (SQLException sqle) {
    
            } catch (NullPointerException npe) {
    
            }
            
            return false;
        }
    private boolean verifyNISuniqueness(String strNIS) {
            try {
                dataconnect.openSQLSELECT("SELECT COUNT(*) AS Amount FROM EmployeeDetails WHERE NIS = " + strNIS.replaceAll("-", "") + "");
                if (dataconnect.rs.next()) {
                    if (dataconnect.rs.getInt("Amount") == 0) {
                        dataconnect.closeSQLSELECT();
                        return true;
                    }
                }
                dataconnect.closeSQLSELECT();
            } catch (SQLException sqle) {
    
            } catch (NullPointerException npe) {
    
            }
    
            return false;
        }

  13. #13
    RickAintree is offline Member
    Join Date
    Dec 2010
    Posts
    22
    Rep Power
    0

    Default

    They are error message standards i have to follow so they have to be that way

  14. #14
    RickAintree is offline Member
    Join Date
    Dec 2010
    Posts
    22
    Rep Power
    0

    Default this is the entire add module. copy and paste n try u will see how its running

    Java Code:
    import java.awt.Color;
    import java.awt.event.ItemListener;
    import java.io.PrintWriter;
    import java.io.StringWriter;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import java.util.regex.Pattern;
    import javax.swing.JOptionPane;
    
    public class FrmAddEmp extends javax.swing.JFrame {
    
        /** Creates new form addModule */
        public FrmAddEmp() {
            initComponents();
            txtNRN.requestFocusInWindow();
            errMsg.delete(0, errMsg.length());
        }
    
    
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
    
            opnErrorMessage = new javax.swing.JDialog();
            headingPanel = new javax.swing.JPanel();
            sepPDI = new javax.swing.JSeparator();
            lblPDIheading = new javax.swing.JLabel();
            empNRNlabel = new javax.swing.JLabel();
            empNISlabel = new javax.swing.JLabel();
            empFnameLabel = new javax.swing.JLabel();
            empMnameLabel = new javax.swing.JLabel();
            empLnameLabel = new javax.swing.JLabel();
            empMaritalStatusLabel = new javax.swing.JLabel();
            empAdd1Label = new javax.swing.JLabel();
            empAdd2Label = new javax.swing.JLabel();
            empParishLabel = new javax.swing.JLabel();
            lblEmail = new javax.swing.JLabel();
            lblHnumber = new javax.swing.JLabel();
            lblHdate = new javax.swing.JLabel();
            txtEmail = new javax.swing.JTextField();
            cmdClear = new javax.swing.JButton();
            cmdCancel = new javax.swing.JButton();
            cmdEmerContact = new javax.swing.JButton();
            lblJtitle = new javax.swing.JLabel();
            cboParish = new javax.swing.JComboBox();
            cboJtitle = new javax.swing.JComboBox();
            cmdSave = new javax.swing.JButton();
            txtNRN = new javax.swing.JFormattedTextField();
            txtNIS = new javax.swing.JFormattedTextField();
            txtHnumber = new javax.swing.JFormattedTextField();
            txtCnumber = new javax.swing.JFormattedTextField();
            txtHdate = new javax.swing.JFormattedTextField();
            lblCnumber = new javax.swing.JLabel();
            txtFname = new javax.swing.JFormattedTextField();
            txtMname = new javax.swing.JFormattedTextField();
            txtLname = new javax.swing.JFormattedTextField();
            txtAdd1 = new javax.swing.JFormattedTextField();
            txtAdd2 = new javax.swing.JFormattedTextField();
            cboMaritalStatusLnk = new javax.swing.JComboBox();
            lblMnameTip = new javax.swing.JLabel();
            lblAsterich1 = new javax.swing.JLabel();
            lblAsterich2 = new javax.swing.JLabel();
            lblNBtip = new javax.swing.JLabel();
            cboJtitleLnk = new javax.swing.JComboBox();
            cboMaritalStatus = new javax.swing.JComboBox();
            cboParishLnk = new javax.swing.JComboBox();
            txtEmailVer = new javax.swing.JTextField();
            lblEmailVer = new javax.swing.JLabel();
            lblEmpAdd = new javax.swing.JLabel();
            sepEmpAdd = new javax.swing.JSeparator();
            sepEmpPersInfo = new javax.swing.JSeparator();
            lblEmpPersInfo = new javax.swing.JLabel();
            sepEmpContInfo = new javax.swing.JSeparator();
            lblEmpContInfo = new javax.swing.JLabel();
            sepEmpEmployInfo = new javax.swing.JSeparator();
            lblEmpEmployInfo = new javax.swing.JLabel();
            lblEmailTip = new javax.swing.JLabel();
            lblNRNtip = new javax.swing.JLabel();
            lblNIStip = new javax.swing.JLabel();
            lblHdateFormat = new javax.swing.JLabel();
            mnuBar = new javax.swing.JMenuBar();
    
            javax.swing.GroupLayout opnErrorMessageLayout = new javax.swing.GroupLayout(opnErrorMessage.getContentPane());
            opnErrorMessage.getContentPane().setLayout(opnErrorMessageLayout);
            opnErrorMessageLayout.setHorizontalGroup(
                opnErrorMessageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 400, Short.MAX_VALUE)
            );
            opnErrorMessageLayout.setVerticalGroup(
                opnErrorMessageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 300, Short.MAX_VALUE)
            );
    
            setTitle("Prosoft Development Inc Employee Details System");
            setBackground(new java.awt.Color(0, 70, 213));
    
            sepPDI.setForeground(new java.awt.Color(0, 70, 213));
    
            lblPDIheading.setFont(new java.awt.Font("Times New Roman", 1, 24));
            lblPDIheading.setForeground(new java.awt.Color(0, 70, 213));
            lblPDIheading.setText("New Employee");
    
            javax.swing.GroupLayout headingPanelLayout = new javax.swing.GroupLayout(headingPanel);
            headingPanel.setLayout(headingPanelLayout);
            headingPanelLayout.setHorizontalGroup(
                headingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(headingPanelLayout.createSequentialGroup()
                    .addGroup(headingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(headingPanelLayout.createSequentialGroup()
                            .addGap(165, 165, 165)
                            .addComponent(sepPDI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(headingPanelLayout.createSequentialGroup()
                            .addGap(305, 305, 305)
                            .addComponent(lblPDIheading)))
                    .addContainerGap(357, Short.MAX_VALUE))
            );
            headingPanelLayout.setVerticalGroup(
                headingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(headingPanelLayout.createSequentialGroup()
                    .addGap(6, 6, 6)
                    .addComponent(lblPDIheading)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(sepPDI, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            );
    
            empNRNlabel.setText("Nat. Reg. #:");
    
            empNISlabel.setText("NIS:");
    
            empFnameLabel.setText("First Name:");
    
            empMnameLabel.setText("Middle Name:");
    
            empLnameLabel.setText("Last Name:");
    
            empMaritalStatusLabel.setText("Marital Status:");
    
            empAdd1Label.setText("Address 1:");
    
            empAdd2Label.setText("Address 2:");
    
            empParishLabel.setText("Parish:");
    
            lblEmail.setText("Email:");
    
            lblHnumber.setText("Tel # H:");
    
            lblHdate.setText("Hired Date:");
    
            txtEmail.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    txtEmailActionPerformed(evt);
                }
            });
    
            cmdClear.setText("Clear");
            cmdClear.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseReleased(java.awt.event.MouseEvent evt) {
                    cmdClearMouseReleased(evt);
                }
            });
            cmdClear.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    cmdClearActionPerformed(evt);
                }
            });
    
            cmdCancel.setText("Cancel");
            cmdCancel.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseReleased(java.awt.event.MouseEvent evt) {
                    cmdCancelMouseReleased(evt);
                }
            });
            cmdCancel.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    cmdCancelActionPerformed(evt);
                }
            });
    
            cmdEmerContact.setText("Add Emergency Contact Info.");
    
            lblJtitle.setText("Job Title:");
    
            cboParish.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "St.Michael", "Christ Church", "St.Andrew", "St.George", "St.James", "St.John", "St.Joseph", "St.Lucy", "St.Peter", "St.Philip", "St.Thomas" }));
            cboParish.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    cboParishActionPerformed(evt);
                }
            });
    
            cboJtitle.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Manager", "Administrative Specialist", "Computer Programmer", "Junior Computer Programmer", "Technician", "Junior Technician", "System Analyst", "Network Administrator", "IT Specialist" }));
            cboJtitle.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    cboJtitlejComboBox1ActionPerformed(evt);
                }
            });
    
            cmdSave.setText("Save");
            cmdSave.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseReleased(java.awt.event.MouseEvent evt) {
                    cmdSaveMouseReleased(evt);
                }
            });
            cmdSave.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    cmdSaveActionPerformed(evt);
                }
            });
    
            try {
                txtNRN.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("######-####")));
            } catch (java.text.ParseException ex) {
                ex.printStackTrace();
            }
            txtNRN.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    txtNRNActionPerformed(evt);
                }
            });
            txtNRN.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    focusLostNRN(evt);
                }
            });
    
            try {
                txtNIS.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("######")));
            } catch (java.text.ParseException ex) {
                ex.printStackTrace();
            }
    
            try {
                txtHnumber.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###-####")));
            } catch (java.text.ParseException ex) {
                ex.printStackTrace();
            }
    
            try {
                txtCnumber.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###-####")));
            } catch (java.text.ParseException ex) {
                ex.printStackTrace();
            }
    
            try {
                txtHdate.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####/##/##")));
            } catch (java.text.ParseException ex) {
                ex.printStackTrace();
            }
            txtHdate.setToolTipText("yyyy/mm/dd");
    
            lblCnumber.setText("Tel # C:");
    
            txtFname.setMaximumSize(new java.awt.Dimension(30, 30));
            txtFname.setMinimumSize(new java.awt.Dimension(3, 3));
            txtFname.addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusLost(java.awt.event.FocusEvent evt) {
                    validateFnameHnd(evt);
                }
            });
    
            txtMname.setMaximumSize(new java.awt.Dimension(30, 30));
            txtMname.setMinimumSize(new java.awt.Dimension(3, 3));
    
            txtLname.setMaximumSize(new java.awt.Dimension(30, 30));
            txtLname.setMinimumSize(new java.awt.Dimension(3, 3));
    
            cboMaritalStatusLnk.setVisible(false);
            cboMaritalStatusLnk.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "M", "D", "S" }));
            cboMaritalStatusLnk.setToolTipText("");
            cboMaritalStatusLnk.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    cboMaritalStatusLnkActionPerformed(evt);
                }
            });
    
            lblMnameTip.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblMnameTip.setText("(Optional Field)");
    
            lblAsterich1.setForeground(new java.awt.Color(255, 0, 0));
            lblAsterich1.setText("*");
    
            lblAsterich2.setForeground(new java.awt.Color(255, 0, 0));
            lblAsterich2.setText("*");
    
            lblNBtip.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblNBtip.setForeground(new java.awt.Color(255, 0, 0));
            lblNBtip.setText("NB* At lease one contact number must be entered");
    
            cboJtitleLnk.setVisible(false);
            cboJtitleLnk.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09" }));
            cboJtitleLnk.setFocusable(false);
            cboJtitleLnk.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    cboJtitleLnkActionPerformed(evt);
                }
            });
    
            cboMaritalStatus.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Married", "Divorced", "Single" }));
            cboMaritalStatus.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    cboMaritalStatusActionPerformed(evt);
                }
            });
    
            cboParishLnk.setVisible(false);
            cboParishLnk.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "M", "X", "A", "G", "S", "J", "O", "L", "E", "P", "T" }));
    
            lblEmailVer.setText("ReType Email:");
    
            lblEmpAdd.setFont(new java.awt.Font("Tahoma", 1, 14));
            lblEmpAdd.setForeground(new java.awt.Color(0, 51, 255));
            lblEmpAdd.setText("Employee Address");
    
            lblEmpPersInfo.setFont(new java.awt.Font("Tahoma", 1, 14));
            lblEmpPersInfo.setForeground(new java.awt.Color(0, 51, 255));
            lblEmpPersInfo.setText("Employee Personal Information");
    
            lblEmpContInfo.setFont(new java.awt.Font("Tahoma", 1, 14));
            lblEmpContInfo.setForeground(new java.awt.Color(0, 51, 255));
            lblEmpContInfo.setText("Employee Contact Information");
    
            lblEmpEmployInfo.setFont(new java.awt.Font("Tahoma", 1, 14));
            lblEmpEmployInfo.setForeground(new java.awt.Color(0, 51, 255));
            lblEmpEmployInfo.setText("Employee Employment Information");
    
            lblEmailTip.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblEmailTip.setText("(Optional Field)");
    
            lblNRNtip.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblNRNtip.setText("(Must be 10 Characters)");
    
            lblNIStip.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblNIStip.setText("(Must be 6 Characters)");
    
            lblHdateFormat.setText("(yyyy/mm/dd)");
    
            mnuBar.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N
            setJMenuBar(mnuBar);
    
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(headingPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(lblNBtip)
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(empMaritalStatusLabel)
                                        .addComponent(empFnameLabel)
                                        .addComponent(empMnameLabel)
                                        .addComponent(empLnameLabel)
                                        .addComponent(empNRNlabel)
                                        .addComponent(empNISlabel))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(txtNRN, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(lblNRNtip))
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(txtNIS, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(lblNIStip))
                                        .addGroup(layout.createSequentialGroup()
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                .addComponent(txtLname, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(txtMname, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(txtFname, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(lblMnameTip))
                                        .addGroup(layout.createSequentialGroup()
                                            .addGap(1, 1, 1)
                                            .addComponent(cboMaritalStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(18, 18, 18)
                                            .addComponent(cboMaritalStatusLnk, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addComponent(lblEmpAdd)
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(empAdd2Label)
                                        .addComponent(empAdd1Label)
                                        .addComponent(empParishLabel))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(cboParish, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(cboParishLnk, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addComponent(txtAdd2, javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(txtAdd1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addComponent(sepEmpPersInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblEmpPersInfo)
                                .addComponent(sepEmpAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 123, Short.MAX_VALUE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(lblJtitle)
                                        .addComponent(lblHdate))
                                    .addGap(25, 25, 25)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(txtHdate, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(lblHdateFormat))
                                        .addComponent(cboJtitleLnk, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(cboJtitle, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addGroup(layout.createSequentialGroup()
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                    .addComponent(lblEmail)
                                                    .addComponent(lblEmailVer))
                                                .addGroup(layout.createSequentialGroup()
                                                    .addGap(1, 1, 1)
                                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                        .addComponent(lblHnumber)
                                                        .addComponent(lblCnumber))))
                                            .addGap(25, 25, 25)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(txtEmailVer, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)
                                                .addGroup(layout.createSequentialGroup()
                                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                        .addComponent(txtCnumber, javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(txtHnumber, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(lblAsterich2)
                                                        .addComponent(lblAsterich1)))
                                                .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(sepEmpContInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblEmpContInfo)))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(lblEmailTip))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(cmdClear)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(cmdCancel)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(cmdSave)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(cmdEmerContact))
                                .addComponent(lblEmpEmployInfo)
                                .addComponent(sepEmpEmployInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, 18))))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(headingPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(30, 30, 30)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(lblEmpPersInfo)
                            .addGap(18, 18, 18)
                            .addComponent(sepEmpPersInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(empNRNlabel)
                                .addComponent(txtNRN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblNRNtip))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(empNISlabel)
                                .addComponent(txtNIS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblNIStip))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(empFnameLabel)
                                .addComponent(txtFname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(empMnameLabel)
                                .addComponent(txtMname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblMnameTip))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(empLnameLabel)
                                .addComponent(txtLname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(empMaritalStatusLabel)
                                .addComponent(cboMaritalStatusLnk, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(cboMaritalStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(29, 29, 29)
                            .addComponent(lblEmpAdd)
                            .addGap(18, 18, 18)
                            .addComponent(sepEmpAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addGap(26, 26, 26)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(empAdd2Label)
                                        .addComponent(txtAdd2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(empAdd1Label)
                                    .addComponent(txtAdd1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(empParishLabel)
                                .addComponent(cboParish, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(cboParishLnk, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(lblEmpContInfo)
                            .addGap(18, 18, 18)
                            .addComponent(sepEmpContInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblEmail)
                                .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblEmailTip))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(txtEmailVer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblEmailVer))
                            .addGap(9, 9, 9)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(lblHnumber)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(txtHnumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(txtCnumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(lblCnumber)))
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(26, 26, 26)
                                    .addComponent(lblAsterich2))
                                .addComponent(lblAsterich1))
                            .addGap(71, 71, 71)
                            .addComponent(lblEmpEmployInfo)
                            .addGap(17, 17, 17)
                            .addComponent(sepEmpEmployInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblHdate)
                                .addComponent(txtHdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblHdateFormat))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblJtitle)
                                .addComponent(cboJtitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(cboJtitleLnk, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGap(83, 83, 83)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                        .addComponent(cmdSave)
                        .addComponent(cmdEmerContact)
                        .addComponent(cmdClear)
                        .addComponent(cmdCancel)
                        .addComponent(lblNBtip))
                    .addContainerGap())
            );
    
            java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-832)/2, (screenSize.height-616)/2, 832, 616);
        }// </editor-fold>                        
    
        private void txtEmailActionPerformed(java.awt.event.ActionEvent evt) {                                         
            // TODO add your handling code here:
    }
    1st Part

  15. #15
    RickAintree is offline Member
    Join Date
    Dec 2010
    Posts
    22
    Rep Power
    0

    Default 2nd part

    Java Code:
      private void cmdClearActionPerformed(java.awt.event.ActionEvent evt) {                                         
            // TODO add your handling code here:
            //Clear Text Boxes
            txtNRN.setText("");
            txtNIS.setText("");
            txtFname.setText("");
            txtMname.setText("");
            txtLname.setText("");
            txtAdd1.setText("");
            txtAdd2.setText("");
            txtEmail.setText("");
            txtHnumber.setText("");
            txtCnumber.setText("");
            txtHdate.setText("");
            txtEmailVer.setText("");
            //reset backgrounds of fields
            txtNRN.setBackground(Color.WHITE);
            txtNIS.setBackground(Color.WHITE);
            txtFname.setBackground(Color.WHITE);
            txtMname.setBackground(Color.WHITE);
            txtLname.setBackground(Color.WHITE);
            txtAdd1.setBackground(Color.WHITE);
            txtAdd2.setBackground(Color.WHITE);
            txtEmail.setBackground(Color.WHITE);
            txtEmailVer.setBackground(Color.WHITE);
            txtHnumber.setBackground(Color.WHITE);
            txtCnumber.setBackground(Color.WHITE);
            txtHdate.setBackground(Color.WHITE);
    }                                        
    
        private void cboJtitlejComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {                                                    
            // TODO add your handling code here:
            cboJtitleLnk.setSelectedIndex(cboJtitle.getSelectedIndex());
          
    
    }                                                   
    
        private void cmdCancelActionPerformed(java.awt.event.ActionEvent evt) {                                          
            // TODO add your handling code here:
            // Closes Jframe
            this.dispose();
            new FrmNavigation().setVisible(true);
    }                                         
    
        private void cmdCancelMouseReleased(java.awt.event.MouseEvent evt) {                                        
            // TODO add your handling code here:
            
    }                                       
    
        private void cmdClearMouseReleased(java.awt.event.MouseEvent evt) {                                       
            // TODO add your handling code here:
    
            
    
    }                                      
    
        @SuppressWarnings("static-access")
        private void cmdSaveActionPerformed(java.awt.event.ActionEvent evt) {                                        
            // TODO add your handling code here:
    
            //Set Names to Proper Case
          txtFname.setText(pc.toProperCase(txtFname.getText()));
          txtMname.setText(pc.toProperCase(txtMname.getText()));
          txtLname.setText(pc.toProperCase(txtLname.getText()));
          txtAdd1.setText(pc.toProperCase(txtAdd1.getText()));
          txtAdd2.setText(pc.toProperCase(txtAdd2.getText()));
          //Validate Fields
          
         if ((validateNRN(txtNRN.getText())) & (validateNIS(txtNIS.getText()) )
              & (validateFname(txtFname.getText())) & (validateMname(txtMname.getText()))
              & (validateLname(txtLname.getText())) & (validateAdd1(txtAdd1.getText()))
              & (validateAdd2(txtAdd2.getText())) & (validateEmail(txtEmail.getText()))
              & (verifyEmailAdd(txtEmail.getText())) & (validatePnum(txtHnumber.getText()))
              & (validateHdate(txtHdate.getText()))  ) {
    
             
            try {
                    StringBuffer SQLQuery = new StringBuffer();
                    SQLQuery.append("INSERT INTO EmployeeDetails (NRN,NIS,FirstName,MiddleName,LastName,MaritalStatus,Address1,Address2,Parish,Email,HomeNumber,CellNumber,HiredDate,JobTitle) VALUES (");
                    SQLQuery.append(txtNRN.getText().replaceAll("-", ""));
                    SQLQuery.append(",");
                    SQLQuery.append(txtNIS.getText());
                    SQLQuery.append(",'");
                    SQLQuery.append(txtFname.getText());
                    SQLQuery.append("','");
                    SQLQuery.append(txtMname.getText());
                    SQLQuery.append("','");
                    SQLQuery.append(txtLname.getText());
                    SQLQuery.append("','");
                    SQLQuery.append(cboMaritalStatusLnk.getSelectedItem().toString());
                    SQLQuery.append("','");
                    SQLQuery.append(txtAdd1.getText());
                    SQLQuery.append("','");
                    SQLQuery.append(txtAdd2.getText());
                    SQLQuery.append("','");
                    SQLQuery.append(cboParishLnk.getSelectedItem().toString());
                    SQLQuery.append("','");
                    SQLQuery.append(txtEmail.getText());
                    SQLQuery.append("',");
                    SQLQuery.append(txtHnumber.getText().replaceAll("-", ""));
                    SQLQuery.append(",");
                    SQLQuery.append(txtCnumber.getText().replaceAll("-", ""));
                    SQLQuery.append(",'");
                    SQLQuery.append(txtHdate.getText());
                    SQLQuery.append("','");
                    SQLQuery.append(cboJtitleLnk.getSelectedItem().toString());
                    SQLQuery.append("');");               
                    //Transmit data to database
                    System.out.println(SQLQuery);
                    dataconnect.querySQLINSERT(SQLQuery.toString());
            }catch(SQLException sqle){
                    sqle.printStackTrace();
                    this.dispose();
                                    }
                                                      }
        else{
    
              JOptionPane.showMessageDialog(opnErrorMessage,errMsg);
              errMsg.delete(0, errMsg.length());
            }                                  
    }                                       
       
        private void cboMaritalStatusActionPerformed(java.awt.event.ActionEvent evt) {                                                 
                    cboMaritalStatusLnk.setSelectedIndex(cboMaritalStatus.getSelectedIndex());
    }                                                
    
        private void cboParishActionPerformed(java.awt.event.ActionEvent evt) {                                          
           cboParishLnk.setSelectedIndex(cboParish.getSelectedIndex());
    }                                         
    
       
        }                                 
                               
                       
    
        /**t
        * @param args the command line arguments
        */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                 new FrmAddEmp().setVisible(true);
    
                }
                
            });
        }
    
        // Variables declaration - do not modify                     
        private javax.swing.JComboBox cboJtitle;
        private javax.swing.JComboBox cboJtitleLnk;
        private javax.swing.JComboBox cboMaritalStatus;
        private javax.swing.JComboBox cboMaritalStatusLnk;
        private javax.swing.JComboBox cboParish;
        private javax.swing.JComboBox cboParishLnk;
        private javax.swing.JButton cmdCancel;
        private javax.swing.JButton cmdClear;
        private javax.swing.JButton cmdEmerContact;
        private javax.swing.JButton cmdSave;
        private javax.swing.JLabel empAdd1Label;
        private javax.swing.JLabel empAdd2Label;
        private javax.swing.JLabel empFnameLabel;
        private javax.swing.JLabel empLnameLabel;
        private javax.swing.JLabel empMaritalStatusLabel;
        private javax.swing.JLabel empMnameLabel;
        private javax.swing.JLabel empNISlabel;
        private javax.swing.JLabel empNRNlabel;
        private javax.swing.JLabel empParishLabel;
        private javax.swing.JPanel headingPanel;
        private javax.swing.JLabel lblAsterich1;
        private javax.swing.JLabel lblAsterich2;
        private javax.swing.JLabel lblCnumber;
        private javax.swing.JLabel lblEmail;
        private javax.swing.JLabel lblEmailTip;
        private javax.swing.JLabel lblEmailVer;
        private javax.swing.JLabel lblEmpAdd;
        private javax.swing.JLabel lblEmpContInfo;
        private javax.swing.JLabel lblEmpEmployInfo;
        private javax.swing.JLabel lblEmpPersInfo;
        private javax.swing.JLabel lblHdate;
        private javax.swing.JLabel lblHdateFormat;
        private javax.swing.JLabel lblHnumber;
        private javax.swing.JLabel lblJtitle;
        private javax.swing.JLabel lblMnameTip;
        private javax.swing.JLabel lblNBtip;
        private javax.swing.JLabel lblNIStip;
        private javax.swing.JLabel lblNRNtip;
        private javax.swing.JLabel lblPDIheading;
        private javax.swing.JMenuBar mnuBar;
        private javax.swing.JDialog opnErrorMessage;
        private javax.swing.JSeparator sepEmpAdd;
        private javax.swing.JSeparator sepEmpContInfo;
        private javax.swing.JSeparator sepEmpEmployInfo;
        private javax.swing.JSeparator sepEmpPersInfo;
        private javax.swing.JSeparator sepPDI;
        private javax.swing.JFormattedTextField txtAdd1;
        private javax.swing.JFormattedTextField txtAdd2;
        private javax.swing.JFormattedTextField txtCnumber;
        private javax.swing.JTextField txtEmail;
        private javax.swing.JTextField txtEmailVer;
        private javax.swing.JFormattedTextField txtFname;
        private javax.swing.JFormattedTextField txtHdate;
        private javax.swing.JFormattedTextField txtHnumber;
        private javax.swing.JFormattedTextField txtLname;
        private javax.swing.JFormattedTextField txtMname;
        private javax.swing.JFormattedTextField txtNIS;
        private javax.swing.JFormattedTextField txtNRN;
        // End of variables declaration                   
    private cnConnection dataconnect = new cnConnection();
    private ProperCase pc = new ProperCase();
    List<String> errorMessages = new ArrayList<String>();
    StringBuffer errMsg = new StringBuffer();
    
     public static String getStackTrace(Throwable t)
        {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw, true);
            t.printStackTrace(pw);
            pw.flush();
            sw.flush();
            return sw.toString();
        }
    //Verify Email Address
     private boolean verifyEmailMatch() {
            if (new String(txtEmail.getText()).equals(new String(txtEmailVer.getText())) == true) {
                return true;
            } else {
                return false;
            }
        }
     //Validate Name
         public static boolean validateName(String strName) {
            return strName.matches("[a-zA-z]+([ '-][a-zA-Z]+)*");
        }
    //Validate Address
         public static boolean validateAddress(String strName) {
            return  strName.matches("[A-Za-z0-9# '-\\./\"]+[A-Za-z0-9# '-\\./\"]");
    
        }
    //Validate Email Address
         public static boolean verifyEmail(String strName) {
            return strName.matches("[A-Za-z0-9#!$_\\.-]+.[A-Za-z0-9#!$_\\.-]*+@[A-Za-z0-9]*+.[A-Za-z0-9]*");
        }
    
         public  boolean validateEmail (String emailFields){
              //Validate Email
         if (txtEmail.getText().isEmpty() == false & verifyEmail(txtEmail.getText()) == false) {
            errMsg.append ("\nV3 - Invalid Email, ");
            
            
        } return false;
         }
    
          public  boolean verifyEmailAdd (String emailFields){
          if (verifyEmailMatch() == false){
              
            errMsg.append ("\nEU4 The Emails you typed do not match");
            txtEmail.setBackground(Color.PINK);
            txtEmailVer.setBackground(Color.PINK);
            return false;
          }
          else {
              txtEmail.setBackground(Color.WHITE);
              txtEmailVer.setBackground(Color.WHITE);
              return true;
          }
    
         }
         public  boolean validateFname (String FnameField){
          //Validate Names
          //First Name______________________________________
          if (txtFname.getText().equals("")) {
    
            errMsg.append ("\nV4 - Enter First Name");
            txtFname.setBackground(Color.PINK);
              return false;
        }
        else if (txtFname.getText().length() == 1){
            errMsg.append ("\nV1 - First Name must be greater than 1 character");
              txtFname.setBackground(Color.PINK);
              return false;
        }
       else  if  (validateName(txtFname.getText()) == false){
            errMsg.append("\nV7 - Invalid Character in First Name");
              txtFname.setBackground(Color.PINK);
              return false;
        }
        else {
              txtFname.setBackground(Color.WHITE);
              return true;
        }
         }
         public  boolean validateMname (String MnameField){
        //Middle Name______________________________________
    
        if (txtMname.getText().length() == 1){
            errMsg.append ("\nV1 - Middle Name must be greater than 1 character");
              txtMname.setBackground(Color.PINK);
              return false;
        }
         else if  (txtMname.getText().isEmpty() == false & validateName(txtMname.getText()) == false){
            errMsg.append ("\nV7 - Invalid Character in Middle Name");
            txtMname.setBackground(Color.PINK);
              return false;
        }
         else
              txtMname.setBackground(Color.WHITE);
              return true;
        
         }
         public  boolean validateLname (String LnameField){
        //Last Name________________________________________
          if (txtLname.getText().equals("") ) {
            errMsg.append ("\nV4 - Enter Last Name");
            txtLname.setBackground(Color.PINK);
              return false;
             }
        else if (txtLname.getText().length() == 1){
            errMsg.append("\nV1 - Last Name must be greater than 1 character");
            txtLname.setBackground(Color.PINK);
              return false;
        }
         else if  (validateName(txtLname.getText()) == false){
            errMsg.append("\nV7 - Invalid Character in Last Name");
            txtLname.setBackground(Color.PINK);
              return false;
        }
        else {
              txtLname.setBackground(Color.WHITE);
        }return true;
         }
         public  boolean validateNRN (String nrnField){
        //Validate NRN
        if (txtNRN.getText().equals("      -    ")){
           errMsg.append ("V4 - Enter NRN");
           txtNRN.setBackground(Color.PINK);
           return false;
        }
          else if (txtNRN.getText().length() < 10){
            errMsg.append ("V2 - NRN out of range");
            txtNRN.setBackground(Color.PINK);
            return false;
        }
          else if (verifyNRNuniqueness(txtNRN.getText().replaceAll("-", "")) == false ){
    
              errMsg.append ("IO4 - NRN already exist");
              txtNRN.setBackground(Color.PINK);
            return false;
    
          }
          else {
                txtNRN.setBackground(Color.WHITE);
              return true;
          }
         }
         public  boolean validateNIS (String nisField){
        //Validate NIS
          if (txtNIS.getText().equals("      ")){
           errMsg.append ("\nV4 - Enter NIS");
           txtNIS.setBackground(Color.PINK);
           return false;
        }
          else if (txtNIS.getText().length() < 6){
            errMsg.append("\nV2 - NIS out of range");
            txtNIS.setBackground(Color.PINK);
            return false;
        }
          else if (verifyNISuniqueness(txtNIS.getText().replaceAll("-", "")) == false ){
    
              errMsg.append ("\nIO4 - NIS already exist");
              txtNIS.setBackground(Color.PINK);
            return false;
          }
          else {
              txtNIS.setBackground(Color.WHITE);
              return true;
          }
         }
         public  boolean validateAdd1 (String add1Field){
        //Validate Addresses
        //Address Line 1
        if (txtAdd1.getText().equals("")){
             errMsg.append ("\nV4 - Enter Address Line 1");
              txtAdd1.setBackground(Color.PINK);
              return false;
        }
        else if (validateAddress(txtAdd1.getText()) == false) {
            errMsg.append ("\nV7 - Invalid Character in Address Line 1");
            txtAdd1.setBackground(Color.PINK);
            return false;
        }
        else {
              txtAdd1.setBackground(Color.WHITE);
              return true;
        }
         }
         public  boolean validateAdd2 (String add2Field){
        //Address Line 2
        if (txtAdd2.getText().equals("")){
             errMsg.append ("\nV4 - Enter Address Line 2");
              txtAdd2.setBackground(Color.PINK);
              return false;
        }
              else if (validateAddress(txtAdd2.getText()) == false) {
            errMsg.append("\nV7 - Invalid Character in Address Line 2");
            txtAdd2.setBackground(Color.PINK);
            return false;
        }
        else {
              txtAdd2.setBackground(Color.WHITE);
              return true;
        }
         }
         public  boolean validatePnum (String hNumField){
         //Validate Phone Numbers
        if (txtHnumber.getText().equals("   -    ") & txtCnumber.getText().equals("   -    ")){
            errMsg.append ("\nV4 - Enter Contact Number");
            txtHnumber.setBackground(Color.PINK);
            txtCnumber.setBackground(Color.PINK);
            return false;
        }
        
        else {
            
            txtHnumber.setBackground(Color.WHITE);
            txtCnumber.setBackground(Color.WHITE);
            
            return true;
        }
                   
         }
         public  boolean validateHdate (String hDateField){
        //Validate Hired Date
         if (txtHdate.getText().equals("    /  /  ")){
             errMsg.append ("\nV4 - Enter Hired Date");
            txtHdate.setBackground(Color.PINK);
            return false;
         }
         else {
            txtHdate.setBackground(Color.WHITE);
            return true;
         }
        
        }
    private boolean verifyNRNuniqueness(String strNRN) {
            try {
                dataconnect.openSQLSELECT("SELECT COUNT(*) AS Amount FROM EmployeeDetails WHERE NRN = " + strNRN.replaceAll("-", "") + "");
                if (dataconnect.rs.next()) {
                    if (dataconnect.rs.getInt("Amount") == 0) {
                        dataconnect.closeSQLSELECT();
                        return true;
                    }
                }
                dataconnect.closeSQLSELECT();
            } catch (SQLException sqle) {
    
            } catch (NullPointerException npe) {
    
            }
            
            return false;
        }
    private boolean verifyNISuniqueness(String strNIS) {
            try {
                dataconnect.openSQLSELECT("SELECT COUNT(*) AS Amount FROM EmployeeDetails WHERE NIS = " + strNIS.replaceAll("-", "") + "");
                if (dataconnect.rs.next()) {
                    if (dataconnect.rs.getInt("Amount") == 0) {
                        dataconnect.closeSQLSELECT();
                        return true;
                    }
                }
                dataconnect.closeSQLSELECT();
            } catch (SQLException sqle) {
    
            } catch (NullPointerException npe) {
    
            }
    
            return false;
        }
    }
    //2nd Part

  16. #16
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    Do not eat exceptions!
    You are losing information there that may be important.

    At the very least in the catch clause do printStackTrace() so you can see what's happening.

    There's far too much there for us to go through. You need to start putting in debugging (like suggested above) and see what's happening. And print the stack traces!

Similar Threads

  1. add an If Else statement and......uh????
    By sonny in forum New To Java
    Replies: 6
    Last Post: 03-04-2010, 06:57 PM
  2. if statement help please!!
    By soc86 in forum New To Java
    Replies: 5
    Last Post: 12-02-2008, 02:56 PM
  3. If statement, please help??
    By soc86 in forum New To Java
    Replies: 5
    Last Post: 11-23-2008, 02:58 PM
  4. Help with if statement
    By carl in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 07:53 AM
  5. Statement or Prepared Statement ?
    By paty in forum JDBC
    Replies: 3
    Last Post: 08-01-2007, 04:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •