⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jticketsbagticket.java

📁 是一个专门设计用于触摸屏的POS(point of sales)应用软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
//    Tina POS is a point of sales application designed for touch screens.//    Copyright (C) 2005 Adrian Romero Corchado.//    http://sourceforge.net/projects/tinapos////    This program is free software; you can redistribute it and/or modify//    it under the terms of the GNU General Public License as published by//    the Free Software Foundation; either version 2 of the License, or//    (at your option) any later version.////    This program is distributed in the hope that it will be useful,//    but WITHOUT ANY WARRANTY; without even the implied warranty of//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the//    GNU General Public License for more details.////    You should have received a copy of the GNU General Public License//    along with this program; if not, write to the Free Software//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USApackage net.adrianromero.tpv.panelsales;import java.awt.*;import java.util.ArrayList;import javax.swing.*;import net.adrianromero.data.gui.MessageInf;import net.adrianromero.tpv.forms.AppView; import net.adrianromero.tpv.forms.AppLocal; import net.adrianromero.tpv.ticket.*;import net.adrianromero.tpv.printer.*;import net.adrianromero.basic.BasicException;import net.adrianromero.data.gui.JMessageDialog;import net.adrianromero.scripting.ScriptEngine;import net.adrianromero.scripting.ScriptException;import net.adrianromero.scripting.ScriptFactory;import net.adrianromero.tpv.forms.DataLogicSystem;import net.adrianromero.tpv.forms.SentenceContainer;public class JTicketsBagTicket extends JTicketsBag {    //    private Template m_tempTicket;    private DeviceTicket m_TP;        private TicketParser m_TTP;        private TicketParser m_TTP2;         private TicketInfo m_ticket;    private TicketInfo m_ticketCopy;        private JTicketsBagTicketBag m_TicketsBagTicketBag;    private JPanelTicketEdits m_panelticket;            /** Creates new form JTicketsBagTicket */    public JTicketsBagTicket(AppView oApp, JPanelTicketEdits panelticket) {        // Lista de tickets del cierre actual en orden desdencente...        //SELECT TICKETS.TICKETID, TICKETS.DATENEW, TICKETS.MONEY, SUM(PRODUCTSOUT.UNITS * PRODUCTSOUT.PRICE), SUM(PRODUCTSOUT.UNITS * PRODUCTSOUT.PRICE * (1 + PRODUCTSOUT.TAXRATE))//FROM TICKETS, PRODUCTSOUT WHERE TICKETS.TICKETID = PRODUCTSOUT.TICKETID//AND TICKETS.MONEY = 20//GROUP BY TICKETS.TICKETID//ORDER BY TICKETS.DATENEW DESC                super(oApp);        m_panelticket = panelticket;                 // Inicializo la impresora...        m_TP = new DeviceTicket();           // Inicializo el parser de documentos de ticket        m_TTP = new TicketParser(m_TP, m_App.lookupDataLogic(DataLogicSystem.class)); // para visualizar el ticket        m_TTP2 = new TicketParser(m_App.getDeviceTicket(), m_App.lookupDataLogic(DataLogicSystem.class)); // para imprimir el ticket                initComponents();                m_TicketsBagTicketBag = new JTicketsBagTicketBag(this);                m_jTicketEditor.addEditorKeys(m_jKeys);                // Este deviceticket solo tiene una impresora, la de pantalla        m_jPanelTicket.add(m_TP.getDevicePrinter("1").getPrinterComponent(), BorderLayout.CENTER);    }        public void activate() {                // precondicion es que no tenemos ticket activado ni ticket en el panel                m_ticket = null;        m_ticketCopy = null;                printTicket();                        m_jTicketEditor.reset();        m_jTicketEditor.activate();                m_panelticket.setActiveTicket(null, null);                      // postcondicion es que tenemos ticket activado aqui y ticket en el panel    }        public boolean deactivate() {                // precondicion es que tenemos ticket activado aqui y ticket en el panel                m_ticket = null;           m_ticketCopy = null;        return true;               // postcondicion es que no tenemos ticket activado ni ticket en el panel    }        public void saveTicket() {        if (m_ticketCopy != null) {                       // Para editar borramos el ticket anterior            deleteTicket(m_ticketCopy);        }        saveTicket(m_panelticket.getActiveTicket()); // guardamos el ticket nuevo sea editar o devolver                m_ticket = null;        m_ticketCopy = null;    }        public void cancelTicket() {                m_ticket = null;        m_ticketCopy = null;        resetToTicket();     }            public void deleteeraseTicket() {        // Solo se nos invoca desde editar        if (m_ticketCopy != null) {                       // Para editar borramos el ticket anterior            deleteTicket(m_ticketCopy);        }                m_ticket = null;        m_ticketCopy = null;        resetToTicket();    }            public void canceleditionTicket() {                // m_ticket = null; // Nos queremos quedar con el ticket anterior        m_ticketCopy = null;        resetToTicket();    }            private void resetToTicket() {               printTicket();        m_jTicketEditor.reset();                m_panelticket.setActiveTicket(null, null);     }        protected JComponent getBagComponent() {        return m_TicketsBagTicketBag;    }        protected JComponent getNullComponent() {        return this;    }          private void readTicket() {                try {            Integer ticketid = m_jTicketEditor.getValueInteger();            TicketInfo ticket = m_App.lookupDataLogic(SentenceContainer.class).loadTicket(ticketid);            if (ticket != null) {                m_ticket = ticket;                m_ticketCopy = null; // se asigna al pulsar el boton de editar o devolver                printTicket();            }                    } catch (BasicException e) {            // No se puede leer el ticket            // No hay valor...        }                m_jTicketEditor.reset();    }        private void printTicket() {                // imprimo m_ticket                m_jEdit.setEnabled(m_ticket != null);        m_jRefund.setEnabled(m_ticket != null && m_ticket.getTotal() > 0.0);        m_jPrint.setEnabled(m_ticket != null);                // Este deviceticket solo tiene una impresora, la de pantalla        m_TP.getDevicePrinter("1").reset();                if (m_ticket == null) {            m_jTicketId.setText(null);                    } else {            m_jTicketId.setText(String.valueOf(m_ticket.getId()));                        try {                ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY);                script.put("ticket", m_ticket);                m_TTP.printTicket(script.eval(m_App.lookupDataLogic(DataLogicSystem.class).getResourceAsXML("Printer.TicketPreview")).toString());            } catch (ScriptException e) {                MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), e);                msg.show(this);            } catch (TicketPrinterException eTP) {                MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), eTP);                msg.show(this);            }        }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -