Beispiel #1
0
  public void actualizar() {
    try {
      ServiceHb helper = new ServiceHb();
      helper.iniciarTransaccion();
      List<Ctecobrar> lt = null;
      if ((cte.getIdcliente() == 0) && (cte.getIdproyecto() == 0)) {
        lt = helper.getListCteCobrar(cte.getId());
      } else {
        lt = helper.getListCteCobrar(cte.getIdcliente(), cte.getIdproyecto());
      }
      helper.cerrarSesion();
      DefaultTableModel temp2 = (DefaultTableModel) jTable1.getModel();
      for (int i = temp2.getRowCount() - 1; i >= 0; i--) {
        temp2.removeRow(i);
      }
      Double d1 = 0.0;
      Double d2 = 0.0;
      DecimalFormat df = new DecimalFormat("0.00");
      for (Ctecobrar i : lt) {
        d1 = d1 + Double.parseDouble(i.getMontos());
        d2 = d2 + Double.parseDouble(i.getSaldo());
        Object nuevo[] = {
          Funcion.DateFormatSql(i.getFecha()),
          i.getFactura(),
          i.getPlanpagos(),
          i.getPlanpagos(),
          i.getMontos(),
          i.getSaldo(),
          i,
          i.getId(),
          i
        };
        temp2.addRow(nuevo);
      }
      jLabel3.setText("$" + df.format(d1).replace(",", "."));
      jLabel4.setText("$" + df.format(d2).replace(",", "."));
    } catch (Exception io) {

    }
  }
Beispiel #2
0
  private void jTable1MouseClicked(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_jTable1MouseClicked
    int row = jTable1.getSelectedRow();
    int col = jTable1.getSelectedColumn();
    if (col == 6) {
      String selectedSiteName = JOptionPane.showInputDialog(null, "Clave ");
      if (selectedSiteName.equalsIgnoreCase("cajamarca")) {
        try {
          ServiceHb helper = new ServiceHb();
          helper.iniciarTransaccion();
          Ctecobrar p = (Ctecobrar) jTable1.getValueAt(row, col);
          String fecha[] = ("" + jTable1.getValueAt(row, 0)).split("-");
          Calendar ca = Calendar.getInstance();
          ca.set(
              Integer.parseInt(fecha[0]),
              Integer.parseInt(fecha[1]) - 1,
              Integer.parseInt(fecha[2]));

          p.setFecha(new java.sql.Date(ca.getTimeInMillis()));
          p.setFactura("" + jTable1.getValueAt(row, 1));
          p.setPlanpagos("" + jTable1.getValueAt(row, 2));
          p.setObservacion("" + jTable1.getValueAt(row, 3));
          p.setMontos("" + jTable1.getValueAt(row, 4));
          p.setSaldo("" + jTable1.getValueAt(row, 5));
          helper.actualizarObjeto(p);
          helper.confirmarTransaccion();
          helper.cerrarSesion();
          JOptionPane.showMessageDialog(null, "Cuenta Actualizada");
          actualizar();
        } catch (Exception io) {

        }
      }
    }
    if (col == 7) {
      try {
        editarfacturas edi =
            new editarfacturas(
                null, null, true, Integer.parseInt(jTable1.getValueAt(row, 7).toString()));
      } catch (Exception io) {
        System.out.println(io);
      }
    }
    if (col == 8) {
      String selectedSiteName = JOptionPane.showInputDialog(null, "Clave ");
      if (selectedSiteName.equalsIgnoreCase("cajamarca")) {
        try {
          ServiceHb helper = new ServiceHb();
          helper.iniciarTransaccion();
          Ctecobrar p = (Ctecobrar) jTable1.getValueAt(row, col);
          helper.eliminarObjeto(p);
          helper.confirmarTransaccion();
          helper.cerrarSesion();
          JOptionPane.showMessageDialog(null, "Cuenta Eliminada");
          dispose();
        } catch (Exception io) {

        }
      }
    }
  } // GEN-LAST:event_jTable1MouseClicked