private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
        String type = txtFieldType.getText();
        lblError.setText("");
        boolean dbResult = false;
        int capacity = -1;
        int planeNumber = -1;
        String ErrorMessage = "";
        type.trim();
        if (type.isEmpty()) {
            ErrorMessage += "No type entered \n";
        }

        if (txtFieldCapacity.getText().isEmpty()) {
            ErrorMessage += "no Capacity entered \n";
        } else {
            try {
                capacity = Integer.parseInt(txtFieldCapacity.getText());
            } catch (NumberFormatException nfe) {
                ErrorMessage += "Capacity issn't a number \n";
            }
        }

        if (txtFieldNumber.getText().isEmpty()) {
            ErrorMessage += "no number entered \n";
        } else {
            try {
                planeNumber = Integer.parseInt(txtFieldNumber.getText());
            } catch (NumberFormatException nfe) {
                ErrorMessage += "plane number isn't a number \n";
            }
        }

        if (ErrorMessage.isEmpty()) {
            if (plane == null) {
                plane = new Plane();
                plane.setNumber(planeNumber);
                plane.setType(type);
                plane.setCapacity(capacity);
                dbResult = Controller.Controller.Instance().save((plane));
            } else {
                plane.setNumber(planeNumber);
                plane.setType(type);
                plane.setCapacity(capacity);
                dbResult = Controller.Controller.Instance().update(plane);
            }
            
            if (dbResult) {
                JOptionPane.showMessageDialog(this, "Plane saved");
                this.dispose();
            } else {
                JOptionPane.showMessageDialog(this, "Error while saving plane!");
            }
        }
        lblError.setText(ErrorMessage);
    }//GEN-LAST:event_btnSaveActionPerformed