completamento modifiche

in caso di presenza di una prenotazione legata ad una tessera, il saldo non viene aggiornato se la stessa risulta già pagata.
inoltre, se pagata, non sarà possibile modificare i prodotti presenti nel carrello.

effettuata pulizia codice e creazione nuove funzioni per migliorare la leggibilità del sorgente
This commit is contained in:
Francesco Di Sciascio 2025-06-04 09:44:18 +02:00
parent df62c97c24
commit 2cdc76f9a4
4 changed files with 476 additions and 457 deletions

View File

@ -0,0 +1,23 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package puntocassa;
/**
* Classe che descrive i parametri da passare agli oggetti di tipo java.awt.Event.ActionEvent
* @author assis
*/
public class EventParameters {
public final String idProdotto;
public final String idCategoria;
public final boolean flagPrenotazionePagata;
public final String idPrenDettaglio;
public EventParameters(String idProdotto, String idCategoria, boolean flagPrenotazionePagata, String idPrenDettaglio){
this.idProdotto = idProdotto;
this.idCategoria = idCategoria;
this.flagPrenotazionePagata = flagPrenotazionePagata;
this.idPrenDettaglio = idPrenDettaglio;
}
}

View File

@ -3,7 +3,6 @@
* To change this template file, choose Tools | Templates * To change this template file, choose Tools | Templates
* and open the template in the editor. * and open the template in the editor.
*/ */
package puntocassa; package puntocassa;
import java.awt.Font; import java.awt.Font;
@ -31,37 +30,39 @@ public class FrmStorno extends javax.swing.JFrame {
private PuntoCassa frmPuntoCassa; private PuntoCassa frmPuntoCassa;
private Long idTessera = 0L, idPuntoCassa = 0L; private Long idTessera = 0L, idPuntoCassa = 0L;
public int HFont = 15; public int hFont = 15;
private int AltControlli = 100; private int altRigaGriglia = 0;
private int LargControlli = 100; private Boolean azzera = false;
private int AltRigaGriglia = 0; private Boolean stornoEffettuato = false;
private Boolean Azzera=false;
private Boolean StornoEffettuato=false;
/** /**
* Creates new form frm * Creates new form frm
*
* @param frm
* @param idTessera
* @param idPuntoCassa
* @param imgPath
* @param azzera
*/ */
public FrmStorno(PuntoCassa frm,Long IDTessera,Long IDPuntoCassa,String imgPath,Boolean azzera) { public FrmStorno(PuntoCassa frm, Long idTessera, Long idPuntoCassa, String imgPath, Boolean azzera) {
frmPuntoCassa = frm; frmPuntoCassa = frm;
frmPuntoCassa.setEnabled(false); frmPuntoCassa.setEnabled(false);
//KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(frmPuntoCassa.keyDispatcher);
frmPuntoCassa.addRemoveKeyDispatcher(false); frmPuntoCassa.addRemoveKeyDispatcher(false);
idPuntoCassa=IDPuntoCassa; this.idPuntoCassa = idPuntoCassa;
idTessera=IDTessera; this.idTessera = idTessera;
Azzera=azzera; this.azzera = azzera;
initComponents(); initComponents();
String startDir = System.getProperty("user.dir"); String startDir = System.getProperty("user.dir");
File IconaApp = new File(startDir + "/risorse/logo.png"); File iconaApp = new File(startDir + "/risorse/logo.png");
if (IconaApp.exists()) { if (iconaApp.exists()) {
ImageIcon icon = new ImageIcon(startDir + "/risorse/logo.png"); ImageIcon icon = new ImageIcon(startDir + "/risorse/logo.png");
this.setIconImage(icon.getImage()); this.setIconImage(icon.getImage());
} }
ImageIcon icon = new ImageIcon(imgPath + "freccia_down.jpg"); ImageIcon icon = new ImageIcon(imgPath + "freccia_down.jpg");
Image img = icon.getImage(); Image img = icon.getImage();
Image newimg = img.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH); Image newimg = img.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH);
@ -73,7 +74,7 @@ public class FrmStorno extends javax.swing.JFrame {
Image newimg2 = img2.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH); Image newimg2 = img2.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH);
icon2 = new ImageIcon(newimg2); icon2 = new ImageIcon(newimg2);
jbtnSu.setIcon(icon2); jbtnSu.setIcon(icon2);
Aggiorna(); aggiorna();
} }
@ -210,52 +211,27 @@ public class FrmStorno extends javax.swing.JFrame {
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void jbtnAnnullaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAnnullaActionPerformed private void jbtnAnnullaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAnnullaActionPerformed
// ClearTable((MyTableModel)jTblStudenti.getModel());
// frmPuntoCassa.setEnabled(true);
// frmPuntoCassa=null;
// if (Azzera){
// frmPuntoCassa.AzzeraDopoStorno();
// }
this.dispose(); this.dispose();
}//GEN-LAST:event_jbtnAnnullaActionPerformed }//GEN-LAST:event_jbtnAnnullaActionPerformed
private void ClearTable(MyTableModel model) {
try {
for (Integer i = model.getRowCount() - 1; i >= 0; i--) {
model.deleteRow(i);
}
} catch (Exception e) {
}
}
private void Tastiera(JTextField jTxt,Integer MyX,Integer MyY){
MyKeyBoard myk=new MyKeyBoard(this,false);
myk.txt=jTxt;
myk.parent=this;
Rectangle s=this.getBounds();
Rectangle s2=jTxt.getBounds();
Integer l=s.x+s2.x+MyX;
if(l+800>s.x+s.width){l=s.x+s.width-800;}
myk.setBounds(l,s.y+s2.y+60+MyY, 800, 300);
myk.setVisible(true);
}
private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
try { try {
frmPuntoCassa.setEnabled(true); frmPuntoCassa.setEnabled(true);
//KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(frmPuntoCassa.keyDispatcher);
frmPuntoCassa.addRemoveKeyDispatcher(true); frmPuntoCassa.addRemoveKeyDispatcher(true);
frmPuntoCassa.toFront(); frmPuntoCassa.toFront();
frmPuntoCassa.repaint(); frmPuntoCassa.repaint();
if (Azzera && StornoEffettuato==false){ if (azzera && stornoEffettuato == false) {
frmPuntoCassa.azzeraDopoStorno(); frmPuntoCassa.azzeraDopoStorno();
} }
frmPuntoCassa = null; frmPuntoCassa = null;
this.dispose(); this.dispose();
}catch(Exception ex){} } catch (Exception ex) {
}
}//GEN-LAST:event_formWindowClosed }//GEN-LAST:event_formWindowClosed
private void jBtnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnOKActionPerformed private void jBtnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnOKActionPerformed
@ -263,28 +239,19 @@ public class FrmStorno extends javax.swing.JFrame {
MyTableModel model = new MyTableModel(); MyTableModel model = new MyTableModel();
model = (MyTableModel) jTblStudenti.getModel(); model = (MyTableModel) jTblStudenti.getModel();
Object[] row = model.getRow(jTblStudenti.getSelectedRow()); Object[] row = model.getRow(jTblStudenti.getSelectedRow());
// QueryDati("select a.id 0,a.data 1,a.num_progressivo as Progressivo 2,p.nome as Prodotto,a.importo 4,a.punti 5,a.saldo_pre,a.saldo_post,a.punti_pre,a.punti_post,p.id as idProdotto " + From + Where + " order by a.data,a.num_progressivo", QueryCount, Col, ColType, jTblStudenti, false);
//Boolean Ok=MyInsert("insert into ristorni (ID_TESSERA,ID_PRODOTTO,ID_PUNTO_CASSA,DATA,NUM_PROGRESSIVO,IMPORTO,PUNTI,ID_TIPO_PAGAMENTO,ID_TURNO) " + Boolean ok = Utils.myInsert("insert into ristorni (ID_TESSERA,ID_PRODOTTO,ID_PUNTO_CASSA,DATA,NUM_PROGRESSIVO,IMPORTO,PUNTI,ID_TIPO_PAGAMENTO,ID_TURNO,FLAG_IN_VASSOIO,SALDO_PRE,SALDO_POST,PUNTI_PRE,PUNTI_POST,FLAG_GRATUITA,FLAG_ASPORTO,FLAG_BONUS,ID_PREN_DETTAGLIO) "
// "values (" + idTessera + "," + row[1] + "," + idPuntoCassa + ",to_date('" + row[2] + "','dd/mm/yyyy HH24:MI:SS')," + row[3] + ","+ row[5] + "," + row[6] + "," + row[7] + "," + row[8] + ")"); + "SELECT ID_TESSERA,ID_PRODOTTO,ID_PUNTO_CASSA,DATA,NUM_PROGRESSIVO,IMPORTO,PUNTI,ID_TIPO_PAGAMENTO,ID_TURNO,FLAG_IN_VASSOIO,SALDO_PRE,SALDO_POST,PUNTI_PRE,PUNTI_POST,FLAG_GRATUITA,FLAG_ASPORTO,FLAG_BONUS,ID_PREN_DETTAGLIO "
Boolean Ok=MyInsert("insert into ristorni (ID_TESSERA,ID_PRODOTTO,ID_PUNTO_CASSA,DATA,NUM_PROGRESSIVO,IMPORTO,PUNTI,ID_TIPO_PAGAMENTO,ID_TURNO,FLAG_IN_VASSOIO,SALDO_PRE,SALDO_POST,PUNTI_PRE,PUNTI_POST,FLAG_GRATUITA,FLAG_ASPORTO,FLAG_BONUS) " + + "FROM st_acquisti WHERE num_progressivo = " + row[3], this.frmPuntoCassa);
"SELECT ID_TESSERA,ID_PRODOTTO,ID_PUNTO_CASSA,DATA,NUM_PROGRESSIVO,IMPORTO,PUNTI,ID_TIPO_PAGAMENTO,ID_TURNO,FLAG_IN_VASSOIO,SALDO_PRE,SALDO_POST,PUNTI_PRE,PUNTI_POST,FLAG_GRATUITA,FLAG_ASPORTO,FLAG_BONUS " + if (ok) {
"FROM st_acquisti WHERE num_progressivo = " + row[3]); Utils.myInsert("Delete from St_Acquisti where num_progressivo=" + row[3], this.frmPuntoCassa);
if(Ok){ stornoEffettuato = true;
//MyInsert("Delete from St_Acquisti where id="+ row[0]);
MyInsert("Delete from St_Acquisti where num_progressivo="+ row[3]);
StornoEffettuato=true;
} }
if (!azzera) {
if (Azzera){
// frmPuntoCassa.AzzeraDopoStorno();
}else
{
frmPuntoCassa.aggiornaProgressivi(); frmPuntoCassa.aggiornaProgressivi();
} }
//frmPuntoCassa.CercaTessera();
this.dispose(); this.dispose();
} }
@ -306,48 +273,28 @@ public class FrmStorno extends javax.swing.JFrame {
} }
}//GEN-LAST:event_jbtnGiuActionPerformed }//GEN-LAST:event_jbtnGiuActionPerformed
private Boolean MyInsert(String Query) {
Boolean res=false;
try {
Connection dbConnection = DriverManager.getConnection(frmPuntoCassa.dbStringa, frmPuntoCassa.dbUsername, frmPuntoCassa.dbPassword);
Statement st = dbConnection.createStatement();
ResultSet rs = st.executeQuery(Query);
rs.close();
st.close();
dbConnection.close();
res=true;
} catch (SQLException e) {
JOptionPane.showMessageDialog(this, "Errore MySelect ['" + e.getMessage() + " " + Query + "']");
}
return res; private void queryDati(String query, String queryCount, String[] colonne, String[] colTypes, JTable jTbl) {
}
private void QueryDati(String Query,String QueryCount,String[] Colonne,String[] ColType, JTable jTbl,Boolean Editable){
try { try {
MyApplication MyA=new MyApplication();
MyTableModel model = new MyTableModel(); MyTableModel model = new MyTableModel();
model.setColumname(Colonne); model.setColumname(colonne);
int rowCount = Integer.parseInt(Utils.mySelect(queryCount, "righe", frmPuntoCassa));
// model.setEditable(Editable); Object[][] data = rowData(query, colonne, colTypes, rowCount);
// int [] colBool=new int[1];
// colBool[0]=7;
// model.setColBoolean(colBool);
// int[] cols=new int[1];
// cols[0]=7;
// model.setColModificabile(cols);
int rowCount=Integer.parseInt(Utils.mySelect(QueryCount, "righe", frmPuntoCassa));
Object[][] data = RowData(Query, Colonne,ColType,rowCount);
model.setData(data); model.setData(data);
try{jTbl.setModel(model);}catch(Exception e){} try {
jTbl.setModel(model);
} catch (Exception e) {
}
jTbl.setAutoCreateColumnsFromModel(true); jTbl.setAutoCreateColumnsFromModel(true);
jTbl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTbl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jTbl.getTableHeader().setFont(new Font("Tahoma", Font.BOLD, 16)); jTbl.getTableHeader().setFont(new Font("Tahoma", Font.BOLD, 16));
jTbl.setFont(new Font("Tahoma", 0, 16)); jTbl.setFont(new Font("Tahoma", 0, 16));
TableColumn column = jTbl.getColumn("id"); TableColumn column = jTbl.getColumn("id");
column.setMinWidth(0); column.setMinWidth(0);
column.setMaxWidth(0); column.setMaxWidth(0);
@ -389,114 +336,93 @@ public class FrmStorno extends javax.swing.JFrame {
} }
} }
private void Aggiorna() {
private void aggiorna() {
try { try {
String From=" from st_acquisti a inner join prodotti p on a.id_prodotto=p.id inner join Tipi_Pagamenti tp on a.id_tipo_pagamento=tp.id "; String fromClause = " from st_acquisti a inner join prodotti p on a.id_prodotto=p.id inner join Tipi_Pagamenti tp on a.id_tipo_pagamento=tp.id ";
String Where= "where TRUNC(data) = TRUNC(SYSDATE) and id_tessera=" + idTessera + " and flag_in_vassoio=0 and id_punto_cassa=" + idPuntoCassa ; String whereClause = "where TRUNC(data) = TRUNC(SYSDATE) and id_tessera=" + idTessera + " and flag_in_vassoio=0 and id_punto_cassa=" + idPuntoCassa;
// String Where= " and UPPER(Cognome) like '" + jtxtCognome.getText().trim().toUpperCase().replace("'", "''") + "%' "; String[] colNames = {"id", "idProdotto", "Data", "Progressivo", "Prodotto", "Importo", "id_Tipo_Pagamento", "id_Turno", "Pagamento"};
// if (jtxtNome.getText().trim().length()>0) {Where=Where + " and UPPER(Nome) like '" + jtxtNome.getText().trim().toUpperCase().replace("'", "''") + "%'"; } String[] colTypes = {"long", "long", "data", "integer", "text", "float", "long", "long", "text"};
// if (jtxtCodFis.getText().trim().length()>0) {Where=Where + " and UPPER(Matricola) like '" + jtxtCodFis.getText().trim().toUpperCase().replace("'", "''") + "%'"; } String QueryCount = "Select count(*) as righe " + fromClause + whereClause;
String[] Col = {"id", "idProdotto", "Data","Progressivo","Prodotto","Importo","id_Tipo_Pagamento","id_Turno","Pagamento"}; queryDati("select a.id,p.id as idProdotto,a.data,a.num_progressivo as Progressivo,p.nome as Prodotto,a.importo,a.id_tipo_pagamento,a.id_turno,tp.Nome as Pagamento " + fromClause + whereClause + " order by a.data desc,a.num_progressivo desc", QueryCount, colNames, colTypes, jTblStudenti);
String[] ColType = {"long", "long", "data","integer", "text", "float", "long", "long", "text"};
String QueryCount="Select count(*) as righe " + From + Where;
QueryDati("select a.id,p.id as idProdotto,a.data,a.num_progressivo as Progressivo,p.nome as Prodotto,a.importo,a.id_tipo_pagamento,a.id_turno,tp.Nome as Pagamento " + From + Where + " order by a.data desc,a.num_progressivo desc", QueryCount, Col, ColType, jTblStudenti, false);
//jTblStudenti.getColumn("Drawing").setPreferredWidth(200);
Font f = new Font("Tahoma", 0, 18); Font f = new Font("Tahoma", 0, 18);
jTblStudenti.setFont(f); jTblStudenti.setFont(f);
if(AltRigaGriglia==0){AltRigaGriglia=jTblStudenti.getRowHeight();} if (altRigaGriglia == 0) {
// txtUsername.setSize(CalcolaLarghezzaAltezza(txtUsername.getWidth(),LargControlli), CalcolaLarghezzaAltezza(txtUsername.getHeight(),AltControlli)); altRigaGriglia = jTblStudenti.getRowHeight();
}
jTblStudenti.setRowHeight(25); jTblStudenti.setRowHeight(25);
//ClearTable((MyTableModel)jTblTessere.getModel());
if (jTblStudenti.getRowCount() > 0) { if (jTblStudenti.getRowCount() > 0) {
jTblStudenti.setRowSelectionInterval(0, 0); jTblStudenti.setRowSelectionInterval(0, 0);
} }
///AggiornaTessera(0);
} catch (Exception e) { } catch (Exception e) {
} }
} }
private Integer CalcolaLarghezzaAltezza(Integer LarControllo,Integer Percentuale){
Integer D = Percentuale - 100;
if (D == 0) {
return LarControllo;
} else {
Integer N = LarControllo + ((LarControllo * D) / 100);
return N;
}
}
public Object[][] RowData(String Query, String[] Cols, String[] ColType, int rowCount) { public Object[][] rowData(String query, String[] cols, String[] colTypes, int rowCount) {
Object[][] rows = null; Object[][] rows = null;
try { try {
Connection dbConnection = DriverManager.getConnection(frmPuntoCassa.dbStringa, frmPuntoCassa.dbUsername, frmPuntoCassa.dbPassword); Connection dbConnection = DriverManager.getConnection(frmPuntoCassa.dbStringa, frmPuntoCassa.dbUsername, frmPuntoCassa.dbPassword);
Statement st = dbConnection.createStatement(); Statement st = dbConnection.createStatement();
ResultSet rs = st.executeQuery(Query); ResultSet rs = st.executeQuery(query);
rows = new Object[rowCount][]; rows = new Object[rowCount][];
int r = 0; int r = 0;
while (rs.next()) { while (rs.next()) {
Object[] row = new Object[Cols.length]; Object[] row = new Object[cols.length];
for (int i = 0; i < Cols.length; i++) { for (int i = 0; i < cols.length; i++) {
if (rs.getString(Cols[i].replace(" ", "_")) == null) { if (rs.getString(cols[i].replace(" ", "_")) == null) {
row[i] = ""; row[i] = "";
} else { } else {
row[i] = rs.getString(Cols[i].replace(" ", "_")); row[i] = rs.getString(cols[i].replace(" ", "_"));
} }
switch (ColType[i]) { switch (colTypes[i]) {
case "text": case "text" -> {
if (rs.getString(Cols[i].replace(" ", "_")) == null) { if (rs.getString(cols[i].replace(" ", "_")) == null) {
row[i] = ""; row[i] = "";
} else { } else {
row[i] = rs.getString(Cols[i].replace(" ", "_")); row[i] = rs.getString(cols[i].replace(" ", "_"));
} }
break; }
case "integer": case "integer" -> {
if (rs.getString(Cols[i].replace(" ", "_")) == null) { if (rs.getString(cols[i].replace(" ", "_")) == null) {
row[i] = 0; row[i] = 0;
} else { } else {
row[i] = rs.getInt(Cols[i].replace(" ", "_")); row[i] = rs.getInt(cols[i].replace(" ", "_"));
} }
break; }
case "long": case "long" -> {
if (rs.getString(Cols[i].replace(" ", "_")) == null) { if (rs.getString(cols[i].replace(" ", "_")) == null) {
row[i] = 0; row[i] = 0;
} else { } else {
row[i] = rs.getLong(Cols[i].replace(" ", "_")); row[i] = rs.getLong(cols[i].replace(" ", "_"));
} }
break; }
case "boolean": case "boolean" -> {
if (rs.getString(Cols[i].replace(" ", "_")) == null) { if (rs.getString(cols[i].replace(" ", "_")) == null) {
row[i] = false; row[i] = false;
} else { } else {
row[i] = rs.getBoolean(Cols[i].replace(" ", "_")); row[i] = rs.getBoolean(cols[i].replace(" ", "_"));
} }
break; }
case "float": case "float" -> {
if (rs.getString(Cols[i].replace(" ", "_")) == null) { if (rs.getString(cols[i].replace(" ", "_")) == null) {
row[i] = 0.00; row[i] = 0.00;
} else { } else {
String v = rs.getString(Cols[i].replace(" ", "_")); String v = rs.getString(cols[i].replace(" ", "_"));
row[i] = Float.parseFloat(v.replace(",", ".")); row[i] = Float.valueOf(v.replace(",", "."));
}
} }
break; case "data" -> {
case "data":
row[i] = ""; row[i] = "";
if (rs.getString(Cols[i].replace(" ", "_")) != null) { if (rs.getString(cols[i].replace(" ", "_")) != null) {
// Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",Locale.ITALY).parse(rs.getString(Cols[i]));
//SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); String[] d = rs.getString(cols[i].replace(" ", "_")).split("-");
String[] d= rs.getString(Cols[i].replace(" ", "_")).split("-");
if (d.length >= 3) { if (d.length >= 3) {
String Ora = ""; String Ora = "";
@ -511,18 +437,12 @@ public class FrmStorno extends javax.swing.JFrame {
row[i] = d[2].trim().substring(0, 2) + "/" + d[1] + "/" + d[0] + " " + Ora; row[i] = d[2].trim().substring(0, 2) + "/" + d[1] + "/" + d[0] + " " + Ora;
} }
} }
}
break;
} }
} }
rows[r] = row; rows[r] = row;
r++; r++;
/*int id = rs.getInt("id");
String name = rs.getString("name");
int age = rs.getInt("age");
String address = rs.getString("address");
float salary = rs.getFloat("salary");*/
} }
rs.close(); rs.close();
@ -537,6 +457,7 @@ public class FrmStorno extends javax.swing.JFrame {
} }
} }
/** /**
* @param args the command line arguments * @param args the command line arguments
*/ */

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.2" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> <Form version="1.5" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties> <Properties>
<Property name="defaultCloseOperation" type="int" value="0"/> <Property name="defaultCloseOperation" type="int" value="0"/>
<Property name="title" type="java.lang.String" value="Prova di titolo"/> <Property name="title" type="java.lang.String" value="Prova di titolo"/>
@ -880,7 +880,7 @@
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Container class="javax.swing.JPanel" name="pnlLista"> <Container class="javax.swing.JPanel" name="pnlListaProdotti">
<Properties> <Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="ff" red="cc" type="rgb"/> <Color blue="cc" green="ff" red="cc" type="rgb"/>
@ -899,7 +899,7 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
<SubComponents> <SubComponents>
<Container class="javax.swing.JScrollPane" name="scpLista"> <Container class="javax.swing.JScrollPane" name="scpListaProdotti">
<Properties> <Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/> <Font name="Tahoma" size="14" style="0"/>
@ -911,12 +911,18 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents> <SubComponents>
<Component class="javax.swing.JTable" name="tblLista"> <Component class="javax.swing.JTable" name="tblListaProdotti">
<Properties> <Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="0" rowCount="4"/> <Table columnCount="0" rowCount="4"/>
</Property> </Property>
<Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
<TableColumnModel selectionModel="0"/>
</Property>
<Property name="name" type="java.lang.String" value="jtbl" noResource="true"/> <Property name="name" type="java.lang.String" value="jtbl" noResource="true"/>
<Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
<TableHeader reorderingAllowed="true" resizingAllowed="true"/>
</Property>
</Properties> </Properties>
</Component> </Component>
</SubComponents> </SubComponents>
@ -947,7 +953,7 @@
<Property name="verticalGap" type="int" value="2"/> <Property name="verticalGap" type="int" value="2"/>
</Layout> </Layout>
</Container> </Container>
<Container class="javax.swing.JPanel" name="pnlLista1"> <Container class="javax.swing.JPanel" name="pnlListaComposizioni">
<Properties> <Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="ff" red="cc" type="rgb"/> <Color blue="cc" green="ff" red="cc" type="rgb"/>
@ -969,7 +975,7 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
<SubComponents> <SubComponents>
<Container class="javax.swing.JScrollPane" name="scpLista1"> <Container class="javax.swing.JScrollPane" name="scpListaComposizioni">
<Properties> <Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/> <Font name="Tahoma" size="14" style="0"/>
@ -981,7 +987,7 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents> <SubComponents>
<Component class="javax.swing.JTable" name="tblLista1"> <Component class="javax.swing.JTable" name="tblListaComposizioni">
<Properties> <Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="0" rowCount="4"/> <Table columnCount="0" rowCount="4"/>

View File

@ -90,7 +90,10 @@ public class PuntoCassa extends JFrame implements ActionListener {
private int colIDProdotto = 3; private int colIDProdotto = 3;
private int colImporto2 = 4; private int colImporto2 = 4;
private int colCategoria = 5; private int colCategoria = 5;
private int colIdPrenDettaglio = 6;
private int colIdPrenotazione = 3;
public Long idPuntoCassa = 0L; public Long idPuntoCassa = 0L;
//public Long idPrenDettaglio = 0L;
private Boolean consentiCredito = false; private Boolean consentiCredito = false;
private Long idProfiloTariffario = 0L; private Long idProfiloTariffario = 0L;
private Long idProfiloTariffarioDefault = 0L; private Long idProfiloTariffarioDefault = 0L;
@ -141,6 +144,8 @@ public class PuntoCassa extends JFrame implements ActionListener {
private static Boolean bottoneImposta = true; private static Boolean bottoneImposta = true;
private static Boolean asporto = false; private static Boolean asporto = false;
private static Boolean flagPrecaricaLista = false; private static Boolean flagPrecaricaLista = false;
private static Boolean flagPrenotazionePagata = false;
private static final Object[] siNoOptions = {"Si", "No"};
//delta per la grafica (in px) //delta per la grafica (in px)
private int deltaWidth = 14; private int deltaWidth = 14;
@ -785,13 +790,13 @@ public class PuntoCassa extends JFrame implements ActionListener {
jTBP2 = new javax.swing.JToggleButton(); jTBP2 = new javax.swing.JToggleButton();
jTBP3 = new javax.swing.JToggleButton(); jTBP3 = new javax.swing.JToggleButton();
jbtnEsci = new javax.swing.JButton(); jbtnEsci = new javax.swing.JButton();
pnlLista = new javax.swing.JPanel(); pnlListaProdotti = new javax.swing.JPanel();
scpLista = new javax.swing.JScrollPane(); scpListaProdotti = new javax.swing.JScrollPane();
tblLista = new javax.swing.JTable(); tblListaProdotti = new javax.swing.JTable();
pnlProdotti = new javax.swing.JPanel(); pnlProdotti = new javax.swing.JPanel();
pnlLista1 = new javax.swing.JPanel(); pnlListaComposizioni = new javax.swing.JPanel();
scpLista1 = new javax.swing.JScrollPane(); scpListaComposizioni = new javax.swing.JScrollPane();
tblLista1 = new javax.swing.JTable(); tblListaComposizioni = new javax.swing.JTable();
pnlLogin = new javax.swing.JPanel(); pnlLogin = new javax.swing.JPanel();
btnLogin = new javax.swing.JButton(); btnLogin = new javax.swing.JButton();
txtUsername = new javax.swing.JTextField(); txtUsername = new javax.swing.JTextField();
@ -1314,13 +1319,13 @@ public class PuntoCassa extends JFrame implements ActionListener {
pnlTop.add(pnlAzioni); pnlTop.add(pnlAzioni);
pnlAzioni.setBounds(0, 153, 378, 73); pnlAzioni.setBounds(0, 153, 378, 73);
pnlLista.setBackground(new java.awt.Color(204, 255, 204)); pnlListaProdotti.setBackground(new java.awt.Color(204, 255, 204));
pnlLista.setBorder(javax.swing.BorderFactory.createTitledBorder("Lista")); pnlListaProdotti.setBorder(javax.swing.BorderFactory.createTitledBorder("Lista"));
pnlLista.setLayout(new javax.swing.BoxLayout(pnlLista, javax.swing.BoxLayout.LINE_AXIS)); pnlListaProdotti.setLayout(new javax.swing.BoxLayout(pnlListaProdotti, javax.swing.BoxLayout.LINE_AXIS));
scpLista.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N scpListaProdotti.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
tblLista.setModel(new javax.swing.table.DefaultTableModel( tblListaProdotti.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] { new Object [][] {
{}, {},
{}, {},
@ -1331,13 +1336,13 @@ public class PuntoCassa extends JFrame implements ActionListener {
} }
)); ));
tblLista.setName("jtbl"); // NOI18N tblListaProdotti.setName("jtbl"); // NOI18N
scpLista.setViewportView(tblLista); scpListaProdotti.setViewportView(tblListaProdotti);
pnlLista.add(scpLista); pnlListaProdotti.add(scpListaProdotti);
pnlTop.add(pnlLista); pnlTop.add(pnlListaProdotti);
pnlLista.setBounds(288, 0, 140, 144); pnlListaProdotti.setBounds(288, 0, 140, 144);
pnlProdotti.setBackground(new java.awt.Color(204, 255, 204)); pnlProdotti.setBackground(new java.awt.Color(204, 255, 204));
pnlProdotti.setBorder(javax.swing.BorderFactory.createTitledBorder("Prodotto")); pnlProdotti.setBorder(javax.swing.BorderFactory.createTitledBorder("Prodotto"));
@ -1345,13 +1350,13 @@ public class PuntoCassa extends JFrame implements ActionListener {
pnlTop.add(pnlProdotti); pnlTop.add(pnlProdotti);
pnlProdotti.setBounds(0, 0, 8, 33); pnlProdotti.setBounds(0, 0, 8, 33);
pnlLista1.setBackground(new java.awt.Color(204, 255, 204)); pnlListaComposizioni.setBackground(new java.awt.Color(204, 255, 204));
pnlLista1.setBorder(javax.swing.BorderFactory.createTitledBorder("Lista")); pnlListaComposizioni.setBorder(javax.swing.BorderFactory.createTitledBorder("Lista"));
pnlLista1.setLayout(new javax.swing.BoxLayout(pnlLista1, javax.swing.BoxLayout.LINE_AXIS)); pnlListaComposizioni.setLayout(new javax.swing.BoxLayout(pnlListaComposizioni, javax.swing.BoxLayout.LINE_AXIS));
scpLista1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N scpListaComposizioni.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
tblLista1.setModel(new javax.swing.table.DefaultTableModel( tblListaComposizioni.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] { new Object [][] {
{}, {},
{}, {},
@ -1362,14 +1367,14 @@ public class PuntoCassa extends JFrame implements ActionListener {
} }
)); ));
tblLista1.setName("jtbl"); // NOI18N tblListaComposizioni.setName("jtbl"); // NOI18N
scpLista1.setViewportView(tblLista1); scpListaComposizioni.setViewportView(tblListaComposizioni);
pnlLista1.add(scpLista1); pnlListaComposizioni.add(scpListaComposizioni);
pnlTop.add(pnlLista1); pnlTop.add(pnlListaComposizioni);
pnlLista1.setBounds(288, 0, 140, 144); pnlListaComposizioni.setBounds(288, 0, 140, 144);
pnlLista1.getAccessibleContext().setAccessibleName("Lista1"); pnlListaComposizioni.getAccessibleContext().setAccessibleName("Lista1");
getContentPane().add(pnlTop); getContentPane().add(pnlTop);
pnlTop.setBounds(0, 188, 0, 0); pnlTop.setBounds(0, 188, 0, 0);
@ -1665,14 +1670,14 @@ public class PuntoCassa extends JFrame implements ActionListener {
w = tw - x; w = tw - x;
//h = (int) (25 * th / 100); //h = (int) (25 * th / 100);
h = pnlProdotti.getHeight() / 6 * 2; h = pnlProdotti.getHeight() / 6 * 2;
pnlLista.setLocation(x, y); pnlListaProdotti.setLocation(x, y);
pnlLista.setSize(w, h); pnlListaProdotti.setSize(w, h);
scpLista.setLocation(0, 0); scpListaProdotti.setLocation(0, 0);
scpLista.setSize(w, h); scpListaProdotti.setSize(w, h);
scpLista.setBackground(Color.BLUE); scpListaProdotti.setBackground(Color.BLUE);
tblLista.setLocation(0, 0); tblListaProdotti.setLocation(0, 0);
tblLista.setSize(w, h); tblListaProdotti.setSize(w, h);
tblLista.setShowGrid(true); tblListaProdotti.setShowGrid(true);
int Col1 = (w / 100) * 80; int Col1 = (w / 100) * 80;
MyTableModel model = new MyTableModel(); MyTableModel model = new MyTableModel();
@ -1681,28 +1686,28 @@ public class PuntoCassa extends JFrame implements ActionListener {
Object[][] data = null; Object[][] data = null;
model.setRow(data); model.setRow(data);
tblLista.setModel(model); tblListaProdotti.setModel(model);
tblLista.getColumnModel().getColumn(0).setPreferredWidth(Col1); tblListaProdotti.getColumnModel().getColumn(0).setPreferredWidth(Col1);
tblLista.getColumnModel().getColumn(1).setPreferredWidth(50); tblListaProdotti.getColumnModel().getColumn(1).setPreferredWidth(50);
tblLista.getColumnModel().getColumn(1).setCellRenderer(new DecimalFormatRenderer()); tblListaProdotti.getColumnModel().getColumn(1).setCellRenderer(new DecimalFormatRenderer());
tblLista.getColumnModel().getColumn(2).setPreferredWidth(50); tblListaProdotti.getColumnModel().getColumn(2).setPreferredWidth(50);
tblLista.setVisible(true); tblListaProdotti.setVisible(true);
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ** Panel Lista1 // ** Panel Lista1
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
y = h; y = h;
pnlLista1.setBorder(javax.swing.BorderFactory.createTitledBorder("Composizione")); pnlListaComposizioni.setBorder(javax.swing.BorderFactory.createTitledBorder("Composizione"));
pnlLista1.setLocation(x, y); pnlListaComposizioni.setLocation(x, y);
//pnlLista1.setSize(w, 70); //pnlLista1.setSize(w, 70);
pnlLista1.setSize(w, pnlProdotti.getHeight() / 6); pnlListaComposizioni.setSize(w, pnlProdotti.getHeight() / 6);
scpLista1.setLocation(0, 0); scpListaComposizioni.setLocation(0, 0);
scpLista1.setSize(w, h); scpListaComposizioni.setSize(w, h);
scpLista1.setBackground(Color.BLUE); scpListaComposizioni.setBackground(Color.BLUE);
tblLista1.setLocation(0, 0); tblListaComposizioni.setLocation(0, 0);
tblLista1.setSize(w, h); tblListaComposizioni.setSize(w, h);
tblLista1.setShowGrid(true); tblListaComposizioni.setShowGrid(true);
MyTableModel model1 = new MyTableModel(); MyTableModel model1 = new MyTableModel();
String[] colVassoio = {"Vassoio", "Prezzo"}; String[] colVassoio = {"Vassoio", "Prezzo"};
@ -1710,11 +1715,11 @@ public class PuntoCassa extends JFrame implements ActionListener {
Object[][] data1 = null; Object[][] data1 = null;
model1.setRow(data1); model1.setRow(data1);
tblLista1.setModel(model1); tblListaComposizioni.setModel(model1);
tblLista1.getColumnModel().getColumn(0).setPreferredWidth(Col1); tblListaComposizioni.getColumnModel().getColumn(0).setPreferredWidth(Col1);
tblLista1.getColumnModel().getColumn(1).setPreferredWidth(50); tblListaComposizioni.getColumnModel().getColumn(1).setPreferredWidth(50);
tblLista1.setVisible(true); tblListaComposizioni.setVisible(true);
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ** Panel Cliente // ** Panel Cliente
@ -1733,9 +1738,9 @@ public class PuntoCassa extends JFrame implements ActionListener {
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// ** Panel Conto // ** Panel Conto
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
x = pnlLista.getX();//pnlAzioni.getWidth(); x = pnlListaProdotti.getX();//pnlAzioni.getWidth();
y = pnlLista.getHeight() + pnlLista1.getHeight(); y = pnlListaProdotti.getHeight() + pnlListaComposizioni.getHeight();
w = pnlLista.getWidth(); w = pnlListaProdotti.getWidth();
h = 220;//th-y; h = 220;//th-y;
pnlConto.setLocation(x, y); pnlConto.setLocation(x, y);
@ -1811,7 +1816,19 @@ public class PuntoCassa extends JFrame implements ActionListener {
pulsantiCategoria(id, cmd); pulsantiCategoria(id, cmd);
case "PRODOTTO" -> { case "PRODOTTO" -> {
if (isCassaAperta) { //boolean prenotazionePagata = false;
String idPrenDettaglio = "null";
Object src = e.getSource();
if (src instanceof EventParameters evtParams) {
flagPrenotazionePagata = evtParams.flagPrenotazionePagata;
idPrenDettaglio = evtParams.idPrenDettaglio;
}
//inserisci i prodotti se la cassa è aperta e
//non c'è una prenotazione da gestire oppure
//c'è una prenotazione e si stanno inserendo i prodotti in lista (idPrenDettaglio viene valorizzato in inserisciPrenotazioni())
if (isCassaAperta &&
(idPrenotazione == 0 || !idPrenDettaglio.equals("null"))) {
sql = "SELECT " sql = "SELECT "
+ "prodotti.id as idProdotto," + "prodotti.id as idProdotto,"
+ "prodotti.nome, " + "prodotti.nome, "
@ -1825,6 +1842,8 @@ public class PuntoCassa extends JFrame implements ActionListener {
+ "where prodotti.id = " + id + " and Tariffe.id_fascia=" + idProfiloTariffario; + "where prodotti.id = " + id + " and Tariffe.id_fascia=" + idProfiloTariffario;
try { try {
//spengo altri togglebutton //spengo altri togglebutton
for (Integer y = 0; y < this.pnlProdotti.getComponentCount(); y++) { for (Integer y = 0; y < this.pnlProdotti.getComponentCount(); y++) {
JToggleButton bt = (JToggleButton) this.pnlProdotti.getComponent(y); JToggleButton bt = (JToggleButton) this.pnlProdotti.getComponent(y);
@ -1843,7 +1862,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword);
st = dbConnection.createStatement(); st = dbConnection.createStatement();
rs = st.executeQuery(sql); rs = st.executeQuery(sql);
MyTableModel model = (MyTableModel) tblLista.getModel(); MyTableModel model = (MyTableModel) tblListaProdotti.getModel();
while (rs.next()) { while (rs.next()) {
Double prezzo = 0.0; Double prezzo = 0.0;
@ -1870,16 +1889,19 @@ public class PuntoCassa extends JFrame implements ActionListener {
} }
} }
//21-12-8<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //21-12-8<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
model.addRow(new Object[]{rs.getString("nome"), prezzo, punti, rs.getLong("idProdotto"), prezzo, rs.getLong("id_Categoria")}); model.addRow(new Object[]{rs.getString("nome"), prezzo, punti, rs.getLong("idProdotto"), prezzo, rs.getLong("id_Categoria"), idPrenDettaglio});
} }
if (model.getRowCount() > 0) { if (model.getRowCount() > 0) {
tblLista.setRowSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); tblListaProdotti.setRowSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1);
} }
tblLista.setModel(model); tblListaProdotti.setModel(model);
controllaCompleti(model); if(idPrenotazione == 0)
controllaCompleti(model, "null");
else
controllaCompleti(model, idPrenotazione.toString());
controllaExtra(model); controllaExtra(model);
sommaColonne(model); sommaColonne(model, flagPrenotazionePagata);
//inizio 21-12-18<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //inizio 21-12-18<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
if (jbtnChiudi.isEnabled()) { if (jbtnChiudi.isEnabled()) {
@ -1908,6 +1930,9 @@ public class PuntoCassa extends JFrame implements ActionListener {
System.out.println(ex.getMessage()); System.out.println(ex.getMessage());
} }
} }
else if(idPrenotazione > 0 && idPrenDettaglio.equals("null")){
JOptionPane.showMessageDialog(this, "Non è possibile modificare prodotti e composizioni se è presente una prenotazione collegata alla tessera");
}
} }
default -> { default -> {
@ -1971,25 +1996,30 @@ public class PuntoCassa extends JFrame implements ActionListener {
/** /**
* funzione che calcola i prezzi dei prodotti e il totale in base alla * funzione che calcola i prezzi dei prodotti e il totale in base alla
* fascia dello studente oppure utilizza la fascia di default * fascia dello studente oppure utilizza la fascia di default.
* Se flagPrenotazionePagata = true vuol dire che non va modificato il saldo
* residuo della tessera perchè la somma delle colonne viene richiamata
* a seguito della verifica di una prenotazione pagata
* *
* @param model * @param model
* @param flagPrenotazionePagata
*/ */
private void sommaColonne(MyTableModel model) { private void sommaColonne(MyTableModel model, boolean flagPrenotazionePagata) {
Double t = model.somma(colImporto); Double t = model.somma(colImporto);
MyTableModel model2 = (MyTableModel) tblLista1.getModel(); MyTableModel model2 = (MyTableModel) tblListaComposizioni.getModel();
if (model2.getRowCount() > 0) { if (model2.getRowCount() > 0) {
t = t + model2.somma(1); t = t + model2.somma(1);
} }
DecimalFormat df2 = new DecimalFormat("#,###,###,##0.00"); DecimalFormat df2 = new DecimalFormat("#,###,###,##0.00");
if(!flagPrenotazionePagata)
txtTotaleCassa.setText("" + df2.format(t)); txtTotaleCassa.setText("" + df2.format(t));
int p = model.sommaInt(2); int p = model.sommaInt(2);
txtTotalePunti.setText("Punti " + p); txtTotalePunti.setText("Punti " + p);
//if(idModoPagamento==0L){ //if(idModoPagamento==0L){
if (cercaTestoModoPagamento().equalsIgnoreCase("A scalare")) { if (cercaTestoModoPagamento().equalsIgnoreCase("A scalare") && !flagPrenotazionePagata) {
Double saldoCarta = 0.0; Double saldoCarta = 0.0;
if (lblSaldo.getText().trim().length() > 0) { if (lblSaldo.getText().trim().length() > 0) {
String saldo = lblSaldo.getText().replace("", "").trim().replace(".", ""); String saldo = lblSaldo.getText().replace("", "").trim().replace(".", "");
@ -2031,12 +2061,12 @@ public class PuntoCassa extends JFrame implements ActionListener {
} }
//02/09/2021 //02/09/2021
private void controllaCompleti(MyTableModel model) { private void controllaCompleti(MyTableModel model, String idPrenotazione) {
if (passaggiEsauritiNoComposizione == true) { if (passaggiEsauritiNoComposizione == true) {
return; return;
} }
MyTableModel model1 = (MyTableModel) tblLista1.getModel(); MyTableModel model1 = (MyTableModel) tblListaComposizioni.getModel();
//clearTable(model1); //clearTable(model1);
model1.clearTable(); model1.clearTable();
Boolean composizionePresente = false; Boolean composizionePresente = false;
@ -2053,15 +2083,15 @@ public class PuntoCassa extends JFrame implements ActionListener {
if (gratuitaResidue > 0) {//Gratuita_ResidueProg if (gratuitaResidue > 0) {//Gratuita_ResidueProg
//clearTable(model1); //clearTable(model1);
model1.clearTable(); model1.clearTable();
model1.addRow(new Object[]{model.getValueAt(i, 0), 0.00, model.getValueAt(i, 3)}); model1.addRow(new Object[]{model.getValueAt(i, 0), 0.00, model.getValueAt(i, 3), idPrenotazione});
} else if (flagBonus == 1 && bonusResidui > 0) { } else if (flagBonus == 1 && bonusResidui > 0) {
//clearTable(model1); //clearTable(model1);
model1.clearTable(); model1.clearTable();
model1.addRow(new Object[]{model.getValueAt(i, 0), 0.00, model.getValueAt(i, 3)}); model1.addRow(new Object[]{model.getValueAt(i, 0), 0.00, model.getValueAt(i, 3), idPrenotazione});
} else { } else {
//clearTable(model1); //clearTable(model1);
model1.clearTable(); model1.clearTable();
model1.addRow(new Object[]{model.getValueAt(i, 0), model.getValueAt(i, 1), model.getValueAt(i, 3)}); model1.addRow(new Object[]{model.getValueAt(i, 0), model.getValueAt(i, 1), model.getValueAt(i, 3), idPrenotazione});
} }
model.setValueAt(0.0, i, colImporto); model.setValueAt(0.0, i, colImporto);
@ -2092,11 +2122,11 @@ public class PuntoCassa extends JFrame implements ActionListener {
//clearTable(model1); //clearTable(model1);
model1.clearTable(); model1.clearTable();
if (gratuitaResidue > 0) {//Gratuita_ResidueProg if (gratuitaResidue > 0) {//Gratuita_ResidueProg
model1.addRow(new Object[]{nomeVassoio, 0.00, idVassoio}); model1.addRow(new Object[]{nomeVassoio, 0.00, idVassoio, idPrenotazione});
} else if (flagBonus == 1 && bonusResidui > 0) { } else if (flagBonus == 1 && bonusResidui > 0) {
model1.addRow(new Object[]{nomeVassoio, 0.00, idVassoio}); model1.addRow(new Object[]{nomeVassoio, 0.00, idVassoio, idPrenotazione});
} else { } else {
model1.addRow(new Object[]{nomeVassoio, prezzo, idVassoio}); model1.addRow(new Object[]{nomeVassoio, prezzo, idVassoio, idPrenotazione});
} }
//azzero elemento appena inserito se fa parte di una composizione //azzero elemento appena inserito se fa parte di una composizione
@ -2384,10 +2414,9 @@ public class PuntoCassa extends JFrame implements ActionListener {
// ** Quando viene chiusa la form esce dall'applicazione // ** Quando viene chiusa la form esce dall'applicazione
// ========================================================================== // ==========================================================================
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
Object[] options = {"Si", "No"};
Object selectedValue = JOptionPane.showOptionDialog(this, "Confermi chiusura programma?", "Attenzione", Object selectedValue = JOptionPane.showOptionDialog(this, "Confermi chiusura programma?", "Attenzione",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[1]); JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, siNoOptions, siNoOptions[1]);
if (Integer.parseInt(selectedValue.toString()) == 0) { if (Integer.parseInt(selectedValue.toString()) == 0) {
Utils.myInsert("UPDATE PARAMETRI set valore='NO' where chiave='FlagDownloadInCorso'", this); Utils.myInsert("UPDATE PARAMETRI set valore='NO' where chiave='FlagDownloadInCorso'", this);
@ -2746,17 +2775,17 @@ public class PuntoCassa extends JFrame implements ActionListener {
private void jbtnSuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSuActionPerformed private void jbtnSuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSuActionPerformed
// TODO add your handling code here: // TODO add your handling code here:
if (tblLista.getSelectedRow() > 0) { if (tblListaProdotti.getSelectedRow() > 0) {
tblLista.setRowSelectionInterval(tblLista.getSelectedRow() - 1, tblLista.getSelectedRow() - 1); tblListaProdotti.setRowSelectionInterval(tblListaProdotti.getSelectedRow() - 1, tblListaProdotti.getSelectedRow() - 1);
tblLista.scrollRectToVisible(new Rectangle(tblLista.getCellRect(tblLista.getSelectedRow(), 0, true))); tblListaProdotti.scrollRectToVisible(new Rectangle(tblListaProdotti.getCellRect(tblListaProdotti.getSelectedRow(), 0, true)));
} }
}//GEN-LAST:event_jbtnSuActionPerformed }//GEN-LAST:event_jbtnSuActionPerformed
private void jbtnDuplicaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnDuplicaActionPerformed private void jbtnDuplicaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnDuplicaActionPerformed
// TODO add your handling code here: // TODO add your handling code here:
if (tblLista.getSelectedRow() >= 0) { if (tblListaProdotti.getSelectedRow() >= 0) {
MyTableModel model = (MyTableModel) tblLista.getModel(); MyTableModel model = (MyTableModel) tblListaProdotti.getModel();
Object row[] = model.getRow(tblLista.getSelectedRow()); Object row[] = model.getRow(tblListaProdotti.getSelectedRow());
Boolean isComposizione = false; Boolean isComposizione = false;
if (Long.parseLong(row[5].toString()) == 0L) { if (Long.parseLong(row[5].toString()) == 0L) {
isComposizione = true; isComposizione = true;
@ -2767,21 +2796,21 @@ public class PuntoCassa extends JFrame implements ActionListener {
} else { } else {
model.addRow(row); model.addRow(row);
tblLista.setRowSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); tblListaProdotti.setRowSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1);
tblLista.setModel(model); tblListaProdotti.setModel(model);
controllaCompleti(model); controllaCompleti(model, null);
controllaExtra(model); controllaExtra(model);
sommaColonne(model); sommaColonne(model, flagPrenotazionePagata);
} }
} }
}//GEN-LAST:event_jbtnDuplicaActionPerformed }//GEN-LAST:event_jbtnDuplicaActionPerformed
private void jbtnGiuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnGiuActionPerformed private void jbtnGiuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnGiuActionPerformed
// TODO add your handling code here: // TODO add your handling code here:
if (tblLista.getSelectedRow() < tblLista.getRowCount() - 1) { if (tblListaProdotti.getSelectedRow() < tblListaProdotti.getRowCount() - 1) {
tblLista.setRowSelectionInterval(tblLista.getSelectedRow() + 1, tblLista.getSelectedRow() + 1); tblListaProdotti.setRowSelectionInterval(tblListaProdotti.getSelectedRow() + 1, tblListaProdotti.getSelectedRow() + 1);
tblLista.scrollRectToVisible(new Rectangle(tblLista.getCellRect(tblLista.getSelectedRow(), 0, true))); tblListaProdotti.scrollRectToVisible(new Rectangle(tblListaProdotti.getCellRect(tblListaProdotti.getSelectedRow(), 0, true)));
} }
}//GEN-LAST:event_jbtnGiuActionPerformed }//GEN-LAST:event_jbtnGiuActionPerformed
@ -2799,16 +2828,20 @@ public class PuntoCassa extends JFrame implements ActionListener {
}//GEN-LAST:event_jbtnStampaActionPerformed }//GEN-LAST:event_jbtnStampaActionPerformed
private void cancellaComposizioni() { private void cancellaComposizioni() {
try { try {
MyTableModel model1 = (MyTableModel) tblLista1.getModel(); MyTableModel model1 = (MyTableModel) tblListaComposizioni.getModel();
//clearTable(model1); //clearTable(model1);
model1.clearTable(); model1.clearTable();
} catch (Exception e) { } catch (Exception e) {
} }
} }
private void jbtnEliminaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnEliminaActionPerformed private void jbtnEliminaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnEliminaActionPerformed
if(idPrenotazione > 0){
JOptionPane.showMessageDialog(this, "Non è possibile modificare prodotti e composizioni se è presente una prenotazione collegata alla tessera");
}
else {
cancellaComposizioni(); cancellaComposizioni();
MyTableModel model = (MyTableModel) tblLista.getModel(); MyTableModel model = (MyTableModel) tblListaProdotti.getModel();
Integer riga = tblLista.getSelectedRow(); Integer riga = tblListaProdotti.getSelectedRow();
if (riga >= 0) { if (riga >= 0) {
model.deleteRow(riga); model.deleteRow(riga);
//ripristino i prezzi //ripristino i prezzi
@ -2816,17 +2849,17 @@ public class PuntoCassa extends JFrame implements ActionListener {
model.setValueAt(model.getValueAt(i, colImporto2), i, colImporto); model.setValueAt(model.getValueAt(i, colImporto2), i, colImporto);
} }
//doLayout(); //doLayout();
if (tblLista.getRowCount() > 0) { if (tblListaProdotti.getRowCount() > 0) {
if (riga > 0) { if (riga > 0) {
tblLista.setRowSelectionInterval(riga - 1, riga - 1); tblListaProdotti.setRowSelectionInterval(riga - 1, riga - 1);
} else { } else {
tblLista.setRowSelectionInterval(0, 0); tblListaProdotti.setRowSelectionInterval(0, 0);
} }
} }
controllaCompleti(model); controllaCompleti(model, null);
controllaExtra(model); controllaExtra(model);
sommaColonne(model); sommaColonne(model, flagPrenotazionePagata);
//spengo altri togglebutton //spengo altri togglebutton
for (Integer y = 0; y < this.pnlProdotti.getComponentCount(); y++) { for (Integer y = 0; y < this.pnlProdotti.getComponentCount(); y++) {
@ -2843,7 +2876,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
} }
doLayout(); doLayout();
} }
}
}//GEN-LAST:event_jbtnEliminaActionPerformed }//GEN-LAST:event_jbtnEliminaActionPerformed
private void jbtnChiudiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnChiudiActionPerformed private void jbtnChiudiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnChiudiActionPerformed
@ -2856,7 +2889,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
private boolean verificaPrenotazioni() { private boolean verificaPrenotazioni() {
boolean ok = true; boolean ok = true;
if (idTessera > 0L && idPrenotazione > 0L) { if (idTessera > 0L && idPrenotazione > 0L) {
MyTableModel model = (MyTableModel) tblLista.getModel(); MyTableModel model = (MyTableModel) tblListaProdotti.getModel();
StringBuilder elencoIdProdotti = new StringBuilder(); StringBuilder elencoIdProdotti = new StringBuilder();
for (int i = model.getRowCount() - 1; i >= 0; i--) { for (int i = model.getRowCount() - 1; i >= 0; i--) {
Long idCateg = Long.valueOf(model.getValueAt(i, colCategoria).toString()); Long idCateg = Long.valueOf(model.getValueAt(i, colCategoria).toString());
@ -2940,9 +2973,9 @@ public class PuntoCassa extends JFrame implements ActionListener {
private void jbtnEsciActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnEsciActionPerformed private void jbtnEsciActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnEsciActionPerformed
Object[] options = {"Si", "No"};
Object selectedValue = JOptionPane.showOptionDialog(this, "Confermi chiusura sessione?", "Attenzione", Object selectedValue = JOptionPane.showOptionDialog(this, "Confermi chiusura sessione?", "Attenzione",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, siNoOptions, siNoOptions[0]);
if (Integer.parseInt(selectedValue.toString()) == 0) { if (Integer.parseInt(selectedValue.toString()) == 0) {
pnlErrore.setVisible(false); pnlErrore.setVisible(false);
pnlLogin.setVisible(true); pnlLogin.setVisible(true);
@ -3034,9 +3067,8 @@ public class PuntoCassa extends JFrame implements ActionListener {
try { try {
Boolean aggiorna = false; Boolean aggiorna = false;
if (messaggio) { if (messaggio) {
Object[] options = {"Si", "No"};
Object selectedValue = JOptionPane.showOptionDialog(this, "Confermi aggiornamento del database locale?", "Attenzione", Object selectedValue = JOptionPane.showOptionDialog(this, "Confermi aggiornamento del database locale?", "Attenzione",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, siNoOptions, siNoOptions[0]);
if (Integer.parseInt(selectedValue.toString()) != 0) { if (Integer.parseInt(selectedValue.toString()) != 0) {
return; return;
} else { } else {
@ -3133,23 +3165,36 @@ public class PuntoCassa extends JFrame implements ActionListener {
}//GEN-LAST:event_btnImpostaClienteActionPerformed }//GEN-LAST:event_btnImpostaClienteActionPerformed
private void jbtnAnnullaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAnnullaActionPerformed private void jbtnAnnullaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAnnullaActionPerformed
MyTableModel model = (MyTableModel) tblLista.getModel(); if(idPrenotazione > 0)
{
Object selectedValue = JOptionPane.showOptionDialog(this, "Desideri bypassare la prenotazione?", "Attenzione",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, siNoOptions, siNoOptions[0]);
if (Integer.parseInt(selectedValue.toString()) == 0) {
annulla();
doLayout();
idPrenotazione = 0L;
flagPrenotazionePagata = false;
}
//JOptionPane.showMessageDialog(this, "Non è possibile modificare prodotti e composizioni se è presente una prenotazione collegata alla tessera");
}
else
{
MyTableModel model = (MyTableModel) tblListaProdotti.getModel();
if (model.getRowCount() > 0) { if (model.getRowCount() > 0) {
Object[] options = {"Si", "No"};
Object selectedValue = JOptionPane.showOptionDialog(this, "Desideri annullare tutte le righe?", "Attenzione", Object selectedValue = JOptionPane.showOptionDialog(this, "Desideri annullare tutte le righe?", "Attenzione",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, siNoOptions, siNoOptions[0]);
if (Integer.parseInt(selectedValue.toString()) == 0) { if (Integer.parseInt(selectedValue.toString()) == 0) {
annulla(); annulla();
doLayout(); doLayout();
} }
} }
}
}//GEN-LAST:event_jbtnAnnullaActionPerformed }//GEN-LAST:event_jbtnAnnullaActionPerformed
private void annulla() { private void annulla() {
try { try {
MyTableModel model = (MyTableModel) tblLista.getModel(); MyTableModel model = (MyTableModel) tblListaProdotti.getModel();
MyTableModel model1 = (MyTableModel) tblLista1.getModel(); MyTableModel model1 = (MyTableModel) tblListaComposizioni.getModel();
//clearTable(model);
//clearTable(model1);
model.clearTable(); model.clearTable();
model1.clearTable(); model1.clearTable();
jbtnSu.setEnabled(false); jbtnSu.setEnabled(false);
@ -3157,7 +3202,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
jbtnElimina.setEnabled(false); jbtnElimina.setEnabled(false);
jbtnAnnulla.setEnabled(false); jbtnAnnulla.setEnabled(false);
jbtnDuplica.setEnabled(false); jbtnDuplica.setEnabled(false);
sommaColonne(model); sommaColonne(model, flagPrenotazionePagata);
if (idTessera == 0L) { if (idTessera == 0L) {
jbtnChiudi.setEnabled(false); jbtnChiudi.setEnabled(false);
@ -3340,8 +3385,8 @@ public class PuntoCassa extends JFrame implements ActionListener {
jTBP3.setEnabled(true); jTBP3.setEnabled(true);
selezionaTipoPagamento(0); selezionaTipoPagamento(0);
MyTableModel modelX = (MyTableModel) tblLista.getModel(); MyTableModel modelX = (MyTableModel) tblListaProdotti.getModel();
sommaColonne(modelX); sommaColonne(modelX, flagPrenotazionePagata);
} catch (Exception ex) { } catch (Exception ex) {
LogManager.getLogger(PuntoCassa.class).error(ex); LogManager.getLogger(PuntoCassa.class).error(ex);
@ -3437,15 +3482,23 @@ public class PuntoCassa extends JFrame implements ActionListener {
DecimalFormat df2 = new DecimalFormat("#,###,###,##0.00"); DecimalFormat df2 = new DecimalFormat("#,###,###,##0.00");
lblSaldo.setText("" + df2.format(saldo)); lblSaldo.setText("" + df2.format(saldo));
//24-01-2020-------------------------- //l'aggiornamento del residuo va fatto solo se non c'è una prenotazione in corso
MyTableModel model = (MyTableModel) tblLista.getModel(); //oppure se la prenotazione in corso non risulta pagata, altrimenti il residuo
//resta pari al saldo della tessera
if(idPrenotazione == 0 || !flagPrenotazionePagata){
MyTableModel model = (MyTableModel) tblListaProdotti.getModel();
Double t = model.somma(colImporto); Double t = model.somma(colImporto);
MyTableModel model2 = (MyTableModel) tblLista1.getModel(); MyTableModel model2 = (MyTableModel) tblListaComposizioni.getModel();
if (model2.getRowCount() > 0) { if (model2.getRowCount() > 0) {
t = t + model2.somma(1); t = t + model2.somma(1);
} }
//--------------------------- //---------------------------
lblResiduo.setText("" + df2.format(saldo - t)); lblResiduo.setText("" + df2.format(saldo - t));
}
else {
lblResiduo.setText("" + df2.format(saldo));
}
lblPunti.setText(punti); lblPunti.setText(punti);
String tipo = cercaTestoModoPagamento(); String tipo = cercaTestoModoPagamento();
lblTipoPagamento.setText(tipo); lblTipoPagamento.setText(tipo);
@ -3571,10 +3624,11 @@ public class PuntoCassa extends JFrame implements ActionListener {
} }
} }
private void chiudi() { private void chiudi() {
//04-02-2019--------------------------------------------- //04-02-2019---------------------------------------------
MyTableModel model = (MyTableModel) tblLista.getModel(); MyTableModel model = (MyTableModel) tblListaProdotti.getModel();
if (model.getRowCount() > 0) { if (model.getRowCount() > 0) {
String numTessera = jTxtTessera.getText(); String numTessera = jTxtTessera.getText();
@ -3660,7 +3714,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
//09-05-2019 //09-05-2019
String composizione = Utils.spaziBianchi("", 20, false); String composizione = Utils.spaziBianchi("", 20, false);
MyTableModel model2 = (MyTableModel) tblLista1.getModel(); MyTableModel model2 = (MyTableModel) tblListaComposizioni.getModel();
for (int i = 0; i < model2.getRowCount(); i++) { for (int i = 0; i < model2.getRowCount(); i++) {
String completo = model2.getValueAt(i, 0).toString(); String completo = model2.getValueAt(i, 0).toString();
String pasto = ""; String pasto = "";
@ -3705,13 +3759,13 @@ public class PuntoCassa extends JFrame implements ActionListener {
String vassoio = "1"; String vassoio = "1";
Utils.myInsert("Insert into Acquisti " Utils.myInsert("Insert into Acquisti "
+ "(id,id_Tessera,id_Prodotto,id_Punto_Cassa,Data,Importo,Punti," + "(id,id_Tessera,id_Prodotto,id_Punto_Cassa,Data,Importo,Punti,"
+ "Num_Progressivo,id_Tipo_Pagamento,flag_in_vassoio,id_Turno,flag_asporto,flag_passaggio_tessera)" + "Num_Progressivo,id_Tipo_Pagamento,flag_in_vassoio,id_Turno,flag_asporto,flag_passaggio_tessera, id_pren_dettaglio)"
+ "values(-1," + tessera + "," + model.getValueAt(i, colIDProdotto) + "," + "values(-1," + tessera + "," + model.getValueAt(i, colIDProdotto) + ","
//+ idPuntoCassa + "," + formattaDataOra(adesso) + "," //+ idPuntoCassa + "," + formattaDataOra(adesso) + ","
+ idPuntoCassa + "," + formatLocalDateTime(adesso) + "," + idPuntoCassa + "," + formatLocalDateTime(adesso) + ","
+ model.getValueAt(i, colImporto) + "," + model.getValueAt(i, colPunti) + "," + model.getValueAt(i, colImporto) + "," + model.getValueAt(i, colPunti) + ","
+ progressivo + "," + idModoPagamento + "," + vassoio + "," + idTurno + "," + progressivo + "," + idModoPagamento + "," + vassoio + "," + idTurno + ","
+ flagAsporto + "," + flagPassaggioTessera + ")", + flagAsporto + "," + flagPassaggioTessera + "," + model.getValueAt(i, colIdPrenDettaglio) + ")",
this); this);
aggiornaProgressivoPagamentiTurno(Double.valueOf(model.getValueAt(i, colImporto).toString())); aggiornaProgressivoPagamentiTurno(Double.valueOf(model.getValueAt(i, colImporto).toString()));
@ -3733,19 +3787,21 @@ public class PuntoCassa extends JFrame implements ActionListener {
Utils.myInsert("Insert into Acquisti " Utils.myInsert("Insert into Acquisti "
+ "(id,id_Tessera,id_Prodotto,id_Punto_Cassa,Data,Importo,Punti,Num_Progressivo,id_Tipo_Pagamento," + "(id,id_Tessera,id_Prodotto,id_Punto_Cassa,Data,Importo,Punti,Num_Progressivo,id_Tipo_Pagamento,"
+ "id_Turno,flag_gratuita,flag_bonus,flag_asporto,flag_passaggio_tessera)" + "id_Turno,flag_gratuita,flag_bonus,flag_asporto,flag_passaggio_tessera, id_pren_dettaglio)"
+ "values(-1," + tessera + "," + model2.getValueAt(i, 2) + "," + idPuntoCassa + "," + "values(-1," + tessera + "," + model2.getValueAt(i, 2) + "," + idPuntoCassa + ","
+ //formattaDataOra(adesso) + "," + model2.getValueAt(i, 1) + ",0," + progressivo + "," + + //formattaDataOra(adesso) + "," + model2.getValueAt(i, 1) + ",0," + progressivo + "," +
formatLocalDateTime(adesso) + "," + model2.getValueAt(i, 1) + ",0," + progressivo + "," formatLocalDateTime(adesso) + ","
+ model2.getValueAt(i, 1)
+ ",0," + progressivo + ","
+ idModoPagamento + "," + idTurno + "," + flagGratuita + "," + flagBonus + "," + idModoPagamento + "," + idTurno + "," + flagGratuita + "," + flagBonus + ","
+ flagAsporto + "," + flagPassaggioTessera + ")", + flagAsporto + "," + flagPassaggioTessera + "," + model2.getValueAt(i, colIdPrenotazione) + ")",
this); this);
aggiornaProgressivoPagamentiTurno(Double.valueOf(model2.getValueAt(i, 1).toString())); aggiornaProgressivoPagamentiTurno(Double.valueOf(model2.getValueAt(i, 1).toString()));
model2.deleteRow(i); model2.deleteRow(i);
spiaProgressivo = true; spiaProgressivo = true;
} }
} else { } /*else {
StringBuilder elencoIdProdotti = new StringBuilder(); StringBuilder elencoIdProdotti = new StringBuilder();
for (int i = model.getRowCount() - 1; i >= 0; i--) { for (int i = model.getRowCount() - 1; i >= 0; i--) {
Long idCateg = Long.valueOf(model.getValueAt(i, colCategoria).toString()); Long idCateg = Long.valueOf(model.getValueAt(i, colCategoria).toString());
@ -3753,12 +3809,12 @@ public class PuntoCassa extends JFrame implements ActionListener {
//04/03/2022 non e possibile acquistare prodotti che non siano partedi una composizione //04/03/2022 non e possibile acquistare prodotti che non siano partedi una composizione
String vassoio = "1"; String vassoio = "1";
Utils.myInsert("Insert into Acquisti (id,id_Prodotto,id_Punto_Cassa,Data,Importo,Punti,Num_Progressivo,id_Tipo_Pagamento," Utils.myInsert("Insert into Acquisti (id,id_Prodotto,id_Punto_Cassa,Data,Importo,Punti,Num_Progressivo,id_Tipo_Pagamento,"
+ "flag_in_vassoio,id_Turno,flag_asporto,flag_passaggio_tessera)values(-1," + "flag_in_vassoio,id_Turno,flag_asporto,flag_passaggio_tessera, id_pren_dettaglio)values(-1,"
//+ model.getValueAt(i, colIDProdotto) + "," + idPuntoCassa + "," + formattaDataOra(adesso) + "," //+ model.getValueAt(i, colIDProdotto) + "," + idPuntoCassa + "," + formattaDataOra(adesso) + ","
+ model.getValueAt(i, colIDProdotto) + "," + idPuntoCassa + "," + formatLocalDateTime(adesso) + "," + model.getValueAt(i, colIDProdotto) + "," + idPuntoCassa + "," + formatLocalDateTime(adesso) + ","
+ model.getValueAt(i, colImporto) + "," + model.getValueAt(i, colPunti) + model.getValueAt(i, colImporto) + "," + model.getValueAt(i, colPunti)
+ "," + progressivo + "," + idModoPagamento + "," + vassoio + "," + idTurno + "," + "," + progressivo + "," + idModoPagamento + "," + vassoio + "," + idTurno + ","
+ flagAsporto + "," + flagPassaggioTessera + ")", + flagAsporto + "," + flagPassaggioTessera + "," + "null" + ")",
this); this);
aggiornaProgressivoPagamentiTurno(Double.valueOf(model.getValueAt(i, colImporto).toString())); aggiornaProgressivoPagamentiTurno(Double.valueOf(model.getValueAt(i, colImporto).toString()));
@ -3781,11 +3837,11 @@ public class PuntoCassa extends JFrame implements ActionListener {
} }
Utils.myInsert("Insert into Acquisti (id,id_Prodotto,id_Punto_Cassa,Data,Importo,Punti,Num_Progressivo,id_Tipo_Pagamento," Utils.myInsert("Insert into Acquisti (id,id_Prodotto,id_Punto_Cassa,Data,Importo,Punti,Num_Progressivo,id_Tipo_Pagamento,"
+ "id_Turno,flag_gratuita,flag_bonus,flag_asporto,flag_passaggio_tessera)values(-1," + "id_Turno,flag_gratuita,flag_bonus,flag_asporto,flag_passaggio_tessera, id_pren_dettaglio)values(-1,"
//+ model2.getValueAt(i, 2) + "," + idPuntoCassa + "," + formattaDataOra(adesso) + "," //+ model2.getValueAt(i, 2) + "," + idPuntoCassa + "," + formattaDataOra(adesso) + ","
+ model2.getValueAt(i, 2) + "," + idPuntoCassa + "," + formatLocalDateTime(adesso) + "," + model2.getValueAt(i, 2) + "," + idPuntoCassa + "," + formatLocalDateTime(adesso) + ","
+ model2.getValueAt(i, 1) + ",0," + progressivo + "," + idModoPagamento + "," + idTurno + model2.getValueAt(i, 1) + ",0," + progressivo + "," + idModoPagamento + "," + idTurno
+ "," + flagGratuita + "," + flagBonusPerInsert + "," + flagAsporto + "," + flagPassaggioTessera + ")", + "," + flagGratuita + "," + flagBonusPerInsert + "," + flagAsporto + "," + flagPassaggioTessera + "," + "null" + ")",
this); this);
aggiornaProgressivoPagamentiTurno(Double.valueOf(model2.getValueAt(i, 1).toString())); aggiornaProgressivoPagamentiTurno(Double.valueOf(model2.getValueAt(i, 1).toString()));
model2.deleteRow(i); model2.deleteRow(i);
@ -3793,7 +3849,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
} }
} }*/
//aggiorno progressivi------------- //aggiorno progressivi-------------
if (spiaProgressivo) { if (spiaProgressivo) {
@ -3845,6 +3901,13 @@ public class PuntoCassa extends JFrame implements ActionListener {
} }
/**
* Verifica se i prodotti selezionati differiscono da quelli presenti
* nella prenotazione collegata alla tessera. L'utente può scegliere di
* modificare i prodotti, oppure di azzerare la lista
* @param elencoIdProdotto
* @return
*/
private boolean controllaDiscrepanzePrenotazioni(String elencoIdProdotto) { private boolean controllaDiscrepanzePrenotazioni(String elencoIdProdotto) {
boolean ok = true; boolean ok = true;
if (elencoIdProdotto.length() > 0) { if (elencoIdProdotto.length() > 0) {
@ -3872,14 +3935,14 @@ public class PuntoCassa extends JFrame implements ActionListener {
} }
} }
Object[] options = {"Si", "No"};
Object selectedValue = JOptionPane.showOptionDialog(this, Object selectedValue = JOptionPane.showOptionDialog(this,
"I prodotti selezionati sono diversi dai prenotati!\nVuoi proseguire?", "Prenotazione", "I prodotti selezionati sono diversi dai prenotati!\nVuoi proseguire?", "Prenotazione",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, null); JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, siNoOptions, null);
if (Integer.parseInt(selectedValue.toString()) == 1) { if (Integer.parseInt(selectedValue.toString()) == 1) {
azzeraDopoStorno(); azzeraDopoStorno();
return false; return false;
} }
} }
} }
return ok; return ok;
@ -3930,8 +3993,8 @@ public class PuntoCassa extends JFrame implements ActionListener {
private void azzera() { private void azzera() {
try { try {
MyTableModel model = (MyTableModel) tblLista.getModel(); MyTableModel model = (MyTableModel) tblListaProdotti.getModel();
MyTableModel model1 = (MyTableModel) tblLista1.getModel(); MyTableModel model1 = (MyTableModel) tblListaComposizioni.getModel();
model.clearTable(); model.clearTable();
model1.clearTable(); model1.clearTable();
} catch (Exception e) { } catch (Exception e) {
@ -3939,6 +4002,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
messaggioSaldoUnaVolta = false; messaggioSaldoUnaVolta = false;
idTessera = 0L; idTessera = 0L;
idPrenotazione = 0L; idPrenotazione = 0L;
flagPrenotazionePagata = false;
idProfiloTariffario = 0L; idProfiloTariffario = 0L;
setModoPagamento(modoPagamentoDefault); setModoPagamento(modoPagamentoDefault);
isCassaAperta = false; isCassaAperta = false;
@ -4118,7 +4182,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
if (scadenzaTessera.after(now) && idStato != 2) { if (scadenzaTessera.after(now) && idStato != 2) {
MyTableModel model = (MyTableModel) tblLista.getModel(); MyTableModel model = (MyTableModel) tblListaProdotti.getModel();
String modoPagamento = cercaTestoModoPagamento(); String modoPagamento = cercaTestoModoPagamento();
lblCategoria.setText(dati[0]); lblCategoria.setText(dati[0]);
@ -4166,9 +4230,9 @@ public class PuntoCassa extends JFrame implements ActionListener {
forzaPrezzi(model); forzaPrezzi(model);
} }
controllaCompleti(model); controllaCompleti(model, null);
controllaExtra(model); controllaExtra(model);
sommaColonne(model); sommaColonne(model, flagPrenotazionePagata);
stoCalcolando = true; stoCalcolando = true;
//comprende la verifica del saldo //comprende la verifica del saldo
@ -4234,9 +4298,8 @@ public class PuntoCassa extends JFrame implements ActionListener {
Long numeroPassaggi = Utils.mySelectInteger(queryPassaggi, "NRec", this); Long numeroPassaggi = Utils.mySelectInteger(queryPassaggi, "NRec", this);
//fine---- //fine----
if (flagEsegueStorni && numeroPassaggi > 0) { if (flagEsegueStorni && numeroPassaggi > 0) {
Object[] options = {"Si", "No"};
Object selectedValue = JOptionPane.showOptionDialog(this, "N° passaggi giornalieri esauriti. Non è possibile usufruire del pasto!\nSi desidera effettuare uno storno per un pasto erroneamente addebitato?", "Attenzione", Object selectedValue = JOptionPane.showOptionDialog(this, "N° passaggi giornalieri esauriti. Non è possibile usufruire del pasto!\nSi desidera effettuare uno storno per un pasto erroneamente addebitato?", "Attenzione",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[1]); JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, siNoOptions, siNoOptions[1]);
if (Integer.parseInt(selectedValue.toString()) == 0) { if (Integer.parseInt(selectedValue.toString()) == 0) {
apriStorno(true); apriStorno(true);
} else { } else {
@ -4257,9 +4320,8 @@ public class PuntoCassa extends JFrame implements ActionListener {
String controlloPunto = "Select controlla_abilitazione('" + numeroTessera + "'," + idPuntoCassa + ") as T from dual"; String controlloPunto = "Select controlla_abilitazione('" + numeroTessera + "'," + idPuntoCassa + ") as T from dual";
Long abilitato = Utils.mySelectInteger(controlloPunto, "T", this); Long abilitato = Utils.mySelectInteger(controlloPunto, "T", this);
if (abilitato == 0) { if (abilitato == 0) {
Object[] options = {"Si", "No"};
Object selectedValue = JOptionPane.showOptionDialog(this, "Tessera non abilitata per questo punto di distribuzione!\nConsenti passaggio?", "Attenzione", Object selectedValue = JOptionPane.showOptionDialog(this, "Tessera non abilitata per questo punto di distribuzione!\nConsenti passaggio?", "Attenzione",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, siNoOptions, siNoOptions[0]);
if (Integer.parseInt(selectedValue.toString()) != 0) { if (Integer.parseInt(selectedValue.toString()) != 0) {
return false; return false;
} else { } else {
@ -4283,9 +4345,8 @@ public class PuntoCassa extends JFrame implements ActionListener {
+ "where rownum = 1"; + "where rownum = 1";
String idP = Utils.mySelect(query, "nr", this); String idP = Utils.mySelect(query, "nr", this);
if (idP.length() > 0) { if (idP.length() > 0) {
Long rowCount = Long.valueOf(idP); idPrenotazione = Long.valueOf(idP);
idPrenotazione = rowCount; if (idPrenotazione > 0L) {
if (rowCount > 0L) {
query = "SELECT Distinct Nome FROM VIEW_PRENOTAZIONI_TURNO v join prodotti p on v.ID_PRODOTTO=p.ID " query = "SELECT Distinct Nome FROM VIEW_PRENOTAZIONI_TURNO v join prodotti p on v.ID_PRODOTTO=p.ID "
+ "WHERE id_Modalita in (2,3) " + "WHERE id_Modalita in (2,3) "
+ "and id_stato in (0,1) " + "and id_stato in (0,1) "
@ -4322,11 +4383,11 @@ public class PuntoCassa extends JFrame implements ActionListener {
private void inserisciPrenotazioni() { private void inserisciPrenotazioni() {
try { try {
MyTableModel model = (MyTableModel) tblLista.getModel(); MyTableModel model = (MyTableModel) tblListaProdotti.getModel();
MyTableModel model1 = (MyTableModel) tblLista1.getModel(); MyTableModel model1 = (MyTableModel) tblListaComposizioni.getModel();
model.clearTable(); model.clearTable();
model1.clearTable(); model1.clearTable();
sommaColonne(model); sommaColonne(model, flagPrenotazionePagata);
String query = "SELECT * FROM VIEW_PRENOTAZIONI_TURNO " String query = "SELECT * FROM VIEW_PRENOTAZIONI_TURNO "
+ "WHERE id_Modalita in (2,3) " + "WHERE id_Modalita in (2,3) "
@ -4340,9 +4401,17 @@ public class PuntoCassa extends JFrame implements ActionListener {
ResultSet rs = st.executeQuery(query); ResultSet rs = st.executeQuery(query);
while (rs.next()) { while (rs.next()) {
//l'ID nella VIEW_PRENOTAZIONI_TURNO corrisponde all'ID della tabella SIR.PRENOTAZIONI_PASTI_DETTAGLIO
//idPrenDettaglio = Long.valueOf(rs.getString("ID"));
boolean flagPagato = Double.parseDouble(rs.getString("IMPORTO_PAGATO")) > 0.0;
EventParameters evtParams = new EventParameters(rs.getString("ID_PRODOTTO"),
null,
flagPagato,
rs.getString("ID"));
java.awt.event.ActionEvent evt; java.awt.event.ActionEvent evt;
evt = new java.awt.event.ActionEvent(new Object(), 0, "PRODOTTO[" + rs.getString("ID_PRODOTTO") + "]"); evt = new java.awt.event.ActionEvent(evtParams, 0, "PRODOTTO[" + rs.getString("ID_PRODOTTO") + "]");
actionPerformed(evt); actionPerformed(evt);
} }
@ -5026,17 +5095,17 @@ public class PuntoCassa extends JFrame implements ActionListener {
private javax.swing.JPanel pnlCliente; private javax.swing.JPanel pnlCliente;
private javax.swing.JPanel pnlConto; private javax.swing.JPanel pnlConto;
private javax.swing.JPanel pnlErrore; private javax.swing.JPanel pnlErrore;
private javax.swing.JPanel pnlLista; private javax.swing.JPanel pnlListaComposizioni;
private javax.swing.JPanel pnlLista1; private javax.swing.JPanel pnlListaProdotti;
private javax.swing.JPanel pnlLogin; private javax.swing.JPanel pnlLogin;
private javax.swing.JPanel pnlProdotti; private javax.swing.JPanel pnlProdotti;
protected javax.swing.JPanel pnlTop; protected javax.swing.JPanel pnlTop;
private javax.swing.JScrollPane scpLista; private javax.swing.JScrollPane scpListaComposizioni;
private javax.swing.JScrollPane scpLista1; private javax.swing.JScrollPane scpListaProdotti;
private javax.swing.JPanel subPnlCliente; private javax.swing.JPanel subPnlCliente;
private javax.swing.JPanel subPnlTessera; private javax.swing.JPanel subPnlTessera;
private javax.swing.JTable tblLista; private javax.swing.JTable tblListaComposizioni;
private javax.swing.JTable tblLista1; private javax.swing.JTable tblListaProdotti;
private javax.swing.JPasswordField txtPassword; private javax.swing.JPasswordField txtPassword;
private javax.swing.JTextField txtTotaleCassa; private javax.swing.JTextField txtTotaleCassa;
private javax.swing.JTextField txtTotalePunti; private javax.swing.JTextField txtTotalePunti;