Vous êtes sur la page 1sur 1

package DAO;

import
import
import
import
import
import

TO.FacturaTO;
cnMySQL.MySQL;
java.sql.CallableStatement;
java.sql.Connection;
java.sql.PreparedStatement;
java.sql.ResultSet;

public class FacturaDAO {


public void insert(FacturaTO objFacturaTO)throws Exception{
Connection cn=MySQL.getInstance().getConnection();
String sql="CALL sp_insert_factura(?,?,?,?,?)";
CallableStatement cs=cn.prepareCall(sql);
cs.setString(1, objFacturaTO.getIdcliente());
cs.setString(2, objFacturaTO.getIdempleado());
cs.setDouble(3, objFacturaTO.getStotfact());
cs.setDouble(4, objFacturaTO.getIgvfact());
cs.setDouble(5, objFacturaTO.getTotafact());
cs.execute();
}
public String mostrarUltimoCodigo()throws Exception{
Connection cn=MySQL.getInstance().getConnection();
String sql="select * from factura";
PreparedStatement ps=cn.prepareStatement(sql);
ResultSet rs=ps.executeQuery();
rs.last();
return rs.getString(1);
}

package DAO;
import
import
import
import

TO.DetalleTO;
cnMySQL.MySQL;
java.sql.CallableStatement;
java.sql.Connection;

public class DetalleDAO {


public void insert(DetalleTO objDetalleTO)throws Exception{
Connection cn=MySQL.getInstance().getConnection();
String sql="CALL sp_insert_detalle(?,?,?,?,?)";
CallableStatement cs=cn.prepareCall(sql);
cs.setString(1, objDetalleTO.getIdfactura());
cs.setString(2, objDetalleTO.getIdproducto());
cs.setDouble(3, objDetalleTO.getPrecprod());
cs.setInt(4, objDetalleTO.getCantidad());
cs.setDouble(5, objDetalleTO.getImporte());
cs.execute();
}

Vous aimerez peut-être aussi