public void Atualizar(DTOMotorista dto, string codigo) { try { bd = new AcessoBancoDados(); bd.Conectar(); string comando = "UPDATE Motorista set NOME = '" + dto.NOME + "', CPF ='" + dto.CPF + "', DATA_NASCIMENTO ='" + dto.DATA_NASCIMENTO + "', RG ='" + dto.RG + "', ENDERECO ='" + dto.ENDERECO + "', CIDADE ='" + dto.CIDADE + "', CEP ='" + dto.CEP + "', TELEFONE ='" + dto.TELEFONE + "'where CODIGO ='" + codigo; bd.ExecutarComandoSQL(comando); } catch (Exception ex) { throw new Exception("Erro ao tentar atualizar o motorista: " + ex.Message); } finally { bd = null; } }
public void inserirMotorista(DTOMotorista dto) { try { bd = new AcessoBancoDados(); bd.Conectar(); string comando = "INSERT INTO motorista (NOME,CPF,DATA_NASCIMENTO,RG,ENDERECO,CIDADE,CEP,TELEFONE) values ('" + dto.NOME + "', '" + dto.CPF + "', '" + dto.DATA_NASCIMENTO + "', '" + dto.RG + "', '" + dto.ENDERECO + "', '" + dto.CIDADE + "', '" + dto.CEP + "', '" + dto.TELEFONE + "')"; bd.ExecutarComandoSQL(comando); } catch (Exception ex) { throw new Exception("Erro ao tentar cadastrar motorista " + ex.Message); } finally { bd = null; } }