private void countrySaveBTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_countrySaveBTActionPerformed
       String landcode = landcodeTextField.getText();
       Integer region = -1;
       String countryname = null;
       boolean dbResult = false;
        lblError.setText("");
        String ErrorMessage = "";
        if (landcode.isEmpty()) {
            ErrorMessage += "No landcode entered \n";
        }

        if (countrynameTextField.getText().isEmpty()) {
            ErrorMessage += "no Country name entered \n";
            
        }else{
            countryname = countrynameTextField.getText();
        }
        
         if(regionTextField.getText().isEmpty()){
                ErrorMessage += "No Region entered \n";
         }else{
                try {
                     region = Integer.parseInt(regionTextField.getText());
                }catch (NumberFormatException nfe) {
                    ErrorMessage += "Region isn't a number \n";
                }
         }
        

        if (ErrorMessage.isEmpty()) {
            if (country == null) {
                country = new Country();
                country.setLandcode(landcode);
                country.setCountry(countryname);
                country.setRegion(region);
                dbResult = Controller.Controller.Instance().save(country);
            } else {
                country.setLandcode(landcode);
                country.setCountry(countryname);
                country.setRegion(region);
                dbResult = Controller.Controller.Instance().update(country);
            }
            
            if (dbResult) {
                JOptionPane.showMessageDialog(this, "Country saved");
                this.dispose();
            } else {
                JOptionPane.showMessageDialog(this, "Error while saving country!");
            }
        }
        lblError.setText(ErrorMessage);
    }//GEN-LAST:event_countrySaveBTActionPerformed