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