private void m_jCloseCashActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_m_jCloseCashActionPerformed // TODO add your handling code here: int res = JOptionPane.showConfirmDialog( this, AppLocal.getIntString("message.wannaclosecash"), AppLocal.getIntString("message.title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (res == JOptionPane.YES_OPTION) { Date dNow = new Date(); try { // Cerramos la caja si esta pendiente de cerrar. if (m_App.getActiveCashDateEnd() == null) { new StaticSentence( m_App.getSession(), "UPDATE CLOSEDCASH SET DATEEND = ? WHERE HOST = ? AND MONEY = ?", new SerializerWriteBasic( new Datas[] {Datas.TIMESTAMP, Datas.STRING, Datas.STRING})) .exec( new Object[] {dNow, m_App.getProperties().getHost(), m_App.getActiveCashIndex()}); } } catch (BasicException e) { MessageInf msg = new MessageInf( MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotclosecash"), e); msg.show(this); } try { // Creamos una nueva caja m_App.setActiveCash( UUID.randomUUID().toString(), m_App.getActiveCashSequence() + 1, dNow, null); // creamos la caja activa m_dlSystem.execInsertCash( new Object[] { m_App.getActiveCashIndex(), m_App.getProperties().getHost(), m_App.getActiveCashSequence(), m_App.getActiveCashDateStart(), m_App.getActiveCashDateEnd() }); // ponemos la fecha de fin m_PaymentsToClose.setDateEnd(dNow); // print report printPayments("Printer.CloseCash"); // Mostramos el mensaje JOptionPane.showMessageDialog( this, AppLocal.getIntString("message.closecashok"), AppLocal.getIntString("message.title"), JOptionPane.INFORMATION_MESSAGE); } catch (BasicException e) { MessageInf msg = new MessageInf( MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotclosecash"), e); msg.show(this); } try { loadData(); } catch (BasicException e) { MessageInf msg = new MessageInf( MessageInf.SGN_NOTICE, AppLocal.getIntString("label.noticketstoclose"), e); msg.show(this); } } } // GEN-LAST:event_m_jCloseCashActionPerformed
private void loadData() throws BasicException { // Reset m_jSequence.setText(null); m_jMinDate.setText(null); m_jMaxDate.setText(null); m_jPrintCash.setEnabled(false); m_jCloseCash.setEnabled(false); m_jCount.setText(null); // AppLocal.getIntString("label.noticketstoclose"); m_jCash.setText(null); m_jSales.setText(null); m_jSalesSubtotal.setText(null); m_jSalesTaxes.setText(null); m_jSalesTotal.setText(null); m_jTicketTable.setModel(new DefaultTableModel()); m_jsalestable.setModel(new DefaultTableModel()); // LoadData m_PaymentsToClose = PaymentsModel.loadInstance(m_App); // Populate Data m_jSequence.setText(m_PaymentsToClose.printSequence()); m_jMinDate.setText(m_PaymentsToClose.printDateStart()); m_jMaxDate.setText(m_PaymentsToClose.printDateEnd()); if (m_PaymentsToClose.getPayments() != 0 || m_PaymentsToClose.getSales() != 0) { m_jPrintCash.setEnabled(true); m_jCloseCash.setEnabled(true); m_jCount.setText(m_PaymentsToClose.printPayments()); m_jCash.setText(m_PaymentsToClose.printPaymentsTotal()); m_jSales.setText(m_PaymentsToClose.printSales()); m_jSalesSubtotal.setText(m_PaymentsToClose.printSalesBase()); m_jSalesTaxes.setText(m_PaymentsToClose.printSalesTaxes()); m_jSalesTotal.setText(m_PaymentsToClose.printSalesTotal()); } m_jTicketTable.setModel(m_PaymentsToClose.getPaymentsModel()); TableColumnModel jColumns = m_jTicketTable.getColumnModel(); jColumns.getColumn(0).setPreferredWidth(200); jColumns.getColumn(0).setResizable(false); jColumns.getColumn(1).setPreferredWidth(100); jColumns.getColumn(1).setResizable(false); m_jsalestable.setModel(m_PaymentsToClose.getSalesModel()); jColumns = m_jsalestable.getColumnModel(); jColumns.getColumn(0).setPreferredWidth(200); jColumns.getColumn(0).setResizable(false); jColumns.getColumn(1).setPreferredWidth(100); jColumns.getColumn(1).setResizable(false); }