Versamento (parziale)
This commit is contained in:
Binary file not shown.
@@ -180,6 +180,9 @@
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Versamento"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnVersamentoActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnPrelievo">
|
||||
<Properties>
|
||||
|
||||
@@ -180,6 +180,9 @@
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Versamento"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnVersamentoActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnPrelievo">
|
||||
<Properties>
|
||||
|
||||
@@ -108,6 +108,7 @@ public class GUIMyBank extends javax.swing.JFrame {
|
||||
btnAprireContoCorrente.addActionListener(this::btnAprireContoCorrenteActionPerformed);
|
||||
|
||||
btnVersamento.setText("Versamento");
|
||||
btnVersamento.addActionListener(this::btnVersamentoActionPerformed);
|
||||
|
||||
btnPrelievo.setText("Prelievo");
|
||||
|
||||
@@ -208,6 +209,20 @@ txtCognome.setBorder(borderOriginale);
|
||||
txtSaldoIniziale.setBorder(borderOriginale);
|
||||
}//GEN-LAST:event_txtSaldoInizialeFocusGained
|
||||
|
||||
private void btnVersamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVersamentoActionPerformed
|
||||
String versamento;
|
||||
boolean error;
|
||||
|
||||
do {
|
||||
error = false;
|
||||
versamento = JOptionPane.showInputDialog("Inserire l'importo da versare:");
|
||||
if (!isNumeroValid(versamento)) {
|
||||
JOptionPane.showMessageDialog(null, "L'importo che si desidera versare non è valido.");
|
||||
error = true;
|
||||
}
|
||||
} while (error);
|
||||
}//GEN-LAST:event_btnVersamentoActionPerformed
|
||||
|
||||
private void btnAprireContoCorrenteActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnAprireContoCorrenteActionPerformed
|
||||
String nome = txtNome.getText();
|
||||
String cognome = txtCognome.getText();
|
||||
@@ -251,7 +266,7 @@ txtCognome.setBorder(borderOriginale);
|
||||
// if(dataDiNascita.isEmpty()){
|
||||
// dataDiNascitaError = true;
|
||||
// }
|
||||
if (!isSaldoInizialeValid(saldoIniziale)) {
|
||||
if (!isNumeroValid(saldoIniziale)) {
|
||||
JOptionPane.showMessageDialog(null, "Il saldo iniziale non è valido.");
|
||||
txtSaldoIniziale.setBorder(new LineBorder(Color.red));
|
||||
return;
|
||||
@@ -276,21 +291,21 @@ txtCognome.setBorder(borderOriginale);
|
||||
return !pattern.matcher(codiceFiscale).find();
|
||||
}
|
||||
|
||||
boolean isSaldoInizialeValid(String saldoIniziale) {
|
||||
boolean isSaldoInizialeValid = true;
|
||||
double valoreSaldoIniziale;
|
||||
boolean isNumeroValid(String numero) {
|
||||
boolean isNumeroValid = true;
|
||||
double valoreNumero;
|
||||
|
||||
try {
|
||||
valoreSaldoIniziale = Double.parseDouble(saldoIniziale);
|
||||
valoreNumero = Double.parseDouble(numero);
|
||||
|
||||
if (valoreSaldoIniziale <= 0) {
|
||||
isSaldoInizialeValid = false;
|
||||
if (valoreNumero <= 0) {
|
||||
isNumeroValid = false;
|
||||
}
|
||||
} catch (NumberFormatException _) {
|
||||
isSaldoInizialeValid = false;
|
||||
isNumeroValid = false;
|
||||
}
|
||||
|
||||
return isSaldoInizialeValid;
|
||||
return isNumeroValid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user