@Override public boolean eliminarPersona(int id_persona) { boolean flat = false; String query = "DELETE FROM persona WHERE id_persona=" + id_persona + ""; Statement st = null; try { st = cn.conexion().createStatement(); st.executeUpdate(query); cn.guardar(); cn.cerrar(); flat = true; } catch (Exception e) { cn.restaurar(); cn.cerrar(); System.out.println("ERROR" + e.getMessage()); } finally { if (cn.conexion() != null) { cn.cerrar(); } } return flat; }
@Override /*public List<Venta> listarVenta() { List<Venta> lista=null; Statement st=null; ResultSet rs=null; Venta ve=null; String query="select * from persona"; try { lista = new ArrayList<>(); st= conexion().createStatement(); rs=st.executeQuery(query); while (rs.next()) { ve =new Venta(); ve.setId_persona(rs.getInt("id_persona")); ve.setNombre(rs.getString("nombre")); ve.setApepat(rs.getString("apepat")); ve.setApemat(rs.getNString("apemat")); // per.setFecha_nac(rs.getNString("yyyy-mm-dd")); ve.setSexo(rs.getNString("sexo")); ve.setDni(rs.getInt("dni")); ve.setCelular(rs.getInt("celular")); ve.setTelefono(rs.getInt("telefono")); ve.setDireccion(rs.getString("direccion")); lista.add(ve); } cerrar(); } catch (Exception e) { System.out.println("ERROR:"+e.getMessage()); e.printStackTrace(); cerrar(); } return lista; }*/ @Override public boolean eliminarVenta(int id_venta) { boolean flat = false; String query = "DELETE FROM persona WHERE id_persona=" + id_venta + ""; Statement st = null; try { st = cn.conexion().createStatement(); st.executeUpdate(query); cn.guardar(); cn.cerrar(); flat = true; } catch (Exception e) { cn.restaurar(); cn.cerrar(); System.out.println("ERROR" + e.getMessage()); } finally { if (cn.conexion() != null) { cn.cerrar(); } } return flat; }
@Override public boolean actualizarPersona(Persona persona) { boolean flat = false; String query = "UPDATE persona SET nombre='" + persona.getNombre() + "'," + "apell_pater='" + persona.getApell_pater() + "'," + "apell_mater='" + persona.getApell_mater() + "'," + "direccion='" + persona.getDireccion() + "'," + "correo='" + persona.getCorreo() + "'," + "telefono=" + persona.getTelefono() + "," + "celular='" + persona.getCelular() + "'," + "ruc='" + persona.getRuc() + "'," + "nro_documento ='" + persona.getNro_documento() + "'," + "tipo_persona='" + persona.getTipo_persona() + "'," + "tipo_documento ='" + persona.getTipo_documento() + "'," + "genero ='" + persona.getGenero() + "' WHERE id_persona =" + persona.getId_persona() + ""; Statement st = null; try { st = cn.conexion().createStatement(); st.executeUpdate(query); cn.guardar(); cn.cerrar(); flat = true; } catch (Exception e) { cn.restaurar(); cn.cerrar(); System.out.println("ERROR" + e.getMessage()); } finally { if (cn.conexion() != null) { cn.cerrar(); } } return flat; }