private void btnUUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUUpdateActionPerformed
        // TODO add your handling code here:
        lblUHint.setVisible(false);
        if(ThisUser.UserType!=User.U_Types.ADMIN)
        {
            tbxError.setText("Permission denied.");
            return ;
        }
        String id = tbxUUserID.getText().trim().replace("'", "");
        if (id.equals(""))
        {
            tbxError.setText("Empty user ID.");
            return ;
        }

        Pattern namepattern = Pattern.compile("^[A-Z][a-zA-Z ,.'-]*$");
        String fn = tbxUFirstName.getText().trim();
        if (!namepattern.matcher(fn).matches())
        {
            tbxError.setText("Invalid first name.");
            lblUHint.setText("Unacceptable first name.");
            lblUHint.setVisible(true);
            return ;
        }
        fn = fn.replace("'", "\\'");
        String ln = tbxULastName.getText().trim();
        if (!namepattern.matcher(ln).matches())
        {
            tbxError.setText("Invalid last name.");
            lblUHint.setText("Unacceptable last name.");
            lblUHint.setVisible(true);
            return ;
        }
        ln = ln.replace("'", "\\'"); 
        Pattern pattern = Pattern.compile("[0-9]{4}/[0-9]{2}/[0-9]{2}");
        Pattern pattern2 = Pattern.compile("[0-9]{2}/[0-9]{2}/[0-9]{4}");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
        Date bd = new Date();
        String tbd = tbxUBirthDate.getText();
        if (pattern.matcher(tbd).matches())
        {
            //bd = sdf.parse(tbxBirthDate.getText());
            sdf = new SimpleDateFormat("yyyy/MM/dd");
        }
        else if (pattern2.matcher(tbd).matches())
        {
            sdf = new SimpleDateFormat("MM/dd/yyyy");
        }
        else
        {
            tbxError.setText("Invalid birthdate.");
            lblUHint.setText("Wrong Format. Example: "+"2000/01/01");
            lblUHint.setVisible(true);
            return ;
        }
        try
        {
            bd = sdf.parse(tbxUBirthDate.getText());
        }
        catch(Exception e)
        {
            tbxError.setText("Invalid birthdate.");
            lblUHint.setText("Wrong Format. Example: "+"2000/01/01");
            lblUHint.setVisible(true);
            return ;
        }
        sdf = new SimpleDateFormat("yyyy/MM/dd");
        Date ed = new Date();
        try
        {
            ed = sdf.parse(lblUEnrollDate.getText());
        }
        catch(Exception e)
        {
        }
        
        String Address = tbxUAddress1.getText().replace("'", "\\'").replace(";", "");
        Address +=";";
        Address += tbxUAddress2.getText().replace("'", "\\'").replace(";", "");
        if (Address.equals(";"))
        {
            tbxError.setText("Empty address.");
            return ;
        }
        pattern = Pattern.compile("[0-9]{5}");
        
        String zc = tbxUZipcode.getText().trim().replace("'", "");
        if (!pattern.matcher(zc).matches())
        {
            tbxError.setText("Invalid zipcode.");
            lblUHint.setText("Wrong Format. Example: "+"25858");
            lblUHint.setVisible(true);
            return ;
        }
        
        String ph = tbxUPhone.getText().trim().replace("'", "");
        pattern = Pattern.compile("[0-9]{3}\\-?[0-9]{3}\\-?[0-9]{4}");
        if (!pattern.matcher(ph).matches())
        {
            tbxError.setText("Invalid phone number.");
            lblUHint.setText("Wrong Format. Example: "+"919-360-5662");
            lblUHint.setVisible(true);
            return ;
        }
        ph = ph.replace("-", "");
        ph = ph.substring(0,3)+"-"+ph.substring(3,6)+"-"+ph.substring(6);
        User.U_Types ut = User.U_Types.GUEST;
        switch(cbxUUserType.getSelectedIndex())
        {
            case 1:
                ut = User.U_Types.DOCTOR;
                break;
            case 2:
                ut = User.U_Types.ADMIN;
                break;
            default:
                ut = User.U_Types.LABTECH;
                break;
        }
        //String pwd = tbxUPwd.getText().replace("'", "");
        
        User_Controller UC = new User_Controller("localhost", DBName, DBAccount, DBPwd);
        
        boolean flag = UC.UpdateUser(id, fn, ln, bd, ed, Address, zc, ph, ut);
        if(!flag)
        {
            tbxError.setText(UC.err);
            return;
        }
        ReturnedUsers = UC.SearchUser(id, "ID");
        ShowUsers();
        tbxError.setText("User '" + id +"' is updated successfully. Password not included.");
    }