Documente Academic
Documente Profesional
Documente Cultură
Paquete de Reportes
Clases.conexionBase;
static factura.Factura.ivaboolean;
java.sql.PreparedStatement;
java.sql.ResultSet;
java.sql.SQLException;
java.text.DecimalFormat;
javax.swing.JOptionPane;
javax.swing.JTable;
javax.swing.table.DefaultTableModel;
/**
*
* @author CarlosEfrain
*/
public class conexionFactura extends conexionBase {
public int stock, idventa, idcuentacobrar, Nperiodo, Nmese;
public double interes, adelanto;
//
TextAutoCompleter textAutoAcompleter = new
TextAutoCompleter( Factura.txtcodigocliente );
DecimalFormat fd = new DecimalFormat("0.00");
public String[] ProductoDtos2 = new String[9];
public String[] Productovacio = {"", "", "", "", "", "", "", "", ""};
public conexionFactura() {
conectar("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/contable",
"root", "12345");
}
//*****************************************************************************
public void consultarClienteTotal(JTable tabla) {
String[] columna = {"cedula-ruc", "Nombres ", "Apellidos", "Direccin"};
DefaultTableModel encabezado = new DefaultTableModel(null, columna);
tabla.setModel(encabezado);
String[] entrenadorDtos2 = new String[4];
String sql = "select * from clientes ";
PreparedStatement sentencia_sql = null;
ResultSet rs = null;
try {
sentencia_sql = miConexion.prepareStatement(sql);
rs = sentencia_sql.executeQuery(sql);
while (rs.next()) {
entrenadorDtos2[0] = rs.getString("ruc");
entrenadorDtos2[1] = rs.getString("nombres");
entrenadorDtos2[2] = rs.getString("apellidos");
entrenadorDtos2[3] = rs.getString("direccion");
encabezado.addRow(entrenadorDtos2);
}
rs.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error en obtener los datos " +
e.getMessage());
}
}
//*****************************************************************************
public void consultarProductoTotal(JTable tabla) {
String[] columna = {"Codigo", "Descripcion ", "Precio", "cantidad"};
DefaultTableModel encabezado = new DefaultTableModel(null, columna);
//poner la validacion
tabla.setModel(encabezado);
String[] Dtos2 = new String[4];
String sql = " SELECT * FROM producto where '" + Factura.listaPorductos
+ "' not LIKE CONCAT('%', codigo_producto, '%')";
PreparedStatement sentencia_sql = null;
ResultSet rs = null;
try {
sentencia_sql = miConexion.prepareStatement(sql);
rs = sentencia_sql.executeQuery(sql);
while (rs.next()) {
Dtos2[0] = String.valueOf(rs.getInt("codigo_producto"));
Dtos2[1] = rs.getString("descripcion");
Dtos2[2] = String.valueOf(rs.getDouble("precio"));
Dtos2[3] = "1";
encabezado.addRow(Dtos2);
}
rs.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error en obtener los datos " +
e.getMessage());
}
}
//******************************************************************************
****************
public void consultarProductoTabla(JTable tabla, String codigo, double
cantidad) {
DefaultTableModel modelo = (DefaultTableModel) tabla.getModel();
tabla.setModel(modelo);
double subt = 0;
String valor = "";
boolean seguir = true, lleno;
int contF = 0, nuFlias = modelo.getRowCount();
//0
1
2
3 4
5
6
7 8
9
//linea cdgio descripcion bodega cantidad unidad precio unit descto
subtotal
String sql = "select * from producto where codigo_producto=" + codigo +
"";
PreparedStatement sentencia_sql = null;
ResultSet rs = null;
try {
sentencia_sql = miConexion.prepareStatement(sql);
rs = sentencia_sql.executeQuery(sql);
while (rs.next()) {
ProductoDtos2[0] = "";
ProductoDtos2[1] = String.valueOf(rs.getInt("codigo_producto"));
ProductoDtos2[2] = rs.getString("descripcion");
ProductoDtos2[3] = rs.getString("bodega");
ProductoDtos2[4] = String.valueOf(cantidad);
ProductoDtos2[5] = rs.getString("unidad");
ProductoDtos2[6] = String.valueOf(rs.getDouble("precio"));
ProductoDtos2[7] = "";
subt = Double.parseDouble(ProductoDtos2[6]) * cantidad;
ProductoDtos2[8] = String.valueOf(subt);
while (seguir) {
valor = String.valueOf(tabla.getValueAt(contF, 3));
// JOptionPane.showMessageDialog(null, "valor: "+valor);
if (tabla.getValueAt(contF, 3) == null) {
// JOptionPane.showMessageDialog(null, "entro"+valor);
// modelo.setValueAt(ProductoDtos2[0], contF, 0);
modelo.setValueAt(ProductoDtos2[1], contF, 1);
modelo.setValueAt(ProductoDtos2[2], contF, 2);
modelo.setValueAt(ProductoDtos2[3], contF, 3);
modelo.setValueAt(ProductoDtos2[4], contF, 4);
modelo.setValueAt(ProductoDtos2[5], contF, 5);
modelo.setValueAt(ProductoDtos2[6], contF, 6);
modelo.setValueAt(ProductoDtos2[7], contF, 7);
modelo.setValueAt(ProductoDtos2[8], contF, 8);
Factura.tablaInstan = false;
seguir = false;
}
if (contF == nuFlias) {
modelo.addRow(Productovacio);
}
contF++;
}
// modelo.addRow(ProductoDtos2);
int Nfilas = modelo.getRowCount();
double subtotal = 0, descuento = 0, iva = 0, total = 0;
Factura.listaPorductos = "";
// JOptionPane.showMessageDialog(null, "hay : ;) "+Nfilas);
for (int i = 0; i < Nfilas; i++) {
// JOptionPane.showMessageDialog(null, "hay vamos : ;) ");
if (modelo.getValueAt(i, 3) != null) {
subtotal = subtotal + Double.parseDouble(modelo.getValueAt(i,
8).toString());
Factura.listaPorductos = Factura.listaPorductos + "," +
modelo.getValueAt(i, 1).toString();
//JOptionPane.showMessageDialog(null, "hay vamos sub sub : ;)
"+subtotal);
if (!modelo.getValueAt(i, 7).toString().equals("")) {
descuento = ((Double.parseDouble(modelo.getValueAt(i,
7).toString()) / 100) * (Double.parseDouble(modelo.getValueAt(i, 8).toString())))
+ descuento;
}
} else {
descuento = descuento + 0.0;
}
if (ivaboolean) {
iva = (subtotal - descuento) * 0.12;
} else {
iva = 0;
}
total = (subtotal - descuento) + iva;
}
Factura.total = total;
Factura.iva = iva;
Factura.descuento = descuento;
Factura.subtotal = subtotal;
Factura.txtsubtotal.setText(String.valueOf(fd.format(subtotal)));
Factura.txtsubtotal.setText(String.valueOf(fd.format(descuento)));
Factura.txtiva.setText(String.valueOf(fd.format(iva)));
Factura.txtotal.setText(String.valueOf(fd.format(total)));
}
rs.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error en obtener los datos " +
e.getMessage());
}
}
//*****************************************************************************
public void consultarProductoStock(String codigo) {
String sql = "select * from producto where codigo_producto=" + codigo +
"";
PreparedStatement sentencia_sql = null;
ResultSet rs = null;
try {
sentencia_sql = miConexion.prepareStatement(sql);
rs = sentencia_sql.executeQuery(sql);
while (rs.next()) {
stock = rs.getInt("stock");
}
rs.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error en obtener los datos " +
e.getMessage());
}
}
////////////////////////////////////////////////////////////////////////////////////////
//fechaemision fechavence subtotal descuento iva totalcobrado totalcobrar
idcliente
//******************************************************************************
*******************
public void ingresarFactura(String fechae, String fechav, double sub, double
des, double iva, double total, String idcliente, String observacion) {
int n1 = 0;
String sql2;
PreparedStatement sentencia_sql2;
try {
sql2 = "insert into venta ( fechaemision, fechavence, subtotal,
descuento, iva, totalcobrar, idcliente, observacion)" + "values(?,?,?,?,?,?,?,?)";
sentencia_sql2 = miConexion.prepareStatement(sql2);
sentencia_sql2.setString(1, fechae);
sentencia_sql2.setString(2, fechav);
sentencia_sql2.setDouble(3, sub);
sentencia_sql2.setDouble(4, des);
sentencia_sql2.setDouble(5, iva);
sentencia_sql2.setDouble(6, total);
sentencia_sql2.setString(7, idcliente);
sentencia_sql2.setString(8, observacion);
n1 = sentencia_sql2.executeUpdate();
if (n1 > 0) {
JOptionPane.showMessageDialog(null, "venta ingresada
correctamente");
}
} catch (SQLException e) {
JOptionPane.showMessageDialog(null, "Error datos no ingresados" +
e.getMessage());
}
}
//******************************************************************************
************************
//******************************************************************************
entrenadorDtos2[2]= rs.getString("apellidos");
entrenadorDtos2[3]= rs.getString("direccion");*/
Factura.textAutoCompleter.addItem(rs.getString("ruc") + "---" +
rs.getString("nombres") + "" + rs.getString("apellidos"));
//textAutoAcompleter.addItem(rs.getString("ruc")
+"-"+rs.getString("nombres"));
}
rs.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error en obtener los datos de
venta " + e.getMessage());
}
}
//////////////
public void autllenarCliente(String codigo) {
Factura.txtNombreCliente.setText("");
Factura.txtDireccionCliente.setText("");
//textAutoAcompleter.removeAllItems();
String sql = "SELECT * FROM clientes where ruc ='" + codigo + "'";
PreparedStatement sentencia_sql = null;
ResultSet rs = null;
String[] entrenadorDtos2 = new String[4];
try {
sentencia_sql = miConexion.prepareStatement(sql);
rs = sentencia_sql.executeQuery(sql);
while (rs.next()) {
Factura.txtcodigocliente.setText(rs.getString("ruc"));
Factura.txtNombreCliente.setText(rs.getString("nombres") + " " +
rs.getString("apellidos"));
Factura.txtDireccionCliente.setText(rs.getString("direccion"));
}
rs.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error en obtener los datos de
venta " + e.getMessage());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
public void autcompleteProducto(String codigo) {
// Factura.textAutoCompleter = new
TextAutoCompleter( Factura.txtcodigocliente);
Factura.textAutoCompleterProducto.removeAllItems();
String sql = "SELECT * FROM producto where codigo_producto like '" +
codigo + "%'";
PreparedStatement sentencia_sql = null;
ResultSet rs = null;
String[] entrenadorDtos2 = new String[4];
try {
sentencia_sql = miConexion.prepareStatement(sql);
rs = sentencia_sql.executeQuery(sql);
while (rs.next()) {
// JOptionPane.showMessageDialog(null, "weonnnnn :D ");
Factura.textAutoCompleterProducto.addItem(rs.getString("codigo_producto") +
"---" + rs.getString("descripcion"));
//textAutoAcompleter.addItem(rs.getString("ruc")
+"-"+rs.getString("nombres"));
}
rs.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error en obtener los datos de
venta " + e.getMessage());
}
}
public void autllenarProducto(String codigo) {
}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////CUENTAS POR COBRAR //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
public void ingresarCuentaPorCobrar(int ID_VENTA, String FECHA_REGISTRO,
double INTERES, double VALOR_INTERES, double TOTAL_CUENTA, int
CANT_CUOTAS, double VALOR_CUOTAS, String FECHA_COBRO, int
NUM_CUOTA_COBRADA, double VALOR_COBRADO, double
VALOR_POR_COBRAR, double ADELANTO) {
int n1 = 0;
String sql2;
PreparedStatement sentencia_sql2;
try {
sql2 = "insert into cuentas_por_cobrar (ID_VENTA, FECHA_REGISTRO,
INTERES, VALOR_INTERES, TOTAL_CUENTA, CANT_CUOTAS, VALOR_CUOTAS,
FECHA_COBRO, NUM_CUOTA_COBRADA, VALOR_COBRADO,
VALOR_POR_COBRAR, ADELANTO)" + "values(?,?,?,?,?,?,?,?,?,?,?,?)";
sentencia_sql2 = miConexion.prepareStatement(sql2);
sentencia_sql2.setInt(1, ID_VENTA);
sentencia_sql2.setString(2, FECHA_REGISTRO);
sentencia_sql2.setDouble(3, INTERES);
sentencia_sql2.setDouble(4, VALOR_INTERES);
sentencia_sql2.setDouble(5, TOTAL_CUENTA);
sentencia_sql2.setDouble(6, CANT_CUOTAS);
sentencia_sql2.setDouble(7, VALOR_CUOTAS);
sentencia_sql2.setString(8, FECHA_COBRO);
sentencia_sql2.setInt(9, NUM_CUOTA_COBRADA);
sentencia_sql2.setDouble(10, VALOR_COBRADO);
sentencia_sql2.setDouble(11, VALOR_POR_COBRAR);
sentencia_sql2.setDouble(12, ADELANTO);
n1 = sentencia_sql2.executeUpdate();
if (n1 > 0) {//JOptionPane.showMessageDialog(null, "datos ingresados
correctamente");
}
} catch (SQLException e) {
JOptionPane.showMessageDialog(null, "Error datos no ingresados" +
e.getMessage());
}
}
//CUOTAS_COBRAR_Detalle, ID_CUENTA_POR_COBRAR, NUM_CUOTA,
VALOR_CUOTA, INTERES, VALOR_TOTAL_CUOTA
//CUOTAS_COBRAR_Detalle, ID_CUENTA_POR_COBRAR, NUM_CUOTA,
VALOR_CUOTA, INTERES, VALOR_MORA, PAGO
public void ingresarCuentaDetalle(int ID_CUENTA_POR_COBRAR, int
NUM_CUOTA, double VALOR_CUOTA, double INTERES, String FECHA_EMISION,
String FECHA_VENCIMIENTO) {
int n1 = 0;
String sql2;
PreparedStatement sentencia_sql2;
try {
java.sql.Connection;
java.sql.PreparedStatement;
java.sql.ResultSet;
java.sql.SQLException;
import
import
import
import
import
import
import
java.sql.Statement;
java.util.ArrayList;
java.util.logging.Level;
java.util.logging.Logger;
javax.swing.JOptionPane;
javax.swing.JTable;
javax.swing.table.DefaultTableModel;
/**
*
* @author Usuario
*/
public abstract class BD_cliente {
public static void insertarCliente(Cliente c) throws SQLException {
Connection cnn = Conexion.getConnection();
PreparedStatement ps = null;
ps = cnn.prepareStatement("INSERT INTO clientes
(ruc,nombres,apellidos,id_estado_civil,direccion,id_genero,"
+ " fecha_ingreso,correo,id_parroquia) VALUES (?,?,?,?,?,?,?,?,?)");
ps.setString(1, c.getRUC());
ps.setString(2, c.getNombres());
ps.setString(3, c.getApellidos());
ps.setInt(4, c.getEc().getId_estado_civil());
ps.setString(5, c.getDireccion());
ps.setInt(6, c.getGe().getId_genero());
ps.setString(7, c.getFecha_ingreso());
ps.setString(8, c.getEmail());
ps.setInt(9, c.getPa().getId_parroquia());
ps.executeUpdate();
cnn.close();
ps.close();
}
// public static Cliente buscarCliente(String ruc) throws SQLException {
//
return buscarCliente("select
ruc,nombres,apellidos,id_estado_civil,direccion,id_genero,fecha_ingreso,correo,i
d_parroquia from clientes where ruc=" + ruc, null);
// }
//
// public static Cliente buscarClienteNombre(String nombre) throws
SQLException {
//
return buscarCliente("select
ruc,nombres,apellidos,id_estado_civil,direccion,id_genero,fecha_ingreso,correo,i
d_parroquia from clientes where nombres=" + nombre, null);
// }
//
// public static Cliente buscarClienteApellido(String apellido) throws
SQLException {
//
return buscarCliente("select
ruc,nombres,apellidos,id_estado_civil,direccion,id_genero,fecha_ingreso,correo,i
d_parroquia from clientes where apellidos=" + apellido, null);
// }
//
// public static Cliente buscarCliente(String sql, Cliente c) throws
SQLException {
//
Connection cnn = Conexion.getConnection();
//
PreparedStatement ps = null;
//
//
ps = cnn.prepareStatement(sql);
//
ResultSet rs = ps.executeQuery();
//
if (rs.next()) {
//
if (c == null) {
//
c = new Cliente() {
//
};
//
}
//
c.setRUC(rs.getString("ruc"));
//
c.setNombres(rs.getString("nombres"));
//
c.setApellidos(rs.getString("apellidos"));
//
c.setEc(BD_estado_civil.buscar_EstadoCivil_Codigo(rs.getInt("id_estado_civil")));
//
c.setDireccion(rs.getString("direccion"));
//
c.setGe(BD_genero.buscar_Genero_Codigo(rs.getInt("id_genero")));
//
c.setFecha_ingreso(rs.getString("fecha_ingreso"));
//
c.setEmail(rs.getString("correo"));
//
c.setPa(BD_parroquia.buscar_Parroquia_Codigo(rs.getInt("id_parroquia")));
//
}
//
cnn.close();
//
ps.close();
//
return c;
// }
///******************************************************************************
******///////////////////
public static Cliente buscarClientes(String ruc) throws SQLException {
return buscarClientes(ruc, null);
}
public static Cliente buscarClientes(String ruc, Cliente c) throws
SQLException {
Connection cnn = Conexion.getConnection();
PreparedStatement ps = null;
ps = cnn.prepareStatement("select
nombres,apellidos,id_estado_civil,direccion,id_genero,fecha_ingreso,correo,id_p
arroquia from clientes where ruc = ?");
ps.setString(1, ruc);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
if (c == null) {
c = new Cliente() {
};
}
c.setRUC(ruc);
c.setNombres(rs.getString("nombres"));
c.setApellidos(rs.getString("apellidos"));
c.setEc(BD_estado_civil.buscar_EstadoCivil_Codigo(rs.getInt("id_estado_civil")));
c.setDireccion(rs.getString("direccion"));
c.setGe(BD_genero.buscar_Genero_Codigo(rs.getInt("id_genero")));
c.setFecha_ingreso(rs.getString("fecha_ingreso"));
c.setEmail(rs.getString("correo"));
c.setPa(BD_parroquia.buscar_Parroquia_Codigo(rs.getInt("id_parroquia")));
}
cnn.close();
ps.close();
return c;
}
//******************************************************************************
**********////////////////////
//******************************************************************************
******///////////////////
public static Cliente buscarClientes_ecivil(int ecivil) throws SQLException {
return buscarClientes_ecivil(ecivil, null);
}
ps.setInt(5, c.getGe().getId_genero());
ps.setString(6, c.getFecha_ingreso());
ps.setString(7, c.getEmail());
ps.setInt(8, c.getPa().getId_parroquia());
int rowsUpdated = ps.executeUpdate();
cnn.close();
ps.close();
if (rowsUpdated > 0) {
return true;
} else {
return false;
}
}
public static ArrayList<Cliente> mostrarClientes() throws SQLException {
Connection cnn = Conexion.getConnection();
PreparedStatement ps = null;
ArrayList<Cliente> lista = new ArrayList<>();
ps = cnn.prepareStatement("select
ruc,nombres,apellidos,id_estado_civil,direccion,id_genero,fecha_ingreso,correo,i
d_parroquia from clientes");
//
ResultSet rs = ps.executeQuery();
while (rs.next()) {
Cliente c = new Cliente() {
};
c.setRUC(rs.getString("ruc"));
c.setNombres(rs.getString("nombres"));
c.setApellidos(rs.getString("apellidos"));
c.setEc(BD_estado_civil.buscar_EstadoCivil_Codigo(rs.getInt("id_estado_civil")));
c.setDireccion(rs.getString("direccion"));
c.setGe(BD_genero.buscar_Genero_Codigo(rs.getInt("id_genero")));
c.setFecha_ingreso(rs.getString("fecha_ingreso"));
c.setEmail(rs.getString("correo"));
c.setPa(BD_parroquia.buscar_Parroquia_Codigo(rs.getInt("id_parroquia")));
}
cnn.close();
ps.close();
return lista;
}
public static ArrayList<Cliente> listarClienteNombre(String nombre) {
}
cn.close();
} catch (SQLException e) {
System.err.println(e.getMessage());
return null;
}
return list;
}
public void listar_clientes(JTable Tabla) {
try {
String[] titulos = {"Ruc", "Nombres", "Apellidos", "Direccion", "F.
Ingreso", "Correo"};
String[] registros = new String[6];
DefaultTableModel modelo = new DefaultTableModel(null, titulos);
Tabla.setModel(modelo);
Connection cnn = Conexion.getConnection();
PreparedStatement sentencia_sql = null;
sentencia_sql = cnn.prepareStatement("select
ruc,nombres,apellidos,id_estado_civil,direccion,id_genero,fecha_ingreso,correo,i
d_parroquia from clientes");
ResultSet rs = sentencia_sql.executeQuery();
while (rs.next()) {
registros[0] = rs.getString("ruc");
registros[1] = rs.getString("nombres");
registros[2] = rs.getString("apellidos");
registros[3] = rs.getString("direccion");
registros[4] = rs.getString("fecha_ingreso");
registros[5] = rs.getString("correo");
modelo.addRow(registros);
}
} catch (SQLException ex) {
Logger.getLogger(BD_provincia.class.getName()).log(Level.SEVERE,
null, ex);
}
}
public void eliminar_producto(String id) {
int n = 0;
String sql;
PreparedStatement ps;
Connection cnn = Conexion.getConnection();
Cliente c = new Cliente() {
};
try {
sql = "delete from clientes where ruc = ?";
ps = cnn.prepareStatement(sql);
ps.setString(1, id);
n = ps.executeUpdate();
if (n > 0) {
JOptionPane.showMessageDialog(null, "Cliente eliminado
Correctamente");
}
} catch (SQLException e) {
JOptionPane.showMessageDialog(null, "Error al eliminar producto " +
e.getMessage());
}
}
public static boolean eliminarCategoria(String codigo) throws SQLException
{
Connection cnn = Conexion.getConnection();
PreparedStatement ps = null;
ps = cnn.prepareStatement("delete from clientes where ruc = ?");
ps.setString(1, codigo);
int rowsUpdated = ps.executeUpdate();
cnn.close();
ps.close();
if (rowsUpdated > 0) {
return true;
} else {
return false;
} } }
Clase Producto
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Clases;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import
import
import
import
import
import
import
import
import
java.sql.Connection;
java.sql.PreparedStatement;
java.sql.ResultSet;
java.sql.SQLException;
java.util.logging.Level;
java.util.logging.Logger;
javax.swing.JTable;
javax.swing.JTextField;
javax.swing.table.DefaultTableModel;
/**
*
* @author Usuario
*/
public abstract class BD_producto {
public static void insertarProducto(Producto p, JTextField Foto) throws
SQLException {
FileInputStream archivoFoto;
File nombreFoto;
Connection cnn = Conexion.getConnection();
PreparedStatement ps = null;
ps = cnn.prepareStatement( "INSERT INTO producto
(codigo_producto,descripcion,codigo_tipo,costo,precio,stock_min,stock_max,uni
dad,estado,stock,bodega,foto,fecha_ingreso) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)" );
ps.setInt(1, p.getCodigo());
ps.setString(2, p.getNombre_producto());
ps.setInt(3, p.getCat().getCodigo_tipo());
ps.setDouble(4, p.getCosto());
ps.setDouble(5, p.getPrecio());
ps.setInt(6, p.getStock_min());
ps.setInt(7, p.getStock_max());
ps.setString(8, p.getUnidad());
ps.setString(9, p.getEstado());
ps.setInt(10, p.getStock());
ps.setString(11, p.getBodega());
ps.setString(12, p.ruta);
ps.setString(13, p.getFecha());
try {
nombreFoto = new File(Foto.getText());
archivoFoto = new FileInputStream(nombreFoto);