private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed

        if(checkInput())
        {
            
            if(!passwordField.getText().equals(confirmPasswordField.getText()))
            {
                Dialogs.ErrorDialog errorDialog = new ErrorDialog(this, true, "Podane hasła są różne!", "CreateAccountWindow", "saveButtonActionPerformed", "");
                errorDialog.setVisible(true);
                return;
            }
            
            DataRow row = new DataRow(loginTextField.getText());
            row.setTableName("users");
            row.setName(loginTextField.getText());
            row.addAttribute("userPassword", passwordField.getText());
            row.addAttribute("firstName", nameTextField.getText());
            row.addAttribute("surname", surnameTextField.getText());
            row.addAttribute("street", streetTextField.getText());
            row.addAttribute("number", numberTextField.getText());
            row.addAttribute("secondNumber", localNumberTextField.getText());
            row.addAttribute("postCode", postCodeTextField.getText());
            row.addAttribute("city", cityTextField.getText());
            try
            {
                DataVector.getInstance().dbManager.createUser(row);
                boolean result = DataVector.getInstance().dbManager.login(loginTextField.getText(), passwordField.getText());
                if(result)
                {
                    DataRow parameters = new DataRow();
                    parameters.setTableName("users");
                    parameters.addAttribute("name", loginTextField.getText());
                    row = DataVector.getInstance().dbManager.select(parameters).get(0);
                    MainWindow wind = new MainWindow(row);
                    DataVector.getInstance().setMainWindow(wind);
                    wind.setVisible(true);
                    this.dispose();

                } else {
                    Dialogs.ErrorDialog dialog = new ErrorDialog(this, true, "Błąd logowania!", "CreateAccountWindow", "login", "");
                    dialog.setVisible(true);
                    
                }
            } catch(Exception e) {
                Dialogs.ErrorDialog errorDialog = new ErrorDialog(this, true, e.getMessage(), "CreateAccountWindow", "saveButtonActionPerformed", "");
                errorDialog.setVisible(true);
            }
            
        } else {
            Dialogs.ErrorDialog errorDialog = new ErrorDialog(this, true, "Nie wypełniono wymaganych pól!", "CreateAccountWindow", "saveButtonActionPerformed", "");
            errorDialog.setVisible(true);
        }
    }//GEN-LAST:event_saveButtonActionPerformed