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 isn'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().AddPlane(plane);
                } else {
                    Plane p = new Plane();
                    p.setNumber(planeNumber);
                    p.setType(type);
                    p.setCapacity(capacity);
                    dbResult = Controller.Controller.Instance().ChangePlane(p, plane);
                    
                }
                if(!dbResult){
                    lblError.setText("Plane saved !");
                    lblError.setForeground(Color.GREEN);

                    JOptionPane.showMessageDialog(this, "Plane Saved");
                    this.dispose();
                }
                else{
                    lblError.setText("Error while saving plane !");
                    lblError.setForeground(Color.RED);
                }
        }
        else{
            lblError.setText(ErrorMessage);
        }

    }//GEN-LAST:event_btnSaveActionPerformed