/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package puntocassa; //import javax.swing.JDialog; //import java.beans.*; import java.awt.*; import java.awt.event.*; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.sql.*; import java.text.DecimalFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.Properties; import java.util.Timer; import java.util.TimerTask; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.BorderFactory; import javax.swing.ButtonModel; import javax.swing.DefaultComboBoxModel; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRootPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.JToggleButton; import javax.swing.ListSelectionModel; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.plaf.FontUIResource; import javax.swing.table.DefaultTableModel; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import jssc.SerialPort; import jssc.SerialPortException; import jxl.write.DateTime; import oracle.jdbc.*; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import static puntocassa.MyApplication.path; //****************************************************************************** // * // * @author Master // * //****************************************************************************** public class PuntoCassa extends JFrame implements ActionListener { // ========================================================================== // *** Variabili globali relative alle connessioni // ========================================================================== public static String Versione="2.4"; public static String dbStringa = ""; private String dbTipo = ""; private String dbDriver = ""; public static String dbUsername = ""; public static String dbPassword = ""; //public static Connection dbConnection; //private Integer statoConnessione = 0; private String utenteLoggato = ""; private String imgPath = "";// "L:\\Lavoro\\Goffredo\\risorse\\"; // private String Path_Aggiornamento=""; private int displayWidth = 1024; private int displayHeight = 768; private Long Progressivo = 0L; private Long ProgressivoTurno = 0L; private Long ProgressivoGiorno = 0L; private Double ProgressivoScalare = 0.0; private Double ProgressivoContanti = 0.0; private Double ProgressivoTicket = 0.0; private Double ProgressivoDifferito = 0.0; private Double SaldoMinimoStop = 0.0; private Long idTurno = 0L; private String NomeTurno = ""; private Long idTurnoAttuale = 0L; private String NomeTurnoAttuale = ""; private int ColImporto = 1; private int ColPunti = 2; private int ColIDProdotto = 3; private int ColImporto2 = 4; private int ColCategoria = 5; public Long idPuntoCassa = 0L; private Boolean ConsentiCredito = false; private Long idProfiloTariffario = 0L; private Long idProfiloTariffarioDefault = 0L; public static Long idModoPagamento = 0L; public static String ModoPagamentoDefault = "A scalare"; public static Integer FLAG_BONUS = 0; private Long idTessera = 0L; private Long idPrenotazione = 0L; private Boolean CassaAperta = false; private Long idAccount = 0L; Timer timerCard; private int NumeroCategorie = 0; private Boolean StatoCardLettore = false; StringBuilder TestoSwipCard = new StringBuilder(); StringBuilder TestoRFIDCard = new StringBuilder(); StringBuilder LogTestoTessera = new StringBuilder(); String LogNumeroTessera = "", LogIDTessera = "", LogTesseraErrore = ""; // StringBuilder TestoCarteCF=new StringBuilder(); // private String TesseraCartaCF=""; private Boolean UnSoloTipoPagamento = false; private Boolean MenùGiornoPresente = false, MessaggioSaldoUnaVolta = false; private Boolean FlagMostraDataDiNascita = true; private Boolean StoCalcolando = false; private Boolean FlagEsegueStorni = true; //private Boolean MessaggioFlagExtraUnaVolta = false; // private Boolean TesseraCFLetta=false; //private String idComposizione="",cmdComposizione=""; private void VerificaAggiornamentoDB() { //FlagProponiAggiornamentoDB 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) { //jBtnDBActionPerformed(null); AggiornaDB(true); } } else { if (Agg == 0) { //jBtnDBActionPerformed(null); AggiornaDB(false); } } } private void VerificaModoPagamento() { String FlagImpostaTipoPagamento = MySelect("Select Valore from Parametri where chiave='FlagImpostaTipoPagamento' ", "Valore"); if (FlagImpostaTipoPagamento.equals("NO")) { // jBtnTicket.setEnabled(false); UnSoloTipoPagamento = true; } else { // jBtnTicket.setEnabled(true); UnSoloTipoPagamento = false; } } private void LogTessera() { try { if (LogIDTessera == "" && LogNumeroTessera == "" && LogTestoTessera.toString().length() <= 0) { } else { 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) { } } enum statiCarta { Assente, Inserita, Tolta } public statiCarta StatoCarta; public Boolean CartaLetta = false; public static KeyEventDispatcher keyDispatcher; public int HFont = 15; private int AltControlli = 100; private int LargControlli = 100; private int AltRigaGriglia = 0; // private Object[][] Completi; // private Object[] CompletiDett; public frmProgress MyProgress; public frmMeteo MyMeteo; private int Gratuita_Residue = 0; //private int Gratuita_ResidueProg=0; private int Bonus_Residui = 0; //private int Bonus_ResiduiProg=0; private StringBuilder ModiPagamento = new StringBuilder(""); private static Boolean KeyDespatcherAttivo = false; public Boolean PassaggioTessera = false; private Boolean PassaggiEsauritiNoComposizione = false; private static Boolean Visualizza_Messaggi_Display = true; private static String Message_Display = ""; public static Boolean FlagExtra = false; public static Boolean FlagRicevuta = false; Timer timerDisplay = new Timer(); private static Integer DelaySwipCard = 100; private static Boolean BottoneImposta = true; private static Boolean Asporto = false; private static Boolean FlagPrecaricaLista = false; // ========================================================================== // *** Metodo per identificare la classe esterna dall'interno dei membri classe // ========================================================================== public PuntoCassa getOuter() { return PuntoCassa.this; } // ========================================================================== // *** Sottoclasse per la gestione degli eventi a timer // ========================================================================== public class TimerDBConn extends java.util.TimerTask { // ======================================================================= // ** Implementazione del riferimento alla classe contenitore // ======================================================================= private PuntoCassa pc; Connection dbConnection; TimerDBConn(PuntoCassa pc) { this.pc = pc; } PuntoCassa getPuntoCassa() { return pc; } // ======================================================================= // ** Contiene il processo da eseguire in background // ======================================================================= public void run() { String sql; Statement st = null; ResultSet rs; // ==================================================================== // * Se non c'è connessione al DB prova a connettersi // ==================================================================== //if (this.pc.statoConnessione == 0) { try { Class.forName(dbDriver); dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); //this.pc.statoConnessione = 1; } catch (Exception ex) { //this.pc.statoConnessione = 0; this.pc.utenteLoggato = ""; this.pc.lblStatoConnessione.setText("Errore di connessione al db"); } //} // ==================================================================== // * Se c'è connessione // ==================================================================== //if (this.pc.statoConnessione == 1) { // ----------------------------------------------------------------- // *** Verifica lo stato di attività della connessione // ----------------------------------------------------------------- if (dbTipo.equals("Oracle")) { // sql = "SELECT to_char(sysdate, 'hh24:mi') AS now FROM dual"; sql = "Select Valore as now from Parametri where chiave='UltimoAggTabelle'"; } else { sql = "SELECT now() AS now FROM dual"; } try { st = dbConnection.createStatement(); rs = st.executeQuery(sql); while (rs.next()) { String strRiga = rs.getString("now"); this.pc.lblStatoConnessione.setText(strRiga + " Vers. " + Versione); } // -------------------------------------------------------------- // ** Verifica se c'è un utente loggato // -------------------------------------------------------------- this.pc.pnlErrore.setVisible(false); // -------------------------------------------------------------- // ** Verifica se c'è un utente loggato // -------------------------------------------------------------- if (this.pc.utenteLoggato == "") { this.pc.pnlLogin.setVisible(true); } else { this.pc.pnlLogin.setVisible(false); } rs.close(); st.close(); dbConnection.close(); } catch (SQLException e) { this.pc.pnlErrore.setVisible(true); this.pc.lblMessaggioErrore.setText("Errore di connessione al database!");//Errore query " + sql); } // ================================================================= // * Altrimenti ... // ================================================================= /*} else { this.pc.lblStatoConnessione.setText("Errore di connessione al database"); }*/ } } private void ClearTable(MyTableModel model) { try { for (Integer i = model.getRowCount() - 1; i >= 0; i--) { model.deleteRow(i); } } catch (Exception e) { } } // ========================================================================== // *** Sottoclasse per i button categoria // ========================================================================== public class ButtonCategoria extends javax.swing.JButton { } // ========================================================================== // *** Sottoclasse per i button prodotto // ========================================================================== public class ButtonProdotto extends javax.swing.JButton { } // ========================================================================== // *** Constructor della classe PuntoCassa // ========================================================================== public PuntoCassa() { // ----------------------------------------------------------------------- // *** Esegue le impostazioni di base // ----------------------------------------------------------------------- initComponents(); // ----------------------------------------------------------------------- // *** Legge la configurazione dal file XML // ----------------------------------------------------------------------- try { DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = documentFactory.newDocumentBuilder(); //Document document = builder.parse(new File("../risorse/puntocassa.xml")); String startDir = System.getProperty("user.dir"); Document document = builder.parse(new File(startDir + "/risorse/puntocassa.xml")); File IconaApp = new File(startDir + "/risorse/logo.png"); if (IconaApp.exists()) { ImageIcon icon = new ImageIcon(startDir + "/risorse/logo.png"); this.setIconImage(icon.getImage()); } // -------------------------------------------------------------------- // ** Accesso al database // -------------------------------------------------------------------- NodeList database = document.getElementsByTagName("database"); for (int i = 0; i < database.getLength(); i++) { Node nodo = database.item(i); if (nodo.getNodeType() == Node.ELEMENT_NODE) { Element db = (Element) nodo; String attivo = db.getElementsByTagName("attivo").item(0).getFirstChild().getNodeValue(); String tipo = db.getElementsByTagName("tipo").item(0).getFirstChild().getNodeValue(); String driver = db.getElementsByTagName("driver").item(0).getFirstChild().getNodeValue(); String server = db.getElementsByTagName("server").item(0).getFirstChild().getNodeValue(); String porta = db.getElementsByTagName("porta").item(0).getFirstChild().getNodeValue(); String istanza = db.getElementsByTagName("istanza").item(0).getFirstChild().getNodeValue(); String username = db.getElementsByTagName("username").item(0).getFirstChild().getNodeValue(); String password = db.getElementsByTagName("password").item(0).getFirstChild().getNodeValue(); if (attivo.equals("SI")) { Encoding en = new Encoding(); dbUsername = username; dbPassword = en.decodeString(password); dbTipo = tipo; dbDriver = driver; if (tipo.equals("MySQL")) { dbStringa = "jdbc:mysql://" + server + ":" + porta + "/" + istanza; } else if (tipo.equals("Oracle")) { dbStringa = "jdbc:oracle:thin:@" + server + ":" + porta + ":" + istanza; } } } } // -------------------------------------------------------------------- // ** Path // -------------------------------------------------------------------- NodeList paths = document.getElementsByTagName("path"); for (int i = 0; i < paths.getLength(); i++) { Node path = paths.item(i); if (path.getNodeType() == Node.ELEMENT_NODE) { Element p = (Element) path; imgPath = p.getElementsByTagName("img_path").item(0).getFirstChild().getNodeValue(); if (imgPath.equalsIgnoreCase("..\\risorse\\")) { imgPath = startDir + "/risorse/"; } // Path_Aggiornamento= p.getElementsByTagName("Aggiornamento").item(0).getFirstChild().getNodeValue(); // Path_Aggiornamento=Path_Aggiornamento.replaceAll(Pattern.quote("\\"), Matcher.quoteReplacement("/")); } } // -------------------------------------------------------------------- // ** Etichette // -------------------------------------------------------------------- NodeList etichette = document.getElementsByTagName("etichette"); String Titolo = ""; MyApplication MyA = 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(); idPuntoCassa = Long.parseLong(MyA.MySelect(this, "SELECT valore FROM parametri WHERE chiave = 'IdPuntoCassa'", "valore")); String Credito = MyA.MySelect(this, "SELECT valore FROM parametri WHERE chiave = 'FlagIgnoraSaldoStop'", "valore"); if (Credito.equalsIgnoreCase("SI")) { ConsentiCredito = true; } Titolo = Titolo + " " + idPuntoCassa; this.setTitle(Titolo); //Aggiornamento 14-01-2019 //String P=MyA.MySelect(this,"select tp.id || '|' || tp.nome as valore from tipi_pagamenti tp, punti_distribuzione pd, punti_cassa pc where pc.id_punto_distribuzione = pd.id and pd.id_tipo_paga_default = tp.id and pc.id =" + idPuntoCassa, "valore"); String P = MyA.MySelect(this, "select tp.id || '|' || tp.nome || '|' || pd.flag_bonus || '|' || pd.flag_extra as valore from punti_cassa pc inner join punti_distribuzione pd on pc.id_punto_distribuzione = pd.id inner join tipi_pagamenti tp on pd.id_tipo_paga_default = tp.id where pc.id=" + idPuntoCassa, "valore"); String[] El = P.split("\\|",-1); if (El.length >= 2) { idModoPagamento = Long.parseLong(El[0]); ModoPagamentoDefault = El[1]; lblTipoPagamento.setText(El[1]); //Aggiornamento 14-01-2019 FLAG_BONUS = Integer.parseInt(El[2]); FlagExtra=false; if (El[3].equalsIgnoreCase("1")){ FlagExtra=true; } PulsantiModoPagamento(); } } } // -------------------------------------------------------------------- // ** display // -------------------------------------------------------------------- NodeList disp = document.getElementsByTagName("display"); for (int i = 0; i < disp.getLength(); i++) { Node display = disp.item(i); if (display.getNodeType() == Node.ELEMENT_NODE) { Element p = (Element) display; displayWidth = Integer.parseInt(p.getElementsByTagName("larghezza").item(0).getFirstChild().getNodeValue()); displayHeight = Integer.parseInt(p.getElementsByTagName("altezza").item(0).getFirstChild().getNodeValue()); HFont = Integer.parseInt(p.getElementsByTagName("fontSize").item(0).getFirstChild().getNodeValue()); AltControlli = Integer.parseInt(p.getElementsByTagName("altezzaControlli").item(0).getFirstChild().getNodeValue()); LargControlli = Integer.parseInt(p.getElementsByTagName("larghezzaControlli").item(0).getFirstChild().getNodeValue()); String tastiera = p.getElementsByTagName("TastieraVideo").item(0).getFirstChild().getNodeValue(); // MyApplication MyA=new MyApplication(); if (tastiera.equals("NO")) { MyA.TastieraVideo = false; } else { MyA.TastieraVideo = true; } } } //jPB.setVisible(false); //adatto panel login Font f = new Font("Tahoma", 0, HFont); UIManager.put( "OptionPane.messageFont", new FontUIResource(new Font("Tahoma", Font.BOLD, HFont)) ); UIManager.put("OptionPane.buttonFont", new FontUIResource(new Font("Tahoma", Font.BOLD, 25))); btnLogin.setFont(f); pnlLogin.setSize(CalcolaLarghezzaAltezza(pnlLogin.getWidth(), LargControlli), CalcolaLarghezzaAltezza(pnlLogin.getHeight(), AltControlli)); lblPassword.setFont(f); lblUsername.setFont(f); txtUsername.setFont(f); txtPassword.setFont(f); jTxtTessera.setFont(f); jChLogin.setFont(f); jBtnReadCard.setVisible(false); // -------------------------------------------------------------------- // ** ID_PUNTO_CASSA // -------------------------------------------------------------------- // if(idPuntoCassa<=0L){ // idPuntoCassa = Long.parseLong(document.getElementsByTagName("ID_Punto_Cassa").item(0).getFirstChild().getNodeValue()); // } jcmbSC.setVisible(false); String VMD = document.getElementsByTagName("Visualizza_Messaggi_Display").item(0).getFirstChild().getNodeValue(); if (VMD.equalsIgnoreCase("SI")) { Visualizza_Messaggi_Display = true; } else { Visualizza_Messaggi_Display = false; } Message_Display = document.getElementsByTagName("Messaggio_Display").item(0).getFirstChild().getNodeValue(); updateReaderCombo(); String UltimiMovimenti = MyA.MySelect(this, "SELECT valore FROM parametri WHERE chiave = 'FlagVisualizzaUltimiPassaggi'", "valore"); if (UltimiMovimenti.equalsIgnoreCase("NO")) { jBtnMovimenti.setEnabled(false); } timerCard = new java.util.Timer(); timerCard.schedule(new CardTask(this), 0, 1 * 1000); StatoAttivoNonLoggato(); // String flagExtra = MySelect("Select Valore from Parametri where Chiave='FlagExtra'", "Valore"); // if (flagExtra.equalsIgnoreCase("NO")) { // FlagExtra = false; // } else { // FlagExtra = true; // } String flagRicevuta = MySelect("Select Valore from Parametri where Chiave='FlagRicevuta'", "Valore"); if (flagRicevuta.equalsIgnoreCase("NO")) { FlagRicevuta = false; //jbtnStampa.setEnabled(false); } else { FlagRicevuta = true; } String flagDataNascita = MySelect("Select Valore from Parametri where Chiave='FlagMostraDataDiNascita'", "Valore"); if (flagDataNascita.equalsIgnoreCase("NO")) { FlagMostraDataDiNascita = false; } else { FlagMostraDataDiNascita = true; } String flagEsegueStorni = MySelect("Select Valore from Parametri where Chiave='FlagEsegueStorni'", "Valore"); if (flagEsegueStorni.equalsIgnoreCase("NO")){ FlagEsegueStorni = false; } else { FlagEsegueStorni = true; } String TimeoutSwipCard = MySelect("Select Valore from Parametri where Chiave='TimeoutSwipCard'", "Valore"); if (MyA.isNumeric(TimeoutSwipCard)) { DelaySwipCard = Integer.parseInt(TimeoutSwipCard); } MyInsert("UPDATE PARAMETRI set valore='NO' where chiave='FlagDownloadInCorso'"); String asporto = MySelect("Select Valore from Parametri where Chiave='FlagDefaultAsporto'", "Valore"); if (asporto.equalsIgnoreCase("SI")) { Asporto = true; } String flagPrecarica = MySelect("Select Valore from Parametri where Chiave='FlagPrecaricaLista'", "Valore"); if (flagPrecarica.equalsIgnoreCase("NO")) { FlagPrecaricaLista = false; } else { FlagPrecaricaLista = true; } // KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); // manager.addKeyEventDispatcher(new KeyEventDispatcher() { // // // @Override // public boolean dispatchKeyEvent(KeyEvent e) { // // int id = e.getID(); // int keyCode = e.getKeyCode(); // if (id == KeyEvent.KEY_RELEASED) { // if (keyCode != 144 && keyCode!=16) { // char tasto=e.getKeyChar(); // PuntoCassa.this.TestoSwipCard.append(tasto); // System.out.println(TestoSwipCard.toString()); // } // } // return true; // } // // } // ); keyDispatcher = new KeyEventDispatcher() { Boolean Swip = false; Boolean SpiaAltreCarte = false; Boolean TimerUnaVolta = false; MyApplication MyP = new MyApplication(); public boolean dispatchKeyEvent(KeyEvent e) { int id = e.getID(); if (jbtnChiudi.isEnabled() && pnlLogin.isVisible() == false && jTxtTessera.getText().length() > 0) { e.consume(); if (MyP.UnaVolta == false) { MyP.UnaVolta = true; // JOptionPane.showOptionDialog(PuntoCassa.this, "Chiudere la transazione!", "Attenzione", // JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); } return false; } MyP.UnaVolta = false; int keyCode = e.getKeyCode(); if (id == KeyEvent.KEY_RELEASED) { String tasto = "" + e.getKeyChar(); System.out.println(keyCode + " - " + tasto); LogTestoTessera.append(e.getKeyChar()); // if (keyCode != 16){ // TestoCarteCF.append(tasto); // } if (tasto.equalsIgnoreCase("ò")) { //144 Swip = true; } //05-12-2017 if (keyCode == 16 || keyCode == 45 || tasto.equalsIgnoreCase("ò")) { SpiaAltreCarte = true; } if (tasto.equalsIgnoreCase("ò") == false && keyCode != 16 && keyCode != 45 && Swip) { //keyCode != 144 && keyCode != 17 TestoSwipCard.append(tasto); System.out.println(TestoSwipCard.toString()); } if (keyCode == 45 && Swip) { //keyCode != 144 Swip = false; System.out.println(TestoSwipCard.toString()); warn(); } //30-11-2017 modifica per rfid if (keyCode != 16) { TestoRFIDCard.append(tasto); } if (keyCode == 10 && Swip == false && SpiaAltreCarte == false) { //keyCode != 144 System.out.println(TestoRFIDCard.toString()); TestoSwipCard = TestoRFIDCard; TestoRFIDCard = new StringBuilder(); warn(); } //29-10-18------------------------------------------------------ if (TimerUnaVolta == false) { TimerUnaVolta = true; final Timer timer = new Timer(); final TimerTask task = new TimerTask() { @Override public void run() { if (TestoRFIDCard.toString().length() > 2) { System.out.println("Timer: " + TestoRFIDCard.toString()); TestoSwipCard = TestoRFIDCard; TestoRFIDCard = new StringBuilder(); warn(); } timer.cancel(); timer.purge(); TimerUnaVolta = false; } }; timer.schedule(task, 5000); } //fine 29-10-18------------------------------------------------------ // char tasto = e.getKeyChar(); // if (keyCode == 144){Swip=true;} // if (keyCode != 144 && keyCode != 16 && keyCode != 17) { // // TestoSwipCard.append(tasto); // System.out.println(TestoSwipCard.toString()); // warn(); // } // if (Swip == false) { // AddRemoveKeyDispatcher(false); // if (keyCode != 16 && keyCode != 17 && keyCode != 8 && keyCode != 127) { // txtUsername.setText(txtUsername.getText() + tasto); // } // } } return true; } // private Boolean VerificaCF(String Testo) { // Boolean ok = false; // String El[] = Testo.split("_"); // if (El[0].substring(0, 1).equalsIgnoreCase("%")) { // if (El[0].length() == 17) { // TesseraCartaCF=El[0]; //// final Timer timer = new Timer(); //// final TimerTask task = new TimerTask() { //// @Override //// public void run() { // String CF = TesseraCartaCF.substring(1, 17); // String Q = "select * from(SELECT c.nome || '|' || u.cognome || '|' || u.nome || '|' || TO_CHAR (u.data_di_nascita, 'dd/mm/yyyy') || '|' || u.matricola || '|' || a.nome || '|' || c.nome || '|' || f.nome || '|' || t.ID || '|' || TO_CHAR (t.data_scadenza, 'dd/mm/yyyy') || '|' || t.id_stato || '|' || u.ID || '|' || f.ID || '|' || t.gratuita_residue AS ris " // + "FROM tessere t " // + "INNER JOIN utenti u on t.id_utente = u.id " // + "INNER JOIN categorie_utenti c on u.id_categoria = c.id " // + "INNER JOIN aziende a on c.id_azienda = a.id " // + "INNER JOIN categorie_utenti_fasce cf on cf.id_categoria_utenti = c.id " // + "INNER JOIN fasce f on cf.id_fascia = f.id " // + "WHERE u.codice_fiscale = '" + CF + "' " // + "AND t.id_stato = 1 " // + "ORDER BY t.data_scadenza desc, t.data_emissione desc) where ROWNUM=1"; // String Q2 = "select * from(SELECT t.Numero AS ris " // + "FROM tessere t " // + "INNER JOIN utenti u on t.id_utente = u.id " // + "INNER JOIN categorie_utenti c on u.id_categoria = c.id " // + "INNER JOIN aziende a on c.id_azienda = a.id " // + "INNER JOIN categorie_utenti_fasce cf on cf.id_categoria_utenti = c.id " // + "INNER JOIN fasce f on cf.id_fascia = f.id " // + "WHERE u.codice_fiscale = '" + CF + "' " // + "AND t.id_stato = 1 " // + "ORDER BY t.data_scadenza desc, t.data_emissione desc) where ROWNUM=1"; // String Tessera = MySelect(Q2, "ris"); // jTxtTessera.setText(Tessera); // PassaggioTessera = true; // ok=true; // CercaTessera(Q); // //// timer.cancel(); //// timer.purge(); // StatoCardLettore = false; // //// } //// }; //// //// timer.schedule(task, DelaySwipCard); // // } // } // // return ok; // } public void warn() { if (StatoCardLettore) { return; } // System.out.println("TestoCarteCF: " + TestoCarteCF.toString()); // if(TesseraCFLetta){ // System.out.println("TestoCarteCF letta "); // // return; // } //29-10-2018 TestoRFIDCard = new StringBuilder(); //fine 29-10-2018 // Boolean èCF = false; // TesseraCartaCF=""; // if (TestoCarteCF.toString().length() > 0) { // // èCF=VerificaCF(TestoCarteCF.toString().replaceAll("\n", "")); // TesseraCFLetta=èCF; // TestoCarteCF=new StringBuilder(); // // } if (TestoSwipCard.toString().length() > 0) {// && èCF==false) { StatoCardLettore = true; final Timer timer = new Timer(); final TimerTask task = new TimerTask() { @Override public void run() { String Tessera = ""; //per tessere tipo 8 e 9 if (TestoSwipCard.toString().indexOf("ì") >= 0) { String[] txt = TestoSwipCard.toString().split("ì"); // per tessera MASTERCARD CARDHOLDER if (TestoSwipCard.toString().length() > 30) { Tessera = txt[0].trim().replace("_", ""); } else { Tessera = txt[1].trim().replace("_", ""); } } else if (TestoSwipCard.toString().indexOf("&") >= 0) { // per tessera MASTERCARD CARDHOLDER String[] txt = TestoSwipCard.toString().split("&"); Tessera = txt[0].trim().replace("%B", ""); } else { Tessera = TestoSwipCard.toString().trim().replace("_", ""); } //per tessera tipo 3 if (Tessera.length() >= 17 && Tessera.length() <= 19) { Tessera = Tessera.substring(0, 7); } //per tessere tipo 6 e 7 if (Tessera.length() == 21) { Tessera = Tessera.substring(0, 10); int PosI = 0; for (int i = 0; i <= Tessera.length(); i++) { if (Tessera.substring(i, i + 1).equalsIgnoreCase("0") == false) { PosI = i; break; } } Tessera = Tessera.substring(PosI); } SpiaAltreCarte = false; Swip = false; if (pnlLogin.isVisible()) { ControllaLogInCarta(Tessera); // Swip = false; } else { //05/11/2018 le nuove tessere con CF a volte leggono solo la matricola // if (TestoCarteCF.toString().equalsIgnoreCase("%E_ò" + Tessera + "_") || (TestoCarteCF.toString().length()>1 && TestoCarteCF.toString().length()<=8 )) { // System.out.println("intrappolato:" + TestoCarteCF.toString()); // TesseraCFLetta=false; // TestoCarteCF=new StringBuilder(); // Azzera(); // } else { jTxtTessera.setText(Tessera); PassaggioTessera = true; LogNumeroTessera = Tessera; CercaTessera(); // } } TestoSwipCard = new StringBuilder(); // String[] txt = TestoSwipCard.toString().split("ò"); // if (txt.length > 1) { // String Tessera = txt[1].trim().replace("_", ""); // if (pnlLogin.isVisible()) { // ControllaLogInCarta(Tessera); // Swip=false; // } else { // jTxtTessera.setText(Tessera); // CercaTessera(); // // } // TestoSwipCard = new StringBuilder(); // StatoCardLettore = false; // System.out.println(Tessera); // } timer.cancel(); timer.purge(); StatoCardLettore = false; } }; timer.schedule(task, DelaySwipCard); } } }; // MyApplication MyA = new MyApplication(); // if (MyA.TastieraVideo) { KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keyDispatcher); KeyDespatcherAttivo = true; // } VerificaDB(); //KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keyDispatcher); // KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher( // new KeyEventDispatcher() { // // public boolean dispatchKeyEvent(KeyEvent e) { // int id = e.getID(); // int keyCode = e.getKeyCode(); // if (id == KeyEvent.KEY_RELEASED) { // if (keyCode != 144 && keyCode != 16 && keyCode != 17) { // char tasto = e.getKeyChar(); // TestoSwipCard.append(tasto); // System.out.println(TestoSwipCard.toString()); // warn(); // } // } // // return true; // } // // public void warn() { // if(StatoCardLettore){return;} // if (TestoSwipCard.toString().length()>0 ){ // StatoCardLettore=true; // // final Timer timer = new Timer(); // // final TimerTask task = new TimerTask() { // @Override // public void run() { // String[] txt=TestoSwipCard.toString().split("ò"); // if (txt.length>0){ // String Tessera=txt[1].trim().replace("_", ""); // jTxtTessera.setText(Tessera); // CercaTessera(); // TestoSwipCard=new StringBuilder(); // StatoCardLettore=false; // System.out.println(Tessera); // } // // // timer.cancel(); // timer.purge(); // StatoCardLettore=false; // // } // }; // timer.schedule(task, 1000); // // // } // } // }); } 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(); //Display(Message_Display," "," "); } private void VerificaAggiornamentiJAR() { try { String PathURL_Aggiornamento = MySelect("Select Valore from Parametri where chiave='UrlJAR' ", "Valore"); if (PathURL_Aggiornamento.length() > 0) { String startDir = System.getProperty("user.dir"); URL url = new URL(PathURL_Aggiornamento); HttpURLConnection httpCon = (HttpURLConnection) url.openConnection(); // File fileAgg = new File(Path_Aggiornamento); Date d = new Date(httpCon.getLastModified()); System.out.println(' ' + d.toString()); File fileAttuale = new File(startDir + "/Cassa.jar"); // File fileAgg = new File(startDir + "/Cassa.jar"); Date dA = new Date(fileAttuale.lastModified()); if (d.after(dA)) { if (JOptionPane.showConfirmDialog(null, "Aggiornamento disponibile. Aggiornare?", "Aggiornamento", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { System.out.print("Aggiorna............."); Process proc = Runtime.getRuntime().exec("java -jar " + startDir + "/Aggiornamento.jar " + startDir + " " + PathURL_Aggiornamento); System.exit(0); } } } } catch (IOException ex) { //Logger.getLogger(PuntoCassa.class.getName()).log(Level.SEVERE, null, ex); } } private void updateReaderCombo() { try { MyApplication MyA = new MyApplication(); jcmbSC.setModel(new DefaultComboBoxModel(MyA.SC.listReaders())); } catch (Exception ex) { //JOptionPane.showMessageDialog(this, "Card Reader non collegato!", "Update Reader Combo", JOptionPane.ERROR_MESSAGE); } } private void ScaricaImmagini() { this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try { Statement st; ResultSet rs; String sql = "SELECT distinct prodotti.id FROM prodotti inner join catalogo_punti_cassa on prodotti.id=CATALOGO_PUNTI_CASSA.ID_Prodotto WHERE prodotti.nome IS NOT NULL and CATALOGO_PUNTI_CASSA.id_Punto_Cassa=" + idPuntoCassa; //Integer nr=MySelectInteger("SELECT distinct count(*) as tot FROM prodotti inner join catalogo_punti_cassa on prodotti.id=CATALOGO_PUNTI_CASSA.ID_PUNTO_CASSA WHERE prodotti.nome IS NOT NULL and CATALOGO_PUNTI_CASSA.idPunto_Cassa=" + idPuntoCassa, "tot"); Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); st = dbConnection.createStatement(); rs = st.executeQuery(sql); //InputStream gifdata = null; //Integer row=1; while (rs.next()) { getImage(rs.getString("id")); /*String FullName = imgPath + rs.getString("id") + ".jpg"; gifdata = rs.getBinaryStream(1); File giffile = new File(FullName); FileOutputStream file = new FileOutputStream(giffile); int chunk = 0; while ((chunk = gifdata.read()) != -1) { file.write(chunk); } file.flush(); file.close(); /*Integer val=(100/nr)*row; jPB.setValue(val);*/ // row++; } st.close(); rs.close(); dbConnection.close(); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Errore Scarico Immagini " + e.getMessage(), "ScaricaImmagini", JOptionPane.ERROR_MESSAGE); } this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } 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; } } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ // //GEN-BEGIN:initComponents private void initComponents() { pnlErrore = new javax.swing.JPanel(); lblMessaggioErrore = new javax.swing.JLabel(); pnlTop = new javax.swing.JPanel(); pnlCliente = new javax.swing.JPanel(); jPanel1 = new javax.swing.JPanel(); lblCodice1 = new javax.swing.JLabel(); lblSaldo = new javax.swing.JLabel(); lblCodice2 = new javax.swing.JLabel(); lblPunti = new javax.swing.JLabel(); jTxtTessera = new javax.swing.JTextField(); btnImpostaCliente = new javax.swing.JButton(); jBtnReadCard = new javax.swing.JButton(); jcmbSC = new javax.swing.JComboBox(); lblCodice3 = new javax.swing.JLabel(); lblTipoPagamento = new javax.swing.JLabel(); lblCodice4 = new javax.swing.JLabel(); lblResiduo = new javax.swing.JLabel(); lblCodice5 = new javax.swing.JLabel(); lblGratuità = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); lblCodice = new javax.swing.JLabel(); lblCategoria = new javax.swing.JLabel(); lblDenominazione = new javax.swing.JLabel(); lblCognome = new javax.swing.JLabel(); lblOrganizzazione = new javax.swing.JLabel(); lblNome = new javax.swing.JLabel(); lblOrganizzazione1 = new javax.swing.JLabel(); lblNascita = new javax.swing.JLabel(); lblOrganizzazione2 = new javax.swing.JLabel(); lblScadTessera = new javax.swing.JLabel(); lblOrganizzazione3 = new javax.swing.JLabel(); lblAzienda = new javax.swing.JLabel(); lblOrganizzazione4 = new javax.swing.JLabel(); lblConvenzione = new javax.swing.JLabel(); lblOrganizzazione5 = new javax.swing.JLabel(); lblFascia = new javax.swing.JLabel(); pnlCategorie = new javax.swing.JPanel(); pnlConto = new javax.swing.JPanel(); jbtnDuplica = new javax.swing.JButton(); jbtnElimina = new javax.swing.JButton(); jbtnAnnulla = new javax.swing.JButton(); jbtnSu = new javax.swing.JButton(); jbtnGiu = new javax.swing.JButton(); txtTotaleCassa = new javax.swing.JTextField(); jbtnChiudi = new javax.swing.JButton(); jbtnStampa = new javax.swing.JButton(); txtTotalePunti = new javax.swing.JTextField(); pnlAzioni = new javax.swing.JPanel(); jBtnStorno = new javax.swing.JButton(); jBtnAsporto = new javax.swing.JToggleButton(); jBtnprodotti = new javax.swing.JButton(); jBtnMovimenti = new javax.swing.JButton(); jBtnBuoni = new javax.swing.JButton(); jTBP0 = new javax.swing.JToggleButton(); jTBP1 = new javax.swing.JToggleButton(); jTBP2 = new javax.swing.JToggleButton(); jTBP3 = new javax.swing.JToggleButton(); jbtnEsci = new javax.swing.JButton(); pnlLista = new javax.swing.JPanel(); scpLista = new javax.swing.JScrollPane(); tblLista = new javax.swing.JTable(); pnlProdotti = new javax.swing.JPanel(); pnlLista1 = new javax.swing.JPanel(); scpLista1 = new javax.swing.JScrollPane(); tblLista1 = new javax.swing.JTable(); pnlLogin = new javax.swing.JPanel(); btnLogin = new javax.swing.JButton(); txtUsername = new javax.swing.JTextField(); lblUsername = new javax.swing.JLabel(); lblPassword = new javax.swing.JLabel(); txtPassword = new javax.swing.JPasswordField(); btnTermina = new javax.swing.JButton(); jChLogin = new javax.swing.JCheckBox(); jBtnDB1 = new javax.swing.JButton(); lblUtenteLoggato = new javax.swing.JLabel(); lblStatoConnessione = new javax.swing.JLabel(); lblInfo = new javax.swing.JLabel(); lblInfo2 = new javax.swing.JLabel(); lblDB = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setTitle("Prova di titolo"); setName("frmPrincipale"); // NOI18N setResizable(false); addComponentListener(new java.awt.event.ComponentAdapter() { public void componentResized(java.awt.event.ComponentEvent evt) { resizeRules(evt); } }); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } public void windowDeiconified(java.awt.event.WindowEvent evt) { formWindowDeiconified(evt); } }); getContentPane().setLayout(null); pnlErrore.setBackground(new java.awt.Color(255, 255, 153)); pnlErrore.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); pnlErrore.setLayout(null); lblMessaggioErrore.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblMessaggioErrore.setText("lblMessaggioErrore"); lblMessaggioErrore.setToolTipText(""); lblMessaggioErrore.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); lblMessaggioErrore.setName("lblMessaggioErrore"); // NOI18N pnlErrore.add(lblMessaggioErrore); lblMessaggioErrore.setBounds(96, 24, 600, 240); getContentPane().add(pnlErrore); pnlErrore.setBounds(0, 0, 0, 0); pnlTop.setName("pnlTop"); // NOI18N pnlTop.setLayout(null); pnlCliente.setToolTipText(""); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Tessera")); lblCodice1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N lblCodice1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblCodice1.setText("Saldo:"); lblSaldo.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N lblSaldo.setText("[...]"); lblCodice2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N lblCodice2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblCodice2.setText("Punti:"); lblPunti.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N lblPunti.setText("[...]"); jTxtTessera.setToolTipText(""); jTxtTessera.addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { jTxtTesseraFocusGained(evt); } }); btnImpostaCliente.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N btnImpostaCliente.setText("Imposta"); btnImpostaCliente.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnImpostaClienteActionPerformed(evt); } }); jBtnReadCard.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jBtnReadCard.setText("Leggi Tessera"); jBtnReadCard.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnReadCardActionPerformed(evt); } }); jcmbSC.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); lblCodice3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N lblCodice3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblCodice3.setText("Tipo Pagamento:"); lblTipoPagamento.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N lblTipoPagamento.setText("[...]"); lblCodice4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N lblCodice4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblCodice4.setText("Residuo:"); lblResiduo.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N lblResiduo.setText("[...]"); lblCodice5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N lblCodice5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblCodice5.setText("Gratuità Residue:"); lblGratuità.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N lblGratuità.setText("[...]"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(lblCodice2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblCodice1, javax.swing.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE)) .addGap(8, 8, 8) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblPunti, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblSaldo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(lblCodice3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblCodice4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblCodice5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(lblResiduo, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) .addComponent(lblTipoPagamento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblGratuità, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE))) .addComponent(btnImpostaCliente, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE) .addComponent(jTxtTessera))) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(48, 48, 48) .addComponent(jBtnReadCard, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jcmbSC, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jcmbSC, javax.swing.GroupLayout.PREFERRED_SIZE, 3, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jBtnReadCard, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTxtTessera, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnImpostaCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblSaldo) .addComponent(lblCodice1, javax.swing.GroupLayout.Alignment.TRAILING)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblPunti) .addComponent(lblCodice2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblTipoPagamento) .addComponent(lblCodice3)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblResiduo) .addComponent(lblCodice4, javax.swing.GroupLayout.Alignment.TRAILING)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblCodice5) .addComponent(lblGratuità))) ); lblCodice5.getAccessibleContext().setAccessibleName("Gtratuità Residue:"); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Cliente")); lblCodice.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N lblCodice.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblCodice.setText("Categoria:"); lblCategoria.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N lblCategoria.setText("[...]"); lblDenominazione.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N lblDenominazione.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblDenominazione.setText("Cognome:"); lblCognome.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N lblCognome.setText("[...]"); lblOrganizzazione.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N lblOrganizzazione.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblOrganizzazione.setText("Nome:"); lblNome.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N lblNome.setText("[...]"); lblOrganizzazione1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N lblOrganizzazione1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblOrganizzazione1.setText("Data Nascita:"); lblNascita.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N lblNascita.setText("[...]"); lblOrganizzazione2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N lblOrganizzazione2.setForeground(new java.awt.Color(255, 0, 0)); lblOrganizzazione2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblOrganizzazione2.setText("Bonus Residui:"); lblScadTessera.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N lblScadTessera.setForeground(new java.awt.Color(255, 0, 0)); lblScadTessera.setText("[...]"); lblOrganizzazione3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N lblOrganizzazione3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblOrganizzazione3.setText("Azienda:"); lblAzienda.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N lblAzienda.setText("[...]"); lblOrganizzazione4.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N lblOrganizzazione4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblOrganizzazione4.setText("Convenzione:"); lblConvenzione.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N lblConvenzione.setText("[...]"); lblOrganizzazione5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N lblOrganizzazione5.setForeground(new java.awt.Color(255, 0, 0)); lblOrganizzazione5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblOrganizzazione5.setText("Fascia:"); lblFascia.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N lblFascia.setForeground(new java.awt.Color(255, 0, 0)); lblFascia.setText("[...]"); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(lblOrganizzazione5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblOrganizzazione4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblOrganizzazione3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblOrganizzazione2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblCodice, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblDenominazione, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblOrganizzazione, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblOrganizzazione1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(lblConvenzione, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE) .addComponent(lblAzienda, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblScadTessera, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblNascita, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblNome, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblCognome, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblCategoria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblFascia, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(0, 0, 0)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblCodice) .addComponent(lblCategoria)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblDenominazione) .addComponent(lblCognome)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblNome) .addComponent(lblOrganizzazione)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblOrganizzazione1) .addComponent(lblNascita)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblOrganizzazione3) .addComponent(lblAzienda)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblOrganizzazione4) .addComponent(lblConvenzione)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblOrganizzazione5) .addComponent(lblFascia)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblOrganizzazione2) .addComponent(lblScadTessera)) .addGap(6, 6, 6)) ); javax.swing.GroupLayout pnlClienteLayout = new javax.swing.GroupLayout(pnlCliente); pnlCliente.setLayout(pnlClienteLayout); pnlClienteLayout.setHorizontalGroup( pnlClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlClienteLayout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pnlClienteLayout.setVerticalGroup( pnlClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); pnlTop.add(pnlCliente); pnlCliente.setBounds(0, 0, 660, 140); pnlCliente.getAccessibleContext().setAccessibleDescription("Cliente"); pnlCliente.getAccessibleContext().setAccessibleParent(pnlCliente); pnlCategorie.setBackground(new java.awt.Color(255, 204, 204)); pnlCategorie.setBorder(javax.swing.BorderFactory.createTitledBorder("Categoria")); pnlCategorie.setLayout(new java.awt.GridLayout(10, 1, 1, 1)); pnlTop.add(pnlCategorie); pnlCategorie.setBounds(0, 0, 11, 32); pnlConto.setBackground(new java.awt.Color(255, 255, 153)); pnlConto.setBorder(javax.swing.BorderFactory.createTitledBorder("Conto")); pnlConto.setLayout(new java.awt.GridLayout(3, 0, 2, 2)); jbtnDuplica.setBackground(new java.awt.Color(140, 240, 240)); jbtnDuplica.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N jbtnDuplica.setEnabled(false); jbtnDuplica.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnDuplicaActionPerformed(evt); } }); pnlConto.add(jbtnDuplica); jbtnElimina.setBackground(new java.awt.Color(140, 240, 240)); jbtnElimina.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N jbtnElimina.setToolTipText(""); jbtnElimina.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnEliminaActionPerformed(evt); } }); pnlConto.add(jbtnElimina); jbtnAnnulla.setBackground(new java.awt.Color(140, 240, 240)); jbtnAnnulla.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jbtnAnnulla.setText("Annulla"); jbtnAnnulla.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnAnnullaActionPerformed(evt); } }); pnlConto.add(jbtnAnnulla); jbtnSu.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnSuActionPerformed(evt); } }); pnlConto.add(jbtnSu); jbtnGiu.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnGiuActionPerformed(evt); } }); pnlConto.add(jbtnGiu); txtTotaleCassa.setFont(new java.awt.Font("Tahoma", 1, 20)); // NOI18N txtTotaleCassa.setForeground(new java.awt.Color(242, 0, 0)); txtTotaleCassa.setHorizontalAlignment(javax.swing.JTextField.CENTER); txtTotaleCassa.setText("? 0,00"); txtTotaleCassa.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtTotaleCassaActionPerformed(evt); } }); pnlConto.add(txtTotaleCassa); jbtnChiudi.setBackground(new java.awt.Color(51, 255, 51)); jbtnChiudi.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jbtnChiudi.setText("Chiudi"); jbtnChiudi.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnChiudiActionPerformed(evt); } }); pnlConto.add(jbtnChiudi); jbtnStampa.setBackground(new java.awt.Color(255, 255, 255)); jbtnStampa.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnStampaActionPerformed(evt); } }); pnlConto.add(jbtnStampa); txtTotalePunti.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N txtTotalePunti.setHorizontalAlignment(javax.swing.JTextField.CENTER); txtTotalePunti.setText("Punti 0"); txtTotalePunti.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtTotalePuntiActionPerformed(evt); } }); pnlConto.add(txtTotalePunti); pnlTop.add(pnlConto); pnlConto.setBounds(286, 150, 265, 120); pnlAzioni.setBackground(new java.awt.Color(255, 204, 204)); pnlAzioni.setBorder(javax.swing.BorderFactory.createTitledBorder("Azioni")); pnlAzioni.setLayout(new java.awt.GridLayout(2, 6, 2, 2)); jBtnStorno.setToolTipText("Storno"); jBtnStorno.setMargin(new java.awt.Insets(2, 2, 2, 2)); jBtnStorno.setVerticalTextPosition(javax.swing.SwingConstants.TOP); jBtnStorno.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnStornoActionPerformed(evt); } }); pnlAzioni.add(jBtnStorno); jBtnAsporto.setToolTipText("Modalità"); jBtnAsporto.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnAsportoActionPerformed(evt); } }); pnlAzioni.add(jBtnAsporto); jBtnprodotti.setToolTipText("Prodotti"); jBtnprodotti.setMargin(new java.awt.Insets(2, 2, 2, 2)); jBtnprodotti.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnprodottiActionPerformed(evt); } }); pnlAzioni.add(jBtnprodotti); jBtnMovimenti.setToolTipText("Ultimi movimenti"); jBtnMovimenti.setMargin(new java.awt.Insets(2, 2, 2, 2)); jBtnMovimenti.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnMovimentiActionPerformed(evt); } }); pnlAzioni.add(jBtnMovimenti); jBtnBuoni.setToolTipText(""); jBtnBuoni.setMargin(new java.awt.Insets(2, 2, 2, 2)); jBtnBuoni.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnBuoniActionPerformed(evt); } }); pnlAzioni.add(jBtnBuoni); jTBP0.setToolTipText("A Scalare"); jTBP0.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTBP0ActionPerformed(evt); } }); pnlAzioni.add(jTBP0); jTBP1.setToolTipText("Contanti"); jTBP1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTBP1ActionPerformed(evt); } }); pnlAzioni.add(jTBP1); jTBP2.setToolTipText("Ticket"); jTBP2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTBP2ActionPerformed(evt); } }); pnlAzioni.add(jTBP2); jTBP3.setToolTipText("Differito"); jTBP3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTBP3ActionPerformed(evt); } }); pnlAzioni.add(jTBP3); jbtnEsci.setBackground(new java.awt.Color(255, 255, 0)); jbtnEsci.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jbtnEsci.setText("Esci"); jbtnEsci.setToolTipText("Esci"); jbtnEsci.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnEsciActionPerformed(evt); } }); pnlAzioni.add(jbtnEsci); pnlTop.add(pnlAzioni); pnlAzioni.setBounds(0, 153, 315, 75); pnlLista.setBackground(new java.awt.Color(204, 255, 204)); pnlLista.setBorder(javax.swing.BorderFactory.createTitledBorder("Lista")); pnlLista.setLayout(new javax.swing.BoxLayout(pnlLista, javax.swing.BoxLayout.LINE_AXIS)); scpLista.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N tblLista.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {}, {}, {}, {} }, new String [] { } )); tblLista.setName("jtbl"); // NOI18N scpLista.setViewportView(tblLista); pnlLista.add(scpLista); pnlTop.add(pnlLista); pnlLista.setBounds(288, 0, 140, 144); pnlProdotti.setBackground(new java.awt.Color(204, 255, 204)); pnlProdotti.setBorder(javax.swing.BorderFactory.createTitledBorder("Prodotto")); pnlProdotti.setLayout(new java.awt.GridLayout(6, 2, 2, 2)); pnlTop.add(pnlProdotti); pnlProdotti.setBounds(0, 0, 10, 33); pnlLista1.setBackground(new java.awt.Color(204, 255, 204)); pnlLista1.setBorder(javax.swing.BorderFactory.createTitledBorder("Lista")); pnlLista1.setLayout(new javax.swing.BoxLayout(pnlLista1, javax.swing.BoxLayout.LINE_AXIS)); scpLista1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N tblLista1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {}, {}, {}, {} }, new String [] { } )); tblLista1.setName("jtbl"); // NOI18N scpLista1.setViewportView(tblLista1); pnlLista1.add(scpLista1); pnlTop.add(pnlLista1); pnlLista1.setBounds(288, 0, 140, 144); pnlLista1.getAccessibleContext().setAccessibleName("Lista1"); getContentPane().add(pnlTop); pnlTop.setBounds(0, 188, 0, 0); pnlTop.getAccessibleContext().setAccessibleName("pnlTop"); pnlTop.getAccessibleContext().setAccessibleDescription(""); pnlLogin.setBackground(new java.awt.Color(255, 255, 153)); pnlLogin.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Accesso al sistema", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N pnlLogin.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N btnLogin.setText("Login"); btnLogin.setEnabled(false); btnLogin.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); btnLogin.setName("btnLogin"); // NOI18N btnLogin.setVerticalTextPosition(javax.swing.SwingConstants.TOP); btnLogin.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnLoginActionPerformed(evt); } }); txtUsername.setEnabled(false); txtUsername.addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { txtUsernameFocusGained(evt); } }); txtUsername.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { txtUsernameMouseClicked(evt); } }); lblUsername.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblUsername.setText("Username"); lblUsername.setToolTipText(""); lblPassword.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblPassword.setText("Password"); txtPassword.setEnabled(false); txtPassword.addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { txtPasswordFocusGained(evt); } }); txtPassword.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { txtPasswordMouseClicked(evt); } }); btnTermina.setIcon(new javax.swing.ImageIcon(getClass().getResource("/puntocassa/esci2.jpg"))); // NOI18N btnTermina.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); btnTermina.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); btnTermina.setLabel(" Termina Programma"); btnTermina.setName("btnTermina"); // NOI18N btnTermina.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnTerminaActionPerformed(evt); } }); jChLogin.setBackground(new java.awt.Color(255, 255, 153)); jChLogin.setSelected(true); jChLogin.setText("Login con tessera"); jChLogin.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jChLoginActionPerformed(evt); } }); jBtnDB1.setToolTipText("DB"); jBtnDB1.setMargin(new java.awt.Insets(2, 2, 2, 2)); jBtnDB1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBtnDB1ActionPerformed(evt); } }); javax.swing.GroupLayout pnlLoginLayout = new javax.swing.GroupLayout(pnlLogin); pnlLogin.setLayout(pnlLoginLayout); pnlLoginLayout.setHorizontalGroup( pnlLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlLoginLayout.createSequentialGroup() .addContainerGap() .addGroup(pnlLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(lblPassword, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblUsername, javax.swing.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnlLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtPassword) .addComponent(txtUsername) .addComponent(btnLogin, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(pnlLoginLayout.createSequentialGroup() .addComponent(jChLogin) .addGap(0, 0, Short.MAX_VALUE)) .addComponent(jBtnDB1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnTermina, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)) .addContainerGap()) ); pnlLoginLayout.setVerticalGroup( pnlLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnlLoginLayout.createSequentialGroup() .addComponent(jChLogin) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnlLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblUsername)) .addGap(10, 10, 10) .addGroup(pnlLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblPassword)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btnLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jBtnDB1, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnTermina, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); getContentPane().add(pnlLogin); pnlLogin.setBounds(0, 70, 360, 220); pnlLogin.getAccessibleContext().setAccessibleName("pnlLogin"); pnlLogin.getAccessibleContext().setAccessibleDescription(""); lblUtenteLoggato.setText("[Nessun utente connesso]"); lblUtenteLoggato.setVerticalAlignment(javax.swing.SwingConstants.TOP); lblUtenteLoggato.setAlignmentY(0.0F); lblUtenteLoggato.setBorder(javax.swing.BorderFactory.createEtchedBorder()); lblUtenteLoggato.setVerticalTextPosition(javax.swing.SwingConstants.TOP); getContentPane().add(lblUtenteLoggato); lblUtenteLoggato.setBounds(20, 310, 130, 20); lblStatoConnessione.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblStatoConnessione.setText("[Nessuna connessione]"); lblStatoConnessione.setVerticalAlignment(javax.swing.SwingConstants.TOP); lblStatoConnessione.setAlignmentY(0.0F); lblStatoConnessione.setBorder(javax.swing.BorderFactory.createEtchedBorder()); lblStatoConnessione.setVerticalTextPosition(javax.swing.SwingConstants.TOP); getContentPane().add(lblStatoConnessione); lblStatoConnessione.setBounds(425, 340, 120, 20); lblInfo.setText("[Info Turno]"); lblInfo.setVerticalAlignment(javax.swing.SwingConstants.TOP); lblInfo.setAlignmentY(0.0F); lblInfo.setBorder(javax.swing.BorderFactory.createEtchedBorder()); lblInfo.setVerticalTextPosition(javax.swing.SwingConstants.TOP); getContentPane().add(lblInfo); lblInfo.setBounds(180, 340, 130, 20); lblInfo2.setText("[Info Incassi]"); lblInfo2.setVerticalAlignment(javax.swing.SwingConstants.TOP); lblInfo2.setAlignmentY(0.0F); lblInfo2.setBorder(javax.swing.BorderFactory.createEtchedBorder()); lblInfo2.setVerticalTextPosition(javax.swing.SwingConstants.TOP); getContentPane().add(lblInfo2); lblInfo2.setBounds(160, 310, 130, 20); lblDB.setBackground(new java.awt.Color(51, 255, 0)); lblDB.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblDB.setText("DB"); lblDB.setOpaque(true); getContentPane().add(lblDB); lblDB.setBounds(604, 360, 20, 20); getAccessibleContext().setAccessibleName("frmPrincipale"); getAccessibleContext().setAccessibleDescription(""); getAccessibleContext().setAccessibleParent(this); setBounds(0, 0, 857, 531); }// //GEN-END:initComponents // ========================================================================== // ** Imposta dimensioni e posizione dei panel // ========================================================================== private void resize() { int x, y, w, h, tw, th, ptw, pth; // ----------------------------------------------------------------------- // *** Dimensioni del frame // ----------------------------------------------------------------------- this.setSize(displayWidth, displayHeight); tw = this.getWidth(); th = this.getHeight(); // ----------------------------------------------------------------------- // *** Posizione della status bar // ----------------------------------------------------------------------- x = 0; y = th - 50; w = (tw / 8); h = 50; lblUtenteLoggato.setLocation(x, y); lblUtenteLoggato.setSize(w, h); lblInfo.setLocation(w, y); lblInfo.setSize(w * 2 + 60 -lblDB.getWidth(), h); lblInfo2.setLocation(w * 3 + 60-lblDB.getWidth(), y); // lblInfo2.setSize(tw - (w * 2 + 10) - 131, h); int larg=tw - (w * 2 + 10) - 359; lblInfo2.setSize(larg, h); lblStatoConnessione.setLocation(tw - 181-lblDB.getWidth(), y); lblStatoConnessione.setSize(175, h); lblDB.setLocation(tw - 181-lblDB.getWidth()+lblStatoConnessione.getWidth(), y); // txtUtenteLoggato.setLocation(0, 0); // txtStatoConnessione.setLocation(w - txtStatoConnessione.getWidth(), 0); // ----------------------------------------------------------------------- // *** Posizione del panel Errore // ----------------------------------------------------------------------- x = 0; y = 0; w = tw; h = th - lblUtenteLoggato.getHeight(); pnlErrore.setLocation(x, y); pnlErrore.setSize(w, h); // ----------------------------------------------------------------------- // *** Posizione del panel Login // ----------------------------------------------------------------------- x = 0; y = 0; w = pnlLogin.getWidth(); h = pnlLogin.getHeight(); pnlLogin.setLocation((int) (tw - w) / 2, (int) (th - h) / 2); pnlLogin.setSize(w, h); // ----------------------------------------------------------------------- // *** Posizione del panel Top (operativo) // ----------------------------------------------------------------------- x = 0; y = 0; w = tw + 5; h = th - lblUtenteLoggato.getHeight(); pnlTop.setLocation(x, y); pnlTop.setSize(w, h); // ----------------------------------------------------------------------- // *** Posizionamento degli oggetti nel panel Top (operativo) // ----------------------------------------------------------------------- tw = pnlTop.getWidth(); th = pnlTop.getHeight(); // ----------------------------------------------------------------------- // ** Panel Categorie // ----------------------------------------------------------------------- x = 0; y = 0; w = (int) (13 * tw / 100); h = (int) (68 * th / 100); pnlCategorie.setLocation(x, y); pnlCategorie.setSize(w, h); // ----------------------------------------------------------------------- // ** Panel Prodotti // ----------------------------------------------------------------------- x = w; y = 0; w = (int) (57 * tw / 100); h = (int) (68 * th / 100); pnlProdotti.setLocation(x, y); pnlProdotti.setSize(w, h); // ----------------------------------------------------------------------- // ** Panel Lista // ----------------------------------------------------------------------- x = x + w; y = 0; w = tw - x - 10; h = (int) (25 * th / 100); pnlLista.setLocation(x, y); pnlLista.setSize(w, h); scpLista.setLocation(0, 0); scpLista.setSize(w, h); scpLista.setBackground(Color.BLUE); tblLista.setLocation(0, 0); tblLista.setSize(w, h); tblLista.setShowGrid(true); int Col1 = (w / 100) * 80; MyTableModel model = new MyTableModel(); String[] Col = {"Prodotto", "Prezzo", "Punti"}; model.setColumname(Col); Object[][] data = null; model.setRow(data); tblLista.setModel(model); tblLista.getColumnModel().getColumn(0).setPreferredWidth(Col1); tblLista.getColumnModel().getColumn(1).setPreferredWidth(50); tblLista.getColumnModel().getColumn(1).setCellRenderer(new DecimalFormatRenderer()); tblLista.getColumnModel().getColumn(2).setPreferredWidth(50); // tblLista.getColumnModel().getColumn(3).setPreferredWidth(0); // tblLista.getColumnModel().getColumn(3).setMaxWidth(0); // tblLista.getColumnModel().getColumn(3).setMinWidth(0); // tblLista.getColumnModel().getColumn(3).setResizable(false); tblLista.setVisible(true); // ----------------------------------------------------------------------- // ** Panel Lista1 // ----------------------------------------------------------------------- // x = x + w; y = h; // w = tw - x - 10; // h = (int) (50 * th / 100)/2; pnlLista1.setBorder(javax.swing.BorderFactory.createTitledBorder("Composizione")); pnlLista1.setLocation(x, y); pnlLista1.setSize(w, 70); scpLista1.setLocation(0, 0); scpLista1.setSize(w, h); scpLista1.setBackground(Color.BLUE); tblLista1.setLocation(0, 0); tblLista1.setSize(w, h); tblLista1.setShowGrid(true); MyTableModel model1 = new MyTableModel(); String[] ColVassoio = {"Vassoio", "Prezzo"}; model1.setColumname(ColVassoio); Object[][] data1 = null; model1.setRow(data1); tblLista1.setModel(model1); tblLista1.getColumnModel().getColumn(0).setPreferredWidth(Col1); tblLista1.getColumnModel().getColumn(1).setPreferredWidth(50); tblLista1.setVisible(true); // ----------------------------------------------------------------------- // ** Panel Cliente // ----------------------------------------------------------------------- x = 0; y = pnlCategorie.getHeight(); w = pnlCategorie.getWidth() + pnlProdotti.getWidth() - 120; //h = pnlConto.getHeight(); h = th - pnlProdotti.getHeight(); pnlCliente.setLocation(x, y); pnlCliente.setSize(w, h); // ----------------------------------------------------------------------- // ** Panel Conto // ----------------------------------------------------------------------- x = pnlLista.getX();//pnlAzioni.getWidth(); y = pnlLista.getHeight() + pnlLista1.getHeight(); w = pnlLista.getWidth(); h = 220;//th-y; pnlConto.setLocation(x, y); pnlConto.setSize(w, h - 10); ImageIcon icon = new ImageIcon(imgPath + "freccia_down.jpg"); Image img = icon.getImage(); Image newimg = img.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH); icon = new ImageIcon(newimg); jbtnGiu.setIcon(icon); ImageIcon icon2 = new ImageIcon(imgPath + "freccia_up.jpg"); Image img2 = icon2.getImage(); Image newimg2 = img2.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH); icon2 = new ImageIcon(newimg2); jbtnSu.setIcon(icon2); ImageIcon icon3 = new ImageIcon(imgPath + "ticket2.png"); Image img3 = icon3.getImage(); Image newimg3 = img3.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH); icon3 = new ImageIcon(newimg3); jBtnBuoni.setIcon(icon3); ImageIcon iconFulmine = new ImageIcon(imgPath + "fulmine.jpg"); Image imgF = iconFulmine.getImage(); Image newimgF = imgF.getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH); iconFulmine = new ImageIcon(newimgF); jbtnStampa.setIcon(iconFulmine); // ----------------------------------------------------------------------- // ** Panel Azioni // ----------------------------------------------------------------------- //x = 0; x = pnlLista.getX() - 120; y = pnlConto.getY() + pnlConto.getHeight();//pnlProdotti.getHeight() + pnlCliente.getHeight(); w = pnlLista.getWidth() + 120; //pnlCategorie.getWidth() + pnlProdotti.getWidth(); h = th - (pnlLista.getHeight() + pnlLista1.getHeight() + pnlConto.getHeight()); //th-y; pnlAzioni.setLocation(x, y); pnlAzioni.setSize(w, h); // ----------------------------------------------------------------------- // *** Refresh dell'interfaccia // ----------------------------------------------------------------------- this.revalidate(); this.repaint(); } // ========================================================================== // *** Metodo per gestire gli eventi sui button dinamici // ========================================================================== public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); String tipo; String id; String sql = ""; Statement st; ResultSet rs; int i, j, k; // JButton b; i = cmd.indexOf("["); j = cmd.indexOf("]"); id = cmd.substring(i + 1, j); tipo = cmd.substring(0, i); switch (tipo) { case "CATEGORIA": PulsantiCategoria(id, cmd); // for (k = this.pnlProdotti.getComponentCount(); k > 0; k--) { // this.pnlProdotti.remove(k - 1); // } // this.caricaDati("PRODOTTI", id); // //spengo altri togglebutton // for (Integer y =0;y 0) { Prezzo = rs.getDouble("Prezzo"); } else { Prezzo = rs.getDouble("prezzo_base"); } if (rs.getDouble("Punti") > 0) { Punti = rs.getInt("Punti"); } else { Punti = rs.getInt("Punti_Base"); } //14-01-2019 if (model.getRowCount() > 0) { //è una coposizione non la metto if (rs.getLong("id_Categoria") == 0L) { JOptionPane.showOptionDialog(this, "Composizione già presente!", "Attenzione", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); return; } } /* if(Composizioni>0 && rs.getLong("id_Categoria")==0L){ JOptionPane.showOptionDialog(this, "Composizione già presente!", "Attenzione", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); return; }*/ //if ((SaldoTessera < (TotAcquisto + Prezzo)) && idModoPagamento==0L) { //if (SaldoAcquisti(Prezzo)==false && idModoPagamento==0L) { //14-01-19<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< if (Gratuita_Residue > 0 || (FLAG_BONUS == 1 && Bonus_Residui > 0)) { //Prezzo=0.0; } //21-12-8<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< model.addRow(new Object[]{rs.getString("nome"), Prezzo, Punti, rs.getLong("idProdotto"), Prezzo, rs.getLong("id_Categoria")}); /* //9-5-18<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< if (jbtnChiudi.isEnabled()) { if (SaldoAcquisti(Prezzo) == false && CercaTestoModoPagamento().equalsIgnoreCase("A scalare") && Gratuita_Residue <= 0 && ConsentiCredito == false) { JOptionPane.showOptionDialog(this, "Saldo tessera insufficiente!", "Attenzione", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); return; } else { //model.addRow(new Object[]{rs.getString("nome"), Prezzo, Punti, rs.getLong("idProdotto"), Prezzo, rs.getLong("id_Categoria")}); //modificare<<<<<<<<<<<<<<<<<<<<< if (SaldoAcquisti(Prezzo) == false && CercaTestoModoPagamento().equalsIgnoreCase("A scalare") && ConsentiCredito) { if (JOptionPane.showConfirmDialog(null, "Saldo insufficiente. Vuoi autorizzare comunque la transazione?", "Saldo", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { model.addRow(new Object[]{rs.getString("nome"), Prezzo, Punti, rs.getLong("idProdotto"), Prezzo, rs.getLong("id_Categoria")}); MessaggioSaldoUnaVolta=true; } else { return; } } else { model.addRow(new Object[]{rs.getString("nome"), Prezzo, Punti, rs.getLong("idProdotto"), Prezzo, rs.getLong("id_Categoria")}); } } }else{ model.addRow(new Object[]{rs.getString("nome"), Prezzo, Punti, rs.getLong("idProdotto"), Prezzo, rs.getLong("id_Categoria")}); if (idTessera!=0L){jbtnChiudi.setEnabled(true);} }*/ } if (model.getRowCount() > 0) { tblLista.setRowSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); } tblLista.setModel(model); ControllaCompleti(model); ControllaExtra(model); SommaColonne(model); //inizio 21-12-18<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< if (jbtnChiudi.isEnabled()) { if (SaldoAcquisti(0.0) == false && CercaTestoModoPagamento().equalsIgnoreCase("A scalare") && Gratuita_Residue <= 0 && (Bonus_Residui <= 0 || FLAG_BONUS == 0) && ConsentiCredito == false) { JOptionPane.showOptionDialog(this, "Saldo tessera insufficiente!", "Attenzione", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); jbtnEliminaActionPerformed(null); return; } else { //model.addRow(new Object[]{rs.getString("nome"), Prezzo, Punti, rs.getLong("idProdotto"), Prezzo, rs.getLong("id_Categoria")}); //04-02-2019 /* if (SaldoAcquisti(0.0) == false && CercaTestoModoPagamento().equalsIgnoreCase("A scalare") && ConsentiCredito) { if (JOptionPane.showConfirmDialog(null, "Saldo insufficiente. Vuoi autorizzare comunque la transazione?", "Saldo", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { //model.addRow(new Object[]{rs.getString("nome"), UltimoPrezzo, UltimiPunti, rs.getLong("idProdotto"), UltimoPrezzo, rs.getLong("id_Categoria")}); MessaggioSaldoUnaVolta=true; } else { jbtnEliminaActionPerformed(null); return; } } else { //model.addRow(new Object[]{rs.getString("nome"), UltimoPrezzo, UltimiPunti, rs.getLong("idProdotto"), UltimoPrezzo, rs.getLong("id_Categoria")}); } */ } } else { //model.addRow(new Object[]{rs.getString("nome"), UltimoPrezzo, UltimiPunti, rs.getLong("idProdotto"), UltimoPrezzo, rs.getLong("id_Categoria")}); if (idTessera != 0L) { jbtnChiudi.setEnabled(true); } } //fine 21-12-18<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //stessa procedura in Cercates //prendo l'ultimo valore della griglia if (model.getRowCount() > 0) { // Double UP = Double.parseDouble(model.getValueAt(model.getRowCount() - 1, ColImporto).toString()); // String UProd = model.getValueAt(model.getRowCount() - 1, 0).toString(); // DecimalFormat df2 = new DecimalFormat("##0.00"); // String PrezzoDisplay = ("E " + df2.format(UP)); // 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); // } // // if (UProd.length() > 20) { // UProd = UProd.substring(0, 20); // } else { // UProd = SpaziBianchi(UProd, 20, true); // } // Display(UProd + fa, PrezzoDisplay);//fa+uprod Double TotAcquisto = 0.0; try { if (txtTotaleCassa.getText().length() > 0) { String Saldo = txtTotaleCassa.getText().replace("? ", "").replace(".", ""); Saldo = Saldo.replace(",", "."); TotAcquisto = Double.parseDouble(Saldo); } } catch (Exception 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); //Aggiornamento12-04-2019 //Display(UProd + fa, PrezzoDisplay);//fa+uprod } rs.close(); st.close(); dbConnection.close(); } catch (Exception ex) { System.out.println(ex.getMessage()); } } break; default: break; } } private void PulsantiCategoria(String id, String cmd) { for (Integer k = this.pnlProdotti.getComponentCount(); k > 0; k--) { this.pnlProdotti.remove(k - 1); } this.caricaDati("PRODOTTI", id); //spengo altri togglebutton if (this.pnlCategorie.getComponentCount()>2){ for (Integer y = 0; y < this.pnlCategorie.getComponentCount(); y++) { JToggleButton bt = (JToggleButton) this.pnlCategorie.getComponent(y); if (bt.getActionCommand() != cmd) { bt.setSelected(false); } else { if (bt.isSelected() == false) { //this.caricaDati("PRODOTTI", "-1"); this.caricaPannello(); } } } } } private Boolean SaldoAcquisti(Double Prezzo) { Boolean OK = false; Double SaldoTessera = 0.0; Double TotAcquisto = 0.0; try { if (lblSaldo.getText().length() > 0) { String Saldo = lblSaldo.getText().replace("? ", "").trim().replace(".", ""); Saldo = Saldo.replace("[", ""); Saldo = Saldo.replace("]", ""); Saldo = Saldo.replace(",", "."); if (Saldo.length() > 0) { SaldoTessera = Double.parseDouble(Saldo); } } if (txtTotaleCassa.getText().length() > 0) { String Saldo = txtTotaleCassa.getText().replace("? ", "").replace(".", ""); Saldo = Saldo.replace(",", "."); TotAcquisto = Double.parseDouble(Saldo); } } catch (Exception e) { } Double S = SaldoTessera - (TotAcquisto + Prezzo); if (S >= SaldoMinimoStop) { OK = true; } // if (SaldoTessera >= (TotAcquisto + Prezzo)) { // OK = true; // } return OK; } private void SommaColonne(MyTableModel model) { Double T = model.Somma(ColImporto); MyTableModel model2 = (MyTableModel) tblLista1.getModel(); if (model2.getRowCount() > 0) { T = T + model2.Somma(1); } DecimalFormat df2 = new DecimalFormat("#,###,###,##0.00"); txtTotaleCassa.setText("? " + df2.format(T)); int P = model.SommaInt(2); txtTotalePunti.setText("Punti " + P); //if(idModoPagamento==0L){ if (CercaTestoModoPagamento().equalsIgnoreCase("A scalare")) { Double SaldoCarta = 0.0; if (lblSaldo.getText().trim().length() > 0) { String Saldo = lblSaldo.getText().replace("? ", "").trim().replace(".", ""); Saldo = Saldo.replace("[", ""); Saldo = Saldo.replace("]", ""); Saldo = Saldo.replace(",", "."); if (Saldo.length() > 0) { SaldoCarta = Double.parseDouble(Saldo); } //SaldoCarta=Double.parseDouble(lblSaldo.getText().trim().replace("? ", "").replace(",", ".")); } SaldoCarta = SaldoCarta - T; lblResiduo.setText("? " + df2.format(SaldoCarta)); } } // private void CaricaCompleti() { //// String Query="Select co.id_vassoio, co.id_categoria_prodotti, pr2.id as id_Prodotto, co.quantita, ta.prezzo, ta.punti "; //// String From=" FROM composizioni co,tariffe ta,prodotti pr,prodotti pr2 " + //// " WHERE pr.id_vassoio = co.id_vassoio AND co.id_categoria_prodotti = pr2.id_categoria " + //// " AND ta.id_prodotto = pr.id AND ta.id_fascia =" + idProfiloTariffario + //// " AND pr.id_categoria = 0 " + //// " ORDER BY ta.prezzo, co.id_vassoio, co.id_categoria_prodotti, pr2.id"; // String Query = "Select distinct co.id_vassoio, co.id_categoria_prodotti, co.quantita, ta.prezzo, ta.punti"; // String From = " FROM composizioni co,tariffe ta,prodotti pr,prodotti pr2 " // + " WHERE pr.id_vassoio = co.id_vassoio AND co.id_categoria_prodotti = pr2.id_categoria " // + " AND ta.id_prodotto = pr.id AND ta.id_fascia =" + idProfiloTariffario // + " AND pr.id_categoria = 0 " // + " ORDER BY ta.prezzo, co.id_vassoio, co.id_categoria_prodotti"; // // String Query2 = "Select distinct co.id_vassoio, co.id_categoria_prodotti, co.quantita, ta.prezzo, ta.punti, " // + "(select count (*) from composizioni where id_vassoio=co.id_vassoio) as nr"; // String From2 = " FROM composizioni co,tariffe ta,prodotti pr,prodotti pr2 " // + " WHERE pr.id_vassoio = co.id_vassoio AND co.id_categoria_prodotti = pr2.id_categoria " // + " AND ta.id_prodotto = pr.id AND ta.id_fascia =" + idProfiloTariffario // + " AND pr.id_categoria = 0 " // + " ORDER BY ta.prezzo, nr, co.id_vassoio, co.id_categoria_prodotti"; // System.out.println(Query + From); // System.out.println(Query2 + From2); // try { // // Integer Size = Integer.parseInt(MySelect("Select count(distinct co.id_vassoio) as nrows " + From, "nrows")); // Integer SizeDett = Integer.parseInt(MySelect("Select count(*) as nrows from (" + Query + From + ")", "nrows")); // Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); // // Statement st = dbConnection.createStatement(); // // Completi = new Object[Size][3]; // CompletiDett = new Object[SizeDett]; // // Integer r = 0; // Integer rr = -1; // ResultSet rs = st.executeQuery(Query2 + From2); // Long idVassoio = -10L; // while (rs.next()) { // Object[] Campi = new Object[6]; // Campi[0] = rs.getLong("id_vassoio"); // Campi[1] = rs.getLong("id_categoria_prodotti"); // Campi[2] = rs.getLong("quantita"); // //Campi[3]=rs.getLong("id_Prodotto"); // Campi[3] = rs.getDouble("prezzo"); // Campi[4] = rs.getLong("punti"); // Campi[5] = 0.0;//pezzi scelti // CompletiDett[r] = Campi; // if (idVassoio != Long.parseLong(Campi[0].toString())) { // idVassoio = Long.parseLong(Campi[0].toString()); // rr++; // } // //// System.out.println("rr: " + rr); // try { // Completi[rr][0] = Campi[0]; // Completi[rr][1] = rs.getDouble("prezzo"); // Completi[rr][2] = 0.0; // } catch (Exception e) { // JOptionPane.showMessageDialog(this, "Errore: dati disallineati nelle tariffe prodotto!"); // } // r++; // } // rs.close(); // st.close(); // dbConnection.close(); // } catch (SQLException e) { // JOptionPane.showMessageDialog(this, "Errore MySelect ['" + e.getMessage() + " " + Query + "']"); // // } // } private void ControllaExtra(MyTableModel model) { //9-5-18<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //jbtnChiudi.setEnabled(true); // if (FlagRicevuta) { // jbtnStampa.setEnabled(true); // } if (FlagExtra == false) { for (int i = 0; i < model.getRowCount(); i++) { Object row[] = model.getRow(i); Double p = Double.parseDouble(row[ColImporto].toString()); if (p != 0) { //if (MessaggioFlagExtraUnaVolta == false) { JOptionPane.showMessageDialog(this, "Composizione errata, questo prodotto sarà eliminato!"); // MessaggioFlagExtraUnaVolta = true; //} //16-10-18<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< // jbtnChiudi.setEnabled(false); // jbtnStampa.setEnabled(false); jbtnEliminaActionPerformed(null); break; } } } else { for (int i = 0; i < model.getRowCount(); i++) { Object row[] = model.getRow(i); Double p = Double.parseDouble(row[ColImporto].toString()); if (p != 0) { JOptionPane.showMessageDialog(this, "Nella lista sono presenti degli extra!"); break; } } } } //02/09/2021 private void ControllaCompleti(MyTableModel model) { if (PassaggiEsauritiNoComposizione == true) { return; } MyTableModel model1 = (MyTableModel) tblLista1.getModel(); ClearTable(model1); //pulisco lista // MyTableModel model1 = (MyTableModel) tblLista1.getModel(); // for (int y = 0; y < model1.getRowCount(); y++) { // model1.deleteRow(y); // doLayout(); // } Boolean ComposizionePresente = false; StringBuilder sb=new StringBuilder(); //verifico se sono presenti composizioni for (int i = 0; i < model.getRowCount(); i++) { Object row[] = model.getRow(i); Double p = Double.parseDouble(row[4].toString()); model.setValueAt(p, i, ColImporto); sb.append(model.getValueAt(i, 3)); sb.append(","); if (Long.parseLong(row[5].toString()) == 0L) { ComposizionePresente = true; if (Gratuita_Residue > 0) {//Gratuita_ResidueProg ClearTable(model1); //Gratuita_ResidueProg--; model1.addRow(new Object[]{model.getValueAt(i, 0), 0.00, model.getValueAt(i, 3)}); } else if (FLAG_BONUS == 1 && Bonus_Residui > 0) { ClearTable(model1); //Bonus_ResiduiProg--; model1.addRow(new Object[]{model.getValueAt(i, 0), 0.00, model.getValueAt(i, 3)}); } else { ClearTable(model1); model1.addRow(new Object[]{model.getValueAt(i, 0), model.getValueAt(i, 1), model.getValueAt(i, 3)}); } model.setValueAt(0.0, i, ColImporto); } } doLayout(); if (ComposizionePresente == false && sb.toString().length()>0) { //aggiorno array Completi // for (int y = 0; y < CompletiDett.length; y++) { // Object[] Campi = new Object[6]; // Campi = (Object[]) CompletiDett[y]; //// if (Long.parseLong(Campi[2].toString()) <= Long.parseLong(Campi[5].toString())) { // if (Long.parseLong(Campi[5].toString()) > 0) { // //cerco id_vassoio e aggiorno // for (int i = 0; i < Completi.length; i++) { // if (Long.parseLong(Campi[0].toString()) == Long.parseLong(Completi[i][0].toString())) { // //12-1-18 // //Completi[i][2] = Long.parseLong(Completi[i][2].toString()) + 1; // Completi[i][2] = Long.parseLong(Completi[i][2].toString()) + Long.parseLong(Campi[5].toString()); // } // } // } // } //trovo il completo giusto // Long idVassoio = 0L, max = 0L; // Double Prezzo = 0.0; // for (int i = 0; i < Completi.length; i++) { // Long NPezzi = Long.parseLong(Completi[i][2].toString()); //// Double Prezzo2=Double.parseDouble(Completi[i][1].toString()); // // if (NPezzi > 0 && NPezzi > max) { // max = Long.parseLong(Completi[i][2].toString()); // idVassoio = Long.parseLong(Completi[i][0].toString()); // Prezzo = Double.parseDouble(Completi[i][1].toString()); // } // // } // if (Long.parseLong(idVassoio.toString()) > 0) { // //MyTableModel model1 = (MyTableModel) tblLista1.getModel(); // //if(model1.getRowCount()>0){model1.deleteRow(0);} // //cancello dalla lista prodotti i prezzi della composizione // for (int y = 0; y < CompletiDett.length; y++) { // Object[] Campi = new Object[6]; // Campi = (Object[]) CompletiDett[y]; // if (idVassoio == Long.parseLong(Campi[0].toString())) { // for (int i = 0; i < model.getRowCount(); i++) { // if (Long.parseLong(Campi[1].toString()) == Long.parseLong(model.getValueAt(i, ColCategoria).toString())) { // Double p = 0.00; // model.setValueAt(p, i, ColImporto); // //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< // // se la quantità per la stessa categoria è >1 devo azzerare tutti i successivi // int qtà = Integer.parseInt(Campi[2].toString()) - 1; // if (qtà > 0) { // for (int j = i + 1; j < model.getRowCount(); j++) { // if (Long.parseLong(Campi[1].toString()) == Long.parseLong(model.getValueAt(j, ColCategoria).toString())) { // model.setValueAt(p, j, ColImporto); // qtà--; // if (qtà <= 0) { // break; // } // } // } // } // //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< // break; // } // } // } // } //azzero prezzi dei componenti della composizione //23-09-22 //for (int i = 0; i < model.getRowCount()-1; i++) { for (int i = 0; i < model.getRowCount(); i++) { model.setValueAt(0.00, i, ColImporto); } String idVassoio = MySelect("SELECT seleziona_composizione('" + sb.toString().substring(0,sb.toString().length()-1) + "') as idCompleto from dual", "idCompleto"); if (Long.parseLong(idVassoio)!=-1) { String Completo = MySelect("Select nome from vassoi where id=" + idVassoio, "nome"); String Prezzo = MySelect("Select prezzo from tariffe where id_fascia=" + idProfiloTariffario + " and id_prodotto=" + idVassoio, "prezzo"); if (Gratuita_Residue > 0) {//Gratuita_ResidueProg ClearTable(model1); //Gratuita_ResidueProg--; model1.addRow(new Object[]{Completo, 0.00, idVassoio}); } else if (FLAG_BONUS == 1 && Bonus_Residui > 0) { ClearTable(model1); //Bonus_ResiduiProg--; model1.addRow(new Object[]{Completo, 0.00, idVassoio}); } else { ClearTable(model1); model1.addRow(new Object[]{Completo, Prezzo, idVassoio}); } //azzero elemento appena inserito se fa parte di una composizione model.setValueAt(0.00, model.getRowCount()-1, ColImporto); doLayout(); }else{ JOptionPane.showMessageDialog(this, "Composizione errata, questo prodotto sarà eliminato!"); jbtnEliminaActionPerformed(null); } // } } if (ComposizionePresente == true && sb.toString().length()>0 && model.getRowCount()>1) { JOptionPane.showMessageDialog(this, "Composizione presente, questo prodotto sarà eliminato!"); jbtnEliminaActionPerformed(null); } } // private void ControllaCompleti(MyTableModel model) { // if (PassaggiEsauritiNoComposizione == true) { // return; // } // // //pulisco lista // MyTableModel model1 = (MyTableModel) tblLista1.getModel(); // //Gratuita_ResidueProg=Gratuita_Residue; // //Bonus_ResiduiProg=Bonus_Residui; // for (int y = 0; y < model1.getRowCount(); y++) { // model1.deleteRow(y); // doLayout(); // } //// if (model1.getRowCount() > 0) { //// model1.deleteRow(0); //// doLayout(); //// } // // //ripulisco array scelte // for (int y = 0; y < CompletiDett.length; y++) { // Object[] Campi = new Object[6]; // Campi = (Object[]) CompletiDett[y]; // Campi[5] = 0L; // CompletiDett[y] = Campi; // } // for (int y = 0; y < Completi.length; y++) { // Completi[y][2] = 0L; // } // //cerco id_categoria // for (int i = 0; i < model.getRowCount(); i++) { // Object row[] = model.getRow(i); // for (int y = 0; y < CompletiDett.length; y++) { // Object[] Campi = new Object[6]; // Campi = (Object[]) CompletiDett[y]; // //12-1-18 // //if (Long.parseLong(Campi[1].toString()) == Long.parseLong(row[ColCategoria].toString())) { // if (Long.parseLong(Campi[1].toString()) == Long.parseLong(row[ColCategoria].toString()) && Long.parseLong(Campi[5].toString()) < Long.parseLong(Campi[2].toString())) { // Campi[5] = Long.parseLong(Campi[5].toString()) + 1; // CompletiDett[y] = Campi; // System.out.println("idVassoio: " + Campi[0].toString() + " - pz scelti per cat: " + Campi[5].toString() + " - max cat: " + Campi[2].toString()); // // ////break; // } // } // // } // // Boolean ComposizionePresente = false; // //verifico se sono presenti composizioni // for (int i = 0; i < model.getRowCount(); i++) { // Object row[] = model.getRow(i); // Double p = Double.parseDouble(row[4].toString()); // model.setValueAt(p, i, ColImporto); // if (Long.parseLong(row[5].toString()) == 0L) { // ComposizionePresente = true; // if (Gratuita_Residue > 0) {//Gratuita_ResidueProg // //Gratuita_ResidueProg--; // model1.addRow(new Object[]{model.getValueAt(i, 0), 0.00, model.getValueAt(i, 3)}); // } else if (FLAG_BONUS == 1 && Bonus_Residui > 0) { // //Bonus_ResiduiProg--; // model1.addRow(new Object[]{model.getValueAt(i, 0), 0.00, model.getValueAt(i, 3)}); // } else { // model1.addRow(new Object[]{model.getValueAt(i, 0), model.getValueAt(i, 1), model.getValueAt(i, 3)}); // } // // model.setValueAt(0.0, i, ColImporto); // } // // } // // if (ComposizionePresente == false) { // //aggiorno array Completi // for (int y = 0; y < CompletiDett.length; y++) { // Object[] Campi = new Object[6]; // Campi = (Object[]) CompletiDett[y]; //// if (Long.parseLong(Campi[2].toString()) <= Long.parseLong(Campi[5].toString())) { // if (Long.parseLong(Campi[5].toString()) > 0) { // //cerco id_vassoio e aggiorno // for (int i = 0; i < Completi.length; i++) { // if (Long.parseLong(Campi[0].toString()) == Long.parseLong(Completi[i][0].toString())) { // //12-1-18 // //Completi[i][2] = Long.parseLong(Completi[i][2].toString()) + 1; // Completi[i][2] = Long.parseLong(Completi[i][2].toString()) + Long.parseLong(Campi[5].toString()); // } // } // } // } // //trovo il completo giusto // Long idVassoio = 0L, max = 0L; // Double Prezzo = 0.0; // for (int i = 0; i < Completi.length; i++) { // Long NPezzi = Long.parseLong(Completi[i][2].toString()); //// Double Prezzo2=Double.parseDouble(Completi[i][1].toString()); // // if (NPezzi > 0 && NPezzi > max) { // max = Long.parseLong(Completi[i][2].toString()); // idVassoio = Long.parseLong(Completi[i][0].toString()); // Prezzo = Double.parseDouble(Completi[i][1].toString()); // } // // } // // if (Long.parseLong(idVassoio.toString()) > 0) { // //MyTableModel model1 = (MyTableModel) tblLista1.getModel(); // //if(model1.getRowCount()>0){model1.deleteRow(0);} // //cancello dalla lista prodotti i prezzi della composizione // for (int y = 0; y < CompletiDett.length; y++) { // Object[] Campi = new Object[6]; // Campi = (Object[]) CompletiDett[y]; // if (idVassoio == Long.parseLong(Campi[0].toString())) { // for (int i = 0; i < model.getRowCount(); i++) { // if (Long.parseLong(Campi[1].toString()) == Long.parseLong(model.getValueAt(i, ColCategoria).toString())) { // Double p = 0.00; // model.setValueAt(p, i, ColImporto); // //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< // // se la quantità per la stessa categoria è >1 devo azzerare tutti i successivi // int qtà = Integer.parseInt(Campi[2].toString()) - 1; // if (qtà > 0) { // for (int j = i + 1; j < model.getRowCount(); j++) { // if (Long.parseLong(Campi[1].toString()) == Long.parseLong(model.getValueAt(j, ColCategoria).toString())) { // model.setValueAt(p, j, ColImporto); // qtà--; // if (qtà <= 0) { // break; // } // } // } // } // //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< // break; // } // } // } // } // // String Completo = MySelect("Select nome from vassoi where id=" + idVassoio, "nome"); // if (Gratuita_Residue > 0) {//Gratuita_ResidueProg // //Gratuita_ResidueProg--; // model1.addRow(new Object[]{Completo, 0.00, idVassoio}); // } else if (FLAG_BONUS == 1 && Bonus_Residui > 0) { // //Bonus_ResiduiProg--; // model1.addRow(new Object[]{Completo, 0.00, idVassoio}); // } else { // model1.addRow(new Object[]{Completo, Prezzo, idVassoio}); // } // // } // } // // } // ======================Com==================================================== // ** Carica i dati di base per la maschera principale // ========================================================================== public void caricaDati(String tipo, String id) { String sql = ""; String azione = ""; String nome = ""; Statement st; ResultSet rs; JToggleButton b; // this.pnlCategorie.setLayout(new GridLayout(2,1,1,1)); JPanel pnl = this.pnlCategorie; switch (tipo) { case "CATEGORIE": //sql = "SELECT id, nome FROM categorie_prodotti WHERE nome IS NOT NULL ORDER BY id"; sql = "SELECT distinct c.id, c.nome, c.descrizione FROM categorie_prodotti c " + " INNER JOIN prodotti p ON p.id_categoria = c.ID " + " INNER JOIN catalogo_punti_cassa l ON l.id_prodotto = p.ID " + " INNER JOIN punti_cassa x ON l.id_punto_cassa = x.ID " + " WHERE x.id =" + idPuntoCassa + " order by c.descrizione"; System.out.println(sql); azione = "CATEGORIA"; pnl = this.pnlCategorie; break; case "PRODOTTI": //sql = "SELECT id, nome FROM prodotti WHERE nome IS NOT NULL AND id_categoria = " + id + " ORDER BY id"; //sql = "SELECT distinct prodotti.id, prodotti.nome FROM prodotti inner join tariffe on prodotti.id=tariffe.id_prodotto inner join catalogo_punti_cassa on prodotti.id=CATALOGO_PUNTI_CASSA.ID_Prodotto WHERE nome IS NOT NULL AND prodotti.id_categoria = " + id + " and catalogo_punti_cassa.id_Punto_cassa=" + idPuntoCassa + " and tariffe.id_fascia=" + idProfiloTariffario + " ORDER BY Prodotti.id"; //sql="Select p.id, p.nome, nvl(t.prezzo, p.prezzo_base) as prezzo, nvl(t.punti, 0) as punti from prodotti p left join tariffe t on t.id_prodotto = p.id where p.id_categoria = " + id + " and p.id_Vassoio is null and (t.id_fascia is null or t.id_fascia = " + idProfiloTariffario +") and catalogo_punti_cassa.id_Punto_cassa=" + idPuntoCassa; //if (id.equalsIgnoreCase("-1")) { /*28-03-2019 sql = "SELECT p.ID, p.nome, NVL (t.prezzo, p.prezzo_base) AS prezzo,NVL (t.punti, 0) AS punti,cat.nome as Categoria "; String sql2 = " FROM prodotti p , tariffe t, catalogo_punti_cassa c,categorie_prodotti cat " + " WHERE p.flag_catalogo_variabile = 1" + " AND p.id_categoria = cat.id " + " AND t.id_prodotto = p.id " + " AND t.id_fascia = " + idProfiloTariffario + " AND c.id_prodotto = p.id AND c.id_punto_cassa =" + idPuntoCassa + " order by cat.descrizione,p.id"; MyApplication MyA = new MyApplication(); String nrec = MyA.MySelect(this, "SELECT count(*) as nrec " + sql2, "nrec"); if (Integer.parseInt(nrec) <= 0) { MenùGiornoPresente = false; String idComposizione = MyA.MySelect(this, "select id from Categorie_Prodotti where Upper(Nome)='COMPOSIZIONE'", "id"); caricaDati("PRODOTTI", idComposizione); break; } else { MenùGiornoPresente = true; sql = sql + sql2; } */ //} else { sql = "SELECT p.ID, p.nome, NVL (t.prezzo, p.prezzo_base) AS prezzo,NVL (t.punti, 0) AS punti FROM prodotti p , tariffe t, catalogo_punti_cassa c " + " WHERE p.id_categoria = " + id + " AND t.id_prodotto = p.id " + " AND t.id_fascia = " + idProfiloTariffario + " AND c.id_prodotto = p.id AND c.id_punto_cassa =" + idPuntoCassa + " ORDER BY p.flag_catalogo_variabile desc, p.nome"; System.out.println(sql); //} azione = "PRODOTTO"; pnl = this.pnlProdotti; break; } try { Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); st = dbConnection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = st.executeQuery(sql); if (tipo.equalsIgnoreCase("CATEGORIE")) { int rowcount = 0; while (rs.next()) { rowcount++; } if (rowcount > 0) { NumeroCategorie = rowcount; rs.beforeFirst(); pnl.setLayout(new GridLayout(rowcount + 1, 1, 1, 1)); } } pnl.removeAll(); while (rs.next()) { nome = "" + rs.getString("nome") + ""; b = new JToggleButton(nome); b.setEnabled(CassaAperta); //getImage(rs.getString("id"),rs.getString("nome") ); // File imageCheck = new File(imgPath + rs.getString("id") + ".jpg"); // ImageIcon img; // if (imageCheck.exists()) { // img = new ImageIcon(imageCheck.getAbsolutePath()); // b.setIcon(img); // b.setHorizontalAlignment(SwingConstants.CENTER); // b.setHorizontalTextPosition(SwingConstants.CENTER); // b.setVerticalAlignment(SwingConstants.TOP); // b.setVerticalTextPosition(SwingConstants.TOP); // } else { b.setHorizontalAlignment(SwingConstants.CENTER); b.setVerticalAlignment(SwingConstants.CENTER); b.setVerticalTextPosition(SwingConstants.CENTER); // } b.setText(nome); // Font f=new Font("Tahoma",0,12); // b.setFont(f); /*28-03-2019------------ if (id.equalsIgnoreCase("-1")) { switch (rs.getString("Categoria").toUpperCase()) { case "PRIMO": Color c = new Color(255, 204, 204); b.setBackground(c); break; case "SECONDO": b.setBackground(Color.CYAN); break; case "CONTORNO": b.setBackground(Color.GREEN); break; default: b.setBackground(Color.yellow); break; } }-----------*/ b.setName(rs.getString("id")); b.setActionCommand(azione + "[" + rs.getString("id") + "]"); b.addActionListener(this); b.setVisible(true); if (tipo.equalsIgnoreCase("CATEGORIE")) { // Color c=new Color(255,0, 102, 102); Font f = new Font("Tahoma", Font.BOLD, 14); b.setFont(f); b.setForeground(Color.RED); } pnl.add(b); } if (tipo.equalsIgnoreCase("CATEGORIE")) { JToggleButton bGost = new JToggleButton("[DEFAULT]"); bGost.setName("btnDefault"); Font f = new Font("Tahoma", Font.BOLD, 14); bGost.setFont(f); bGost.setForeground(Color.RED); bGost.setActionCommand("CATEGORIA[0]"); bGost.addActionListener(this); bGost.setVisible(false); pnl.add(bGost); } this.revalidate(); this.repaint(); rs.close(); st.close(); dbConnection.close(); } catch (SQLException e) { } } public void caricaPannello() { String azione = "PRODOTTO"; String where = ""; Statement st; ResultSet rs; JToggleButton b; String sql = "select * from (SELECT p.ID, p.nome, NVL (t.prezzo, p.prezzo_base) AS prezzo,NVL (t.punti, 0) AS punti,cat.nome as Categoria "; String sql2 = " FROM prodotti p , tariffe t, catalogo_punti_cassa c,categorie_prodotti cat " + " WHERE p.flag_catalogo_variabile = 1" + " AND p.id_categoria = cat.id " + " AND t.id_prodotto = p.id " + " AND t.id_fascia = " + idProfiloTariffario + " AND c.id_prodotto = p.id AND c.id_punto_cassa =" + idPuntoCassa; MyApplication MyA = new MyApplication(); String nrec = MyA.MySelect(this, "SELECT count(*) as nrec " + sql2, "nrec"); if (Integer.parseInt(nrec) <= 0) { MenùGiornoPresente = false; String idComposizione = MyA.MySelect(this, "select id from Categorie_Prodotti where Upper(Nome)='COMPOSIZIONE'", "id"); caricaDati("PRODOTTI", idComposizione); } else { MenùGiornoPresente = true; sql = sql + sql2; } JPanel pnl = this.pnlProdotti; pnl.setLayout(new GridLayout(6, 5, 1, 1)); pnl.removeAll(); for (Integer r = 0; r < 6; r++) { Color c2 = new Color(255, 153, 255); switch (r) { case 0: where = " and upper(cat.CODICE)='PRIM' "; break; case 1: where = " and upper(cat.CODICE)='SECO' "; c2 = Color.CYAN; break; case 2: where = " and upper(cat.CODICE)='CONT' "; c2 = new Color(146, 208, 80); break; case 3: where = " and upper(cat.CODICE)='DESS' "; c2 = Color.yellow; break; case 4: where = " and (upper(cat.CODICE)='INSA' OR upper(cat.CODICE)='UNI' OR upper(cat.CODICE)='UNR2') "; c2 = Color.GREEN; break; case 5: where = " and (upper(cat.CODICE)='SALA' OR upper(cat.CODICE)='PIZZ') "; c2 = new Color(255, 217, 102); break; } Integer np=0; try { Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); st = dbConnection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = st.executeQuery(sql + where + " order by p.id) where ROWNUM <= 7"); Font f=new Font("Tahoma", Font.BOLD,13); String Jolly=""; String idJolly=""; while (rs.next()) { if (rs.getString("nome").toUpperCase().indexOf("JOLLY")>=0) { Jolly= "" + rs.getString("nome") + ""; idJolly= rs.getString("id"); } else { String nome = "" + rs.getString("nome") + ""; JToggleButton bt = new JToggleButton(nome); bt.setBackground(c2); bt.setEnabled(CassaAperta); bt.setFont(f); // MyCanvas tl = new MyCanvas(nome); Insets ins = new Insets(0, 0, 0, 0); bt.setMargin(ins); bt.setHorizontalAlignment(SwingConstants.LEFT); bt.setVerticalAlignment(SwingConstants.TOP); bt.setVerticalTextPosition(SwingConstants.TOP); bt.setName(rs.getString("id")); bt.setActionCommand(azione + "[" + rs.getString("id") + "]"); bt.addActionListener(this); // bt.add(tl); bt.setVisible(true); // JLabel text3 = new JLabel(); // text3.setText(nome); // text3.setFont(f); // text3.setLocation(0, 0); // text3.setHorizontalAlignment(SwingConstants.LEFT); // text3.setVerticalAlignment(SwingConstants.TOP); // text3.setVerticalTextPosition(SwingConstants.TOP); // text3.setSize(200,200); // bt.add(text3); // bt.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); pnl.add(bt); np++; if(np==5){break;} } } for (Integer c = np; c < 6; c++) { JToggleButton bt; if (c == 5 && Jolly.length() > 1) { bt = new JToggleButton(Jolly); bt.setName(idJolly); bt.setActionCommand(azione + "[" + idJolly + "]"); } else { bt = new JToggleButton(""); bt.setName("0"); bt.setActionCommand(azione + "[0]"); } bt.setBackground(c2); bt.setFont(f); bt.setEnabled(CassaAperta); Insets ins = new Insets(0, 0, 0, 0); bt.setMargin(ins); bt.setHorizontalAlignment(SwingConstants.LEFT); bt.setVerticalAlignment(SwingConstants.TOP); bt.setVerticalTextPosition(SwingConstants.TOP); bt.addActionListener(this); bt.setVisible(true); pnl.add(bt); } rs.close(); st.close(); dbConnection.close(); } catch (SQLException e) { } } this.revalidate(); this.repaint(); } /* public void caricaDati(String tipo, String id) { String sql = ""; String azione = ""; String nome = ""; Statement st; ResultSet rs; JToggleButton b; // this.pnlCategorie.setLayout(new GridLayout(2,1,1,1)); JPanel pnl = this.pnlCategorie; switch (tipo) { case "CATEGORIE": //sql = "SELECT id, nome FROM categorie_prodotti WHERE nome IS NOT NULL ORDER BY id"; sql = "SELECT distinct c.id, c.nome, c.descrizione FROM categorie_prodotti c " + " INNER JOIN prodotti p ON p.id_categoria = c.ID " + " INNER JOIN catalogo_punti_cassa l ON l.id_prodotto = p.ID " + " INNER JOIN punti_cassa x ON l.id_punto_cassa = x.ID " + " WHERE x.id =" + idPuntoCassa + " order by c.descrizione"; System.out.println(sql); azione = "CATEGORIA"; pnl = this.pnlCategorie; break; case "PRODOTTI": //sql = "SELECT id, nome FROM prodotti WHERE nome IS NOT NULL AND id_categoria = " + id + " ORDER BY id"; //sql = "SELECT distinct prodotti.id, prodotti.nome FROM prodotti inner join tariffe on prodotti.id=tariffe.id_prodotto inner join catalogo_punti_cassa on prodotti.id=CATALOGO_PUNTI_CASSA.ID_Prodotto WHERE nome IS NOT NULL AND prodotti.id_categoria = " + id + " and catalogo_punti_cassa.id_Punto_cassa=" + idPuntoCassa + " and tariffe.id_fascia=" + idProfiloTariffario + " ORDER BY Prodotti.id"; //sql="Select p.id, p.nome, nvl(t.prezzo, p.prezzo_base) as prezzo, nvl(t.punti, 0) as punti from prodotti p left join tariffe t on t.id_prodotto = p.id where p.id_categoria = " + id + " and p.id_Vassoio is null and (t.id_fascia is null or t.id_fascia = " + idProfiloTariffario +") and catalogo_punti_cassa.id_Punto_cassa=" + idPuntoCassa; if (id.equalsIgnoreCase("-1")) { sql = "SELECT p.ID, p.nome, NVL (t.prezzo, p.prezzo_base) AS prezzo,NVL (t.punti, 0) AS punti,cat.nome as Categoria "; String sql2 = " FROM prodotti p , tariffe t, catalogo_punti_cassa c,categorie_prodotti cat " + " WHERE p.flag_catalogo_variabile = 1" + " AND p.id_categoria = cat.id " + " AND t.id_prodotto = p.id " + " AND t.id_fascia = " + idProfiloTariffario + " AND c.id_prodotto = p.id AND c.id_punto_cassa =" + idPuntoCassa + " order by cat.descrizione,p.id"; MyApplication MyA = new MyApplication(); String nrec = MyA.MySelect(this, "SELECT count(*) as nrec " + sql2, "nrec"); if (Integer.parseInt(nrec) <= 0) { MenùGiornoPresente = false; String idComposizione = MyA.MySelect(this, "select id from Categorie_Prodotti where Upper(Nome)='COMPOSIZIONE'", "id"); caricaDati("PRODOTTI", idComposizione); break; } else { MenùGiornoPresente = true; sql = sql + sql2; } } else { sql = "SELECT p.ID, p.nome, NVL (t.prezzo, p.prezzo_base) AS prezzo,NVL (t.punti, 0) AS punti FROM prodotti p , tariffe t, catalogo_punti_cassa c " + " WHERE p.id_categoria = " + id + " AND t.id_prodotto = p.id " + " AND t.id_fascia = " + idProfiloTariffario + " AND c.id_prodotto = p.id AND c.id_punto_cassa =" + idPuntoCassa + " ORDER BY p.flag_catalogo_variabile desc, p.nome"; } azione = "PRODOTTO"; pnl = this.pnlProdotti; break; } try { Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); st = dbConnection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = st.executeQuery(sql); if (tipo.equalsIgnoreCase("CATEGORIE")) { int rowcount = 0; while (rs.next()) { rowcount++; } if (rowcount > 0) { NumeroCategorie = rowcount; rs.beforeFirst(); pnl.setLayout(new GridLayout(rowcount + 1, 1, 1, 1)); } } pnl.removeAll(); while (rs.next()) { nome = "" + rs.getString("nome") + ""; b = new JToggleButton(nome); b.setEnabled(CassaAperta); //getImage(rs.getString("id"),rs.getString("nome") ); // File imageCheck = new File(imgPath + rs.getString("id") + ".jpg"); // ImageIcon img; // if (imageCheck.exists()) { // img = new ImageIcon(imageCheck.getAbsolutePath()); // b.setIcon(img); // b.setHorizontalAlignment(SwingConstants.CENTER); // b.setHorizontalTextPosition(SwingConstants.CENTER); // b.setVerticalAlignment(SwingConstants.TOP); // b.setVerticalTextPosition(SwingConstants.TOP); // } else { b.setHorizontalAlignment(SwingConstants.CENTER); b.setVerticalAlignment(SwingConstants.CENTER); b.setVerticalTextPosition(SwingConstants.CENTER); // } b.setText(nome); // Font f=new Font("Tahoma",0,12); // b.setFont(f); /*28-03-2019------------ if (id.equalsIgnoreCase("-1")) { switch (rs.getString("Categoria").toUpperCase()) { case "PRIMO": Color c = new Color(255, 204, 204); b.setBackground(c); break; case "SECONDO": b.setBackground(Color.CYAN); break; case "CONTORNO": b.setBackground(Color.GREEN); break; default: b.setBackground(Color.yellow); break; } }-----------*/ /* b.setName(rs.getString("id")); b.setActionCommand(azione + "[" + rs.getString("id") + "]"); b.addActionListener(this); b.setVisible(true); if (tipo.equalsIgnoreCase("CATEGORIE")) { // Color c=new Color(255,0, 102, 102); Font f = new Font("Tahoma", Font.BOLD, 14); b.setFont(f); b.setForeground(Color.RED); } pnl.add(b); } if (tipo.equalsIgnoreCase("CATEGORIE")) { JToggleButton bGost = new JToggleButton("[DEFAULT]"); bGost.setName("btnDefault"); Font f = new Font("Tahoma", Font.BOLD, 14); bGost.setFont(f); bGost.setForeground(Color.RED); bGost.setActionCommand("CATEGORIA[-1]"); bGost.addActionListener(this); bGost.setVisible(false); pnl.add(bGost); } this.revalidate(); this.repaint(); rs.close(); st.close(); dbConnection.close(); } catch (SQLException e) { } } */ private void CaricaModiPagamento() { try { Statement st; ResultSet rs; Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); st = dbConnection.createStatement(); rs = st.executeQuery("Select * from Tipi_Pagamenti order by id"); while (rs.next()) { ModiPagamento.append(rs.getString("id") + ';' + rs.getString("nome") + "|"); //03-07-2017 // if (rs.getString("nome").equalsIgnoreCase("Contanti")){ // idModoPagamento=rs.getLong("id"); // } } this.revalidate(); this.repaint(); rs.close(); st.close(); dbConnection.close(); } catch (SQLException e) { } } // ========================================================================== // ** Quando viene chiusa la form esce dall'applicazione // ========================================================================== private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm Object[] options = {"Sì", "No"}; Object selectedValue = JOptionPane.showOptionDialog(this, "Confermi chiusura programma?", "Attenzione", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[1]); if (Integer.parseInt(selectedValue.toString()) == 0) { MyInsert("UPDATE PARAMETRI set valore='NO' where chiave='FlagDownloadInCorso'"); Long nrec = MySelectInteger("SELECT count(*) as nrec FROM acquisti", "nrec"); if (nrec > 0) { if (JOptionPane.showConfirmDialog(null, "Attenzione, ci sono " + nrec + " passaggi non ancora trasferiti al database centrale,\nconferma chiusura programma?", "Acquisti", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { StatoAttivoNonLoggato(); System.exit(0); } else { return; } } StatoAttivoNonLoggato(); System.exit(0); } }//GEN-LAST:event_exitForm // ========================================================================== // ** Click sul btnLogin // ========================================================================== private Boolean Turno() { Boolean OK = false; String Query = "select t.dalle, t.alle, t.id, t.nome from turni t, turni_punti_distribuzione x, punti_distribuzione p, punti_cassa c where x.id_turno = t.id and x.id_punto_distribuzione = p.id and c.id_punto_distribuzione = p.id and c.id =" + idPuntoCassa; try { String[] mo = MySelect("Select sysdate as mo from dual", "mo").split(" "); Statement st; ResultSet rs; Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); st = dbConnection.createStatement(); rs = st.executeQuery(Query); while (rs.next()) { String Dalle = rs.getString("dalle"); String Alle = rs.getString("alle"); try { //Date Adesso=new Date(); Date Adesso = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ENGLISH).parse(mo[0] + " " + mo[1]); Date Da = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ENGLISH).parse(mo[0] + " " + Dalle); Date A = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ENGLISH).parse(mo[0] + " " + Alle); //JOptionPane.showMessageDialog(this, Da + " e " + Adesso.compareTo(A)); if (Adesso.after(Da) && Adesso.before(A)) { idTurno = rs.getLong("id"); NomeTurno = rs.getString("nome"); idTurnoAttuale = idTurno; NomeTurnoAttuale = NomeTurno; OK = true; break; } } catch (Exception e) { } } rs.close(); st.close(); dbConnection.close(); } catch (SQLException e) { JOptionPane.showMessageDialog(this, "Errore DB ['" + Query + "']"); } return OK; } private void TurnoAttuale() { String Query = "select t.dalle, t.alle, t.id, t.nome from turni t, turni_punti_distribuzione x, punti_distribuzione p, punti_cassa c where x.id_turno = t.id and x.id_punto_distribuzione = p.id and c.id_punto_distribuzione = p.id and c.id =" + idPuntoCassa; try { String[] mo = MySelect("Select sysdate as mo from dual", "mo").split(" "); Statement st; ResultSet rs; Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); st = dbConnection.createStatement(); rs = st.executeQuery(Query); while (rs.next()) { String Dalle = rs.getString("dalle"); String Alle = rs.getString("alle"); try { //Date Adesso=new Date(); Date Adesso = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ENGLISH).parse(mo[0] + " " + mo[1]); Date Da = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ENGLISH).parse(mo[0] + " " + Dalle); Date A = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ENGLISH).parse(mo[0] + " " + Alle); //JOptionPane.showMessageDialog(this, Da + " e " + Adesso.compareTo(A)); if (Adesso.after(Da) && Adesso.before(A)) { idTurnoAttuale = rs.getLong("id"); NomeTurnoAttuale = rs.getString("nome"); break; } } catch (Exception e) { } } rs.close(); st.close(); dbConnection.close(); } catch (SQLException e) { JOptionPane.showMessageDialog(this, "Errore DB ['" + Query + "']"); } } private void ImpostaAmbiente() { // ----------------------------------------------------------- // ** id punto cassa // ----------------------------------------------------------- idPuntoCassa = MySelectInteger("select Punti_Cassa.id as idPC from Punti_Cassa where Punti_Cassa.id=" + idPuntoCassa, "idPC"); // ----------------------------------------------------------- // ** Imposta l'ambiente // ----------------------------------------------------------- txtUsername.setEnabled(false); txtPassword.setEnabled(false); btnLogin.setEnabled(false); AddRemoveKeyDispatcher(true); //database di produzione si inceppa nello scarico immagini //ScaricaImmagini(); AggiungiImmaginiPulsanti(); if (jChLogin.isSelected() == false && utenteLoggato.length() <= 0) { utenteLoggato = txtUsername.getText(); } lblUtenteLoggato.setText("LogIn: [" + utenteLoggato + "]"); this.resize(); this.caricaDati("CATEGORIE", "0"); pnlErrore.setVisible(false); pnlLogin.setVisible(false); pnlTop.setVisible(true); pnlProdotti.setVisible(true); jBtnStorno.setEnabled(false); //jBtnTicket.setEnabled(false); //jBtnCarta.setEnabled(false); jBtnAsporto.setEnabled(false); // jBtnBuoni.setEnabled(false); jbtnSu.setEnabled(false); jbtnGiu.setEnabled(false); jbtnElimina.setEnabled(false); jbtnAnnulla.setEnabled(false); // jbtnStampa.setEnabled(false); jbtnDuplica.setEnabled(false); String Pulsante = MySelect("SELECT p.flag_imposta_tessera as Pulsante FROM punti_distribuzione p, punti_cassa c WHERE c.id_punto_distribuzione = p.id AND c.id =" + idPuntoCassa, "Pulsante"); if (Integer.parseInt(Pulsante) == 1) { BottoneImposta = true; btnImpostaCliente.setVisible(true); btnImpostaCliente.setEnabled(true); jTxtTessera.setEnabled(true); } else { BottoneImposta = false; // btnImpostaCliente.setVisible(false); btnImpostaCliente.setEnabled(false); jTxtTessera.setEnabled(false); } //tasto imposta // String QueryTasto="select count(*) as res from punti_cassa pc, punti_distribuzione pd where pc.id_punto_distribuzione = pd.id " + // " and pd.flag_imposta_tessera = 1 and pc.id =" + idPuntoCassa; // MyApplication MyA=new MyApplication(); // Integer Visibile=Integer.parseInt(MyA.MySelect(this, QueryTasto, "res")); // if(Visibile==0){ //// btnImpostaCliente.setVisible(false); // btnImpostaCliente.setEnabled(false); // jTxtTessera.setEnabled(false); // } if (idPuntoCassa != 0) { AggiornaProgressivi(); //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< /* // ----------------------------------------------------------- // ** progressivo assoluto scontrino // ----------------------------------------------------------- String prog = MySelect("select nvl(max(prog_assoluto),0) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa, "Prog"); Progressivo = Long.parseLong(prog); // ----------------------------------------------------------- // ** progressivo giorno turno scontrino // ----------------------------------------------------------- Date Adesso=new Date(); String progT = MySelect("select nvl(max(prog_turno),0) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and id_Turno=" + idTurno + " and data=" + AggiustaData(Adesso) , "Prog"); ProgressivoTurno = Long.parseLong(progT); // ----------------------------------------------------------- // ** progressivo giorno scontrino // ---------------------c-------------------------------------- // String[] El = MySelect("select nvl(max(prog_giorno),0) || '|' || count(*) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and data=" + AggiustaData(Adesso) , "Prog").split("\\|"); // String progG=El[0]; // if (Long.parseLong(El[1])<= 0) { // MyInsert("Insert into Progressivi (data,id_Punto_cassa,id_Turno,prog_assoluto,prog_giorno,prog_turno) " + // " values (" + AggiustaData(Adesso) + "," + idPuntoCassa + "," + idTurno + "," + Progressivo + ",0,0)"); //// " values (" + AggiustaData(Adesso) + "," + idPuntoCassa + "," + idTurno + "," + prog + ",0,0)"); // } String progG = MySelect("select nvl(max(prog_giorno),0) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and data=" + AggiustaData(Adesso) , "Prog"); ProgressivoGiorno = Long.parseLong(progG); String ControlloTurno=MySelect("select count(*) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and data=" + AggiustaData(Adesso) + " and id_Turno=" + idTurno , "Prog"); if (Long.parseLong(ControlloTurno)<=0){ MyInsert("Insert into Progressivi (data,id_Punto_cassa,id_Turno,prog_assoluto,prog_giorno,prog_turno) " + " values (" + AggiustaData(Adesso) + "," + idPuntoCassa + "," + idTurno + "," + Progressivo + "," + ProgressivoGiorno + ",0)"); // } Progressivo++; ProgressivoGiorno++; ProgressivoTurno++; // ----------------------------------------------------------- // ** incassi turno pagamento a scalare // ----------------------------------------------------------- String progPS = MySelect("select nvl(sum(incasso_turno_scalare),0) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and id_Turno=" + idTurno + " and data=" + AggiustaData(Adesso), "Prog"); ProgressivoScalare = Double.parseDouble(progPS); // ----------------------------------------------------------- // ** incassi turno pagamento a contanti // ----------------------------------------------------------- String progPC = MySelect("select nvl(sum(incasso_turno_contanti),0) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and id_Turno=" + idTurno + " and data=" + AggiustaData(Adesso), "Prog"); ProgressivoContanti = Double.parseDouble(progPC); // ----------------------------------------------------------- // ** incassi turno pagamento ticket // ----------------------------------------------------------- String progPT = MySelect("select nvl(sum(incasso_turno_ticket),0) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and id_Turno=" + idTurno + " and data=" + AggiustaData(Adesso), "Prog"); ProgressivoTicket = Double.parseDouble(progPT); AggiornaLabelInfo(); //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */ //KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keyDispatcher); if (btnImpostaCliente.isVisible()) { btnImpostaCliente.setEnabled(false); } jBtnprodotti.setEnabled(false); //jBtnMeteo.setEnabled(false); //jBtnDB.setEnabled(false); Meteo(); if (btnImpostaCliente.isVisible()) { btnImpostaCliente.setEnabled(BottoneImposta); } jBtnprodotti.setEnabled(true); //jBtnMeteo.setEnabled(true); //jBtnDB.setEnabled(true); jbtnDuplica.setText("Duplica
Prodotto"); jbtnElimina.setText("Elimina
Prodotto"); CaricaModiPagamento(); VerificaModoPagamento(); PulsantiModoPagamento(); //modifica 09-5-2018------------------------------------ if (FlagPrecaricaLista) { AbilitaPulsanti(pnlCategorie, true,true); AbilitaPulsanti(pnlProdotti, true,true); idProfiloTariffarioDefault = MySelectInteger("select Valore from Parametri where upper(chiave)='IDFASCIADEFAULT'", "Valore"); System.out.print("" + idProfiloTariffarioDefault); ApriCassaDefault(); } //modifica 09-5-2018------------------------------------ // jbtnDuplica.setLayout(new BorderLayout()); // JLabel label1 = new JLabel("Duplica"); // label1.setFont(jbtnDuplica.getFont()); // JLabel label2 = new JLabel("Prodotto"); // label2.setFont(jbtnDuplica.getFont()); // jbtnDuplica.add(BorderLayout.CENTER,label1); // jbtnDuplica.add(BorderLayout.SOUTH,label2); //label1.setLocation(10, 10); // jTxtTessera.requestFocus(); // // jTxtTessera.getDocument().addDocumentListener(new DocumentListener() { // public void changedUpdate(DocumentEvent e) { //// warn(); // } // public void removeUpdate(DocumentEvent e) { //// warn(); // } // public void insertUpdate(DocumentEvent e) { // warn(); // } // // public void warn() { // if(StatoCardLettore){return;} // if (jTxtTessera.getText().length()>0 ){ // StatoCardLettore=true; //// timerCardLettore = new java.util.Timer(); //// timerCardLettore.schedule(new CardTaskLettore(PuntoCassa.this),1000, 1*5000); // // final Timer timer = new Timer(); // // final TimerTask task = new TimerTask() { // @Override // public void run() { // String[] txt=jTxtTessera.getText().split("ò"); // if (txt.length>0){ // String Tessera=txt[1].trim().replace("_", ""); // jTxtTessera.setText(Tessera); // CercaTessera(); // System.out.println(Tessera); // } // // // timer.cancel(); // timer.purge(); // StatoCardLettore=false; // // } // }; // timer.schedule(task, 1000); // // // } // } // }); } else { JOptionPane.showMessageDialog(this, "ID Punto Cassa non configurato!"); } } private void VerificaDB() { final Timer timer = new Timer(); final TimerTask task = new TimerTask() { @Override public void run() { Long res=MySelectInteger("SELECT db_remoto_connesso as Stato FROM dual", "Stato"); if (res==1){ lblDB.setBackground(Color.green); }else{ lblDB.setBackground(Color.red); } lblDB.setOpaque(true); lblDB.repaint(); } }; timer.schedule(task, 1000, 10000); } public void AggiornaProgressivi() { // ----------------------------------------------------------- // ** progressivo assoluto scontrino // ----------------------------------------------------------- String prog = MySelect("select nvl(max(prog_assoluto),0) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa, "Prog"); // if(Progressivo < Long.parseLong(prog)){ Progressivo = Long.parseLong(prog); // } // ----------------------------------------------------------- // ** progressivo giorno turno scontrino // ----------------------------------------------------------- Date Adesso = new Date(); String progT = MySelect("select nvl(max(prog_turno),0) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and id_Turno=" + idTurno + " and data=" + AggiustaData(Adesso), "Prog"); // if(ProgressivoTurno < Long.parseLong(progT)){ ProgressivoTurno = Long.parseLong(progT);// + 1; // } // ----------------------------------------------------------- // ** progressivo giorno scontrino // ---------------------c-------------------------------------- // String[] El = MySelect("select nvl(max(prog_giorno),0) || '|' || count(*) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and data=" + AggiustaData(Adesso) , "Prog").split("\\|"); // String progG=El[0]; // if (Long.parseLong(El[1])<= 0) { // MyInsert("Insert into Progressivi (data,id_Punto_cassa,id_Turno,prog_assoluto,prog_giorno,prog_turno) " + // " values (" + AggiustaData(Adesso) + "," + idPuntoCassa + "," + idTurno + "," + Progressivo + ",0,0)"); //// " values (" + AggiustaData(Adesso) + "," + idPuntoCassa + "," + idTurno + "," + prog + ",0,0)"); // } String progG = MySelect("select nvl(max(prog_giorno),0) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and data=" + AggiustaData(Adesso), "Prog"); // if(ProgressivoGiorno < Long.parseLong(progG)){ ProgressivoGiorno = Long.parseLong(progG);// + 1; // } String ControlloTurno = MySelect("select count(*) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and data=" + AggiustaData(Adesso) + " and id_Turno=" + idTurno, "Prog"); if (Long.parseLong(ControlloTurno) <= 0) { MyInsert("Insert into Progressivi (data,id_Punto_cassa,id_Turno,prog_assoluto,prog_giorno,prog_turno) " + " values (" + AggiustaData(Adesso) + "," + idPuntoCassa + "," + idTurno + "," + Progressivo + "," + ProgressivoGiorno + ",0)"); // } // Progressivo++; // ProgressivoGiorno++; // ProgressivoTurno++; // ----------------------------------------------------------- // ** incassi turno pagamento a scalare // ----------------------------------------------------------- String progPS = MySelect("select nvl(sum(incasso_turno_scalare),0) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and id_Turno=" + idTurno + " and data=" + AggiustaData(Adesso), "Prog"); ProgressivoScalare = Double.parseDouble(progPS); // ----------------------------------------------------------- // ** incassi turno pagamento a contanti // ----------------------------------------------------------- String progPC = MySelect("select nvl(sum(incasso_turno_contanti),0) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and id_Turno=" + idTurno + " and data=" + AggiustaData(Adesso), "Prog"); ProgressivoContanti = Double.parseDouble(progPC); // ----------------------------------------------------------- // ** incassi turno pagamento ticket // ----------------------------------------------------------- String progPT = MySelect("select nvl(sum(incasso_turno_ticket),0) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and id_Turno=" + idTurno + " and data=" + AggiustaData(Adesso), "Prog"); ProgressivoTicket = Double.parseDouble(progPT); // ----------------------------------------------------------- // ** incassi turno pagamento differito // ----------------------------------------------------------- String progDI = MySelect("select nvl(sum(incasso_turno_differito),0) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and id_Turno=" + idTurno + " and data=" + AggiustaData(Adesso), "Prog"); ProgressivoDifferito = Double.parseDouble(progDI); AggiornaLabelInfo(); if (CercaTestoModoPagamento().equalsIgnoreCase("A scalare") && jTxtTessera.getText().length()>0) { VerificaSaldo(jTxtTessera.getText()); } } private void AggiornaLabelInfo() { Long Prog = Progressivo;// - 1; Long ProgGG = ProgressivoGiorno;// - 1; Long ProgTurno = ProgressivoTurno;// - 1; if(Progressivo<=0) Prog=0L; if(ProgressivoGiorno<=0) ProgGG=0L; if(ProgressivoTurno<=0) ProgTurno=0L; lblInfo.setText("Passaggi: Tot. [" + Prog + "], giorno [" + ProgGG + "], turno [" + ProgTurno + "]"); DecimalFormat df2 = new DecimalFormat("#,###,###,##0.00"); lblInfo2.setText("Incassi [" + NomeTurno + "]: Tot. [" + df2.format(ProgressivoScalare + ProgressivoContanti + ProgressivoTicket + ProgressivoDifferito) + "] SC [" + df2.format(ProgressivoScalare) + "], CO [" + df2.format(ProgressivoContanti) + "], TI [" + df2.format(ProgressivoTicket) + "], DI [" + df2.format(ProgressivoDifferito) + "]"); } public void AddRemoveKeyDispatcher(Boolean Aggiungi) { if (Aggiungi) { if (KeyDespatcherAttivo == false) { KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keyDispatcher); KeyDespatcherAttivo = true; } } else { KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(keyDispatcher); KeyDespatcherAttivo = false; } } private void Meteo() { String Spia = MySelect("select controlla_meteo(" + idPuntoCassa + ") as res from dual", "res"); if (Integer.parseInt(Spia) == 1) { if (MyMeteo == null) { MyMeteo = new frmMeteo(this, idPuntoCassa, true); this.setEnabled(false); Integer w = CalcolaLarghezzaAltezza(300, LargControlli); Integer h = CalcolaLarghezzaAltezza(70, AltControlli); MyMeteo.setSize(w, h); MyMeteo.setLocationRelativeTo(null); //MyD.setLocation((this.getWidth() - this.getLocation().y) / 2, (this.getHeight() - this.getLocation().x) / 2); MyMeteo.setVisible(true); } } } private void resizeRules(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_resizeRules resize(); }//GEN-LAST:event_resizeRules private void jbtnSuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSuActionPerformed // TODO add your handling code here: if (tblLista.getSelectedRow() > 0) { tblLista.setRowSelectionInterval(tblLista.getSelectedRow() - 1, tblLista.getSelectedRow() - 1); tblLista.scrollRectToVisible(new Rectangle(tblLista.getCellRect(tblLista.getSelectedRow(), 0, true))); } }//GEN-LAST:event_jbtnSuActionPerformed private void jbtnDuplicaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnDuplicaActionPerformed // TODO add your handling code here: if (tblLista.getSelectedRow() >= 0) { MyTableModel model = (MyTableModel) tblLista.getModel(); Object row[] = model.getRow(tblLista.getSelectedRow()); Boolean èComposizione = false; if (Long.parseLong(row[5].toString()) == 0L) { èComposizione = true; } if (èComposizione) { JOptionPane.showOptionDialog(this, "Composizione già presente!", "Attenzione", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); return; } else { model.addRow(row); tblLista.setRowSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); tblLista.setModel(model); ControllaCompleti(model); ControllaExtra(model); SommaColonne(model); } } }//GEN-LAST:event_jbtnDuplicaActionPerformed private void jbtnGiuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnGiuActionPerformed // TODO add your handling code here: if (tblLista.getSelectedRow() < tblLista.getRowCount() - 1) { tblLista.setRowSelectionInterval(tblLista.getSelectedRow() + 1, tblLista.getSelectedRow() + 1); tblLista.scrollRectToVisible(new Rectangle(tblLista.getCellRect(tblLista.getSelectedRow(), 0, true))); } }//GEN-LAST:event_jbtnGiuActionPerformed private void jbtnStampaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnStampaActionPerformed // Chiudi(); // Stampa(); Boolean ok= MyInsert("UPDATE PARAMETRI set valore='NO' where chiave='FlagDownloadInCorso'"); if (ok){ JOptionPane.showOptionDialog(this, "Operazione correttamente eseguita.", "Attenzione", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null); }else { JOptionPane.showOptionDialog(this, "Errore nell'aggiornamento del parametro!", "Attenzione", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); } }//GEN-LAST:event_jbtnStampaActionPerformed private void CancellaComposizioni() { try { MyTableModel model1 = (MyTableModel) tblLista1.getModel(); ClearTable(model1); } catch (Exception e) { } } private void jbtnEliminaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnEliminaActionPerformed CancellaComposizioni(); MyTableModel model = (MyTableModel) tblLista.getModel(); Integer Riga = tblLista.getSelectedRow(); if (Riga >= 0) { model.deleteRow(Riga); //ripristino i prezzi for (Integer i = 0; i < model.getRowCount(); i++) { model.setValueAt(model.getValueAt(i, ColImporto2), i, ColImporto); } //doLayout(); if (tblLista.getRowCount() > 0) { if (Riga > 0) { tblLista.setRowSelectionInterval(Riga - 1, Riga - 1); } else { tblLista.setRowSelectionInterval(0, 0); } } ControllaCompleti(model); ControllaExtra(model); SommaColonne(model); //spengo altri togglebutton for (Integer y = 0; y < this.pnlProdotti.getComponentCount(); y++) { JToggleButton bt = (JToggleButton) this.pnlProdotti.getComponent(y); bt.setSelected(false); } if (model.getRowCount() <= 0) { jbtnSu.setEnabled(false); jbtnGiu.setEnabled(false); jbtnElimina.setEnabled(false); jbtnAnnulla.setEnabled(false); //jbtnStampa.setEnabled(false); jbtnDuplica.setEnabled(false); } doLayout(); } }//GEN-LAST:event_jbtnEliminaActionPerformed private void jbtnChiudiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnChiudiActionPerformed if (VerificaPrenotazioni()){ Chiudi(); } }//GEN-LAST:event_jbtnChiudiActionPerformed private boolean VerificaPrenotazioni() { boolean ok=true; if (idTessera > 0L && idPrenotazione>0L) { MyTableModel model = (MyTableModel) tblLista.getModel(); StringBuilder ElencoIdProdotti = new StringBuilder(); for (int i = model.getRowCount() - 1; i >= 0; i--) { Long idCateg = Long.parseLong(model.getValueAt(i, ColCategoria).toString()); if (idCateg != 0L) { ElencoIdProdotti.append(model.getValueAt(i, ColIDProdotto)); ElencoIdProdotti.append(","); } } ok=ControllaDiscrepanzePrenotazioni(ElencoIdProdotti.toString()); AggiornaPrenotazioni(ElencoIdProdotti.toString()); } return ok; } private String GetNumeroTessera() { MyApplication MyA = new MyApplication(); String nTessera = ""; try { MyA.idTesseraA = ""; String[] listReader; listReader = MyA.SC.listReaders(); MyA.SC.setReader(listReader[0]); MyA.SC.connect("T=1"); MyA.SC.getCurrentCardATR(); String nTess = ""; MyA.sendAPDU(this, "d000", "00", "A4", "00", "00", "02", ""); MyA.sendAPDU(this, "d100", "00", "A4", "00", "00", "02", ""); MyA.sendAPDU(this, "d101", "00", "A4", "00", "00", "02", ""); String[] CF = MyA.sendAPDU(this, "", "00", "B0", "00", "00", "00", "140").split("\\|"); MyA.sendAPDU(this, "3f00", "00", "A4", "00", "00", "02", ""); MyA.sendAPDU(this, "1000", "00", "A4", "00", "00", "02", ""); MyA.sendAPDU(this, "1003", "00", "A4", "00", "00", "02", ""); nTess = MyA.sendAPDU(this, "", "00", "B0", "00", "00", "00", "14"); MyA.SC.disconnect(); if (CF.length > 1) { //CodFisLetto = CF[0]; //ScadenzaLetta = MyA.AggiustaDateTessera(CF[1]); nTessera = nTess; //jTxtDatiTessera.setText("Cod. Fis.: " + CodFisLetto + "\n" + "Scadenza: " + ScadenzaLetta + "\n" + "N° Tessera: " + nTessera); } } catch (Exception ex) { //JOptionPane.showMessageDialog(this, ex.getMessage(),"Read Card Exception",JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(this, "Card Reader non collegato o errore di lettura!", "jBtnReadCardActionPerformed", JOptionPane.ERROR_MESSAGE); } finally { return nTessera; } } private void formWindowDeiconified(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowDeiconified // TODO add your handling code here: resize(); }//GEN-LAST:event_formWindowDeiconified private void Tastiera2(java.awt.event.MouseEvent evt) { MyApplication MyA = new MyApplication(); if (jChLogin.isSelected() == false) { if (MyA.TastieraVideo) { if (MyA.UltimoTxt.equalsIgnoreCase(evt.getComponent().toString())) { MyA.UltimoTxt = " "; } else { MyA.UltimoTxt = evt.getComponent().toString(); Rectangle pnl = pnlLogin.getBounds(); Tastiera((JTextField) evt.getComponent(), pnl.x, pnl.y); } } } } //java.awt.event.FocusEvent private void Tastiera2(java.awt.event.FocusEvent evt) { MyApplication MyA = new MyApplication(); if (jChLogin.isSelected() == false) { if (MyA.TastieraVideo) { if (MyA.UltimoTxt.equalsIgnoreCase(evt.getComponent().toString())) { MyA.UltimoTxt = " "; } else { MyA.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 = {"Sì", "No"}; Object selectedValue = JOptionPane.showOptionDialog(this, "Confermi chiusura sessione?", "Attenzione", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); if (Integer.parseInt(selectedValue.toString()) != 0) { return; } else { pnlErrore.setVisible(false); pnlLogin.setVisible(true); pnlTop.setVisible(false); pnlProdotti.setVisible(false); utenteLoggato = ""; idAccount = 0L; lblUtenteLoggato.setText("[Nessun Utente Connesso]"); lblInfo.setText("[Info Turno]"); lblInfo2.setText("[Info Incassi]"); txtPassword.setEnabled(true); txtUsername.setEnabled(true); btnLogin.setEnabled(true); pnlCategorie.removeAll(); pnlProdotti.removeAll(); AddRemoveKeyDispatcher(false); jChLoginActionPerformed(null); Azzera(); StatoAttivoNonLoggato(); } // idTessera=0L; // idProfiloTariffario=0L; // idModoPagamento=0L; // CassaAperta=false; // txtTotaleCassa.setText(""); // txtTotalePunti.setText(""); // //// pnlCategorie.setVisible(false); //// pnlProdotti.setVisible(false); //// AbilitaPulsanti(pnlCategorie, false); //// AbilitaPulsanti(pnlProdotti, false); //// pnlCategorie.setVisible(true); //// pnlProdotti.setVisible(true); // // jTxtTessera.setText(""); // pnlProdotti.removeAll(); // pnlProdotti.repaint(); // lblCategoria.setText(""); // lblCognome.setText(""); // lblNome.setText(""); // lblNascita.setText(""); // lblMatricola.setText(""); // lblAzienda.setText(""); // lblConvenzione.setText(""); // lblFascia.setText(""); // // jBtnStorno.setEnabled(false); // // MyTableModel model=(MyTableModel)tblLista.getModel(); // for (int i = model.getRowCount() - 1; i >= 0; i--) { // model.deleteRow(i); // // } // // MyTableModel model2 = (MyTableModel) tblLista1.getModel(); // for (int i = model2.getRowCount() - 1; i >= 0; i--) { // model2.deleteRow(i); // } }//GEN-LAST:event_jbtnEsciActionPerformed private void jBtnStornoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnStornoActionPerformed ApriStorno(false); }//GEN-LAST:event_jBtnStornoActionPerformed private void ApriStorno(Boolean DaPassaggi) { frmStorno MyD = new frmStorno(this, idTessera, idPuntoCassa, imgPath, DaPassaggi); this.setEnabled(false); Integer w = CalcolaLarghezzaAltezza(550, LargControlli); Integer h = CalcolaLarghezzaAltezza(250, AltControlli); MyD.setSize(w, h); MyD.setLocationRelativeTo(null); //MyD.setLocation((this.getWidth() - this.getLocation().y) / 2, (this.getHeight() - this.getLocation().x) / 2); MyD.setVisible(true); } private void jBtnprodottiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnprodottiActionPerformed frmProdotti MyD = new frmProdotti(this, imgPath); this.setEnabled(false); Integer w = CalcolaLarghezzaAltezza(550, LargControlli); Integer h = CalcolaLarghezzaAltezza(250, AltControlli); MyD.setSize(w, h); MyD.setLocationRelativeTo(null); //MyD.setLocation((this.getWidth() - this.getLocation().y) / 2, (this.getHeight() - this.getLocation().x) / 2); MyD.setVisible(true); }//GEN-LAST:event_jBtnprodottiActionPerformed private void SelezionaTipoPagamento(int idTipo) { /* if(idModoPagamento==0L || idModoPagamento==2L){ ClickContanti(); return; } if(idModoPagamento==1L){ ClickTicket(); return; } if(CercaTestoModoPagamento().equalsIgnoreCase("A scalare") || CercaTestoModoPagamento().equalsIgnoreCase("Ticket")){ ClickContanti(); return; } if(CercaTestoModoPagamento().equalsIgnoreCase("Contanti")){ ClickTicket(); return; } */ String Tipo = SetModoPagamento(idTipo); /* if (CassaAperta == false) { CassaAperta = true; idProfiloTariffario = 0L; idTessera = 0L; AbilitaPulsanti(pnlCategorie, true); AbilitaPulsanti(pnlProdotti, true); CaricaCompleti(); }*/ lblTipoPagamento.setText(Tipo); //PulsantiModoPagamento(); if (Tipo.equalsIgnoreCase("A scalare") && jTxtTessera.getText().length() > 0 ) { //if (Tipo.equalsIgnoreCase("A scalare") && jTxtTessera.getText().length()>0 && FlagPrecaricaLista==false) { VerificaSaldo(jTxtTessera.getText()); } } public void ClickModoPagamento(String ModoPagamento) { if (CassaAperta == false) { CassaAperta = true; idProfiloTariffario = 0L; idTessera = 0L; //AbilitaPulsanti(pnlCategorie, true); //AbilitaPulsanti(pnlProdotti, true); // CaricaCompleti(); } lblResiduo.setText("[...]"); lblSaldo.setText("[...]"); lblTipoPagamento.setText(ModoPagamento); //PulsantiModoPagamento(); } // public void ClickTicket(){ // if (CassaAperta == false) { // CassaAperta = true; // idProfiloTariffario = 0L; // idTessera = 0L; // AbilitaPulsanti(pnlCategorie, true); // AbilitaPulsanti(pnlProdotti, true); // CaricaCompleti(); // } // //AggiungImmagini(jBtnTicket,"Contanti.png",50,50); // //// idModoPagamento = 2L; //// String Tipo = MySelect("Select Nome from Tipi_Pagamenti where id=2", "Nome"); //// lblTipoPagamento.setText(Tipo); //// //jBtnCarta.setEnabled(true); // } public void ClickCarta() { if (SaldoAcquisti(0.0) == false && ConsentiCredito == false) { JOptionPane.showOptionDialog(this, "Saldo tessera insufficiente!", "Attenzione", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); return; } if (CassaAperta == true) { //idModoPagamento = 0L; lblResiduo.setText("[...]"); //String Tipo = MySelect("Select Nome from Tipi_Pagamenti where id=0", "Nome"); SetModoPagamento("A scalare"); String Tipo = CercaTestoModoPagamento(); lblTipoPagamento.setText(Tipo); //PulsantiModoPagamento(); } } private void AggiornaDB(Boolean Messaggio) { try { Boolean Aggiorna = false; if (Messaggio) { Object[] options = {"Sì", "No"}; Object selectedValue = JOptionPane.showOptionDialog(this, "Confermi aggiornamento del database locale?", "Attenzione", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); if (Integer.parseInt(selectedValue.toString()) != 0) { return; } else { Aggiorna = true; } } else { Aggiorna = true; } if (Aggiorna) { MyProgress = new frmProgress(this); this.setEnabled(false); Integer w = CalcolaLarghezzaAltezza(300, LargControlli); Integer h = CalcolaLarghezzaAltezza(100, AltControlli); MyProgress.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); MyProgress.setResizable(false); //MyD.getRootPane().setWindowDecorationStyle(JRootPane.NONE); MyProgress.setTitle("Aggiornamento Database..."); MyProgress.setSize(w, h); MyProgress.setLocationRelativeTo(null); MyProgress.setVisible(true); MyProgress.repaint(); EventQueue.invokeLater(new Runnable() { @Override public void run() { try { //jBtnDB.setEnabled(false); Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); String plsql = "begin lancia_aggiorna_tabelle('S'); end;"; CallableStatement st = dbConnection.prepareCall(plsql); st.execute(); st.close(); dbConnection.close(); //jBtnDB.setEnabled(true); PuntoCassa.this.MyProgress.dispose(); //12/09/2016 if (PuntoCassa.this.pnlLogin.isVisible() == false) { //23-12-15 PuntoCassa.this.ImpostaAmbiente(); PuntoCassa.this.setEnabled(true); } //SELECT esito FROM esiti where id = (select max(id) from esiti); String Esito = MySelect("SELECT esito FROM esiti where id = (select max(id) from esiti)", "esito"); JOptionPane.showOptionDialog(PuntoCassa.this, Esito, "Aggiornamento Database", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); } catch (Exception e) { JOptionPane.showMessageDialog(PuntoCassa.this, "Errore " + e.getMessage()); } } }); } } catch (Exception e) { JOptionPane.showMessageDialog(this, "Errore " + e.getMessage()); } } private void txtTotaleCassaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTotaleCassaActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtTotaleCassaActionPerformed private void jBtnReadCardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnReadCardActionPerformed // TODO add your handling code here: jTxtTessera.setText(""); String nTessera = GetNumeroTessera(); jTxtTessera.setText(nTessera); }//GEN-LAST:event_jBtnReadCardActionPerformed private void jTxtTesseraFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTxtTesseraFocusGained MyApplication MyA = new MyApplication(); if (MyA.TastieraVideo) { if (MyA.UltimoTxt.equalsIgnoreCase(evt.getComponent().toString())) { MyA.UltimoTxt = " "; } else { MyA.UltimoTxt = evt.getComponent().toString(); Rectangle pnl = pnlLogin.getBounds(); Tastiera((JTextField) evt.getComponent(), pnl.x, pnl.y); } } }//GEN-LAST:event_jTxtTesseraFocusGained private void btnImpostaClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImpostaClienteActionPerformed frmCerca MyD = new frmCerca(this, jTxtTessera, imgPath, "", FlagMostraDataDiNascita); this.setEnabled(false); Integer w = CalcolaLarghezzaAltezza(650, LargControlli); Integer h = CalcolaLarghezzaAltezza(250, AltControlli); MyD.setSize(w, h); MyD.setLocationRelativeTo(null); //MyD.setLocation((this.getWidth() - this.getLocation().y) / 2, (this.getHeight() - this.getLocation().x) / 2); MyD.setVisible(true); //CercaTessera(); }//GEN-LAST:event_btnImpostaClienteActionPerformed private void jbtnAnnullaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAnnullaActionPerformed MyTableModel model = (MyTableModel) tblLista.getModel(); if (model.getRowCount() > 0) { Object[] options = {"Sì", "No"}; Object selectedValue = JOptionPane.showOptionDialog(this, "Desideri annullare tutte le righe?", "Attenzione", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); if (Integer.parseInt(selectedValue.toString()) != 0) { return; } else { Annulla(); doLayout(); } } }//GEN-LAST:event_jbtnAnnullaActionPerformed private void Annulla() { try { MyTableModel model = (MyTableModel) tblLista.getModel(); MyTableModel model1 = (MyTableModel) tblLista1.getModel(); ClearTable(model); ClearTable(model1); jbtnSu.setEnabled(false); jbtnGiu.setEnabled(false); jbtnElimina.setEnabled(false); jbtnAnnulla.setEnabled(false); //jbtnStampa.setEnabled(false); jbtnDuplica.setEnabled(false); SommaColonne(model); if(idTessera == 0L){ jbtnChiudi.setEnabled(false); }else{ jbtnChiudi.setEnabled(true); } //spengo altri togglebutton for (Integer y = 0; y < this.pnlProdotti.getComponentCount(); y++) { JToggleButton bt = (JToggleButton) this.pnlProdotti.getComponent(y); bt.setSelected(false); } } catch (Exception e) { } } private void jBtnAsportoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnAsportoActionPerformed if (jBtnAsporto.isSelected()) { AggiungImmagini(jBtnAsporto, "da asporto.jpg", 50, 50); } else { AggiungImmagini(jBtnAsporto, "coltello e forchetta.jpg", 50, 50); } }//GEN-LAST:event_jBtnAsportoActionPerformed private void txtTotalePuntiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTotalePuntiActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtTotalePuntiActionPerformed private void jBtnMovimentiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnMovimentiActionPerformed frmMovimenti MyD = new frmMovimenti(this, idTessera, idPuntoCassa, imgPath); this.setEnabled(false); Integer w = CalcolaLarghezzaAltezza(680, LargControlli); Integer h = CalcolaLarghezzaAltezza(250, AltControlli); MyD.setSize(w, h); MyD.setLocationRelativeTo(null); //MyD.setLocation((this.getWidth() - this.getLocation().y) / 2, (this.getHeight() - this.getLocation().x) / 2); MyD.setVisible(true); }//GEN-LAST:event_jBtnMovimentiActionPerformed private void jBtnBuoniActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnBuoniActionPerformed //Display("Tes 1234567890 Fa C1","Importo","E 1,55"); frmCerca MyD = new frmCerca(this, jTxtTessera, imgPath, "BP", FlagMostraDataDiNascita); this.setEnabled(false); Integer w = CalcolaLarghezzaAltezza(650, LargControlli); Integer h = CalcolaLarghezzaAltezza(250, AltControlli); MyD.setSize(w, h); MyD.setLocationRelativeTo(null); //MyD.setLocation((this.getWidth() - this.getLocation().y) / 2, (this.getHeight() - this.getLocation().x) / 2); MyD.setVisible(true); }//GEN-LAST:event_jBtnBuoniActionPerformed private void jBtnDB1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnDB1ActionPerformed // TODO add your handling code here: //jBtnDBActionPerformed(null); AggiornaDB(true); }//GEN-LAST:event_jBtnDB1ActionPerformed private void jChLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jChLoginActionPerformed // TODO add your handling code here: txtUsername.setEnabled(!jChLogin.isSelected()); txtPassword.setEnabled(!jChLogin.isSelected()); btnLogin.setEnabled(!jChLogin.isSelected()); AddRemoveKeyDispatcher(jChLogin.isSelected()); }//GEN-LAST:event_jChLoginActionPerformed private void btnTerminaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTerminaActionPerformed // TODO add your handling code here: //System.exit(0); exitForm(null); }//GEN-LAST:event_btnTerminaActionPerformed private void txtPasswordMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtPasswordMouseClicked Tastiera2(evt); }//GEN-LAST:event_txtPasswordMouseClicked private void txtPasswordFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtPasswordFocusGained Tastiera2(evt); // MyApplication MyA = new MyApplication(); // if (MyA.TastieraVideo) { // if (MyA.UltimoTxt.equalsIgnoreCase(evt.getComponent().toString())) { // MyA.UltimoTxt = " "; // } else { // MyA.UltimoTxt = evt.getComponent().toString(); // // Rectangle pnl = pnlLogin.getBounds(); // Tastiera((JTextField) evt.getComponent(), pnl.x, pnl.y); // } // } }//GEN-LAST:event_txtPasswordFocusGained private void txtUsernameMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtUsernameMouseClicked Tastiera2(evt); }//GEN-LAST:event_txtUsernameMouseClicked private void txtUsernameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtUsernameFocusGained Tastiera2(evt); // MyApplication MyA = new MyApplication(); // if (MyA.TastieraVideo) { // if (MyA.UltimoTxt.equalsIgnoreCase(evt.getComponent().toString())) { // MyA.UltimoTxt = " "; // } else { // MyA.UltimoTxt = evt.getComponent().toString(); // // Rectangle pnl = pnlLogin.getBounds(); // Tastiera((JTextField) evt.getComponent(), pnl.x, pnl.y); // } // } }//GEN-LAST:event_txtUsernameFocusGained private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoginActionPerformed if (Turno()) { String sql, pwd; int counter = 0; int hash = 0; Statement st; ResultSet rs; pwd = new String(); sql = new String(); // ======================================================================= // *** Verifica la correttezza delle credenziali inserite - Account // ======================================================================= sql = "SELECT count(*) as counter FROM accounts WHERE username = '" + this.txtUsername.getText() + "'"; // try { // Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); // st = dbConnection.createStatement(); // rs = st.executeQuery(sql); // while (rs.next()) { // counter = rs.getInt("counter"); // } MyApplication MyA = new MyApplication(); counter = Integer.parseInt(MyA.MySelect(this, sql, "Counter")); // ==================================================================== // ** Verifica la password // ==================================================================== if (counter == 1) { Encoding en = new Encoding(); pwd = txtPassword.getText(); sql = "SELECT id || '|' || id_Stato as res FROM accounts WHERE username = '" + this.txtUsername.getText() + "' " + "and password = '" + en.encodeString(pwd) + "'"; String[] El = MyA.MySelect(this, sql, "res").split("\\|"); if (MyA.isNumeric(El[0])) { idAccount = Long.parseLong(El[0]); if (Integer.parseInt(El[1]) == 2) { String Messaggio = MyA.MySelect(this, "Select Descrizione from Stati_Accounts where id=" + El[1], "descrizione"); JOptionPane.showMessageDialog(this, Messaggio + "."); return; } } else { idAccount = 0L; } if (idAccount > 0L) { // sql = "select a.id as id_account from accounts a, profili p where p.id_account = a.id and p.id_ruolo = 10000000004" // + " and a.username = '" + txtUsername.getText() + "' and a.password = '" + en.encodeString(pwd) + "'"; // try { sql = "SELECT count(*) as Counter FROM profili p WHERE p.id_account = " + idAccount + " AND p.id_ruolo IN (3, 10000000004)"; counter = Integer.parseInt(MyA.MySelect(this, sql, "Counter")); // st = dbConnection.createStatement(); // rs = st.executeQuery(sql); // while (rs.next()) { // idAccount = rs.getLong("id_account"); // counter = 1; // } // } catch (SQLException e) { // JOptionPane.showMessageDialog(this, "Errore DB ['" + sql + "']"); // // } // da modificare<<<<<<<<<<<<<<<<<<<<<<<<<<< if (counter >0){ ImpostaAmbiente(); txtUsername.setText(""); txtPassword.setText(""); StatoAttivoLoggato(); VerificaAggiornamentoDB(); } else { JOptionPane.showMessageDialog(this, "L'utente non dispone dei privilegi per l'utilizzo del modulo cassa."); } } else { JOptionPane.showMessageDialog(this, "Password errata."); } // sql = "SELECT count(*) as counter FROM accounts WHERE username = '" // + txtUsername.getText() + "' AND password = '" // + en.encodeString(pwd) + "'"; // -------------------------------------------------------------- // *** Errore SQL in verifica password // -------------------------------------------------------------- // ================================================================= // ** Caso account sconosciuto // ================================================================= } else { JOptionPane.showMessageDialog(this, "Account sconosciuto."); } // rs.close(); // st.close(); // dbConnection.close(); // // } catch (SQLException e) { // // -------------------------------------------------------------- // // *** Errore SQL in verifica account // // -------------------------------------------------------------- // JOptionPane.showMessageDialog(this, "Errore DB ['" + sql + "']"); // } } else { JOptionPane.showMessageDialog(this, "Impossibile eseguire il Login al sistema:\nNessun Turno Attivo!"); } }//GEN-LAST:event_btnLoginActionPerformed //a scalare private void jTBP0ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTBP0ActionPerformed if (jTBP0.isSelected()) { try{ jTBP0.setEnabled(false); jTBP1.setSelected(false); jTBP1.setEnabled(true); jTBP2.setSelected(false); jTBP2.setEnabled(true); jTBP3.setSelected(false); jTBP3.setEnabled(true); SelezionaTipoPagamento(0); MyTableModel modelX = (MyTableModel) tblLista.getModel(); SommaColonne(modelX); }catch(Exception ex){} } }//GEN-LAST:event_jTBP0ActionPerformed //contanti private void jTBP1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTBP1ActionPerformed if (jTBP1.isSelected()) { jTBP1.setEnabled(false); jTBP0.setSelected(false); jTBP0.setEnabled(true); jTBP2.setSelected(false); jTBP2.setEnabled(true); jTBP3.setSelected(false); jTBP3.setEnabled(true); SelezionaTipoPagamento(1); } }//GEN-LAST:event_jTBP1ActionPerformed //ticket private void jTBP2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTBP2ActionPerformed if (jTBP2.isSelected()) { jTBP2.setEnabled(false); jTBP1.setSelected(false); jTBP1.setEnabled(true); jTBP0.setSelected(false); jTBP0.setEnabled(true); jTBP3.setSelected(false); jTBP3.setEnabled(true); SelezionaTipoPagamento(2); } }//GEN-LAST:event_jTBP2ActionPerformed //differito private void jTBP3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTBP3ActionPerformed if (jTBP3.isSelected()) { jTBP3.setEnabled(false); jTBP1.setSelected(false); jTBP1.setEnabled(true); jTBP2.setSelected(false); jTBP2.setEnabled(true); jTBP0.setSelected(false); jTBP0.setEnabled(true); SelezionaTipoPagamento(3); } }//GEN-LAST:event_jTBP3ActionPerformed 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 Boolean VerificaSaldo(String NTessera) { /*Double Tot =0.0; MyTableModel model = (MyTableModel) tblLista.getModel(); for (int i = model.getRowCount() - 1; i >= 0; i--) { Tot=Tot+Double.parseDouble(model.getValueAt(i, ColImporto).toString()); }*/ Boolean OK = false; //andare su viewtessere // String QuerySaldo="select t.saldo || '|' || cf.saldo_minimo_alert || '|' || cf.saldo_minimo_stop || '|' || t.punti || '|' as saldi " + // " from tessere t, utenti u, categorie_utenti c, convenzioni_fasce cf" + // " where t.numero = '" + NTessera + "' and t.id_utente = u.id" + // " and u.id_categoria = c.id and cf.id_categoria_utenti = c.id"; String QuerySaldo = "select t.saldo || '|' || cf.saldo_minimo_alert || '|' || cf.saldo_minimo_stop || '|' || t.punti || '|' as saldi " + " from tessere t, utenti u, categorie_utenti c, categorie_utenti_fasce cf" + " where t.numero = '" + NTessera + "' and t.id_utente = u.id" + " and u.id_categoria = c.id and cf.id_categoria_utenti = c.id"; String[] SaldoMinimo = MySelect(QuerySaldo, "saldi").split("\\|"); Double Saldo = 0.0; if (SaldoMinimo.length > 0 && SaldoMinimo[0].length() > 0) { Saldo = Double.parseDouble(SaldoMinimo[0].replace(",", ".")); } Double SaldoAlert = 0.0; if (SaldoMinimo.length > 1 && SaldoMinimo[1].length() > 0) { SaldoAlert = Double.parseDouble(SaldoMinimo[1].replace(",", ".")); } Double SaldoStop = 0.0; if (SaldoMinimo.length > 2 && SaldoMinimo[2].length() > 0) { SaldoStop = Double.parseDouble(SaldoMinimo[2].replace(",", ".")); } SaldoMinimoStop = SaldoStop; String Punti = ""; if (SaldoMinimo.length >= 4) { Punti = SaldoMinimo[3]; } DecimalFormat df2 = new DecimalFormat("#,###,###,##0.00"); lblSaldo.setText("? " + df2.format(Saldo)); //24-01-2020-------------------------- MyTableModel model = (MyTableModel) tblLista.getModel(); Double T = model.Somma(ColImporto); MyTableModel model2 = (MyTableModel) tblLista1.getModel(); if (model2.getRowCount() > 0) { T = T + model2.Somma(1); } //--------------------------- lblResiduo.setText("? " + df2.format(Saldo-T)); lblPunti.setText(Punti); //String Tipo=MySelect("Select Nome from Tipi_Pagamenti where id=0", "Nome"); String Tipo = CercaTestoModoPagamento(); lblTipoPagamento.setText(Tipo); //PulsantiModoPagamento(); //21/12/2016 if (Gratuita_Residue <= 0) {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< if (Gratuita_Residue <= 0 && (FLAG_BONUS == 0 || Bonus_Residui <= 0)) { if ((Saldo-CalcolaTotale()) <= SaldoStop) { //JOptionPane.showMessageDialog(this, "Saldo insufficiente per l'acquisto!", "Saldo", JOptionPane.ERROR_MESSAGE); /*frmPagamento MyD = new frmPagamento(this,idPuntoCassa,idModoPagamento); this.setEnabled(false); Integer w = CalcolaLarghezzaAltezza(490, LargControlli); Integer h = CalcolaLarghezzaAltezza(142, AltControlli); MyD.setSize(w, h); MyD.setLocationRelativeTo(null); //MyD.setLocation((this.getWidth() - this.getLocation().y) / 2, (this.getHeight() - this.getLocation().x) / 2); MyD.setVisible(true); */ //pnlPagamento ModoPag=new pnlPagamento(); //JOptionPane.showMessageDialog(null,ModoPag,"Scegli modo pagamento",JOptionPane.); //04-02-2019 /* if (ConsentiCredito == true) { if (MessaggioSaldoUnaVolta == false) { if (JOptionPane.showConfirmDialog(null, "Saldo insufficiente. Vuoi autorizzare comunque la transazione?", "Saldo", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { MessaggioSaldoUnaVolta = true; return true; } } else { return true; } } MyDialog Dialog = new MyDialog(this, "Scegli modalità pagamento...", true); Integer w = CalcolaLarghezzaAltezza(490, LargControlli); Integer h = CalcolaLarghezzaAltezza(142, AltControlli); Dialog.setSize(w, h); Dialog.setLocationRelativeTo(null); Dialog.setVisible(true); //if (idModoPagamento == 0) { if (CercaTestoModoPagamento().equalsIgnoreCase("A scalare")) { OK = false; } else { OK = true; } */ //31-10-2019 se lista precaricata e saldo <0 devo chudere if (StoCalcolando == false) { if (CercaTestoModoPagamento().equalsIgnoreCase("A scalare")) { if ((Saldo - CalcolaTotale()) < 0) { JOptionPane.showMessageDialog(this, "Saldo insufficiente!", "Saldo", JOptionPane.OK_OPTION); LogTessera(); Azzera(); return true; } } } OK = true; } else if (Saldo <= SaldoAlert) { //JOptionPane.showMessageDialog(this, "Ultimo passaggio consentito con il saldo rilevato sulla tessera!", "Saldo Alert", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(this, "Saldo ridotto, potrebbero non essere disponibili tutti i prodotti!", "Saldo Alert", JOptionPane.ERROR_MESSAGE); OK = true; } else { OK = true; } } return OK; } private String CercaTestoModoPagamento() { String Testo = ""; String[] El = ModiPagamento.toString().split("\\|"); for (int i = 0; i < El.length; i++) { String[] t = El[i].split(";"); if (t[0].equalsIgnoreCase(idModoPagamento.toString())) { Testo = t[1]; break; } } return Testo; } private void SetModoPagamento(String Modo) { String[] El = ModiPagamento.toString().split("\\|"); for (int i = 0; i < El.length; i++) { String[] t = El[i].split(";"); if (t[1].equalsIgnoreCase(Modo)) { idModoPagamento = Long.parseLong(t[0]); break; } } //PulsantiModoPagamento(); } private String SetModoPagamento(Integer Tipo) { String Testo = ""; if (ModiPagamento.toString().length() > 5) { String[] El = ModiPagamento.toString().split("\\|"); int i = Tipo; //for (int i=0;i 0) { String NTessera = jTxtTessera.getText(); if (CercaTestoModoPagamento().equalsIgnoreCase("A scalare")) { String QuerySaldo = "select t.saldo || '|' || cf.saldo_minimo_alert || '|' || cf.saldo_minimo_stop || '|' || t.punti || '|' as saldi " + " from tessere t, utenti u, categorie_utenti c, categorie_utenti_fasce cf" + " where t.numero = '" + NTessera + "' and t.id_utente = u.id" + " and u.id_categoria = c.id and cf.id_categoria_utenti = c.id"; String[] SaldoMinimo = MySelect(QuerySaldo, "saldi").split("\\|"); Double Saldo = 0.0; String Residuo = lblResiduo.getText().trim().replace("?", ""); if (Residuo.equalsIgnoreCase("[...]")) { Residuo = "0"; } Residuo = Residuo.replace(".", ""); Residuo = Residuo.replace(",", "."); Saldo = Double.parseDouble(Residuo); Double SaldoAlert = 0.0; if (SaldoMinimo.length > 1 && SaldoMinimo[1].length() > 0) { SaldoAlert = Double.parseDouble(SaldoMinimo[1].replace(",", ".")); } if (Gratuita_Residue <= 0 && (FLAG_BONUS == 0 || Bonus_Residui <= 0)) { if (Saldo <= SaldoAlert) { //Boolean ChiediModoPagamento = false; if (ConsentiCredito == true) { if (MessaggioSaldoUnaVolta == false) { if (JOptionPane.showConfirmDialog(null, "Saldo insufficiente. Vuoi autorizzare comunque la transazione?", "Saldo", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { MessaggioSaldoUnaVolta = true; } else { return; } } } else { //ChiediModoPagamento = true; } } } /* if (ChiediModoPagamento) { MyDialog Dialog = new MyDialog(this, "Scegli modalità pagamento...", true); Integer w = CalcolaLarghezzaAltezza(490, LargControlli); Integer h = CalcolaLarghezzaAltezza(142, AltControlli); Dialog.setSize(w, h); Dialog.setLocationRelativeTo(null); Dialog.setVisible(true); //da modificare<<<<<<<<<<<<<<<<<<<<<<< if (CercaTestoModoPagamento().equalsIgnoreCase("A scalare")) { return; } else { //OK = true; } }*/ //-------------------------------------------------------- } else { //Pagamento non A Scalare String QuerySaldo = "select t.saldo " + " from tessere t, utenti u, categorie_utenti c, categorie_utenti_fasce cf" + " where t.numero = '" + NTessera + "' and t.id_utente = u.id" + " and u.id_categoria = c.id and cf.id_categoria_utenti = c.id"; Double Saldo = Double.parseDouble(MySelect(QuerySaldo, "saldo")); Double CostoPasto = Double.parseDouble(txtTotaleCassa.getText().replace("?", "").trim().replace(",", ".")); if (Saldo > CostoPasto) { Object[] options = {"A Scalare", "Contanti"}; Object selectedValue = JOptionPane.showOptionDialog(this, "Attenzione, c'è saldo sufficiente sulla tessera,\nscegli la modalità di pagamento da utilizzare", "Modalità Pagamento", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, null); if (Integer.parseInt(selectedValue.toString()) == 0) { //if (JOptionPane.showConfirmDialog(null, "Attenzione, c'è saldo sufficiente sulla tessera, sicuro che vuoi pagare in contanti?", "Modalità Pagamento", JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) { jTBP0.setSelected(true); jTBP0ActionPerformed(null); // Chiudi(); // return; } else { jTBP1.setSelected(true); jTBP1ActionPerformed(null); } } } } Boolean SpiaProgressivo = false; //MyTableModel model=(MyTableModel)tblLista.getModel(); Date Adesso = new Date(); String FlagPassaggioTessera = "0"; if (PassaggioTessera) { FlagPassaggioTessera = "1"; } /*Integer id=1; id=MySelectInteger("Select max(id) as id from Acquisti", "id"); id++;*/ String Tessera = idTessera.toString(); String FlagAsporto = "0"; if (jBtnAsporto.isSelected()) { FlagAsporto = "1"; } //if (idTessera==0L){Tessera="null";} //String Composizione=SpaziBianchi("",20,false); //09-05-2019 /* for (int i = 0; i 20){ Composizione=Composizione.substring(0, 20); } Composizione=SpaziBianchi(Composizione,20,true); break; } } */ String Composizione = SpaziBianchi("", 20, false); MyTableModel model2 = (MyTableModel) tblLista1.getModel(); for (int i = 0; i < model2.getRowCount(); i++) { String Completo = model2.getValueAt(i, 0).toString(); String Pasto = ""; if (Completo.length() > 0) { String TT[] = Completo.split("]", -1); if (TT.length > 0) { Pasto = "Pasto:" + TT[0].replace("[", ""); } } Composizione = SpaziBianchi(Pasto, 10, true); break; } //controllo passaggi if (model.getRowCount() > 0) { String ControlloPassaggi = "SELECT count(*) as passaggi FROM st_acquisti st INNER JOIN prodotti pr ON st.id_prodotto = pr.id WHERE pr.id_categoria = 0 AND trunc(st.data) = trunc(sysdate) AND st.id_tessera = " + idTessera + " AND st.id_turno=" + idTurno; Long AbilitatoPassaggi = MySelectInteger(ControlloPassaggi, "passaggi"); if (AbilitatoPassaggi > 0) { AbilitatoPassaggi = AbilitatoPassaggi + 1; if (JOptionPane.showConfirmDialog(null, "Sei sicuro di voler registrare il passaggio n° " + AbilitatoPassaggi + " sulla tessera " + jTxtTessera.getText() + "?", "Secondo Passaggio", JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) { Azzera(); AggiornaLabelInfo(); return; } } } if (idTessera > 0L) { StringBuilder ElencoIdProdotti = new StringBuilder(); for (int i = model.getRowCount() - 1; i >= 0; i--) { Long idCateg = Long.parseLong(model.getValueAt(i, ColCategoria).toString()); if (idCateg != 0L) { //04/03/2022 non è possibile acquistare prodotti che non siano partedi una composizione // String Imp1 = model.getValueAt(i, ColImporto).toString(); // String Imp2 = model.getValueAt(i, ColImporto2).toString(); String Vassoio = "1"; // if (Imp1.equalsIgnoreCase(Imp2)) { // Vassoio = "0"; // } MyInsert("Insert into Acquisti (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)values(-1," + Tessera + "," + model.getValueAt(i, ColIDProdotto) + "," + idPuntoCassa + "," + AggiustaDateOra(Adesso) + "," + model.getValueAt(i, ColImporto) + "," + model.getValueAt(i, ColPunti) + "," + Progressivo + "," + idModoPagamento + "," + Vassoio + "," + idTurno + "," + FlagAsporto + "," + FlagPassaggioTessera + ")"); AggiornaProgressivoPagamentiTurno(Double.parseDouble(model.getValueAt(i, ColImporto).toString())); ElencoIdProdotti.append(model.getValueAt(i, ColIDProdotto)); ElencoIdProdotti.append(","); //id++; } model.deleteRow(i); SpiaProgressivo = true; } //MyTableModel model2 = (MyTableModel) tblLista1.getModel(); for (int i = model2.getRowCount() - 1; i >= 0; i--) { String FlagGratuita = "0"; String FlagBonus = "0"; if (Gratuita_Residue > 0) {// && Gratuita_Residue>Gratuita_ResidueProg){ FlagGratuita = "1"; } else if (Bonus_Residui > 0) { FlagBonus = "1"; } MyInsert("Insert into Acquisti (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)values(-1," + Tessera + "," + model2.getValueAt(i, 2) + "," + idPuntoCassa + "," + AggiustaDateOra(Adesso) + "," + model2.getValueAt(i, 1) + ",0," + Progressivo + "," + idModoPagamento + "," + idTurno + "," + FlagGratuita + "," + FlagBonus + "," + FlagAsporto + "," + FlagPassaggioTessera + ")"); AggiornaProgressivoPagamentiTurno(Double.parseDouble(model2.getValueAt(i, 1).toString())); //id++; model2.deleteRow(i); SpiaProgressivo = true; } } else { StringBuilder ElencoIdProdotti = new StringBuilder(); for (int i = model.getRowCount() - 1; i >= 0; i--) { Long idCateg = Long.parseLong(model.getValueAt(i, ColCategoria).toString()); if (idCateg != 0L) { //04/03/2022 non è possibile acquistare prodotti che non siano partedi una composizione // String Imp1 = model.getValueAt(i, ColImporto).toString(); // String Imp2 = model.getValueAt(i, ColImporto2).toString(); String Vassoio = "1"; // if (Imp1.equalsIgnoreCase(Imp2)) { // Vassoio = "0"; // } 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," + model.getValueAt(i, ColIDProdotto) + "," + idPuntoCassa + "," + AggiustaDateOra(Adesso) + "," + model.getValueAt(i, ColImporto) + "," + model.getValueAt(i, ColPunti) + "," + Progressivo + "," + idModoPagamento + "," + Vassoio + "," + idTurno + "," + FlagAsporto + "," + FlagPassaggioTessera + ")"); AggiornaProgressivoPagamentiTurno(Double.parseDouble(model.getValueAt(i, ColImporto).toString())); ElencoIdProdotti.append(model.getValueAt(i, ColIDProdotto)); ElencoIdProdotti.append(","); //id++; } model.deleteRow(i); SpiaProgressivo = true; } //MyTableModel model2 = (MyTableModel) tblLista1.getModel(); for (int i = model2.getRowCount() - 1; i >= 0; i--) { String FlagGratuita = "0"; String FlagBonus = "0"; if (Gratuita_Residue > 0) {// && Gratuita_Residue>Gratuita_ResidueProg){ FlagGratuita = "1"; } else if (FLAG_BONUS == 1 && Bonus_Residui > 0) { FlagBonus = "1"; } 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," + model2.getValueAt(i, 2) + "," + idPuntoCassa + "," + AggiustaDateOra(Adesso) + "," + model2.getValueAt(i, 1) + ",0," + Progressivo + "," + idModoPagamento + "," + idTurno + "," + FlagGratuita + "," + FlagBonus + "," + FlagAsporto + "," + FlagPassaggioTessera + ")"); AggiornaProgressivoPagamentiTurno(Double.parseDouble(model2.getValueAt(i, 1).toString())); model2.deleteRow(i); SpiaProgressivo = true; } } //aggiorno progressivi------------- if (SpiaProgressivo) { Progressivo++; ProgressivoGiorno++; ProgressivoTurno++; MyInsert("Update Progressivi set Prog_assoluto=" + Progressivo + ",prog_giorno=" + ProgressivoGiorno + ",prog_Turno=" + ProgressivoTurno + ",incasso_turno_contanti=" + ProgressivoContanti + ",incasso_turno_ticket=" + ProgressivoTicket + ",incasso_turno_scalare=" + ProgressivoScalare + ",incasso_turno_differito=" + ProgressivoDifferito + " where id_Punto_cassa=" + idPuntoCassa + " and id_turno=" + idTurno + " and data=" + AggiustaData(Adesso)); } // // //controllo passaggi // String ControlloPassaggi = "SELECT count(*) as passaggi FROM st_acquisti st INNER JOIN prodotti pr ON st.id_prodotto = pr.id WHERE pr.id_categoria = 0 AND trunc(st.data) = trunc(sysdate) AND st.id_tessera = " + idTessera + " AND st.id_turno=" + idTurno; // Long AbilitatoPassaggi = MySelectInteger(ControlloPassaggi, "passaggi"); // if (AbilitatoPassaggi > 1) { //// JOptionPane.showMessageDialog(this, "Attenzione questo è il secondo passaggio nello stesso turno su questa cassa.", "Numero Passaggi", JOptionPane.INFORMATION_MESSAGE); // Object[] options = {"Sì", "No"}; // Object selectedValue =JOptionPane.showOptionDialog(this, "Sei sicuro di voler registrare il secondo passaggio sulla tessera " + Tessera + "?", "Secondo Passaggio", // JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, null); // if (Integer.parseInt(selectedValue.toString()) == 1) { // Annulla(); // Azzera(); // return; // } // } //aggiornamento 12-04-2019 /* String tp = lblTipoPagamento.getText().trim(); if (tp.length() > 11) { tp = tp.substring(0, 10); } else { tp = SpaziBianchi(tp, 11, true); } tp = tp + " E" + SpaziBianchi(txtTotaleCassa.getText().trim().replace("?", ""), 7, false); String Punti = lblPunti.getText(); if (Punti.length() > 6) { Punti = Punti.substring(0, 5); } else { Punti = SpaziBianchi(Punti, 6, false); } */ String Residuo = lblResiduo.getText().replace("?", "").trim(); if (Residuo.equalsIgnoreCase("[...]")) { Residuo = "0"; } if (Residuo.length() > 6) { Residuo = Residuo.substring(0, 5); } else { Residuo = SpaziBianchi(Residuo, 6, false); } //Aggiornamento 12-04-2019 //String Riga2 = "P " + Punti + " S E " + Residuo; //Display(tp + Riga2, null); Integer Bonus = 0; if (FLAG_BONUS == 1 && Bonus_Residui > 0) { Bonus = Bonus_Residui--; //String Riga2 = " Saldo " + Residuo + " Bon. " + Bonus ; //Display(Composizione + Riga2, null); }//else{ //String Riga2 = " Saldo " + Residuo ; //Display(Composizione + Riga2, null); //} Composizione = SpaziBianchi(Composizione + "Bonus:" + Bonus, 20, true); String Riga2 = "Saldo " + Residuo; Display(Composizione + Riga2, null); timerDisplay.schedule(new TimerTask() { @Override public void run() { StatoAttivoLoggato(); // timerDisplay.cancel(); // timerDisplay.purge(); } }, 8000); Azzera(); AggiornaLabelInfo(); // jTxtTessera.requestFocus(); } private boolean ControllaDiscrepanzePrenotazioni(String ElencoIdProdotto) { boolean ok=true; if (ElencoIdProdotto.length() > 0) { ElencoIdProdotto = ElencoIdProdotto.substring(0, ElencoIdProdotto.length() - 1); String El[] = ElencoIdProdotto.split(","); String Query = "SELECT count(*) as nr FROM VIEW_PRENOTAZIONI_TURNO WHERE id_Modalita in (2,3) and id_stato in (0,1) AND id_turno =" + idTurnoAttuale + " AND id_tessera = " + idTessera + " and id_Prenotazione=" + idPrenotazione; int rowCount = Integer.parseInt(MySelect(Query, "nr")); if(rowCount>0){ if (rowCount == El.length) { Query = "SELECT count(*) as nr FROM VIEW_PRENOTAZIONI_TURNO WHERE id_Modalita in (2,3) and id_stato in (0,1) AND id_turno =" + idTurnoAttuale + " AND id_tessera = " + idTessera + " AND id_Prodotto in (" + ElencoIdProdotto + ") and id_Prenotazione=" + idPrenotazione; rowCount = Integer.parseInt(MySelect(Query, "nr")); if (rowCount == El.length) { return true; } } Object[] options = {"Sì", "No"}; Object selectedValue =JOptionPane.showOptionDialog(this, "I prodotti selezionati sono diversi dai prenotati!\nVuoi proseguire?", "Prenotazione", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, null); if (Integer.parseInt(selectedValue.toString()) == 1) { AzzeraDopoStorno(); return false; } } } return ok; } private void AggiornaPrenotazioni(String ElencoIdProdotto){ try { if (ElencoIdProdotto.length()>0){ //ElencoIdProdotto=ElencoIdProdotto.substring(0,ElencoIdProdotto.length()-1); //String Query="SELECT id FROM VIEW_PRENOTAZIONI_TURNO WHERE id_stato = 1 AND id_turno =" + idTurnoAttuale + " AND id_tessera = " + idTessera + " AND id_Prodotto in (" + ElencoIdProdotto + ")"; String Query="SELECT id FROM VIEW_PRENOTAZIONI_TURNO WHERE id_Modalita in (2,3) and id_stato in (0,1) AND id_turno =" + idTurnoAttuale + " AND id_tessera = " + idTessera + " and id_Prenotazione=" + idPrenotazione; Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); Statement st = dbConnection.createStatement(); ResultSet rs = st.executeQuery(Query); while (rs.next()) { MyInsert("Update PRENOTAZIONI_PASTI set id_Stato=2 where id=" + rs.getString("id")); } rs.close(); st.close(); dbConnection.close(); } } catch (SQLException | NumberFormatException e) { System.err.println(e.getClass().getName() + ": " + e.getMessage()); } finally { } } private void AggiornaProgressivoPagamentiTurno(Double Importo) { /* if (idModoPagamento == 0) { ProgressivoScalare = ProgressivoScalare + Importo; } if (idModoPagamento == 1) { ProgressivoContanti = ProgressivoContanti + Importo; } if (idModoPagamento == 2) { ProgressivoTicket = ProgressivoTicket + Importo; } */ if (CercaTestoModoPagamento().equalsIgnoreCase("A scalare")) { ProgressivoScalare = ProgressivoScalare + Importo; } if (CercaTestoModoPagamento().equalsIgnoreCase("Contanti")) { ProgressivoContanti = ProgressivoContanti + Importo; } if (CercaTestoModoPagamento().equalsIgnoreCase("Ticket")) { ProgressivoTicket = ProgressivoTicket + Importo; } if (CercaTestoModoPagamento().equalsIgnoreCase("Differito")) { ProgressivoDifferito = ProgressivoDifferito + Importo; } } private void Azzera() { try { MyTableModel model = (MyTableModel) tblLista.getModel(); MyTableModel model1 = (MyTableModel) tblLista1.getModel(); ClearTable(model); ClearTable(model1); } catch (Exception e) { } MessaggioSaldoUnaVolta = false; idTessera = 0L; idPrenotazione= 0L; idProfiloTariffario = 0L; //idModoPagamento = 0L; //SetModoPagamento("Contanti"); SetModoPagamento(ModoPagamentoDefault); CassaAperta = false; txtTotaleCassa.setText("? 0,00"); txtTotalePunti.setText("Punti 0"); pnlCategorie.setVisible(false); pnlProdotti.setVisible(false); if (FlagPrecaricaLista == false) { AbilitaPulsanti(pnlCategorie, false,false); AbilitaPulsanti(pnlProdotti, false,false); } pnlCategorie.setVisible(true); pnlProdotti.setVisible(true); Bonus_Residui=0; jTxtTessera.setText(""); pnlProdotti.removeAll(); pnlProdotti.repaint(); lblCategoria.setText(""); lblCognome.setText(""); lblNome.setText(""); lblNascita.setText(""); lblScadTessera.setText(""); lblAzienda.setText(""); lblConvenzione.setText(""); lblFascia.setText(""); jBtnStorno.setEnabled(false); //jBtnCarta.setEnabled(false); jBtnAsporto.setEnabled(false); // jBtnBuoni.setEnabled(false); //jBtnTicket.setEnabled(false); jbtnSu.setEnabled(false); jbtnGiu.setEnabled(false); jbtnElimina.setEnabled(false); jbtnAnnulla.setEnabled(false); //jbtnStampa.setEnabled(false); jbtnDuplica.setEnabled(false); lblSaldo.setText("[...]"); lblPunti.setText("[...]"); lblTipoPagamento.setText("[...]"); //jBtnCarta.setEnabled(false); TestoRFIDCard = new StringBuilder(); TestoSwipCard = new StringBuilder(); // TestoCarteCF = new StringBuilder(); StatoCardLettore = false; if (btnImpostaCliente.isVisible()) { btnImpostaCliente.setEnabled(BottoneImposta); } jBtnBuoni.setEnabled(true); lblResiduo.setText("[...]"); lblGratuità.setText("[...]"); jBtnAsporto.setSelected(false); jBtnAsportoActionPerformed(null); PassaggioTessera = false; PassaggiEsauritiNoComposizione = false; SaldoMinimoStop = 0.0; MyApplication MyP = new MyApplication(); MyP.UnaVolta = false; Gratuita_Residue=0; //MessaggioFlagExtraUnaVolta = false; // TesseraCFLetta=false; //9-5-18<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< if (FlagPrecaricaLista) { ApriCassaDefault(); } } public void ApriCassaDefault() { lblCategoria.setText(""); lblCognome.setText(""); lblNome.setText(""); lblNascita.setText(""); lblScadTessera.setText(""); lblAzienda.setText(""); lblConvenzione.setText(""); lblFascia.setText(""); //Display(Message_Display, " "," "); if (CassaAperta == false) { TurnoAttuale(); if ((idTurnoAttuale - idTurno) != 0) { ProgressivoTurno = 1L; ProgressivoContanti = 0.00; ProgressivoScalare = 0.00; ProgressivoTicket = 0.00; ProgressivoDifferito = 0.00; if (NomeTurnoAttuale.equalsIgnoreCase("Pranzo")) { ProgressivoGiorno = 1L; } idTurno = idTurnoAttuale; NomeTurno = NomeTurnoAttuale; Date Adesso = new Date(); String ControlloTurno = MySelect("select count(*) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and data=" + AggiustaData(Adesso) + " and id_Turno=" + idTurno, "Prog"); if (Long.parseLong(ControlloTurno) <= 0) { MyInsert("Insert into Progressivi (data,id_Punto_cassa,id_Turno,prog_assoluto,prog_giorno,prog_turno) " + " values (" + AggiustaData(Adesso) + "," + idPuntoCassa + "," + idTurno + "," + Progressivo + "," + ProgressivoGiorno + ",0)"); } AggiornaLabelInfo(); } CassaAperta = true; idProfiloTariffario = idProfiloTariffarioDefault;//0L SetModoPagamento(ModoPagamentoDefault); // CaricaCompleti(); //this.caricaDati("PRODOTTI", "-1"); this.caricaPannello(); AbilitaPulsanti(pnlCategorie, true,true); jbtnChiudi.setEnabled(false); } } public void CercaTessera() {//String QueryCF) { MyApplication MyP = new MyApplication(); MyP.UnaVolta = false; SetModoPagamento(ModoPagamentoDefault); String NTessera = jTxtTessera.getText(); // TestoCarteCF=new StringBuilder(); String Query = "SELECT DISTINCT c.nome || '|' || u.cognome || '|' || u.nome || '|' || TO_CHAR (u.data_di_nascita, 'dd/mm/yyyy') || '|' || u.matricola || '|' || a.nome || '|' || c.nome || '|' || f.nome || '|' || t.ID || '|' || TO_CHAR (t.data_scadenza, 'dd/mm/yyyy') || '|' || t.id_stato || '|' || u.ID || '|' || f.ID || '|' || t.gratuita_residue || '|' || t.bonus_residui AS ris " + " FROM categorie_utenti c, tessere t, utenti u, categorie_utenti_fasce cf, fasce f, aziende a WHERE t.id_utente = u.ID AND u.id_categoria = c.ID AND c.id_azienda = a.ID AND cf.id_categoria_utenti = c.ID AND cf.id_fascia = f.ID AND t.numero = '" + NTessera + "'"; // if(QueryCF.length()>0){ // Query=QueryCF; // } String res = MySelect(Query, "ris"); if (res.length() > 0) { String dati[] = res.split("\\|", -1); Date now = new Date(); Date Scadenza = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); idProfiloTariffario = Long.parseLong(dati[12]); if (idProfiloTariffario == idProfiloTariffarioDefault) { JOptionPane.showOptionDialog(this, "Impostato Profilo Tariffario di default!", "Attenzione", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null); } Integer idStato = Integer.parseInt(dati[10]); idTessera = Long.parseLong(dati[8]); LogIDTessera = idTessera.toString(); LogTessera(); try { // controllo abilitazione tessera String ControlloPunto = "Select controlla_abilitazione('" + NTessera + "'," + idPuntoCassa + ") as T from dual"; Long Abilitato = MySelectInteger(ControlloPunto, "T"); if (Abilitato == 0) { //JOptionPane.showMessageDialog(this, "Tessera non abilitata per questo punto di distribuzione!\nConsenti passaggio?",JOptionPane.YES_NO_OPTION); Object[] options = {"Sì", "No"}; 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]); if (Integer.parseInt(selectedValue.toString()) != 0) { return; } else { MyInsert("Insert into Forzature (id,id_account,id_Punto_Cassa,id_Tessera,id_Tipo_Forzatura) values (-1," + idAccount + "," + idPuntoCassa + "," + idTessera + ",1)"); } } //controllo passaggi String ControlloPassaggi = "Select controlla_passaggi('" + NTessera + "'," + idPuntoCassa + ") as T from dual"; Long AbilitatoPassaggi = MySelectInteger(ControlloPassaggi, "T"); if (AbilitatoPassaggi == 0L) { //05/09/2022 String queryPassaggi="select count(*) as NRec 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 where TRUNC(data) = TRUNC(SYSDATE) and id_tessera=" + idTessera + " and flag_in_vassoio=0 and id_punto_cassa=" + idPuntoCassa; Long NPassaggi = MySelectInteger(queryPassaggi, "NRec"); //fine---- if (FlagEsegueStorni && NPassaggi>0) { //JOptionPane.showMessageDialog(this, "Tessera non abilitata per questo punto di distribuzione!\nConsenti passaggio?",JOptionPane.YES_NO_OPTION); Object[] options = {"Sì", "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", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[1]); if (Integer.parseInt(selectedValue.toString()) == 0) { ApriStorno(true); } else { AzzeraDopoStorno(); return; // //16-04-2019 // //CancellaComposizioni(); // Annulla(); // timerDisplay.schedule(new TimerTask() { // // @Override // public void run() { // Azzera(); // AggiornaLabelInfo(); // // } // }, 500); // // //Chiudi(); // PassaggiEsauritiNoComposizione = true; // // //30-11-15 // //Azzera(); // //return; } } else { JOptionPane.showMessageDialog(this, "N° passaggi giornalieri esauriti. Non è possibile usufruire del pasto!"); AzzeraDopoStorno(); return; } } //aggiungo un giorno altrimenti in caso di scadenza nello stesso giorno //considera le ore Scadenza = formatter.parse(dati[9]); Calendar c = Calendar.getInstance(); c.setTime(Scadenza); c.add(Calendar.DATE, 1); Scadenza = c.getTime(); //JOptionPane.showMessageDialog(this, Scadenza + ' ' + now); if (Scadenza.after(now) && idStato != 2) { //String res1 = MySelect("Select Cognome || ' ' || Nome || ';' || id_Categoria as ris from utenti where id=" + dati[1], "ris"); //String dati2[] = res1.split(";"); String ModoP = CercaTestoModoPagamento(); // CaricaCompleti(); lblCategoria.setText(dati[0]); lblCognome.setText(dati[1]); lblNome.setText(dati[2]); if (FlagMostraDataDiNascita) { lblNascita.setText(dati[3]); } //lblScadTessera.setText(dati[9]);//dati[4] lblAzienda.setText(dati[5]); lblConvenzione.setText(dati[6]); lblFascia.setText(dati[7]); jBtnStorno.setEnabled(FlagEsegueStorni); jBtnAsporto.setEnabled(true); jbtnChiudi.setEnabled(true); //VerificaModoPagamento(); if (btnImpostaCliente.isVisible()) { btnImpostaCliente.setEnabled(false); jBtnBuoni.setEnabled(false); } if (FlagPrecaricaLista == false) { CassaAperta = true; AbilitaPulsanti(pnlCategorie, true,true); AbilitaPulsanti(pnlProdotti, true,true); } if (dati.length > 13) { if (dati[13].length() > 0) { Gratuita_Residue = Integer.parseInt(dati[13]); } //Gratuita_ResidueProg = Gratuita_Residue; lblGratuità.setText(dati[13]); } Bonus_Residui = 0; if (dati.length > 14) { if (dati[14].length() > 0) { Bonus_Residui = Integer.parseInt(dati[14]); } } lblScadTessera.setText("" + Bonus_Residui); //CaricaCompleti(); if (ModoP.equalsIgnoreCase("A scalare")) { //VerificaSaldo(NTessera); //modifica 09-11-18 if (CalcolaTotale() > 0.00 && FlagPrecaricaLista == false) { VerificaSaldo(NTessera); } //fine modifica } else { MyApplication MyA = new MyApplication(); String Punti = MyA.MySelect(this, "Select Punti from Tessere where numero='" + NTessera + "'", "Punti"); lblPunti.setText(Punti); String Tipo = CercaTestoModoPagamento(); lblTipoPagamento.setText(Tipo); } StoCalcolando=true; PulsantiModoPagamento(); StoCalcolando=false; //this.caricaDati("PRODOTTI", "-1"); this.caricaPannello(); AbilitaPulsanti(pnlCategorie, true,true); StatoTesseraLetta(Gratuita_Residue, Bonus_Residui); //28-09-2016 quando c'è una sola categoria faccio click if (NumeroCategorie == 1) { Component[] components = pnlCategorie.getComponents(); JToggleButton bt = (JToggleButton) components[0]; //bt.doClick(); } //FlagDefaultAsporto if (Asporto) { jBtnAsporto.setSelected(true); jBtnAsportoActionPerformed(null); } MyTableModel model = (MyTableModel) tblLista.getModel(); if (FlagPrecaricaLista) { ForzaPrezzi(model); } ControllaCompleti(model); ControllaExtra(model); SommaColonne(model); //modifica 09-11-18 if (ModoP.equalsIgnoreCase("A scalare")) { if (CalcolaTotale() > 0.00 && FlagPrecaricaLista) { VerificaSaldo(NTessera); } } //fine modifica //SommaColonne(model); //05-06-2020 if (AbilitatoPassaggi != 0L) { ControllaPrenotazioni(); } } else { JOptionPane.showMessageDialog(this, "Tessera Scaduta o Disabilitata!"); LogTessera(); Azzera(); } } catch (ParseException e) { LogTesseraErrore = e.getMessage().toString(); LogTessera(); Azzera(); } } else { JOptionPane.showMessageDialog(this, "Errore in lettura della tessera!"); LogTessera(); Azzera(); } } // private void ControllaPrenotazioni() { // String Query = "select * from (SELECT id_Prenotazione as nr FROM VIEW_PRENOTAZIONI_TURNO WHERE (id_Modalita=2 or id_Modalita=3) and id_stato = 1 AND id_turno =" + idTurnoAttuale + " AND id_tessera = " + idTessera + " order by id_prenotazione) where rownum = 1 "; // String idP = MySelect(Query, "nr"); // if (idP.length() > 0) { // Long rowCount = Long.parseLong(idP); // idPrenotazione = rowCount; // if (rowCount > 0L) { // if (JOptionPane.showConfirmDialog(null, "Prenotazione presente. Inserisco i prodotti?", "Prenotazione", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { // InserisciPrenotazioni(); // } // } // } // } private void ControllaPrenotazioni() { try { //String Query = "select * from (SELECT id_Prenotazione as nr FROM VIEW_PRENOTAZIONI_TURNO WHERE (id_Modalita=2 or id_Modalita=3) and id_stato = 1 AND id_turno =" + idTurnoAttuale + " AND id_tessera = " + idTessera + " order by id_prenotazione) where rownum = 1 "; String Query="SELECT * FROM (SELECT id_Prenotazione as nr FROM VIEW_PRENOTAZIONI_TURNO WHERE id_modalita in (2,3) AND id_stato IN (0,1) AND id_turno = " + idTurnoAttuale + " AND id_tessera = " + idTessera + " order by id_prenotazione) where rownum = 1"; String idP = MySelect(Query, "nr"); if (idP.length() > 0) { Long rowCount = Long.parseLong(idP); idPrenotazione = rowCount; if (rowCount > 0L) { Query = "SELECT Distinct Nome FROM VIEW_PRENOTAZIONI_TURNO v join prodotti p on v.ID_PRODOTTO=p.ID WHERE id_Modalita in (2,3) and id_stato in (0,1) AND id_turno =" + idTurnoAttuale + " AND id_tessera = " + idTessera + " and id_prenotazione=" + idPrenotazione + " order by Nome"; Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); Statement st = dbConnection.createStatement(); ResultSet rs = st.executeQuery(Query); StringBuilder s =new StringBuilder(""); while (rs.next()) { s.append(rs.getString("Nome")); s.append("\n"); } rs.close(); st.close(); dbConnection.close(); if (JOptionPane.showConfirmDialog(null, "Prenotazione presente:\n" + s.toString() + "Inserisco i prodotti?", "Prenotazione", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { InserisciPrenotazioni(); } } } } catch (SQLException | NumberFormatException e) { System.err.println(e.getClass().getName() + ": " + e.getMessage()); } finally { } } private void InserisciPrenotazioni() { try { MyTableModel model = (MyTableModel) tblLista.getModel(); MyTableModel model1 = (MyTableModel) tblLista1.getModel(); ClearTable(model); ClearTable(model1); SommaColonne(model); String Query = "SELECT * FROM VIEW_PRENOTAZIONI_TURNO WHERE id_Modalita in (2,3) and id_stato in (0,1) AND id_turno =" + idTurnoAttuale + " AND id_tessera = " + idTessera + " and id_prenotazione=" + idPrenotazione; Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); Statement st = dbConnection.createStatement(); ResultSet rs = st.executeQuery(Query); //Long idPrenotazione=0L; while (rs.next()) { // if (idPrenotazione!=rs.getLong("ID_PRENOTAZIONE") && idPrenotazione!=0L){ // break; // } java.awt.event.ActionEvent evt; evt = new java.awt.event.ActionEvent(new Object(), 0, "PRODOTTO[" + rs.getString("ID_PRODOTTO") + "]"); actionPerformed(evt); // idPrenotazione=rs.getLong("ID_PRENOTAZIONE"); } // this.idPrenotazione=idPrenotazione; rs.close(); st.close(); dbConnection.close(); } catch (SQLException | NumberFormatException e) { System.err.println(e.getClass().getName() + ": " + e.getMessage()); } finally { } } public void AzzeraDopoStorno() { Annulla(); timerDisplay.schedule(new TimerTask() { @Override public void run() { Azzera(); AggiornaProgressivi(); //AggiornaLabelInfo(); } }, 500); //Chiudi(); PassaggiEsauritiNoComposizione = true; } 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); } return TotAcquisto; } private void ForzaPrezzi(MyTableModel model) { for (int y = 0; y < model.getRowCount(); y++) { Object row[] = model.getRow(y); String idProdotto = row[3].toString(); String Query = "SELECT Punti || '|' || prezzo as res FROM tariffe where id_Prodotto = " + idProdotto + " and id_fascia=" + idProfiloTariffario; String res = MySelect(Query, "res"); if (res.length() > 0) { String[] El = res.split("\\|", -1); Double Prezzo = 0.0; Integer Punti = 0; Punti = Integer.parseInt(El[0]); Prezzo = Double.parseDouble(El[1].replace(",", ".")); // row[ColImporto]=Prezzo; // row[ColPunti]=Punti; // model.addRow(row); model.setValueAt(Prezzo, y, ColImporto); model.setValueAt(Prezzo, y, ColImporto2); model.setValueAt(Punti, y, ColPunti); doLayout(); } } } //prima modifica del 09-05-18<<<<<<<<<<<<<<<<<<<<<<<<<< // public void CercaTesseraOLD() { // lblCategoria.setText(""); // lblCognome.setText(""); // lblNome.setText(""); // lblNascita.setText(""); // lblScadTessera.setText(""); // lblAzienda.setText(""); // lblConvenzione.setText(""); // lblFascia.setText(""); // // //Display(Message_Display, " "," "); // if (CassaAperta == false) { // // TurnoAttuale(); // if ((idTurnoAttuale - idTurno) != 0) { // // ProgressivoTurno = 1L; // ProgressivoContanti = 0.00; // ProgressivoScalare = 0.00; // ProgressivoTicket = 0.00; // ProgressivoDifferito = 0.00; // if (NomeTurnoAttuale.equalsIgnoreCase("Pranzo")) { // ProgressivoGiorno = 1L; // } // idTurno = idTurnoAttuale; // NomeTurno = NomeTurnoAttuale; // // Date Adesso = new Date(); // String ControlloTurno = MySelect("select count(*) as Prog from Progressivi where id_Punto_cassa=" + idPuntoCassa + " and data=" + AggiustaData(Adesso) + " and id_Turno=" + idTurno, "Prog"); // if (Long.parseLong(ControlloTurno) <= 0) { // MyInsert("Insert into Progressivi (data,id_Punto_cassa,id_Turno,prog_assoluto,prog_giorno,prog_turno) " // + " values (" + AggiustaData(Adesso) + "," + idPuntoCassa + "," + idTurno + "," + Progressivo + "," + ProgressivoGiorno + ",0)"); // } // // AggiornaLabelInfo(); // } // // CassaAperta = true; // idProfiloTariffario = 0L; // //idModoPagamento=0L; // //SetModoPagamento("Contanti"); // SetModoPagamento(ModoPagamentoDefault); // String NTessera = jTxtTessera.getText(); // // String ControlloPunto="select count(*) as T from view_tessere_abilitate where id_punto_cassa =" + idPuntoCassa + " and numero = '" + NTessera + "'"; // // //String res = MySelect("Select data_scadenza || ';' || id_utente || ';' || id_fascia || ';' || id_Stato || ';' || id as ris from tessere where numero='" + NTessera + "'", "ris"); // //String res = MySelect("SELECT t.data_scadenza || ';'|| u.id || ';'||t.id_fascia|| ';'|| t.id_stato|| ';'||t.id || ';'|| u.nome|| ';'|| u.cognome|| ';'|| c.nome as ris FROM tessere t, utenti u, categorie_utenti c, stati_tessere s WHERE t.id_utente = u.id AND u.id_categoria = c.id AND t.id_stato = s.id AND t.numero = '" + NTessera + "'", "ris"); // //String res=MySelect("SELECT data_scadenza || ';'|| id_utente || ';'|| id_fascia|| ';'|| id_stato|| ';'|| id_Tessera || ';'|| nome|| ';'|| cognome|| ';'|| categoria as ris FROM view_tessere where numero = '" + NTessera + "'", "ris"); // //select c.nome as categoria, u.cognome, u.nome, u.data_di_nascita, u.matricola, a.nome as azienda, c.nome as convenzione, f.nome as fascia, t.id as id_tessera, t.data_scadenza, t.id_stato, u.id as id_utente, f.id as id_fascia //// String Query="select distinct c.nome || '|'|| u.cognome || '|'|| u.nome || '|'|| to_char(u.data_di_nascita,'dd/mm/yyyy') || '|'|| u.matricola || '|'|| a.nome || '|'|| c.nome || '|'|| f.nome || '|'|| t.id || '|'|| to_char(t.data_scadenza,'dd/mm/yyyy') || '|'|| t.id_stato || '|'|| u.id || '|'|| f.id || '|'|| t.gratuita_residue as ris" + //// " from categorie_utenti c, tessere t, utenti u, convenzioni_fasce cf, fasce f, convenzioni co, aziende a where u.id_categoria = c.id" + //// " and t.id_utente = u.id and cf.id_categoria_utenti = c.id and cf.id_fascia = f.id and cf.id_convenzione = co.id and co.id_azienda = a.id" + //// " and t.numero = '" + NTessera + "'"; // String Query = "SELECT DISTINCT c.nome || '|' || u.cognome || '|' || u.nome || '|' || TO_CHAR (u.data_di_nascita, 'dd/mm/yyyy') || '|' || u.matricola || '|' || a.nome || '|' || c.nome || '|' || f.nome || '|' || t.ID || '|' || TO_CHAR (t.data_scadenza, 'dd/mm/yyyy') || '|' || t.id_stato || '|' || u.ID || '|' || f.ID || '|' || t.gratuita_residue AS ris " // + " FROM categorie_utenti c, tessere t, utenti u, categorie_utenti_fasce cf, fasce f, aziende a WHERE t.id_utente = u.ID AND u.id_categoria = c.ID AND c.id_azienda = a.ID AND cf.id_categoria_utenti = c.ID AND cf.id_fascia = f.ID AND t.numero = '" + NTessera + "'"; // String res = MySelect(Query, "ris"); // // if (res.length() > 0) { // String dati[] = res.split("\\|"); // // Date now = new Date(); // // Date Scadenza = new Date(); // SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); // // idProfiloTariffario = Long.parseLong(dati[12]); // Integer idStato = Integer.parseInt(dati[10]); // idTessera = Long.parseLong(dati[8]); // // try { // // controllo abilitazione tessera // String ControlloPunto = "Select controlla_abilitazione('" + NTessera + "'," + idPuntoCassa + ") as T from dual"; // Long Abilitato = MySelectInteger(ControlloPunto, "T"); // if (Abilitato == 0) { // //JOptionPane.showMessageDialog(this, "Tessera non abilitata per questo punto di distribuzione!\nConsenti passaggio?",JOptionPane.YES_NO_OPTION); // Object[] options = {"Sì", "No"}; // 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]); // if (Integer.parseInt(selectedValue.toString()) != 0) { // return; // } else { // MyInsert("Insert into Forzature (id,id_account,id_Punto_Cassa,id_Tessera,id_Tipo_Forzatura) values (-1," + idAccount + "," + idPuntoCassa + "," + idTessera + ",1)"); // // } // // } // // //controllo passaggi // String ControlloPassaggi = "Select controlla_passaggi('" + NTessera + "'," + idPuntoCassa + ") as T from dual"; // Long AbilitatoPassaggi = MySelectInteger(ControlloPassaggi, "T"); // // //da togliere<<<<<<<<<<<<<<<<<<<<<<<<< // //AbilitatoPassaggi = 0L; // if (AbilitatoPassaggi == 0L) { // //JOptionPane.showMessageDialog(this, "Tessera non abilitata per questo punto di distribuzione!\nConsenti passaggio?",JOptionPane.YES_NO_OPTION); // //Object[] options = { "Sì", "No" }; // JOptionPane.showOptionDialog(this, "N° passaggi giornalieri esauriti. Non è possibile usufruire del pasto!", "Attenzione", // JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); // //Chiudi(); // CancellaComposizioni(); // PassaggiEsauritiNoComposizione = true; // // //30-11-15 // //Azzera(); // //return; // } // // //aggiungo un giorno altrimenti in caso di scadenza nello stesso giorno // //considera le ore // Scadenza = formatter.parse(dati[9]); // Calendar c = Calendar.getInstance(); // c.setTime(Scadenza); // c.add(Calendar.DATE, 1); // Scadenza = c.getTime(); // // //JOptionPane.showMessageDialog(this, Scadenza + ' ' + now); // if (Scadenza.after(now) && idStato != 2) { // //String res1 = MySelect("Select Cognome || ' ' || Nome || ';' || id_Categoria as ris from utenti where id=" + dati[1], "ris"); // //String dati2[] = res1.split(";"); // // String ModoP = CercaTestoModoPagamento(); // //// if (ModoP.equalsIgnoreCase("A scalare")) { //// if (VerificaSaldo(NTessera)) { // CaricaCompleti(); // lblCategoria.setText(dati[0]); // lblCognome.setText(dati[1]); // lblNome.setText(dati[2]); // if (FlagMostraDataDiNascita) { // lblNascita.setText(dati[3]); // } // lblScadTessera.setText(dati[9]);//dati[4] // lblAzienda.setText(dati[5]); // lblConvenzione.setText(dati[6]); // lblFascia.setText(dati[7]); // jBtnStorno.setEnabled(true); // //jBtnCarta.setEnabled(true); // jBtnAsporto.setEnabled(true); //// jBtnBuoni.setEnabled(true); // //jBtnTicket.setEnabled(true); // //VerificaModoPagamento(); // if (btnImpostaCliente.isVisible()) { // btnImpostaCliente.setEnabled(false); // } // //AbilitaPulsanti(pnlCategorie, true); // //AbilitaPulsanti(pnlProdotti, true); // if (dati.length > 13) { // if (dati[13].length() > 0) { // Gratuita_Residue = Integer.parseInt(dati[13]); // } // //Gratuita_ResidueProg = Gratuita_Residue; // lblGratuità.setText(dati[13]); // } // //CaricaCompleti(); // // if (ModoP.equalsIgnoreCase("A scalare")) { // // VerificaSaldo(NTessera); // // } else { // MyApplication MyA = new MyApplication(); // String Punti = MyA.MySelect(this, "Select Punti from Tessere where numero='" + NTessera + "'", "Punti"); // lblPunti.setText(Punti); // String Tipo = CercaTestoModoPagamento(); // lblTipoPagamento.setText(Tipo); // // } // PulsantiModoPagamento(); // //this.caricaDati("PRODOTTI", "-1"); // this.caricaPannello(); // StatoTesseraLetta(0, 0); // // //28-09-2016 quando c'è una sola categoria faccio click // if (NumeroCategorie == 1) { // Component[] components = pnlCategorie.getComponents(); // JToggleButton bt = (JToggleButton) components[0]; // bt.doClick(); // } //// } else { //// Azzera(); ////// CassaAperta=false; ////// idProfiloTariffario=0L; ////// idTessera=0L; ////// idModoPagamento=0L; //// } // // //FlagDefaultAsporto // if (Asporto) { // jBtnAsporto.setSelected(true); // jBtnAsportoActionPerformed(null); // } // // } else { // JOptionPane.showMessageDialog(this, "Tessera Scaduta o Disabilitata!"); // Azzera(); //// CassaAperta=false; //// idProfiloTariffario=0L; //// idTessera=0L; //// idModoPagamento=0L; // } // } catch (ParseException e) { // Azzera(); //// CassaAperta=false; //// idProfiloTariffario=0L; //// idTessera=0L; //// idModoPagamento=0L; // } // } else { // // JOptionPane.showMessageDialog(this, "Errore in lettura della tessera!"); // Azzera(); // } // } //// String[] Dati=MySelect("Select nome || ' ' || cognome as nc from utenti", dbTipo); //// lblCodiceDati.setText(Dati[0]); //// lblDenominazioneDati.setText(Dati[0]); //// lblOrganizzazioneDati.setText(Dati[2]); // // } private void AbilitaPulsanti(JPanel aPanel, Boolean Abilita,Boolean Apertura) { Component c = null; Component[] components = aPanel.getComponents(); if (components != null) { int numComponents = components.length; for (int i = 0; i < numComponents; i++) { c = components[i]; if (c != null) { //c.setEnabled(Abilita); JToggleButton bt = (JToggleButton) c; if (bt == null) { c.setEnabled(Abilita); } else { try { if (bt.getText().equalsIgnoreCase("Composizione") && PassaggiEsauritiNoComposizione && aPanel.getName().equalsIgnoreCase("pnlCategorie")) { bt.setEnabled(false); } else { bt.setEnabled(Abilita); } if (bt.getText().equalsIgnoreCase("Composizione") && MenùGiornoPresente == false && Apertura ) { bt.setEnabled(true); bt.setSelected(true); PulsantiCategoria("0", "Categoria[0]"); //bt.setSelected(true); // cmdComposizione=bt.getActionCommand(); // Integer inizio = cmdComposizione.indexOf("["); // Integer fine = cmdComposizione.indexOf("]"); // idComposizione = cmdComposizione.substring(inizio + 1, fine); //// MenùGiorno=true; // Timer timer = new Timer(); // timer.schedule(new TimerTask() { // @Override // public void run() { // PulsantiCategoria(idComposizione, cmdComposizione); // } // }, 1000); } else { bt.setSelected(false); } // bt.setSelected(false); } catch (Exception ex) { } } } } } } 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 { Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); Statement st = dbConnection.createStatement(); ResultSet rs = st.executeQuery(Query); rows = new Object[rowCount][]; int r = 0; while (rs.next()) { Object[] row = new Object[Cols.length]; for (int i = 0; i < Cols.length; i++) { if (rs.getString(Cols[i].replace(" ", "_")) == null) { row[i] = ""; } else { row[i] = rs.getString(Cols[i].replace(" ", "_")); } switch (ColType[i]) { case "text": if (rs.getString(Cols[i].replace(" ", "_")) == null) { row[i] = ""; } else { row[i] = rs.getString(Cols[i].replace(" ", "_")); } break; case "integer": if (rs.getString(Cols[i].replace(" ", "_")) == null) { row[i] = 0; } else { row[i] = rs.getInt(Cols[i].replace(" ", "_")); } break; case "boolean": if (rs.getString(Cols[i].replace(" ", "_")) == null) { row[i] = false; } else { row[i] = rs.getBoolean(Cols[i].replace(" ", "_")); } break; case "float": if (rs.getString(Cols[i].replace(" ", "_")) == null) { row[i] = 0.00; } else { String v = rs.getString(Cols[i].replace(" ", "_")); row[i] = Float.parseFloat(v.replace(",", ".")); } break; } } rows[r] = row; 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(); st.close(); dbConnection.close(); } catch (SQLException | NumberFormatException e) { System.err.println(e.getClass().getName() + ": " + e.getMessage()); } finally { return rows; } } private String MySelect(String Query, String Campo) { String res = ""; try { Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); Statement st = dbConnection.createStatement(); ResultSet rs = st.executeQuery(Query); while (rs.next()) { res = rs.getString(Campo); } rs.close(); st.close(); dbConnection.close(); } catch (SQLException e) { JOptionPane.showMessageDialog(this, "Errore MySelect ['" + e.getMessage() + " " + Query + "']"); } if (res == null) { res = ""; } return res; } private Boolean MyInsert(String Query) { System.out.println(Query); Boolean res = false; try { Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); Statement st = dbConnection.createStatement(); ResultSet rs = st.executeQuery(Query); rs.close(); st.close(); dbConnection.close(); res = true; } catch (Exception e) { JOptionPane.showMessageDialog(this, "Errore MySelect ['" + e.getMessage() + " " + Query + "']"); } return res; } private Long MySelectInteger(String Query, String Campo) { Long res = 0L; try { Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); Statement st = dbConnection.createStatement(); ResultSet rs = st.executeQuery(Query); while (rs.next()) { res = rs.getLong(Campo); } rs.close(); st.close(); dbConnection.close(); } catch (SQLException e) { JOptionPane.showMessageDialog(this, "Errore MySelectInteger ['" + e.getMessage() + " " + Query + "']"); } return res; } public void InsertImage() { String filenamepath = new String("L:\\Lavoro\\Goffredo\\risorse\\Brioche.jpg"); try { //File file =new File(getClass().getClassLoader().getResource(filenamepath).getFile()); 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; try { String Query = "select icona from Prodotti where id=" + idProdotto; // create prepare Statement pst //System.out.println("write from data base1 "); Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); PreparedStatement pst = dbConnection.prepareStatement(Query); //System.out.println("write from data base:2 "); //pst.setString(1,Name); //System.out.println("write from data base:3 "); ResultSet result = pst.executeQuery(); //System.out.println("write from data base:4 "); if (result.next()) { // Name = result.getString(1); //System.out.println("write from data base:5 "); //FullName = "L:\\Lavoro\\Goffredo\\risorse\\copia.jpg"; FullName = imgPath + idProdotto + ".jpg"; //using Srteam Method''''' gifdata = result.getBinaryStream(1); //System.out.println("write from data base:6 "); //create file if (gifdata != null) { File giffile = new File(FullName); //write the byte array into a local file. FileOutputStream file = new FileOutputStream(giffile); int chunk = 0; while ((chunk = gifdata.read()) != -1) { file.write(chunk); } file.flush(); file.close(); } } result.close(); pst.close(); dbConnection.close(); } catch (Exception e) { e.printStackTrace(); } // return FullName; } private byte[] getPhoto(String Query) throws Exception, SQLException { String req = ""; Blob img; byte[] imgData = null; Connection dbConnection = DriverManager.getConnection(dbStringa, dbUsername, dbPassword); Statement stmt = dbConnection.createStatement(); // Query req = Query; ResultSet rset = stmt.executeQuery(req); while (rset.next()) { img = rset.getBlob(1); imgData = img.getBytes(1, (int) img.length()); } rset.close(); stmt.close(); dbConnection.close(); return imgData; } private String AggiustaDateOra(Date Data) { SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); String data = "to_date('" + formatter.format(Data) + "','dd/mm/yyyy HH24:MI:SS')"; return data; } private String AggiustaData(Date Data) { SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); String data = "to_date('" + formatter.format(Data) + "','dd/mm/yyyy')"; return data; } private void AggiungiImmaginiPulsanti() { AggiungImmagini(jBtnStorno, "Storno.png", 70, 70); // AggiungImmagini(jBtnCarta,"tsn.png",80,80); AggiungImmagini(jBtnAsporto, "coltello e forchetta.jpg", 50, 50); // AggiungImmagini(jBtnTicket,"Contanti.png",50,50); AggiungImmagini(jTBP0, "a scalare.png", 50, 50); AggiungImmagini(jTBP1, "Contanti.png", 50, 50); AggiungImmagini(jTBP2, "Ticket.png", 50, 50); AggiungImmagini(jTBP3, "differito.png", 50, 50); AggiungImmagini(jBtnprodotti, "Prodotti.png", 50, 50); // UIManager.put("ToggleButton.select", Color.BLUE); SwingUtilities.updateComponentTreeUI(jTBP0); //AggiungImmagini(jBtnMeteo,"Meteo.png",50,50); //AggiungImmagini(jBtnDB,"DB.png",50,50); AggiungImmagini(jBtnMovimenti, "Movimenti.png", 50, 50); } private void AggiungImmagini(JButton btn, String Immagine, int width, int height) { ImageIcon icon = new ImageIcon(imgPath + Immagine); Image img = icon.getImage(); Image newimg = img.getScaledInstance(width, height, java.awt.Image.SCALE_SMOOTH); icon = new ImageIcon(newimg); btn.setIcon(icon); } private void AggiungImmagini(JToggleButton btn, String Immagine, int width, int height) { ImageIcon icon = new ImageIcon(imgPath + Immagine); Image img = icon.getImage(); Image newimg = img.getScaledInstance(width, height, java.awt.Image.SCALE_SMOOTH); icon = new ImageIcon(newimg); btn.setIcon(icon); btn.setDisabledIcon(null); btn.setDisabledIcon(icon); } // ========================================================================== // * Metodo main() // * // * @param args the command line arguments // * // ========================================================================== public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { // ================================================================= // *** Crea la form base // ================================================================= PuntoCassa p = new PuntoCassa(); p.AggiungImmagini(p.jBtnDB1, "DB.png", 50, 50); // ================================================================= // *** Esegue il resize a seconda delle impostazioni video per // *** occupare tutto lo schermo utile // ================================================================= Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screenSize = toolkit.getScreenSize(); Rectangle winSize = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); // p.setSize(screenSize.width, winSize.height); // p.setLocation(0, 0); p.setSize(1024, 768); p.setLocation((int) (screenSize.width - 1024) / 2, (int) (screenSize.height - 768) / 2); p.resize(); // ================================================================= // *** Mostra la form nello stato iniziale // ================================================================= p.pnlErrore.setVisible(false); p.pnlLogin.setVisible(true); p.lblUtenteLoggato.setVisible(true); p.lblInfo.setVisible(true); p.lblStatoConnessione.setVisible(true); p.pnlTop.setVisible(false); p.setVisible(true); // p.txtUsername.setText("martiri"); // p.txtPassword.setText("ok"); // p.txtUsername.setText("marco"); // p.txtPassword.setText("3104"); // ricordati >>>>>>>>>> //VerificaAggiornamentoDB(); } }); } public void ControllaLogInCarta(String nTessera) { if (Turno()) { String Query = "select a.username || '|' || a.id || '|' || a.id_stato as res" + " from accounts a, utenti u, tessere t, profili p, ruoli r where a.id_utente = u.id" + " and t.id_utente = u.id" + " and p.id_account = a.id" + " and p.id_ruolo = r.id" //+ " and r.id = 10000000004" + //*** Operatore di cassa ***/ + " and t.numero = '" + nTessera + "'"; //*** Numero della tessera letto su smartcard *** MyApplication MyA = new MyApplication(); String[] res = MyA.MySelect(this, Query, "res").split("\\|"); if (res.length >= 3) { utenteLoggato = res[0]; idAccount = Long.parseLong(res[1]); Integer Stato = Integer.parseInt(res[2]); if (utenteLoggato.length() > 0 && idAccount > 0L && Stato == 1) { String sql = "SELECT count(*) as Counter FROM profili p WHERE p.id_account = " + idAccount + " AND p.id_ruolo = 10000000004"; Integer counter = Integer.parseInt(MyA.MySelect(this, sql, "Counter")); if (counter == 1) { ImpostaAmbiente(); VerificaAggiornamentoDB(); } else { idAccount = 0L; utenteLoggato = ""; JOptionPane.showMessageDialog(this, "L'utente non dispone dei privilegi per l'utilizzo del modulo cassa."); } } else { utenteLoggato = ""; idAccount = 0L; if (Stato == 2) { String Messaggio = MyA.MySelect(this, "Select Descrizione from Stati_Accounts where id=" + Stato, "descrizione"); JOptionPane.showMessageDialog(this, Messaggio + "."); } else { JOptionPane.showMessageDialog(this, "Tessera sconosciuta!"); } } } else { JOptionPane.showMessageDialog(this, "Tessera sconosciuta!"); } CartaLetta = true; } else { JOptionPane.showMessageDialog(this, "Impossibile eseguire il Login al sistema:\nNessun Turno Attivo!"); } } private void Display(String Titolo, String Prezzo) { System.out.println("Display: " + Titolo); if (Visualizza_Messaggi_Display) { try { SerialPort serialPort = new SerialPort("COM3"); try { serialPort.openPort();//Open serial port serialPort.setParams(SerialPort.BAUDRATE_9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);//Set params. Also you can set params by this string: serialPort.setParams(9600, 8, 1, 0); String Testo = Titolo; if (Prezzo != null) { Testo = Titolo + SpaziBianchi(Prezzo, 40 - Titolo.length(), false); } serialPort.writeBytes(Testo.getBytes());//Write data to port serialPort.closePort();//Close serial port } catch (SerialPortException ex) { //System.out.println(ex); if (serialPort.isOpened()) { serialPort.closePort(); } JOptionPane.showMessageDialog(this, ex.getMessage()); } } catch (SerialPortException | HeadlessException ex) { JOptionPane.showMessageDialog(this, ex.getMessage()); } } } String SpaziBianchi(String Testo, Integer Num, Boolean Suffisso) { String res = Testo; StringBuilder Suff = new StringBuilder(); if (Testo.length() < Num) { Integer Delta = Num - Testo.length(); for (Integer i = 0; i < Delta; i++) { Suff.append(" "); } if (Suffisso == false) { res = Suff.toString() + Testo; } else { res = Testo + Suff.toString(); } } return res; } private void StatoAttivoNonLoggato() { String PC = idPuntoCassa.toString(); if (PC.length() >= 5) { PC = PC.substring(PC.length() - 5, PC.length()); } else { PC = SpaziBianchi(PC, 5, false); } String Riga = SpaziBianchi(Message_Display, 20, true) + "POS " + PC + " CHIUSO"; Display(Riga, null); } private void StatoAttivoLoggato() { //per evitare che inserendo la tessera successiva mi cancelli il num tessera if (jTxtTessera.getText().trim().length() <= 0) { String PC = idPuntoCassa.toString(); if (PC.length() >= 5) { PC = PC.substring(PC.length() - 5, PC.length()); } else { PC = SpaziBianchi(PC, 5, false); } String Riga = SpaziBianchi(Message_Display, 20, true) + "POS " + PC + " APERTO"; Display(Riga, null); } } private void StatoTesseraLetta(int Gratuità, int Bonus) { String tess = jTxtTessera.getText(); if (tess.length() >= 12) { tess = tess.substring(tess.length() - 12, tess.length()); } else { tess = SpaziBianchi(tess, 12, false); } String fa = "";//lblFascia.getText().replaceAll("Fascia","").trim(); /*if(fa.length()>=13){ fa=fa.substring(fa.length()-13, fa.length()); }else{*/ fa = SpaziBianchi(fa, 13, true); //} if (Gratuità > 0) { } else if (Bonus > 0) { fa = "BONUS "; } //Display("TESSERA " + tess + "FASCIA " + fa ,null); //aggiornamento 14-01-2019 //aggiornamento 12-04-2019 //Display("TESSERA " + tess + " " + fa, null); } 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 { PuntoCassa frmA; public CardTask(PuntoCassa frmx) { frmA = frmx; } public void run() { //Date mo=new Date(); //System.out.println(mo); MyApplication MyA = new MyApplication(); try { MyA.SC.setReader(jcmbSC.getSelectedItem()); MyA.SC.connect("T=1"); //System.out.println(MyA.SC.getCurrentCardATR()); StatoCarta = statiCarta.Inserita; if (pnlLogin.isVisible() == false && CartaLetta == false) { jBtnReadCardActionPerformed(null); //btnImpostaClienteActionPerformed(null); PassaggioTessera = true; frmA.CercaTessera(); CartaLetta = true; } else if (pnlLogin.isVisible() == true && CartaLetta == false) { frmA.ControllaLogInCarta(GetNumeroTessera()); } // System.out.println(StatoCarta); } catch (Exception e) { //JOptionPane.showMessageDialog(frmA, e.getMessage(),"Exception",JOptionPane.ERROR_MESSAGE); if (StatoCarta == statiCarta.Inserita) { StatoCarta = statiCarta.Tolta; } else { StatoCarta = statiCarta.Assente; } CartaLetta = false; //System.out.println(StatoCarta); } } } // Variables declaration - do not modify//GEN-BEGIN:variables public javax.swing.JButton btnImpostaCliente; private javax.swing.JButton btnLogin; private javax.swing.JButton btnTermina; private javax.swing.JToggleButton jBtnAsporto; private javax.swing.JButton jBtnBuoni; private javax.swing.JButton jBtnDB1; private javax.swing.JButton jBtnMovimenti; private javax.swing.JButton jBtnReadCard; private javax.swing.JButton jBtnStorno; private javax.swing.JButton jBtnprodotti; private javax.swing.JCheckBox jChLogin; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JToggleButton jTBP0; private javax.swing.JToggleButton jTBP1; private javax.swing.JToggleButton jTBP2; private javax.swing.JToggleButton jTBP3; private javax.swing.JTextField jTxtTessera; private javax.swing.JButton jbtnAnnulla; private javax.swing.JButton jbtnChiudi; private javax.swing.JButton jbtnDuplica; private javax.swing.JButton jbtnElimina; private javax.swing.JButton jbtnEsci; private javax.swing.JButton jbtnGiu; private javax.swing.JButton jbtnStampa; private javax.swing.JButton jbtnSu; private javax.swing.JComboBox jcmbSC; private javax.swing.JLabel lblAzienda; private javax.swing.JLabel lblCategoria; private javax.swing.JLabel lblCodice; private javax.swing.JLabel lblCodice1; private javax.swing.JLabel lblCodice2; private javax.swing.JLabel lblCodice3; private javax.swing.JLabel lblCodice4; private javax.swing.JLabel lblCodice5; private javax.swing.JLabel lblCognome; private javax.swing.JLabel lblConvenzione; private javax.swing.JLabel lblDB; private javax.swing.JLabel lblDenominazione; private javax.swing.JLabel lblFascia; private javax.swing.JLabel lblGratuità; private javax.swing.JLabel lblInfo; private javax.swing.JLabel lblInfo2; private javax.swing.JLabel lblMessaggioErrore; private javax.swing.JLabel lblNascita; private javax.swing.JLabel lblNome; private javax.swing.JLabel lblOrganizzazione; private javax.swing.JLabel lblOrganizzazione1; private javax.swing.JLabel lblOrganizzazione2; private javax.swing.JLabel lblOrganizzazione3; private javax.swing.JLabel lblOrganizzazione4; private javax.swing.JLabel lblOrganizzazione5; private javax.swing.JLabel lblPassword; private javax.swing.JLabel lblPunti; private javax.swing.JLabel lblResiduo; private javax.swing.JLabel lblSaldo; private javax.swing.JLabel lblScadTessera; private javax.swing.JLabel lblStatoConnessione; private javax.swing.JLabel lblTipoPagamento; private javax.swing.JLabel lblUsername; private javax.swing.JLabel lblUtenteLoggato; private javax.swing.JPanel pnlAzioni; private javax.swing.JPanel pnlCategorie; private javax.swing.JPanel pnlCliente; private javax.swing.JPanel pnlConto; private javax.swing.JPanel pnlErrore; private javax.swing.JPanel pnlLista; private javax.swing.JPanel pnlLista1; private javax.swing.JPanel pnlLogin; private javax.swing.JPanel pnlProdotti; protected javax.swing.JPanel pnlTop; private javax.swing.JScrollPane scpLista; private javax.swing.JScrollPane scpLista1; private javax.swing.JTable tblLista; private javax.swing.JTable tblLista1; private javax.swing.JPasswordField txtPassword; private javax.swing.JTextField txtTotaleCassa; private javax.swing.JTextField txtTotalePunti; private javax.swing.JTextField txtUsername; // End of variables declaration//GEN-END:variables }