private void readTicket(int iTicketid, int iTickettype) { Integer findTicket = 0; try { findTicket = m_jTicketEditor.getValueInteger(); } catch (BasicException e) { } try { TicketInfo ticket = (iTicketid == -1) ? m_dlSales.loadTicket(iTickettype, findTicket) : m_dlSales.loadTicket(iTickettype, iTicketid); if (ticket == null) { // MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, // AppLocal.getIntString("message.notexiststicket")); // msg.show(this); JFrame frame = new JFrame(); JOptionPane.showMessageDialog( frame, AppLocal.getIntString("message.notexiststicket"), AppLocal.getIntString("message.notexiststickettitle"), JOptionPane.WARNING_MESSAGE); } else { m_ticket = ticket; m_ticketCopy = null; // se asigna al pulsar el boton de editar o devolver try { taxeslogic.calculateTaxes(m_ticket); TicketTaxInfo[] taxlist = m_ticket.getTaxLines(); // taxcollection = new ListKeyed<TaxInfo>(taxlist); } catch (TaxesException ex) { } printTicket(); } } catch (BasicException e) { MessageInf msg = new MessageInf( MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadticket"), e); msg.show(this); } m_jTicketEditor.reset(); m_jTicketEditor.activate(); }
private void m_jPrintActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_m_jPrintActionPerformed if (m_ticket != null) { try { ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); script.put("ticket", m_ticket); script.put("taxes", m_ticket.getTaxLines()); m_TTP2.printTicket( script.eval(m_dlSystem.getResourceAsXML("Printer.TicketPreview")).toString()); } catch (ScriptException e) { JMessageDialog.showMessage( this, new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotprint"), e)); } catch (TicketPrinterException e) { JMessageDialog.showMessage( this, new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotprint"), e)); } } } // GEN-LAST:event_m_jPrintActionPerformed
private void printTicket() { // imprimo m_ticket try { m_jEdit.setEnabled( m_ticket != null && (m_ticket.getTicketType() == TicketInfo.RECEIPT_NORMAL || m_ticket.getTicketType() == TicketInfo.RECEIPT_REFUND) && m_dlSales.isCashActive(m_ticket.getActiveCash())); } catch (BasicException e) { m_jEdit.setEnabled(false); } m_jRefund.setEnabled(m_ticket != null && m_ticket.getTicketType() == TicketInfo.RECEIPT_NORMAL); 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(m_ticket.getName()); try { ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); script.put("ticket", m_ticket); script.put("taxes", m_ticket.getTaxLines()); m_TTP.printTicket( script.eval(m_dlSystem.getResourceAsXML("Printer.TicketPreview")).toString()); } catch (ScriptException | TicketPrinterException e) { MessageInf msg = new MessageInf( MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), e); msg.show(this); } } }