Пример #1
0
 public void AtribuirEstrutura(EstruturaEntregaAreaCep estruturaEntregaAreaCep)
 {
     this.EntregaAreaID.Valor = estruturaEntregaAreaCep.EntregaAreaID;
     this.Control.ID          = estruturaEntregaAreaCep.EntregaAreaCepID;
     this.CepInicial.Valor    = estruturaEntregaAreaCep.CepInicio.ToString();
     this.CepFinal.Valor      = estruturaEntregaAreaCep.CepFim.ToString();
 }
Пример #2
0
        public bool VerificaExistente(EstruturaEntregaAreaCep estruturaEntregaAreaCepAdd)
        {
            try
            {
                bool   retorno = true;
                string sql     = @"select top 1 ID from tEntregaAreaCep
                                where  
                                (CepInicial <= " + estruturaEntregaAreaCepAdd.CepInicio + " and CepFinal >= " + estruturaEntregaAreaCepAdd.CepInicio + @")
                                or
                                (CepInicial <= " + estruturaEntregaAreaCepAdd.CepFim + " and CepFinal >= " + estruturaEntregaAreaCepAdd.CepFim + ")";

                bd.Consulta(sql);

                if (bd.Consulta().Read())
                {
                    retorno = false;
                }
                return(retorno);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
 public void Inserir(EstruturaEntregaAreaCep estruturaEntregaAreaCep, int EntregaAreaID)
 {
     estruturaEntregaAreaCep.EntregaAreaID = EntregaAreaID;
     this.AtribuirEstrutura(estruturaEntregaAreaCep);
     this.Inserir();
 }
Пример #4
0
 public void Atualizar(EstruturaEntregaAreaCep estruturaEntregaAreaCep)
 {
     this.AtribuirEstrutura(estruturaEntregaAreaCep);
     this.Atualizar();
 }
Пример #5
0
 public void Inserir(EstruturaEntregaAreaCep estruturaEntregaAreaCep)
 {
     this.AtribuirEstrutura(estruturaEntregaAreaCep);
     this.Inserir();
 }
Пример #6
0
        public List <EstruturaEntregaArea> ListarNovo()
        {
            try
            {
                List <EstruturaEntregaArea>    lista    = new List <EstruturaEntregaArea>();
                EstruturaEntregaArea           area     = new EstruturaEntregaArea();
                List <EstruturaEntregaAreaCep> ListaCep = new List <EstruturaEntregaAreaCep>();
                EstruturaEntregaAreaCep        cep      = new EstruturaEntregaAreaCep();
                List <int> Regionais = new List <int>();

                string sql = @"SELECT 
                                a.ID as AreaID, 
                                a.Nome, c.ID AS CEPID, c.CEPInicial, c.CEPFinal, ra.RegionalID
                                FROM tEntregaArea a (NOLOCK)
                                INNER JOIN tEntregaAreaCep c (NOLOCK) on c.EntregaAreaId = a.id
                                left JOIN tRegionalArea ra (NOLOCK) ON ra.AreaID = a.ID
                                ORDER BY a.Nome";

                bd.Consulta(sql);


                while (bd.Consulta().Read())
                {
                    if (lista.Where(c => c.ID == bd.LerInt("AreaID")).Count() == 0)
                    {
                        ListaCep  = new List <EstruturaEntregaAreaCep>();
                        Regionais = new List <int>();

                        area = new EstruturaEntregaArea()
                        {
                            ID        = bd.LerInt("AreaID"),
                            Nome      = bd.LerString("Nome"),
                            ListaCEP  = ListaCep,
                            Regionais = Regionais,
                        };

                        lista.Add(area);
                    }

                    if (ListaCep.Where(c => c.EntregaAreaCepID == bd.LerInt("CEPID")).Count() == 0)
                    {
                        cep = new EstruturaEntregaAreaCep()
                        {
                            EntregaAreaCepID = bd.LerInt("CEPID"),
                            CepInicio        = bd.LerString("CEPInicial"),
                            CepFim           = bd.LerString("CEPFinal"),
                            EntregaAreaID    = bd.LerInt("AreaID"),
                        };

                        ListaCep.Add(cep);
                    }

                    Regionais.Add(bd.LerInt("RegionalID"));
                }
                return(lista);
            }
            finally
            {
                bd.Fechar();
            }
        }