refactoring variabili e metodi

rimozione metodi e classi inutilizzate
This commit is contained in:
Francesco Di Sciascio 2024-05-06 14:32:49 +02:00
parent 27b6e934a1
commit f7f5a3975e
2 changed files with 308 additions and 388 deletions

View File

@ -1,6 +1,5 @@
package puntocassa;
import javax.swing.table.AbstractTableModel;
/*
@ -8,19 +7,19 @@ import javax.swing.table.AbstractTableModel;
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Marco
*/
public class MyTableModel extends AbstractTableModel{
private String[] columnNames ;
public class MyTableModel extends AbstractTableModel {
private String[] columnNames;
private Object[][] data;
private Boolean editable=false;
private Boolean modificato=false;
private Boolean editable = false;
private Boolean modificato = false;
private int[] colModificabile;
private int[] colBoolean;
private Object[]row;
private Object[] row;
public Double somma(int col) {
Double tot = 0.0;
@ -47,22 +46,22 @@ import javax.swing.table.AbstractTableModel;
}
public Object[] getRow(int Row) {
row=data[Row];
row = data[Row];
return row;
}
public void addRow(Object[] rowData) {
Object[][] data2;
if (data != null) {
data2 = new Object[data.length+1][];
data2 = new Object[data.length + 1][];
int r = 0;
for (int i = 0; i < data.length; i++) {
data2[r] = data[i];
r++;
}
data2[r] = rowData;
}else{
data2=new Object[1][];
} else {
data2 = new Object[1][];
data2[0] = rowData;
}
@ -84,11 +83,12 @@ import javax.swing.table.AbstractTableModel;
}
}
public void deleteRow(int row) {
if (data.length > 0) {
Object[][] data2;
data2 = new Object[data.length - 1][];
int r=0;
int r = 0;
for (int i = 0; i < data.length; i++) {
if (i != row) {
data2[r] = data[i];
@ -100,6 +100,13 @@ import javax.swing.table.AbstractTableModel;
this.fireTableDataChanged();
}
}
public void clearTable() {
for (Integer i = this.getRowCount() - 1; i >= 0; i--) {
this.deleteRow(i);
}
}
public int[] isColBoolean() {
return colBoolean;
}
@ -132,12 +139,12 @@ import javax.swing.table.AbstractTableModel;
this.editable = editable;
}
public void setColumname(String[] colnames){
columnNames=colnames;
public void setColumname(String[] colnames) {
columnNames = colnames;
}
public void setData(Object[][] rowdata){
data=rowdata;
public void setData(Object[][] rowdata) {
data = rowdata;
}
public int getColumnCount() {
@ -145,8 +152,11 @@ import javax.swing.table.AbstractTableModel;
}
public int getRowCount() {
int rows=0;
try{rows=data.length;}catch(Exception ex){}
int rows = 0;
try {
rows = data.length;
} catch (Exception ex) {
}
return rows;
}
@ -155,10 +165,10 @@ import javax.swing.table.AbstractTableModel;
}
public Object getValueAt(int row, int col) {
try{
try {
return data[row][col];
}catch(Exception ex){
} catch (Exception ex) {
return "";
}
@ -196,7 +206,6 @@ import javax.swing.table.AbstractTableModel;
}
@Override
public boolean isCellEditable(int row, int col) {
if (editable) {
@ -220,5 +229,4 @@ import javax.swing.table.AbstractTableModel;
}
}

View File

@ -8,7 +8,6 @@ import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@ -29,7 +28,6 @@ import java.util.TimerTask;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
@ -106,7 +104,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
StringBuilder testoRFIDCard = new StringBuilder();
StringBuilder logTestoTessera = new StringBuilder();
String logNumeroTessera = "", logIDTessera = "", logTesseraErrore = "";
private Boolean unSoloTipoPagamento = false;
private Boolean flagImpostaTipoPagamento = false;
private Boolean menuGiornoPresente = false, messaggioSaldoUnaVolta = false;
private Boolean flagMostraDataDiNascita = true;
private Boolean stoCalcolando = false;
@ -141,68 +139,6 @@ public class PuntoCassa extends JFrame implements ActionListener {
private static Boolean flagPrecaricaLista = false;
private void verificaAggiornamentoDB() {
String flagProponiAggiornamentoDB = mySelect("Select Valore from Parametri where chiave='FlagProponiAggiornamentoDB' ", "Valore");
if (flagProponiAggiornamentoDB.equals("NO")) {
return;
}
Long agg = mySelectInteger("Select DB_locale_aggiornato as Agg from dual", "Agg");
if (flagProponiAggiornamentoDB.equals("SI")) {
if (agg == 0) {
aggiornaDB(true);
}
} else {
if (agg == 0) {
aggiornaDB(false);
}
}
}
private void verificaModoPagamento() {
String flagImpostaTipoPagamento = mySelect("Select Valore from Parametri where chiave='FlagImpostaTipoPagamento' ", "Valore");
unSoloTipoPagamento = flagImpostaTipoPagamento.equals("NO");
}
private void logTessera() {
try {
/*if(!"".equals(logIDTessera) ||
!"".equals(logNumeroTessera) ||
logTestoTessera.toString().length() > 0){*/
if (!logIDTessera.isEmpty()
|| !logNumeroTessera.isEmpty()
|| logTestoTessera.length() > 0) {
myInsert("Insert into LETTURE_TESSERE (STRINGA_LETTA,NUMERO_TESSERA,ID_TESSERA,ERRORE) values "
+ "('" + logTestoTessera.toString().replace("'", "''")
+ "','" + logNumeroTessera
+ "','" + logIDTessera
+ "','" + logTesseraErrore.replace("'", "''")
+ "')");
logIDTessera = "";
logNumeroTessera = "";
logTestoTessera = new StringBuilder();
}
} catch (Exception ex) {
}
}
private void clearTable(MyTableModel model) {
try {
for (Integer i = model.getRowCount() - 1; i >= 0; i--) {
model.deleteRow(i);
}
} catch (Exception e) {
}
}
// ==========================================================================
// *** Constructor della classe PuntoCassa
// ==========================================================================
@ -247,7 +183,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
String password = db.getElementsByTagName("password").item(0).getFirstChild().getNodeValue();
if (attivo.equals("SI")) {
Encoding en = new Encoding();
//Encoding en = new Encoding();
dbUsername = username;
dbPassword = Encoding.decodeString(password);
dbTipo = tipo;
@ -280,13 +216,13 @@ public class PuntoCassa extends JFrame implements ActionListener {
// ** Etichette
// --------------------------------------------------------------------
NodeList etichette = document.getElementsByTagName("etichette");
String titolo = "";
//String titolo = "";
MyApplication myApp = new MyApplication();
for (int i = 0; i < paths.getLength(); i++) {
Node etichetta = etichette.item(i);
if (etichetta.getNodeType() == Node.ELEMENT_NODE) {
Element p = (Element) etichetta;
titolo = p.getElementsByTagName("titolo").item(0).getFirstChild().getNodeValue();
String titolo = p.getElementsByTagName("titolo").item(0).getFirstChild().getNodeValue();
idPuntoCassa = Long.valueOf(myApp.mySelect(this, "SELECT valore FROM parametri WHERE chiave = 'IdPuntoCassa'", "valore"));
String credito = myApp.mySelect(this, "SELECT valore FROM parametri WHERE chiave = 'FlagIgnoraSaldoStop'", "valore");
@ -398,7 +334,31 @@ public class PuntoCassa extends JFrame implements ActionListener {
String flagPrecarica = mySelect("Select Valore from Parametri where Chiave='FlagPrecaricaLista'", "Valore");
flagPrecaricaLista = !flagPrecarica.equalsIgnoreCase("NO");
keyDispatcher = new KeyEventDispatcher() {
keyDispatcher = creaKeyEventDispatcher();
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keyDispatcher);
keyDespatcherAttivo = true;
verificaDB();
} catch (Exception e) {
e.printStackTrace();
}
// -----------------------------------------------------------------------
// *** Aggiunge un timer con relativa schedulazione a 5 secondi
// -----------------------------------------------------------------------
timerDBConn mt = new timerDBConn(this);
java.util.Timer timer = new java.util.Timer();
timer.schedule(mt, 0, 5000);
verificaAggiornamentiJAR();
}
public KeyEventDispatcher creaKeyEventDispatcher(){
return new KeyEventDispatcher() {
Boolean swip = false;
Boolean spiaAltreCarte = false;
Boolean timerUnaVolta = false;
@ -570,26 +530,51 @@ public class PuntoCassa extends JFrame implements ActionListener {
}
};
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keyDispatcher);
keyDespatcherAttivo = true;
verificaDB();
} catch (Exception e) {
e.printStackTrace();
}
// -----------------------------------------------------------------------
// *** Aggiunge un timer con relativa schedulazione a 5 secondi
// -----------------------------------------------------------------------
timerDBConn mt = new timerDBConn(this);
java.util.Timer timer = new java.util.Timer();
timer.schedule(mt, 0, 5000);
verificaAggiornamentiJAR();
/***
* FlagProponiAggiornamentoDB ha 3 possibili valori:
* AUTO vuol dire che, se il db locale è da aggiornare (DB_locale_aggiornato = 0), lo deve fare e basta senza chiedere conferma
* SI vuol dire che, se il db locale è da aggiornare (DB_locale_aggiornato = 0), lo deve fare chiedendo conferma
* NO vuol dire che non lo deve fare nemmeno se è da aggiornare
*/
private void verificaAggiornamentoDB() {
Long dbAggiornato = mySelectInteger("Select DB_locale_aggiornato as Agg from dual", "Agg");
String flagProponiAggiornamentoDB = mySelect("Select Valore from Parametri where chiave='FlagProponiAggiornamentoDB' ", "Valore");
if(dbAggiornato == 0){
if (flagProponiAggiornamentoDB.equals("SI")) {
aggiornaDB(true);
}
else if(flagProponiAggiornamentoDB.equals("AUTO")){
aggiornaDB(false);
}
}
}
private void verificaModoPagamento() {
flagImpostaTipoPagamento = mySelect("Select Valore from Parametri where chiave='FlagImpostaTipoPagamento' ", "Valore").equals("NO");
}
private void logTessera() {
try {
if (!logIDTessera.isEmpty()
|| !logNumeroTessera.isEmpty()
|| logTestoTessera.length() > 0) {
myInsert("Insert into LETTURE_TESSERE (STRINGA_LETTA,NUMERO_TESSERA,ID_TESSERA,ERRORE) values "
+ "('" + logTestoTessera.toString().replace("'", "''")
+ "','" + logNumeroTessera
+ "','" + logIDTessera
+ "','" + logTesseraErrore.replace("'", "''")
+ "')");
logIDTessera = "";
logNumeroTessera = "";
logTestoTessera = new StringBuilder();
}
} catch (Exception ex) {
LogManager.getLogger(PuntoCassa.class).error(ex);
}
}
private void verificaAggiornamentiJAR() {
@ -613,11 +598,8 @@ public class PuntoCassa extends JFrame implements ActionListener {
Runtime.getRuntime().exec("java -jar " + startDir + "/Aggiornamento.jar " + startDir + " " + pathURLAggiornamento);
System.exit(0);
}
}
}
} catch (IOException ex) {
LogManager.getLogger(PuntoCassa.class.getName()).error(ex);
@ -1728,11 +1710,9 @@ public class PuntoCassa extends JFrame implements ActionListener {
tipo = cmd.substring(0, i);
switch (tipo) {
case "CATEGORIA":
pulsantiCategoria(id, cmd);
break;
case "CATEGORIA" -> pulsantiCategoria(id, cmd);
case "PRODOTTO":
case "PRODOTTO" -> {
if (isCassaAperta) {
sql = "SELECT "
+ "prodotti.id as idProdotto,"
@ -1824,30 +1804,30 @@ public class PuntoCassa extends JFrame implements ActionListener {
//stessa procedura in Cercates
//prendo l'ultimo valore della griglia
if (model.getRowCount() > 0) {//
Double totAcquisto = 0.0;
try {
if (txtTotaleCassa.getText().length() > 0) {
String saldo = txtTotaleCassa.getText().replace("? ", "").replace(".", "");
saldo = saldo.replace(",", ".");
totAcquisto = Double.valueOf(saldo);
}
} catch (Exception ex) {
LogManager.getLogger(PuntoCassa.class).error(ex);
}
//DecimalFormat df2 = new DecimalFormat("##0.00");
//String prezzoDisplay = ("E " + df2.format(totAcquisto));
/*String fa = "FASCIA " + lblFascia.getText().replaceAll("Fascia", "").trim();
if (fa.length() >= 10) {
fa = fa.substring(fa.length() - 10, fa.length());
} else {
fa = spaziBianchi(fa, 10, true);
}*/
//String uProd = spaziBianchi("Totale ", 20, true);
}
// if (model.getRowCount() > 0) {//
//
// Double totAcquisto = 0.0;
// try {
//
// if (txtTotaleCassa.getText().length() > 0) {
// String saldo = txtTotaleCassa.getText().replace("? ", "").replace(".", "");
// saldo = saldo.replace(",", ".");
// totAcquisto = Double.valueOf(saldo);
// }
// } catch (Exception ex) {
// LogManager.getLogger(PuntoCassa.class).error(ex);
// }
// //DecimalFormat df2 = new DecimalFormat("##0.00");
// //String prezzoDisplay = ("E " + df2.format(totAcquisto));
// /*String fa = "FASCIA " + lblFascia.getText().replaceAll("Fascia", "").trim();
// if (fa.length() >= 10) {
// fa = fa.substring(fa.length() - 10, fa.length());
// } else {
// fa = spaziBianchi(fa, 10, true);
// }*/
//
// //String uProd = spaziBianchi("Totale ", 20, true);
// }
rs.close();
st.close();
dbConnection.close();
@ -1856,10 +1836,10 @@ public class PuntoCassa extends JFrame implements ActionListener {
System.out.println(ex.getMessage());
}
}
break;
}
default:
break;
default -> {
}
}
}
@ -1979,7 +1959,8 @@ public class PuntoCassa extends JFrame implements ActionListener {
}
MyTableModel model1 = (MyTableModel) tblLista1.getModel();
clearTable(model1);
//clearTable(model1);
model1.clearTable();
Boolean composizionePresente = false;
StringBuilder sb = new StringBuilder();
//verifico se sono presenti composizioni
@ -1992,13 +1973,16 @@ public class PuntoCassa extends JFrame implements ActionListener {
if (Long.parseLong(row[5].toString()) == 0L) {
composizionePresente = true;
if (gratuitaResidue > 0) {//Gratuita_ResidueProg
clearTable(model1);
//clearTable(model1);
model1.clearTable();
model1.addRow(new Object[]{model.getValueAt(i, 0), 0.00, model.getValueAt(i, 3)});
} else if (flagBonus == 1 && bonusResidui > 0) {
clearTable(model1);
//clearTable(model1);
model1.clearTable();
model1.addRow(new Object[]{model.getValueAt(i, 0), 0.00, model.getValueAt(i, 3)});
} else {
clearTable(model1);
//clearTable(model1);
model1.clearTable();
model1.addRow(new Object[]{model.getValueAt(i, 0), model.getValueAt(i, 1), model.getValueAt(i, 3)});
}
@ -2024,7 +2008,8 @@ public class PuntoCassa extends JFrame implements ActionListener {
String prezzo = mySelect("Select prezzo from tariffe where id_fascia=" + idProfiloTariffario + " "
+ "and id_prodotto=" + idVassoio, "prezzo");
clearTable(model1);
//clearTable(model1);
model1.clearTable();
if (gratuitaResidue > 0) {//Gratuita_ResidueProg
model1.addRow(new Object[]{nomeVassoio, 0.00, idVassoio});
} else if (flagBonus == 1 && bonusResidui > 0) {
@ -2694,7 +2679,8 @@ public class PuntoCassa extends JFrame implements ActionListener {
private void cancellaComposizioni() {
try {
MyTableModel model1 = (MyTableModel) tblLista1.getModel();
clearTable(model1);
//clearTable(model1);
model1.clearTable();
} catch (Exception e) {
}
}
@ -2807,7 +2793,15 @@ public class PuntoCassa extends JFrame implements ActionListener {
// TODO add your handling code here:
resize();
}//GEN-LAST:event_formWindowDeiconified
private void tastiera2(java.awt.event.MouseEvent evt) {
private void setTastiera(java.awt.event.MouseEvent evt) {
setTastieraAfterEvent(evt);
}
private void setTastiera(java.awt.event.FocusEvent evt) {
setTastieraAfterEvent(evt);
}
private void setTastieraAfterEvent(ComponentEvent evt) {
MyApplication myApp = new MyApplication();
if (jChLogin.isSelected() == false) {
if (myApp.tastieraVideo) {
@ -2817,26 +2811,13 @@ public class PuntoCassa extends JFrame implements ActionListener {
myApp.ultimoTxt = evt.getComponent().toString();
Rectangle pnl = pnlLogin.getBounds();
tastiera((JTextField) evt.getComponent(), pnl.x, pnl.y);
setTastiera((JTextField) evt.getComponent(), pnl.x, pnl.y);
}
}
}
}
private void tastiera2(java.awt.event.FocusEvent evt) {
MyApplication myApp = new MyApplication();
if (jChLogin.isSelected() == false) {
if (myApp.tastieraVideo) {
if (myApp.ultimoTxt.equalsIgnoreCase(evt.getComponent().toString())) {
myApp.ultimoTxt = " ";
} else {
myApp.ultimoTxt = evt.getComponent().toString();
Rectangle pnl = pnlLogin.getBounds();
tastiera((JTextField) evt.getComponent(), pnl.x, pnl.y);
}
}
}
}
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",
@ -3010,7 +2991,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
myApp.ultimoTxt = evt.getComponent().toString();
Rectangle pnl = pnlLogin.getBounds();
tastiera((JTextField) evt.getComponent(), pnl.x, pnl.y);
setTastiera((JTextField) evt.getComponent(), pnl.x, pnl.y);
}
}
}//GEN-LAST:event_jTxtTesseraFocusGained
@ -3045,8 +3026,10 @@ public class PuntoCassa extends JFrame implements ActionListener {
try {
MyTableModel model = (MyTableModel) tblLista.getModel();
MyTableModel model1 = (MyTableModel) tblLista1.getModel();
clearTable(model);
clearTable(model1);
//clearTable(model);
//clearTable(model1);
model.clearTable();
model1.clearTable();
jbtnSu.setEnabled(false);
jbtnGiu.setEnabled(false);
jbtnElimina.setEnabled(false);
@ -3129,19 +3112,19 @@ public class PuntoCassa extends JFrame implements ActionListener {
}//GEN-LAST:event_btnTerminaActionPerformed
private void txtPasswordMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtPasswordMouseClicked
tastiera2(evt);
setTastiera(evt);
}//GEN-LAST:event_txtPasswordMouseClicked
private void txtPasswordFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtPasswordFocusGained
tastiera2(evt);
setTastiera(evt);
}//GEN-LAST:event_txtPasswordFocusGained
private void txtUsernameMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtUsernameMouseClicked
tastiera2(evt);
setTastiera(evt);
}//GEN-LAST:event_txtUsernameMouseClicked
private void txtUsernameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtUsernameFocusGained
tastiera2(evt);
setTastiera(evt);
}//GEN-LAST:event_txtUsernameFocusGained
@ -3281,7 +3264,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
}
}//GEN-LAST:event_jTBP3ActionPerformed
private void tastiera(JTextField jTxt, Integer MyX, Integer MyY) {
private void setTastiera(JTextField jTxt, Integer MyX, Integer MyY) {
MyKeyBoard keyboard = new MyKeyBoard(this, false);
keyboard.txt = jTxt;
@ -3417,7 +3400,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
jTBP0.setEnabled(true);
jTBP0.setSelected(true);
jTBP0ActionPerformed(null);
if (unSoloTipoPagamento) {
if (flagImpostaTipoPagamento) {
jTBP1.setEnabled(false);
jTBP2.setEnabled(false);
jTBP3.setEnabled(false);
@ -3427,7 +3410,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
jTBP1.setEnabled(true);
jTBP1.setSelected(true);
jTBP1ActionPerformed(null);
if (unSoloTipoPagamento) {
if (flagImpostaTipoPagamento) {
jTBP0.setEnabled(false);
jTBP2.setEnabled(false);
jTBP3.setEnabled(false);
@ -3437,7 +3420,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
jTBP2.setEnabled(true);
jTBP2.setSelected(true);
jTBP2ActionPerformed(null);
if (unSoloTipoPagamento) {
if (flagImpostaTipoPagamento) {
jTBP1.setEnabled(false);
jTBP0.setEnabled(false);
jTBP3.setEnabled(false);
@ -3447,7 +3430,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
jTBP3.setEnabled(true);
jTBP3.setSelected(true);
jTBP3ActionPerformed(null);
if (unSoloTipoPagamento) {
if (flagImpostaTipoPagamento) {
jTBP1.setEnabled(false);
jTBP2.setEnabled(false);
jTBP0.setEnabled(false);
@ -3809,8 +3792,10 @@ public class PuntoCassa extends JFrame implements ActionListener {
try {
MyTableModel model = (MyTableModel) tblLista.getModel();
MyTableModel model1 = (MyTableModel) tblLista1.getModel();
clearTable(model);
clearTable(model1);
/*clearTable(model);
clearTable(model1);*/
model.clearTable();
model1.clearTable();
} catch (Exception e) {
}
messaggioSaldoUnaVolta = false;
@ -4194,8 +4179,10 @@ public class PuntoCassa extends JFrame implements ActionListener {
MyTableModel model = (MyTableModel) tblLista.getModel();
MyTableModel model1 = (MyTableModel) tblLista1.getModel();
clearTable(model);
clearTable(model1);
/*clearTable(model);
clearTable(model1);*/
model.clearTable();
model1.clearTable();
sommaColonne(model);
String query = "SELECT * FROM VIEW_PRENOTAZIONI_TURNO "
@ -4246,9 +4233,9 @@ public class PuntoCassa extends JFrame implements ActionListener {
private Double calcolaTotale() {
Double totAcquisto = 0.00;
if (txtTotaleCassa.getText().length() > 0) {
String Saldo = txtTotaleCassa.getText().replace("? ", "").replace(".", "");
Saldo = Saldo.replace(",", ".");
totAcquisto = Double.parseDouble(Saldo);
String saldo = txtTotaleCassa.getText().replace("? ", "").replace(".", "");
saldo = saldo.replace(",", ".");
totAcquisto = Double.parseDouble(saldo);
}
return totAcquisto;
}
@ -4316,26 +4303,6 @@ public class PuntoCassa extends JFrame implements ActionListener {
}
/*private void stampa() {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
JInternalReport P = new JInternalReport();
P.TitoloReport = "Scontrino";
String Query = "Select Prodotti.Nome as Prodotto,Importo,Acquisti.id from Acquisti inner join Prodotti on Acquisti.id_prodotto=prodotti.id where Num_Progressivo=" + (progressivo - 1) + " and id_Punto_cassa=" + idPuntoCassa;
String[] ColReport = {"Prodotto", "Importo"};
String[] ColTypeReport = {"text", "float"};
String SelectRows = "Select count(*) as nr from Acquisti where Num_Progressivo=" + (progressivo - 1) + " and id_Punto_cassa=" + idPuntoCassa;
int rowCount = Integer.parseInt(mySelect(SelectRows, "nr"));
Object[][] dataReport = rowData(Query, ColReport, ColTypeReport, rowCount);
P.CreaReport(ColReport, ColTypeReport, dataReport);
P.setVisible(true);
P.show();
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}*/
public Object[][] rowData(String Query, String[] Cols, String[] ColType, int rowCount) {
Object[][] rows = null;
try {
@ -4465,55 +4432,30 @@ public class PuntoCassa extends JFrame implements ActionListener {
return res;
}
public void insertImage() {
String filenamepath = new String("L:\\Lavoro\\Goffredo\\risorse\\Brioche.jpg");
try {
File file = new File(filenamepath);
Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword);
Statement stat = dbConnection.createStatement();
PreparedStatement ps = dbConnection.prepareStatement("Update Prodotti set icona=?");
// bind the data......
System.out.println("Lenght:" + file.getAbsolutePath());
InputStream inputimage = new FileInputStream(file);
ps.setBinaryStream(1, inputimage, (int) file.length());
ps.execute();
ps.close();
dbConnection.close();
} catch (Exception e) {
System.out.println("Error at Image Insert:" + e);
e.printStackTrace();
}
}
public void getImage(String idProdotto) {
String FullName = null;
InputStream gifdata = null;
String fullName = null;
InputStream gifData = null;
try {
String Query = "select icona from Prodotti where id=" + idProdotto;
String query = "select icona from Prodotti where id=" + idProdotto;
// create prepare Statement pst
Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword);
PreparedStatement pst = dbConnection.prepareStatement(Query);
PreparedStatement pst = dbConnection.prepareStatement(query);
ResultSet result = pst.executeQuery();
if (result.next()) {
FullName = imgPath + idProdotto + ".jpg";
fullName = imgPath + idProdotto + ".jpg";
//using Srteam Method'''''
gifdata = result.getBinaryStream(1);
gifData = result.getBinaryStream(1);
//create file
if (gifdata != null) {
File giffile = new File(FullName);
if (gifData != null) {
File gifFile = new File(fullName);
//write the byte array into a local file.
FileOutputStream file = new FileOutputStream(giffile);
FileOutputStream file = new FileOutputStream(gifFile);
int chunk = 0;
while ((chunk = gifdata.read()) != -1) {
while ((chunk = gifData.read()) != -1) {
file.write(chunk);
@ -4776,7 +4718,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
}
}
private void statoTesseraLetta(int Gratuita, int Bonus) {
private void statoTesseraLetta(int gratuita, int bonus) {
String tess = jTxtTessera.getText();
if (tess.length() >= 12) {
tess = tess.substring(tess.length() - 12, tess.length());
@ -4786,33 +4728,14 @@ public class PuntoCassa extends JFrame implements ActionListener {
String fa = "";
fa = spaziBianchi(fa, 13, true);
if (Gratuita > 0) {
if (gratuita > 0) {
} else if (Bonus > 0) {
} else if (bonus > 0) {
fa = "BONUS ";
}
}
class MyCanvas extends JComponent {
private String texto = "";
public MyCanvas(String Testo) {
texto = Testo;
}
@Override
public void paintComponent(Graphics g) {
if (g instanceof Graphics2D) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.drawString(texto, 70, 20);
}
}
}
class CardTask extends TimerTask {
@ -4921,7 +4844,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
// --------------------------------------------------------------
// ** Verifica se c'e un utente loggato
// --------------------------------------------------------------
if (this.pc.utenteLoggato == "") {
if (this.pc.utenteLoggato.equals("")) {
this.pc.pnlLogin.setVisible(true);
} else {
this.pc.pnlLogin.setVisible(false);
@ -4939,18 +4862,7 @@ public class PuntoCassa extends JFrame implements ActionListener {
}
}
// ==========================================================================
// *** Sottoclasse per i button categoria
// ==========================================================================
public class buttonCategoria extends javax.swing.JButton {
}
// ==========================================================================
// *** Sottoclasse per i button prodotto
// ==========================================================================
public class buttonProdotto extends javax.swing.JButton {
}
// Variables declaration - do not modify//GEN-BEGIN:variables