Operazioni prodotti multipli
This commit is contained in:
@@ -101,14 +101,10 @@
|
|||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JTextField" name="txtPrezzo">
|
<Component class="javax.swing.JTextField" name="txtPrezzo">
|
||||||
<Events>
|
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txtPrezzoActionPerformed"/>
|
|
||||||
</Events>
|
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JTextField" name="txtQuantita">
|
<Component class="javax.swing.JTextField" name="txtQuantita">
|
||||||
<Events>
|
<Events>
|
||||||
<EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtQuantitaFocusGained"/>
|
<EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtQuantitaFocusGained"/>
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txtQuantitaActionPerformed"/>
|
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JTextField" name="txtImportoTotale">
|
<Component class="javax.swing.JTextField" name="txtImportoTotale">
|
||||||
@@ -128,16 +124,25 @@
|
|||||||
<Properties>
|
<Properties>
|
||||||
<Property name="text" type="java.lang.String" value="Media prezzo"/>
|
<Property name="text" type="java.lang.String" value="Media prezzo"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnPrezzoActionPerformed"/>
|
||||||
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JButton" name="btnQuantita">
|
<Component class="javax.swing.JButton" name="btnQuantita">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="text" type="java.lang.String" value="Media quantità"/>
|
<Property name="text" type="java.lang.String" value="Media quantità"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuantitaActionPerformed"/>
|
||||||
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JButton" name="btnImportoTotale">
|
<Component class="javax.swing.JButton" name="btnImportoTotale">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="text" type="java.lang.String" value="Tot. vendite"/>
|
<Property name="text" type="java.lang.String" value="Tot. vendite"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnImportoTotaleActionPerformed"/>
|
||||||
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -51,13 +51,6 @@ public class GUIVendite extends javax.swing.JFrame {
|
|||||||
|
|
||||||
lblImportoTotale.setText("Importo totale");
|
lblImportoTotale.setText("Importo totale");
|
||||||
|
|
||||||
txtPrezzo.addFocusListener(new java.awt.event.FocusAdapter() {
|
|
||||||
public void focusGained(java.awt.event.FocusEvent evt) {
|
|
||||||
txtPrezzoFocusGained(evt);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
txtQuantita.addFocusListener(new java.awt.event.FocusAdapter() {
|
txtQuantita.addFocusListener(new java.awt.event.FocusAdapter() {
|
||||||
public void focusGained(java.awt.event.FocusEvent evt) {
|
public void focusGained(java.awt.event.FocusEvent evt) {
|
||||||
txtQuantitaFocusGained(evt);
|
txtQuantitaFocusGained(evt);
|
||||||
@@ -70,10 +63,13 @@ public class GUIVendite extends javax.swing.JFrame {
|
|||||||
btnAggiungi.addActionListener(this::btnAggiungiActionPerformed);
|
btnAggiungi.addActionListener(this::btnAggiungiActionPerformed);
|
||||||
|
|
||||||
btnPrezzo.setText("Media prezzo");
|
btnPrezzo.setText("Media prezzo");
|
||||||
|
btnPrezzo.addActionListener(this::btnPrezzoActionPerformed);
|
||||||
|
|
||||||
btnQuantita.setText("Media quantità");
|
btnQuantita.setText("Media quantità");
|
||||||
|
btnQuantita.addActionListener(this::btnQuantitaActionPerformed);
|
||||||
|
|
||||||
btnImportoTotale.setText("Tot. vendite");
|
btnImportoTotale.setText("Tot. vendite");
|
||||||
|
btnImportoTotale.addActionListener(this::btnImportoTotaleActionPerformed);
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
@@ -148,6 +144,33 @@ public class GUIVendite extends javax.swing.JFrame {
|
|||||||
txtQuantita.setBackground(Color.white);
|
txtQuantita.setBackground(Color.white);
|
||||||
}//GEN-LAST:event_txtQuantitaFocusGained
|
}//GEN-LAST:event_txtQuantitaFocusGained
|
||||||
|
|
||||||
|
private void btnPrezzoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrezzoActionPerformed
|
||||||
|
double totale = 0;
|
||||||
|
for(Prodotto prodotto: prodotti){
|
||||||
|
totale += prodotto.getPrezzo();
|
||||||
|
}
|
||||||
|
|
||||||
|
txtPrezzo.setText(Double.toString(totale/prodotti.size()));
|
||||||
|
}//GEN-LAST:event_btnPrezzoActionPerformed
|
||||||
|
|
||||||
|
private void btnQuantitaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuantitaActionPerformed
|
||||||
|
double totale = 0;
|
||||||
|
for(Prodotto prodotto: prodotti){
|
||||||
|
totale += prodotto.getQuantita();
|
||||||
|
}
|
||||||
|
|
||||||
|
txtQuantita.setText(Double.toString(totale/prodotti.size()));
|
||||||
|
}//GEN-LAST:event_btnQuantitaActionPerformed
|
||||||
|
|
||||||
|
private void btnImportoTotaleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportoTotaleActionPerformed
|
||||||
|
double totale = 0;
|
||||||
|
for(Prodotto prodotto: prodotti){
|
||||||
|
totale += prodotto.getTotale();
|
||||||
|
}
|
||||||
|
|
||||||
|
txtImportoTotale.setText(Double.toString(totale));
|
||||||
|
}//GEN-LAST:event_btnImportoTotaleActionPerformed
|
||||||
|
|
||||||
private double leggiCampo(javax.swing.JTextField campo){
|
private double leggiCampo(javax.swing.JTextField campo){
|
||||||
double valoreCampo = -1;
|
double valoreCampo = -1;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user