public void delete(Funcionario funcionario) { Connection conexao = new Conexao().getConexao(); try { PreparedStatement preparedStatement = conexao.prepareStatement("UPDATE funcionarios SET status=false WHERE id = ?;"); preparedStatement.setInt(1, funcionario.getId()); preparedStatement.executeUpdate(); conexao.close(); } catch (SQLException ex) { Logger.getLogger(FuncionarioDAO.class.getName()).log(Level.SEVERE, null, ex); } }
public void update(Funcionario funcionario) { Connection conexao = new Conexao().getConexao(); try { PreparedStatement preparedStatement = conexao.prepareStatement( "UPDATE funcionarios SET nome=?, sobrenome=?, telefone=?, endereco_id=?, salario=?, email=?, cpf=?, nascimento=?, edited=now(), senha=?, gerente=? WHERE id = ?;"); preparedStatement.setString(1, funcionario.getNome()); preparedStatement.setString(2, funcionario.getSobrenome()); preparedStatement.setString(3, funcionario.getTelefone()); preparedStatement.setInt(4, funcionario.getEndereco().getId()); preparedStatement.setDouble(5, funcionario.getSalario()); preparedStatement.setString(6, funcionario.getEmail()); preparedStatement.setString(7, funcionario.getCpf()); preparedStatement.setDate(8, funcionario.getNascimento()); preparedStatement.setString(9, funcionario.getSenha()); preparedStatement.setBoolean(10, funcionario.isGerente()); preparedStatement.setInt(11, funcionario.getId()); preparedStatement.executeUpdate(); conexao.close(); } catch (SQLException ex) { Logger.getLogger(FuncionarioDAO.class.getName()).log(Level.SEVERE, null, ex); } }