public bool CadastrarMotorista(Motorista motorista) { bool resposta = false; try { this.conexao.abrirConexao(); OleDbCommand cadastro = new OleDbCommand ("Insert into Motorista(cpf,nome,dataNascimento,validade,tipo)" + " Values('" + (motorista.getCpf()) + "','" + (motorista.getNome()) + "','" + (motorista.getDataNascimento()) + "'" + ",'" + (motorista.getValidadeCnh()) + "','" + (motorista.getTipoCarteira()) + "')", this.conexao.GetConexao()); cadastro.ExecuteNonQuery(); resposta = true; this.conexao.fecharConexao(); }catch (OleDbException erro) { Console.Out.WriteLine("Erro: " + erro.Message); } return(resposta); }
public bool AlterarMotorista(Motorista motorista, string cpf) { bool resp = false; try { this.conexao.abrirConexao(); OleDbCommand comando = new OleDbCommand ("Update Motorista Set nome = '" + (motorista.getNome()) + "',cpf = '" + (motorista.getCpf()) + "'" + ",dataNascimento = '" + (motorista.getDataNascimento()) + "',validade = '" + (motorista.getValidadeCnh()) + "'" + ",tipo = '" + (motorista.getTipoCarteira()) + "' Where cpf = '" + cpf + "'", this.conexao.GetConexao()); comando.ExecuteNonQuery(); resp = true; this.conexao.fecharConexao(); }catch (OleDbException erro) { Console.Out.WriteLine("Erro : " + erro.Message); } return(resp); }