Search in sources :

Example 31 with RestClientResponseException

use of org.springframework.web.client.RestClientResponseException in project sic by belluccifranco.

the class PagoMultiplesFacturasGUI method lbl_AceptarActionPerformed.

// </editor-fold>//GEN-END:initComponents
private void lbl_AceptarActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_lbl_AceptarActionPerformed
    int respuesta = JOptionPane.showConfirmDialog(this, "¿Esta seguro que desea realizar esta operacion?", "Pago", JOptionPane.YES_NO_OPTION);
    if (respuesta == JOptionPane.YES_OPTION) {
        try {
            if (ftxt_Monto.getValue() == null) {
                ftxt_Monto.setText("0");
            }
            double montoDelPago = Double.parseDouble(ftxt_Monto.getValue().toString());
            int indice = 0;
            long[] idsFacturas = new long[facturas.size()];
            for (Factura factura : facturas) {
                idsFacturas[indice] = factura.getId_Factura();
                indice++;
            }
            RestClient.getRestTemplate().put("/pagos/pagar-multiples-facturas?" + "idFactura=" + Arrays.toString(idsFacturas).substring(1, Arrays.toString(idsFacturas).length() - 1) + "&monto=" + montoDelPago + "&idFormaDePago=" + ((FormaDePago) cmb_FormaDePago.getSelectedItem()).getId_FormaDePago() + "&nota=" + ftxt_Nota.getText(), null);
            this.dispose();
        } catch (RestClientResponseException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (ResourceAccessException ex) {
            LOGGER.error(ex.getMessage());
            JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_conexion"), "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}
Also used : FormaDePago(sic.modelo.FormaDePago) Factura(sic.modelo.Factura) RestClientResponseException(org.springframework.web.client.RestClientResponseException) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 32 with RestClientResponseException

use of org.springframework.web.client.RestClientResponseException in project sic by belluccifranco.

the class PedidosGUI method btn_FacturarActionPerformed.

//GEN-LAST:event_btn_NuevoPedidoActionPerformed
private void btn_FacturarActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_btn_FacturarActionPerformed
    try {
        if (tbl_Pedidos.getSelectedRow() != -1) {
            long nroPedido = (long) tbl_Pedidos.getValueAt(tbl_Pedidos.getSelectedRow(), 2);
            Pedido pedido = Arrays.asList(RestClient.getRestTemplate().getForObject("/pedidos/busqueda/criteria?nroPedido=" + nroPedido + "&idEmpresa=" + EmpresaActiva.getInstance().getEmpresa().getId_Empresa(), Pedido[].class)).get(0);
            if (pedido.getEstado() == EstadoPedido.CERRADO) {
                JOptionPane.showInternalMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_pedido_facturado"), "Error", JOptionPane.ERROR_MESSAGE);
            } else if (this.existeClienteDisponible()) {
                PuntoDeVentaGUI gui_puntoDeVenta = new PuntoDeVentaGUI();
                gui_puntoDeVenta.setPedido(pedido);
                gui_puntoDeVenta.setModal(true);
                gui_puntoDeVenta.setLocationRelativeTo(this);
                gui_puntoDeVenta.setVisible(true);
                this.buscar();
            } else {
                String mensaje = ResourceBundle.getBundle("Mensajes").getString("mensaje_sin_cliente");
                JOptionPane.showInternalMessageDialog(this, mensaje, "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    } catch (RestClientResponseException ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    } catch (ResourceAccessException ex) {
        LOGGER.error(ex.getMessage());
        JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_conexion"), "Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : RenglonPedido(sic.modelo.RenglonPedido) Pedido(sic.modelo.Pedido) EstadoPedido(sic.modelo.EstadoPedido) RestClientResponseException(org.springframework.web.client.RestClientResponseException) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 33 with RestClientResponseException

use of org.springframework.web.client.RestClientResponseException in project sic by belluccifranco.

the class ModificacionProductosBulkGUI method btn_GuardarActionPerformed.

//GEN-LAST:event_btn_MedidasActionPerformed
private void btn_GuardarActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_btn_GuardarActionPerformed
    boolean checkPrecios = false;
    boolean checkMedida = false;
    boolean checkRubro = false;
    boolean checkProveedor = false;
    Medida medida = new Medida();
    Rubro rubro = new Rubro();
    Proveedor proveedor = new Proveedor();
    String preciosProducto = "";
    if (chk_Precios.isSelected() == true) {
        checkPrecios = true;
        preciosProducto = "&precioCosto=" + Double.parseDouble(txt_PrecioCosto.getValue().toString()) + "&gananciaPorcentaje=" + Double.parseDouble(txt_Ganancia_Porcentaje.getValue().toString()) + "&gananciaNeto=" + Double.parseDouble(txt_Ganancia_Neto.getValue().toString()) + "&precioVentaPublico=" + Double.parseDouble(txt_PVP.getValue().toString()) + "&IVAPorcentaje=" + Double.parseDouble(cmb_IVA_Porcentaje.getSelectedItem().toString()) + "&IVANeto=" + Double.parseDouble(txt_IVA_Neto.getValue().toString()) + "&precioLista=" + Double.parseDouble(txt_PrecioLista.getValue().toString());
    }
    if (chk_UnidadDeMedida.isSelected() == true) {
        checkMedida = true;
        medida = (Medida) cmb_Medida.getSelectedItem();
    }
    if (chk_Rubro.isSelected() == true) {
        checkRubro = true;
        rubro = (Rubro) cmb_Rubro.getSelectedItem();
    }
    if (chk_Proveedor.isSelected() == true) {
        checkProveedor = true;
        proveedor = (Proveedor) cmb_Proveedor.getSelectedItem();
    }
    try {
        long[] idsProductos = new long[productosParaModificar.size()];
        int i = 0;
        for (Producto producto : productosParaModificar) {
            idsProductos[i] = producto.getId_Producto();
            i++;
        }
        String uri = "/productos/multiples?idProducto=" + Arrays.toString(idsProductos).substring(1, Arrays.toString(idsProductos).length() - 1);
        if (checkMedida) {
            uri += "&idMedida=" + medida.getId_Medida();
        }
        if (checkRubro) {
            uri += "&idRubro=" + rubro.getId_Rubro();
        }
        if (checkProveedor) {
            uri += "&idProveedor=" + proveedor.getId_Proveedor();
        }
        if (checkPrecios) {
            uri = uri.concat(preciosProducto);
        }
        RestClient.getRestTemplate().put(uri, null);
        JOptionPane.showMessageDialog(this, "Los productos se modificaron correctamente.", "Aviso", JOptionPane.INFORMATION_MESSAGE);
        this.dispose();
    } catch (RestClientResponseException ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    } catch (ResourceAccessException ex) {
        LOGGER.error(ex.getMessage());
        JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_conexion"), "Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : Rubro(sic.modelo.Rubro) Producto(sic.modelo.Producto) Proveedor(sic.modelo.Proveedor) Medida(sic.modelo.Medida) RestClientResponseException(org.springframework.web.client.RestClientResponseException) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 34 with RestClientResponseException

use of org.springframework.web.client.RestClientResponseException in project sic by belluccifranco.

the class DetalleProvinciaGUI method btn_AgregarActionPerformed.

// </editor-fold>//GEN-END:initComponents
private void btn_AgregarActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_btn_AgregarActionPerformed
    try {
        Provincia provincia = new Provincia();
        provincia.setNombre(txt_Nombre.getText().trim());
        provincia.setPais((Pais) cmb_Paises.getSelectedItem());
        RestClient.getRestTemplate().postForObject("/provincias", provincia, Provincia.class);
        txt_Nombre.setText("");
        this.cargarProvinciasDelPais((Pais) cmb_PaisesBusqueda.getSelectedItem());
    } catch (RestClientResponseException ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    } catch (ResourceAccessException ex) {
        LOGGER.error(ex.getMessage());
        JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_conexion"), "Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : RestClientResponseException(org.springframework.web.client.RestClientResponseException) Provincia(sic.modelo.Provincia) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 35 with RestClientResponseException

use of org.springframework.web.client.RestClientResponseException in project sic by belluccifranco.

the class DetalleProvinciaGUI method btn_ActualizarActionPerformed.

//GEN-LAST:event_lst_ProvinciasValueChanged
private void btn_ActualizarActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_btn_ActualizarActionPerformed
    try {
        if (provinciaSeleccionada == null) {
            JOptionPane.showMessageDialog(this, "Seleccione una provincia de la lista para poder continuar.", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            Provincia provinciaModificada = new Provincia();
            provinciaModificada.setId_Provincia(provinciaSeleccionada.getId_Provincia());
            provinciaModificada.setNombre(txt_Nombre.getText().trim());
            provinciaModificada.setPais((Pais) cmb_Paises.getSelectedItem());
            RestClient.getRestTemplate().put("/provincias", provinciaModificada);
            txt_Nombre.setText("");
            provinciaSeleccionada = null;
            cargarProvinciasDelPais((Pais) cmb_PaisesBusqueda.getSelectedItem());
        }
    } catch (RestClientResponseException ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    } catch (ResourceAccessException ex) {
        LOGGER.error(ex.getMessage());
        JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_conexion"), "Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : RestClientResponseException(org.springframework.web.client.RestClientResponseException) Provincia(sic.modelo.Provincia) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Aggregations

RestClientResponseException (org.springframework.web.client.RestClientResponseException)69 ResourceAccessException (org.springframework.web.client.ResourceAccessException)68 ArrayList (java.util.ArrayList)23 Point (java.awt.Point)9 Pais (sic.modelo.Pais)9 Provincia (sic.modelo.Provincia)9 RenglonFactura (sic.modelo.RenglonFactura)9 EstadoPedido (sic.modelo.EstadoPedido)8 Localidad (sic.modelo.Localidad)8 Pedido (sic.modelo.Pedido)8 RenglonPedido (sic.modelo.RenglonPedido)8 IOException (java.io.IOException)6 FormaDePago (sic.modelo.FormaDePago)6 File (java.io.File)5 Producto (sic.modelo.Producto)5 Proveedor (sic.modelo.Proveedor)5 List (java.util.List)4 ExecutionException (java.util.concurrent.ExecutionException)4 SwingWorker (javax.swing.SwingWorker)4 Rubro (sic.modelo.Rubro)4