public static void UpdateCliente(Cliente cli, int id) { PreparedStatement stmt; try { String sql = ("UPDATE tabcliente SET empresa='" + cli.getEmpresa() + "' , cnpj='" + cli.getCnpj() + "', setor='" + cli.getSetor() + "', contato='" + cli.getContato() + "' where idCliente = '" + id + "';"); stmt = Conexao.getConnection().prepareStatement(sql); stmt.executeUpdate(); stmt.close(); } catch (SQLException ex) { Logger.getLogger(ClienteDAO.class.getName()).log(Level.SEVERE, null, ex); throw new RuntimeException("Erro ao Alterar os dados do Cliente: ", ex); } }
public static void CadCliente(Cliente cli) { PreparedStatement stmt; try { String sql = ("INSERT INTO tabcliente(usuario_id_usuario, tabContato_id_contato,empresa,cnpj,setor,contato) VALUES(?,?,?,?,?,?)"); stmt = Conexao.getConnection().prepareStatement(sql); stmt.setInt(1, 3); stmt.setInt(2, cli.getIdContato()); stmt.setString(3, cli.getEmpresa()); stmt.setString(4, cli.getCnpj()); stmt.setString(5, cli.getSetor()); stmt.setString(6, cli.getContato()); stmt.executeUpdate(); stmt.close(); } catch (SQLException ex) { Logger.getLogger(ClienteDAO.class.getName()).log(Level.SEVERE, null, ex); throw new RuntimeException("Erro ao Cadastrar Cliente: ", ex); } }