private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
        String name = txtFieldName.getText();
        String city = txtFieldCity.getText();
        String code = txtFieldCode.getText();
       

        String errorMessage = "";
        name = name.trim();
        if (name.isEmpty()) {
            errorMessage += "Please fill in a name\n";
        }
        
        if(country == null){
            errorMessage += "Please select a country";
        }
       

        city = city.trim();
        if (city.isEmpty()) {
            errorMessage += "please fill in a city \n";
        }

        code = code.trim();
        if (code.isEmpty()) {
            errorMessage += "please fill in a airport code \n";
        }

        if (errorMessage.isEmpty()) {
            if (airport == null) {
                 airport = new Airport();
                airport.setCity(city);
                airport.setCountry(country);
                airport.setName(name);
                airport.setCode(code);
                

                if (Controller.Instance().save(airport)) {
                    JOptionPane.showMessageDialog(this, "Airport saved");
                    this.dispose();
                } else {
                    errorMessage = "Unable to save Airport";
                }
            } else {
                airport.setCity(city);
                airport.setCountry(country);
                airport.setName(name);
                airport.setCode(code);
               

                if (Controller.Instance().update(airport)) {
                    JOptionPane.showMessageDialog(this, "Airport saved");
                    this.dispose();
                } else {
                    errorMessage = "Unable to change Airport";
                }
            }
        }

        lblErrorMessage.setText("" + errorMessage);

    }//GEN-LAST:event_btnSaveActionPerformed