Exemplo n.º 1
0
        public MotoristaColecao ConsultaMotorista(string Nome)
        {
            try
            {
                MotoristaColecao motoristaColecao = new MotoristaColecao();
                acessaDadosSQL.LimpaParametros();
                acessaDadosSQL.AdicionaParametros("@Nome", Nome);
                DataTable dataTableMotorista = acessaDadosSQL.ExecutaConsulta(System.Data.CommandType.StoredProcedure, "uspConsultaMotorista");
                foreach (DataRow linha in dataTableMotorista.Rows)
                {
                    Motorista motorista = new Motorista();
                    motorista.CodMotorista = Convert.ToInt32(linha["CodMotorista"]);
                    motorista.Nome         = Convert.ToString(linha["NomeMotorista"]);
                    motorista.Chapa        = Convert.ToInt32(linha["Chapa"]);
                    motorista.NumeroOnibus = Convert.ToInt32(linha["Numero"]);

                    motoristaColecao.Add(motorista);
                }

                return(motoristaColecao);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 2
0
        public MotoristaColecao ConsultarPorNome(string nome)
        {
            try
            {
                MotoristaColecao motoristaColecao = new MotoristaColecao();

                acessoDadosSqlServer.LimparParametros();
                acessoDadosSqlServer.AdicionarParametros("@CADNOMEMOTORISTA", nome);

                DataTable dataTableMotorista = acessoDadosSqlServer.ExecutarConsulta(CommandType.StoredProcedure, "uspCADMOTORISTAConsultarPorNome");

                foreach (DataRow linha in dataTableMotorista.Rows)
                {
                    Motorista motorista = new Motorista();

                    motorista.IDCADMOTORISTA           = Convert.ToInt32(linha["IDCADMOTORISTA"]);
                    motorista.CADNOMEMOTORISTA         = Convert.ToString(linha["CADNOMEMOTORISTA"]);
                    motorista.CADENDMOTORISTA          = Convert.ToString(linha["CADENDMOTORISTA"]);
                    motorista.CADTELMOTORISTA          = Convert.ToString(linha["CADTELMOTORISTA"]);
                    motorista.CADCPFMOTORISTA          = Convert.ToString(linha["CADCPFMOTORISTA"]);
                    motorista.CADRGMOTORISTA           = Convert.ToString(linha["CADRGMOTORISTA"]);
                    motorista.CADCNHMOTORISTA          = Convert.ToString(linha["CADCNHMOTORISTA"]);
                    motorista.CADDATANASCMOTORISTA     = Convert.ToDateTime(linha["CADDATANASCMOTORISTA"]);
                    motorista.CADDATACADASTROMOTORISTA = Convert.ToDateTime(linha["CADDATACADASTROMOTORISTA"]);
                    motoristaColecao.Add(motorista);
                }
                return(motoristaColecao);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível consultar o motorista por nome. Detalhes: " + ex.Message);
            }
        }
Exemplo n.º 3
0
        public MotoristaColecao ConsultaMotoristaNome()
        {
            try
            {
                MotoristaColecao motoristas      = new MotoristaColecao();
                DataTable        dataTableFiscal = acessaDadosSQL.ExecutaConsulta(System.Data.CommandType.StoredProcedure, "uspConsultaMotoristaNome");
                foreach (DataRow linha in dataTableFiscal.Rows)
                {
                    Motorista motorista = new Motorista();
                    motorista.Nome = Convert.ToString(linha["NomeMotorista"]);

                    motoristas.Add(motorista);
                }

                return(motoristas);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }