Example #1
0
        private List <Motorista> convertDataReaderToList(MySqlDataReader dr)
        {
            List <Motorista> motorista = new List <Motorista>();

            while (dr.Read())
            {
                Motorista m = new Motorista()
                {
                    IdMotorista    = Convert.ToInt32(dr["Id"]),
                    Cpf            = dr["Cpf"].ToString(),
                    Nome           = dr["Nome"].ToString(),
                    Cnh            = dr["Cnh"].ToString(),
                    CategoriaCnh   = dr["Categoria_Cnh"].ToString(),
                    DataNascimento = Convert.ToDateTime(dr["Dt_Nascimento"]),
                    ExameMedico    = dr["Exame_Medico"].ToString(),
                    Email          = dr["Email"].ToString(),
                };
                m.Endereco        = new Endereco();
                m.Endereco.Rua    = dr["Endereco"].ToString();
                m.Endereco.Numero = dr["Numero"].ToString();
                m.Endereco.Cidade = dr["Cidade"].ToString();
                m.Endereco.Bairro = dr["Bairro"].ToString();
                m.Endereco.Cep    = Convert.ToInt32(dr["Cep"]);
                motorista.Add(m);
            }
            return(motorista);
        }
 public void TransportarChefeComissariaDoisAteAviao(Motorista motorista, Pessoa passageiro)
 {
     aviao.ForEach(x => x.comissariaDois    = passageiro);
     aviao.ForEach(x => x.chefeVoo          = motorista);
     terminal.ForEach(x => x.comissariaDois = null);
     terminal.ForEach(x => x.chefeVoo       = null);
 }
        public async Task Excluir(int Id)
        {
            Motorista motorista = ObterMotorista(Id);

            _banco.Remove(motorista);
            await _banco.SaveChangesAsync();
        }
Example #4
0
        private List <Motorista> ListarObjeto(SqlDataReader reader)
        {
            var motorista = new List <Motorista>();

            while (reader.Read())
            {
                var temObjeto = new Motorista()
                {
                    IdMotorista    = int.Parse(reader["IdMotorista"].ToString()),
                    Nome           = reader["NOME"].ToString(),
                    Cpf            = reader["CPF"].ToString(),
                    DataNascimento = DateTime.Parse(reader["DATANASCIMENTO"].ToString()),
                    Sexo           = reader["SEXO"].ToString(),
                    Orgao          = reader["ORGAOEMISSOR"].ToString(),
                    Rg             = reader["RG"].ToString(),
                    Cnh            = long.Parse(reader["CNH"].ToString()),
                    UfRg           = reader["UFRG"].ToString(),
                    Telefone       = reader["TELEFONE"].ToString(),
                    Celular        = reader["CELULAR"].ToString(),
                    Email          = reader["EMAIL"].ToString(),
                    Logradouro     = reader["LOGRADOURO"].ToString(),
                    Bairro         = reader["BAIRRO"].ToString(),
                    Numero         = reader["NUMERO"].ToString(),
                    Complemento    = reader["COMPLEMENTO"].ToString(),
                    Cep            = reader["CEP"].ToString(),
                    Cidade         = reader["CIDADE"].ToString(),
                    Uf             = reader["UF"].ToString()
                };
                motorista.Add(temObjeto);
            }
            reader.Close();
            reader.Dispose();
            return(motorista);
        }
        public ExameMedico BuscarExameMedico(string cpf, DateTime data)
        {
            string Data  = data.ToString("yyyy/MM/dd");
            string query = "SELECT * FROM [dbo].[TB_EXAMEDICO] WHERE [EXAM_DATA] = '" + Data + "' AND [EXAM_MT_CPF] = '" + cpf + "'";

            try
            {
                DataTable dt = _banco.BuscarRegistro(query);

                ExameMedico exameMedico = null;
                DataRow[]   dataRows    = dt.Select("EXAM_MT_CPF = '" + cpf + "'");
                foreach (DataRow dr in dataRows)
                {
                    DateTime            dataexame           = Convert.ToDateTime(dr["EXAM_DATA"].ToString());
                    SituacaoExameMedico situacaoExameMedico = (SituacaoExameMedico)Enum.Parse(typeof(SituacaoExameMedico), dr["EXAM_SITUACAO"].ToString());
                    motorista     = new Motorista();
                    motorista.CPF = dr["EXAM_MT_CPF"].ToString();

                    exameMedico = new ExameMedico(dataexame, dr["EXAM_DESCRICAO"].ToString(), situacaoExameMedico, motorista);
                }

                return(exameMedico);
            }
            catch (ConcorrenciaBancoException e)
            {
                throw new ConcorrenciaBancoException(e.Message);
            }
        }
        public List <ExameMedico> BuscarTodos(DateTime dtinicio, DateTime dtfim)
        {
            List <ExameMedico> exames = new List <ExameMedico>();

            string query = "SELECT * FROM [dbo].[TB_EXAMEDICO] WHERE" +
                           "((YEAR([EXAM_DATAREGISTRO]) >= '" + dtinicio.Year + "' AND YEAR([EXAM_DATAREGISTRO]) <= '" + dtfim.Year + "')" +
                           "AND MONTH([EXAM_DATAREGISTRO]) >= '" + dtinicio.Month + "' AND MONTH([EXAM_DATAREGISTRO]) <= '" + dtfim.Month + "')";

            try
            {
                DataTable   dt          = _banco.BuscarRegistro(query);
                ExameMedico exameMedico = null;
                DataRow[]   dataRows    = dt.Select();
                foreach (DataRow dr in dataRows)
                {
                    DateTime            dataexame           = Convert.ToDateTime(dr["EXAM_DATA"].ToString());
                    SituacaoExameMedico situacaoExameMedico = (SituacaoExameMedico)Enum.Parse(typeof(SituacaoExameMedico), dr["EXAM_SITUACAO"].ToString());
                    motorista     = new Motorista();
                    motorista.CPF = dr["EXAM_MT_CPF"].ToString();

                    exameMedico = new ExameMedico(dataexame, dr["EXAM_DESCRICAO"].ToString(), situacaoExameMedico, motorista);
                    exames.Add(exameMedico);
                }
                return(exames);
            }
            catch (Exception)
            {
                throw new ConcorrenciaBancoException("Erro de concorrência de banco!");
            }
        }
Example #7
0
        public Motorista BuscarCPF(string cpf)
        {
            string query = "SELECT M.[MT_CPF], M.[MT_NOME], M.[MT_RG], M.[MT_ENDERECO], M.[MT_DTNASCIMENTO], M.[MT_TELEFONE], M.[MT_TELEFONE_RECADO]" +
                           ", M.[MT_SITUACAO], C.[CNH_NUMERO], C.[CNH_DTEMISSAO], C.[CNH_DTVENC], C.[CNH_CATEGORIA], C.[CNH_ORGAOEMISSOR], C.[CNH_MT_CPF]" +
                           "FROM [TB_MOTORISTA] AS M JOIN [TB_CNH] AS C ON M.[MT_CPF] = C.[CNH_MT_CPF] WHERE M.[MT_CPF] = '" + cpf + "'";

            try
            {
                DataTable dt = _banco.BuscarRegistro(query);

                Motorista motorista = null;
                CNH       cNH       = new CNH();
                DataRow[] dataRows  = dt.Select("MT_CPF = '" + cpf + "'");
                foreach (DataRow dr in dataRows)
                {
                    DateTime dtnascimento   = Convert.ToDateTime(dr["MT_DTNASCIMENTO"].ToString());
                    long     telefone       = long.Parse(dr["MT_TELEFONE"].ToString());
                    long     telefonerecado = long.Parse(dr["MT_TELEFONE_RECADO"].ToString());
                    bool     situacao       = bool.Parse(dr["MT_SITUACAO"].ToString());
                    cNH.Numero         = long.Parse(dr["CNH_NUMERO"].ToString());
                    cNH.DataEmissao    = Convert.ToDateTime(dr["CNH_DTEMISSAO"].ToString());
                    cNH.DataVencimento = Convert.ToDateTime(dr["CNH_DTVENC"].ToString());
                    cNH.Categoria      = dr["CNH_CATEGORIA"].ToString();
                    cNH.OrgaoEmissor   = dr["CNH_ORGAOEMISSOR"].ToString();

                    motorista = new Motorista(dr["MT_CPF"].ToString(), dr["MT_NOME"].ToString(), dr["MT_RG"].ToString(), dr["MT_DTNASCIMENTO"].ToString(), dtnascimento, telefone, telefonerecado, situacao, cNH);
                }

                return(motorista);
            }
            catch (ConcorrenciaBancoException e)
            {
                throw new ConcorrenciaBancoException(e.Message);
            }
        }
Example #8
0
        //metodo para excluir um motorista..
        public JsonResult ExcluirMotorista(int idMotorista)
        {
            try
            {
                //buscar o motorista na base de dados pelo id..
                MotoristaRepository rep = new MotoristaRepository();
                int qtdAutomoveis       = rep.QtdAutomoveis(idMotorista);
                int qtdCaminhoes        = rep.QtdCaminhoes(idCaminhao);


                if (qtdAutomoveis > 0 || qtdCaminhoes > 0)
                {
                    return(Json($"O Motorista não pode ser excluido, pois possui {qtdAutomoveis * qtdCaminhoes } Veículo cadastrado.",
                                JsonRequestBehavior.AllowGet));
                }


                else
                {
                    Motorista m = rep.FindById(idMotorista);

                    //excluindo o motorista..
                    rep.Delete(m);

                    //retornando mensagem de sucesso..
                    return(Json($"Motorista {m.Nome}, excluído com sucesso.",
                                JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                return(Json(e.Message, JsonRequestBehavior.AllowGet));
            }
        }
        public async Task <IActionResult> Create([Bind("Id,CPF,Nome,CNH,Categoria_Cnh,Dt_Nascimento,Exame_medico,email,endereco,numero,cidade,Bairro,CEP")] Motorista motorista)
        {
            if (IsCpf(motorista.CPF))
            {
                var motoristas = await _context.Motoristas.FirstOrDefaultAsync(m => m.CPF == motorista.CPF || m.CNH == motorista.CNH);

                motorista.CPF = motorista.CPF.Replace(".", "").Replace("-", "");
                if (motoristas != null)
                {
                    ViewBag.Erro = "CPF ou CNH já cadastrado!";
                }
                else
                {
                    if (ModelState.IsValid)
                    {
                        _context.Add(motorista);
                        await _context.SaveChangesAsync();

                        return(RedirectToAction(nameof(Index)));
                    }
                }
            }
            ViewBag.Cpf = "CPF inválido";
            return(View(motorista));
        }
Example #10
0
        public static String DescricaoCaracterizacao(Guid Id)
        {
            String GuidId = Id.ToString().ToUpper();

            if (GuidId.Equals(Fisica.ToString().ToUpper()))
            {
                return(DescricaoTabelasPadroes.CaracterizacaoFisica);
            }
            if (GuidId.Equals(Juridica.ToString().ToUpper()))
            {
                return(DescricaoTabelasPadroes.CaracterizacaoJuridica);
            }
            if (GuidId.Equals(Empresa.ToString().ToUpper()))
            {
                return(DescricaoTabelasPadroes.CaracterizacaoEmpresa);
            }
            if (GuidId.Equals(Aluno.ToString().ToUpper()))
            {
                return(DescricaoTabelasPadroes.CaracterizacaoAluno);
            }
            if (GuidId.Equals(Motorista.ToString().ToUpper()))
            {
                return(DescricaoTabelasPadroes.CaracterizacaoMotorista);
            }
            if (GuidId.Equals(Responsavel.ToString().ToUpper()))
            {
                return(DescricaoTabelasPadroes.CaracterizacaoResponsavel);
            }
            return(String.Empty);
        }
Example #11
0
 private void btnMotoristaExcluir_Click(object sender, EventArgs e)
 {
     using (var context = new CadastroMotoristaContext())
     {
         try
         {
             var       motoristaID = txtMotoristaMotoristaID.Text.ConvertToInt();
             Motorista motorista   = context.Motoristas
                                     .Where(a => a.MotoristaID == motoristaID).FirstOrDefault <Motorista>();
             context.Entry(motorista).State = EntityState.Deleted;
             context.SaveChanges();
         }
         catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
         {
             if (ex.InnerException != null && ex.InnerException is System.Data.Entity.Core.UpdateException)
             {
                 if (ex.InnerException.InnerException != null && ex.InnerException.InnerException is System.Data.SqlClient.SqlException)
                 {
                     MessageBox.Show("Não é possível excluir esse registro, pois ele têm dependência com outro registro incluído no banco de dados.", "Erro");
                 }
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
     LimparMotorista();
 }
Example #12
0
        private void Inserir(Motorista motorista)
        {   //Inserir Contato
            var strQuery = "";

            strQuery += " INSERT INTO CONTATO(TELEFONE, CELULAR, EMAIL) ";
            strQuery += string.Format(" VALUES('{0}','{1}','{2}')", motorista.Telefone, motorista.Celular,
                                      motorista.Email);
            //Inserir Endereço
            strQuery += " INSERT INTO ENDERECO(LOGRADOURO, NUMERO, COMPLEMENTO, CEP, BAIRRO, CIDADE, UF)";
            strQuery += string.Format(" VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", motorista.Logradouro,
                                      motorista.Numero, motorista.Complemento, motorista.Cep, motorista.Bairro, motorista.Cidade, motorista.Uf);
            strQuery += " Declare @IdEndereco int " +
                        "SET @IdEndereco = (SELECT IDENT_CURRENT('ENDERECO')) " +
                        "Declare @IdContato int " +
                        "SET @IdContato = (SELECT IDENT_CURRENT('CONTATO')) ";
            //Inserir Pessoa Fisíca
            strQuery += " INSERT INTO PESSOAFISICA(IDENDERECO, IDCONTATO, NOME, CPF, DATANASCIMENTO, RG, UF_PF, ORGAOEMISSOR, SEXO)";
            strQuery += string.Format("VALUES(@IdEndereco,@IdContato,'{0}','{1}','{2}','{3}','{4}','{5}','{6}') ",
                                      motorista.Nome, motorista.Cpf, motorista.DataNascimento, motorista.Rg, motorista.Uf, motorista.Orgao,
                                      motorista.Sexo);
            strQuery += "Declare @IdPessoaFisica int " +
                        "SET @IdPessoaFisica = (SELECT IDENT_CURRENT('PESSOAFISICA')) ";
            strQuery += " INSERT INTO MOTORISTA(IDPESSOAFISICA, IDTRANSPORTADOR, IDENDERECO, CNH)";
            strQuery += string.Format("VALUES (@IdPessoaFisica,5,@IdEndereco,'{0}') ", motorista.Cnh);

            using (contexto = new Contexto())
            {
                contexto.ExecutaGravacao(strQuery);
            }
        }
 public void TransportarChefePilotoAteAviao(Motorista motorista, Motorista passageiro)
 {
     aviao.ForEach(x => x.chefeVoo    = passageiro);
     aviao.ForEach(x => x.piloto      = motorista);
     terminal.ForEach(x => x.chefeVoo = null);
     terminal.ForEach(x => x.piloto   = null);
 }
        public ActionResult Details(long?id)
        {
            string email     = HttpContext.GetOwinContext().Authentication.User.Identity.Name;
            long?  idCliente = (long?)long.Parse(Gerenciador.FindByEmail(email).Id);

            if (id != null)
            {
                Motorista motorista = MotoristaService.ObterMotoristaPorId(id);

                if (motorista != null)
                {
                    if (motorista.ClienteId != idCliente)
                    {
                        return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
                    }

                    MotoristaViewModel motoristaView = new MotoristaViewModel()
                    {
                        Motorista = motorista
                    };

                    return(View(motoristaView));
                }
            }
            return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
        }
Example #15
0
        private void CarregarGrid(Motorista motoristaFiltro)
        {
            List <Motorista> lstMotoristas = new List <Motorista>();

            this.Cursor = Cursors.WaitCursor;

            try
            {
                lstMotoristas = bizMotorista.PesquisarMotorista(motoristaFiltro).OrderBy(x => x.Nome).ToList();

                LimparGrid();

                foreach (Motorista itemMotorista in lstMotoristas)
                {
                    gvMotoristas.Rows.Add(new object[]
                    {
                        itemMotorista.idMotorista,
                        itemMotorista.Nome,
                        itemMotorista.Telefone
                    });
                }
            }
            catch (SqlException)
            {
                MessageBox.Show(helper.RetornarMensagemPadraoErroAcessoBD(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MessageBox.Show(helper.RetornarMensagemPadraoErroGenerico(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.Cursor = Cursors.Default;
        }
 private void panel1_Paint(object sender, PaintEventArgs e)
 {
     if (byVehicle == true)
     {
         txtPlacaVeiculo.Enabled = false;
         BLL      bll      = new BLL();
         Veiculos veiculos = new Veiculos();
         veiculos = bll.ListaVeiculosPorPlaca(txtPlacaVeiculo.Text);
         txtModeloVeiculo.Text = veiculos.Modelo;
         txtCor.Text           = veiculos.Cor;
         byVehicle             = false;
     }
     else if (byMot == true)
     {
         txtNomeMotorista.Enabled = false;
         BLL       bll       = new BLL();
         Motorista motorista = new Motorista();
         motorista            = bll.ListaMotoristaPorNome(txtNomeMotorista.Text);
         txtCPFMotorista.Text = motorista.CPF;
         byMot = false;
     }
     else
     {
         txtPlacaVeiculo.Enabled  = true;
         txtNomeMotorista.Enabled = true;
         txtNomeMotorista.Text    = "";
         txtCPFMotorista.Text     = "";
         txtPlacaVeiculo.Text     = "";
         txtModeloVeiculo.Text    = "";
         txtCor.Text = "";
     }
 }
Example #17
0
        public void nao_salvar_objeto_nulo()
        {
            var motorista = new Motorista();

            controller.Create(motorista);
            Assert.AreEqual(0, motorista.Id);
        }
Example #18
0
        public bool Create(Motorista Motorista)
        {
            bool         result     = false;
            string       comandoSql = "INSERT INTO motoristas (Nome,CPF,CNH,CatCNH,ValCNH) VALUES (?NOME,?CPF,?CNH,?CATCNH,?VALCNH)";
            MySqlCommand comando    = new MySqlCommand(comandoSql, conexao);

            comando.Parameters.AddWithValue("?NOME", Motorista.Nome);
            comando.Parameters.AddWithValue("?CPF", Motorista.CPF);
            comando.Parameters.AddWithValue("?CNH", Motorista.CNH);
            comando.Parameters.AddWithValue("?CATCNH", Motorista.CategoriaCNH);
            comando.Parameters.AddWithValue("?VALCNH", Motorista.ValidadeCNH.ToString("dd/MM/yyyy"));

            try
            {
                conexao.Open();
                comando.ExecuteNonQuery();
                result = true;
            }
            catch
            {
                result = false;
            }
            finally
            {
                comando.Dispose();
                conexao.Close();
            }

            return(result);
        }
Example #19
0
        public Motorista Read(Motorista Motorista)
        {
            string       comandoSql = "SELECT * FROM motoristas WHERE ID = ?ID ";
            MySqlCommand comando    = new MySqlCommand(comandoSql, conexao);

            comando.Parameters.AddWithValue("?ID", Convert.ToInt16(Motorista.ID));
            try
            {
                conexao.Open();
                MySqlDataReader rd = comando.ExecuteReader();
                while (rd.Read())
                {
                    Motorista.Nome         = Convert.ToString(rd["Nome"]);
                    Motorista.CPF          = Convert.ToString(rd["CPF"]);
                    Motorista.CNH          = Convert.ToString(rd["CNH"]);
                    Motorista.CategoriaCNH = Convert.ToString(rd["CatCNH"]);
                    Motorista.ValidadeCNH  = DateTime.Parse(Convert.ToString(rd["ValCNH"]));
                    Motorista.ID           = Convert.ToInt16(rd["ID"]);
                }
            }
            catch
            {
                Motorista = null;
            }
            finally
            {
                comando.Dispose();
                conexao.Close();
            }

            return(Motorista);
        }
Example #20
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);
            }
        }
Example #21
0
        public bool Delete(Motorista Motorista)
        {
            bool         result     = false;
            string       comandoSql = "DELETE FROM motoristas WHERE ID = ?ID ";
            MySqlCommand comando    = new MySqlCommand(comandoSql, conexao);

            comando.Parameters.AddWithValue("?ID", Convert.ToInt16(Motorista.ID));

            try
            {
                conexao.Open();
                comando.ExecuteNonQuery();
                result = true;
            }
            catch
            {
                result = false;
            }
            finally
            {
                comando.Dispose();
                conexao.Close();
            }

            return(result);
        }
Example #22
0
        public void Atualizar(Motorista motorista)
        {
            using (OracleConnection con = new OracleConnection(AppConfig.StringConexao()))
            {
                var parametros = new DynamicParameters();

                parametros.Add(name: "Nome", value: motorista.Nome, direction: ParameterDirection.Input);
                parametros.Add(name: "CNH", value: motorista.CNH, direction: ParameterDirection.Input);
                parametros.Add(name: "ValidadeCNH", value: motorista.ValidadeCNH, direction: ParameterDirection.Input);
                parametros.Add(name: "RG", value: motorista.RG, direction: ParameterDirection.Input);
                parametros.Add(name: "CPF", value: motorista.CPF, direction: ParameterDirection.Input);
                parametros.Add(name: "Celular", value: motorista.Celular, direction: ParameterDirection.Input);
                parametros.Add(name: "Nextel", value: motorista.Nextel, direction: ParameterDirection.Input);
                parametros.Add(name: "MOP", value: motorista.MOP, direction: ParameterDirection.Input);
                parametros.Add(name: "Id", value: motorista.Id, direction: ParameterDirection.Input);

                con.Execute(@"
                        UPDATE OPERADOR.TB_AG_MOTORISTAS
                            SET 
                                NOME = :Nome,
                                CNH = :CNH,
                                VALIDADE_CNH = :ValidadeCNH,
                                RG = :RG,
                                CPF = :CPF,
                                CELULAR = :Celular,
                                NEXTEL = :Nextel,
                                NUMERO_MOP = :MOP,
                                DT_ULTIMA_ATUALIZACAO = SYSDATE
                            WHERE 
                                AUTONUM = :Id", parametros);
            }
        }
Example #23
0
        public IHttpActionResult Post([FromBody] Motorista motorista)
        {
            if (motorista == null)
            {
                return(BadRequest());
            }

            try
            {
                motorista.Situacao = true;
                bool result = _motoristaService.Cadastrar(motorista, motorista.CNH);
                if (result)
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest("Houve um erro na operação!"));
                }
            }
            catch (RegistroExisteException e)
            {
                return(BadRequest(e.Message));
            }
            catch (ConcorrenciaBancoException e)
            {
                return(BadRequest(e.Message));
            }
        }
Example #24
0
        /// <summary>
        /// Altera a cotação
        /// O usuário que fez a ordem pela primeira vez nao será alterado
        /// O mérito é de quem registrou a ordem
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        private OrdemCarga indexarOrdem(OrdemCarga v)
        {
            if (v != null)
            {
                this._cliFor    = v.Cliente;
                this._motorista = v.Motorista;
                this.dtDataCarregamento.DateTime = v.DataCarregamento;
                this._user      = v.Usuario;
                lblCliente.Text = v.Cliente.RazaoSocial;

                var itens = v.ItensOrdemCarga;
                //passa os itens para tela de itens
                _xFrmItensCarga.AddListaItem(itens);

                //coloque no painel lateral tbm
                if (itens != null)
                {
                    this.listBoxControl1.Items.AddRange(itens.ToArray());
                    this.listBoxControl1.Refresh();

                    this.lblMetrosQuadrados.Text = itens.Sum(m => m.MetrosQuadrado).ToString("N2");
                }


                lblItens.Text = v.NumeroItens.ToString();
                lblItens.Refresh();

                lblTotalCarga.Text = v.TotalCarga.ToString("N2");
                lblTotalCarga.Refresh();
            }

            return(v);
        }
Example #25
0
        private void navBarItemSelectMotorista_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            try
            {
                using (var ctx = new SlateContext())
                {
                    ctx.LazyLoading(false);

                    var x = XFrmFindEntity.ShowDialogFindEntity <Motorista>(new ParamsFindEntity()
                    {
                        Context       = ctx,
                        Columns       = new string[] { "IdMotorista", "NomeMotorista" },
                        DynamicObject = _motorista,
                        Title         = "Localizar Motorista"
                    });

                    //var x = XFrmFindEntity.ShowDiaglogFindEntity<Motorista>(ctx,
                    //    new string[] { "IdMotorista", "NomeMotorista" }, _motorista,
                    //    "Selecionar Motorista");

                    if (x != null)
                    {
                        //recupera o cliente
                        this._motorista = ctx.MotoristaDao.Find(x.IdMotorista);

                        this.lblMotorista.Text = this._motorista.NomeMotorista;
                    }
                }
            }
            catch (Exception ex)
            {
                XMessageIts.ExceptionMessage(ex);
            }
        }
Example #26
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         if (Session["cadastro"] != null && Session["cadastro"] is Motorista && Session["auxiliar"] is Usuario)
         {
             Motorista mot  = (Motorista)Session["cadastro"];
             Usuario   user = (Usuario)Session["auxiliar"];
             if (String.IsNullOrEmpty(user.Usu_email) && String.IsNullOrWhiteSpace(user.Usu_email) && String.IsNullOrEmpty(mot.Mot_nome) && String.IsNullOrWhiteSpace(mot.Mot_nome))
             {
             }
             else
             {
                 txt_email.Text = user.Usu_email.ToString();
                 var dob = Convert.ToDateTime(mot.Mot_datadenascimento);
                 txt_datanasc.Text      = dob.ToString("yyyy-MM-dd");
                 txt_NomeMotorista.Text = mot.Mot_nome.ToString();
                 rbl_sexo.SelectedValue = mot.Mot_genero.ToString();
             }
         }
         else
         {
         }
         ;
     }
 }
 public void TransportarPilotoOficialDoisAteAviao(Motorista motorista, Pessoa passageiro)
 {
     aviao.ForEach(x => x.oficialDois    = passageiro);
     aviao.ForEach(x => x.piloto         = motorista);
     terminal.ForEach(x => x.oficialDois = null);
     terminal.ForEach(x => x.piloto      = null);
 }
Example #28
0
        public void InserirMotorista(Motorista m)
        {
            String query = "INSERT INTO Motorista (Cpf, Nome, Cnh,Categoria_Cnh, Dt_Nascimento,Exame_Medico, Email, Endereco, Numero, Cidade, Bairro, Cep)" +
                           "VALUES (@cpf, @nome, @cnh, @categoriaCnh, @dtNascimento, @exame, @email, @endereco, @numero,@cidade,@bairro, @cep)";
            MySqlConnection conn = new SqlConnection().Criar();
            MySqlCommand    cmd  = new MySqlCommand(query, conn);

            cmd.Parameters.AddWithValue("cpf", m.Cpf);
            cmd.Parameters.AddWithValue("nome", m.Nome);
            cmd.Parameters.AddWithValue("cnh", m.Cnh);
            cmd.Parameters.AddWithValue("categoriaCnh", m.CategoriaCnh);
            cmd.Parameters.AddWithValue("dtNascimento", m.DataNascimento);
            cmd.Parameters.AddWithValue("exame", m.ExameMedico);
            cmd.Parameters.AddWithValue("email", m.Email);
            cmd.Parameters.AddWithValue("endereco", m.Endereco.Rua);
            cmd.Parameters.AddWithValue("numero", m.Endereco.Numero);
            cmd.Parameters.AddWithValue("cidade", m.Endereco.Cidade);
            cmd.Parameters.AddWithValue("bairro", m.Endereco.Bairro);
            cmd.Parameters.AddWithValue("cep", m.Endereco.Cep);
            cmd.Prepare();

            try
            {
                cmd.ExecuteNonQuery();
            }
            finally
            {
                conn.Close();
            }
        }
 public void TransportarPolicialPresidiarioAteAviao(Motorista motorista, Pessoa passageiro)
 {
     aviao.ForEach(x => x.presidiario    = passageiro);
     aviao.ForEach(x => x.policial       = motorista);
     terminal.ForEach(x => x.presidiario = null);
     terminal.ForEach(x => x.policial    = null);
 }
Example #30
0
        public bool Update(Motorista Motorista)
        {
            bool         result     = false;
            string       comandoSql = "UPDATE motoristas SET Nome = ?NOME, CPF = ?CPF, CNH = ?CNH, CatCNH = ?CATCNH, ValCNH = ?VALCNH WHERE ID = ?ID ";
            MySqlCommand comando    = new MySqlCommand(comandoSql, conexao);

            comando.Parameters.AddWithValue("?NOME", Motorista.Nome);
            comando.Parameters.AddWithValue("?CPF", Motorista.CPF);
            comando.Parameters.AddWithValue("?CNH", Motorista.CNH);
            comando.Parameters.AddWithValue("?CATCNH", Motorista.CategoriaCNH);
            comando.Parameters.AddWithValue("?VALCNH", Motorista.ValidadeCNH.ToString("dd/MM/yyyy"));
            comando.Parameters.AddWithValue("?ID", Convert.ToInt16(Motorista.ID));

            try
            {
                conexao.Open();
                comando.ExecuteNonQuery();
                result = true;
            }
            catch
            {
                result = false;
            }
            finally
            {
                comando.Dispose();
                conexao.Close();
            }

            return(result);
        }
 public static Motorista CreateMotorista(int id, string nome, string endereco, int cNH)
 {
     Motorista motorista = new Motorista();
     motorista.Id = id;
     motorista.Nome = nome;
     motorista.Endereco = endereco;
     motorista.CNH = cNH;
     return motorista;
 }
Example #32
0
 public Rota(int pId, string pNome, Motorista pMotorista)
 {
     id = pId;
     nome = pNome;
     motorista = pMotorista;
 }
 public void AddToMotoristas(Motorista motorista)
 {
     base.AddObject("Motoristas", motorista);
 }
 public MotoristaProxy(int idade)
 {
     motorista = new Motorista(idade);
 }