private HistoricoTColetorVO PreencheVO()
        {
            HistoricoTColetorVO historicoColetorVO = new HistoricoTColetorVO();

            historicoColetorVO.Vendedor            = txtVendedor.Text;
            historicoColetorVO.NumeroColetor       = txtColetor.Text;
            historicoColetorVO.DataRelatorioInicio = string.IsNullOrEmpty(txtDataInicial.Text) ? new DateTime?() : Convert.ToDateTime(txtDataInicial.Text);
            historicoColetorVO.DataRelatorioFinal  = string.IsNullOrEmpty(txtDataFinal.Text) ? new DateTime?() : Convert.ToDateTime(txtDataFinal.Text);

            return(historicoColetorVO);
        }
Example #2
0
 public List <HistoricoTColetorVO> ListarRelatorio(HistoricoTColetorVO filtro)
 {
     try
     {
         return(HistoricoTColetorBLL.ListarRelatorio(filtro).ToList().Distinct(new ColetorDistinct()).ToList());
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
         //throw new CABTECException("Erro ao Listar Coletor.");
     }
 }
Example #3
0
        public IQueryable <HistoricoTColetorVO> ListarRelatorio(HistoricoTColetorVO filtro)
        {
            var banco = new SINAF_WebEntities();

            var query = (from registro in banco.HistoricoTColetor
                         join sincronismo in banco.HistoricoTSincronismo on registro.IDHistoricoColetor equals sincronismo.HistoricoTColetor.IDHistoricoColetor
                         orderby registro.NumeroColetor, registro.DataUltimoSincronismo, sincronismo.DataSincronismo
                         select new HistoricoTColetorVO
            {
                IDHistoricoColetor = registro.IDHistoricoColetor,

                NumeroColetor = registro.NumeroColetor,

                DataUltimoSincronismo = registro.DataUltimoSincronismo,

                NumeroTotalSincronismo = registro.NumeroTotalSincronismo,

                NumeroTotalEntrevista = registro.NumeroTotalEntrevista,

                DataSincronismo = sincronismo.DataSincronismo,

                Vendedor = sincronismo.TUsuario.Nome,
            }).AsQueryable();

            if (!string.IsNullOrEmpty(filtro.NumeroColetor))
            {
                query = query.Where(registro => registro.NumeroColetor.Contains(filtro.NumeroColetor));
            }

            if (!string.IsNullOrEmpty(filtro.Vendedor))
            {
                query = query.Where(registro => registro.Vendedor.Contains(filtro.Vendedor));
            }

            if (filtro.DataRelatorioInicio.HasValue)
            {
                query = query.Where(registro => registro.DataSincronismo >= filtro.DataRelatorioInicio);
            }

            if (filtro.DataRelatorioFinal.HasValue)
            {
                query = query.Where(registro => registro.DataSincronismo <= filtro.DataRelatorioFinal);
            }

            return(query);
        }
Example #4
0
        public void Alterar(HistoricoTColetorVO tcoletorvo)
        {
            var banco = new SINAF_WebEntities();

            var query = (from registro in banco.HistoricoTColetor
                         where registro.IDHistoricoColetor.Equals(tcoletorvo.IDHistoricoColetor)
                         select registro).First();

            query.NumeroColetor = tcoletorvo.NumeroColetor;

            query.DataUltimoSincronismo = DateTime.Now;

            query.NumeroTotalSincronismo = query.NumeroTotalSincronismo + 1;

            query.NumeroTotalEntrevista = query.NumeroTotalEntrevista + tcoletorvo.NumeroTotalEntrevista;

            banco.SaveChanges();
        }
Example #5
0
        public HistoricoTColetorVO VerificaInserirInicial(string numeroColetor)
        {
            try
            {
                HistoricoTColetorVO historico = HistoricoTColetorBLL.ObterPorNumero(numeroColetor);

                if (historico == null || historico.IDHistoricoColetor <= 0)
                {
                    historico = new HistoricoTColetorVO();
                    historico.NumeroColetor = numeroColetor;
                    HistoricoTColetorBLL.Inserir(historico);
                }

                return(historico);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #6
0
        public IQueryable <HistoricoTColetorVO> Listar(HistoricoTColetorVO filtro)
        {
            var banco = new SINAF_WebEntities();

            var query = (from registro in banco.HistoricoTColetor
                         select new HistoricoTColetorVO
            {
                IDHistoricoColetor = registro.IDHistoricoColetor,

                NumeroColetor = registro.NumeroColetor,

                DataUltimoSincronismo = registro.DataUltimoSincronismo,

                NumeroTotalSincronismo = registro.NumeroTotalSincronismo,

                NumeroTotalEntrevista = registro.NumeroTotalEntrevista,
            }).AsQueryable();

            return(query);
        }
Example #7
0
 public List <HistoricoTColetorVO> Listar(HistoricoTColetorVO filtro)
 {
     try
     {
         if (filtro.IDHistoricoColetor > 0)
         {
             List <HistoricoTColetorVO> listaRetorno = new List <HistoricoTColetorVO>();
             listaRetorno.Add(HistoricoTColetorBLL.Obter(filtro.IDHistoricoColetor));
             return(listaRetorno);
         }
         else
         {
             return(HistoricoTColetorBLL.Listar(filtro).ToList());
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
         //throw new CABTECException("Erro ao Listar Coletor.");
     }
 }
Example #8
0
        public int Inserir(HistoricoTColetorVO tcoletorvo)
        {
            var banco = new SINAF_WebEntities();

            var query = new HistoricoTColetor
            {
                NumeroColetor = tcoletorvo.NumeroColetor,

                DataUltimoSincronismo = DateTime.Now,

                NumeroTotalSincronismo = 0,

                NumeroTotalEntrevista = 0,
            };

            banco.AddToHistoricoTColetor(query);
            banco.SaveChanges();

            tcoletorvo.IDHistoricoColetor = query.IDHistoricoColetor;

            return(query.IDHistoricoColetor);
        }