Example #1
0
        public InfoSlotsDecisaoModel CarregarTotaisVisaoConsolidada()
        {
            InfoSlotsDecisaoModel retorno = new InfoSlotsDecisaoModel();

            string SQL = @"SELECT SUM (QuantidadeLugaresInterno) 
                        FROM CidadeParticipante (NOLOCK) cp
                        WHERE cp.Inativo = 0 ";

            string SQL2 = @"SELECT SUM (QuantidadeLugares) 
                        FROM CidadeParticipante (NOLOCK) cp
                        WHERE cp.Inativo = 0 ";

            string SQL3 = @"SELECT COUNT (1) 
                        FROM IndicadoInterno (NOLOCK) Indicado 
                        INNER JOIN CidadeParticipante (NOLOCK) cp ON (Indicado.CidadeParticipanteID = cp.ID)
                        WHERE cp.Inativo = 0 AND Indicado.Condutor = 1";

            string SQL4 = @"SELECT COUNT (1) 
                        FROM Indicado (NOLOCK) Indicado 
                        INNER JOIN CidadeParticipante (NOLOCK) cp ON (Indicado.CidadeParticipanteID = cp.ID)
                        WHERE cp.Inativo = 0 AND Indicado.Condutor = 1";

            using (DbConnection con = _db.CreateConnection())
            {
                con.Open();

                retorno.SlotsTotais            = con.ExecuteScalar <int>(SQL);
                retorno.SlotsTotais           += con.ExecuteScalar <int>(SQL2);
                retorno.SlostsOcupadosInternos = con.ExecuteScalar <int>(SQL3);
                retorno.SlotsOcupados          = con.ExecuteScalar <int>(SQL4);

                con.Close();
            }

            return(retorno);
        }
Example #2
0
        public InfoSlotsDecisaoModel CarregarTotaisVisaoInterna()
        {
            InfoSlotsDecisaoModel retorno = new InfoSlotsDecisaoModel();

            string SQL = @"SELECT SUM (QuantidadeLugaresInterno) 
                        FROM CidadeParticipante (NOLOCK) cp
                        WHERE cp.Inativo = 0 ";

            string SQL2 = @"SELECT COUNT (1) 
                        FROM IndicadoInterno (NOLOCK) Indicado 
                        INNER JOIN CidadeParticipante (NOLOCK) cp ON (Indicado.CidadeParticipanteID = cp.ID)
                        WHERE cp.Inativo = 0 AND Indicado.Condutor = 1 AND Indicado.Inativo = 0";

            string SQL3 = @"SELECT COUNT (1)
                        FROM IndicadoInterno (NOLOCK) Indicado 
                        INNER JOIN CidadeParticipante (NOLOCK) cp ON (Indicado.CidadeParticipanteID = cp.ID)
                        WHERE (SELECT DATEDIFF(YEAR, Indicado.DataNascimento, @Hoje)) > 60 
                        AND cp.Inativo = 0 AND Indicado.Condutor = 1 AND Indicado.Inativo = 0";

            string SQL4 = @"SELECT COUNT (1)
                        FROM IndicadoInterno (NOLOCK) Indicado 
                        INNER JOIN CidadeParticipante (NOLOCK) cp ON (Indicado.CidadeParticipanteID = cp.ID)
                        WHERE (SELECT DATEDIFF(YEAR, Indicado.DataNascimento, @Hoje)) < 18 
                        AND cp.Inativo = 0 AND Indicado.Condutor = 1 AND Indicado.Inativo = 0";

            string SQL5 = @"SELECT COUNT (1)
                        FROM IndicadoInterno (NOLOCK) Indicado 
                        INNER JOIN CidadeParticipante (NOLOCK) cp ON (Indicado.CidadeParticipanteID = cp.ID)
                        WHERE (SELECT DATEDIFF(YEAR, Indicado.DataNascimento, @Hoje)) >= 18 AND (SELECT DATEDIFF(YEAR, Indicado.DataNascimento, @Hoje)) <= 35
                        AND cp.Inativo = 0 AND Indicado.Condutor = 1 AND Indicado.Inativo = 0";

            string SQL6 = @"SELECT COUNT (1)
                        FROM IndicadoInterno (NOLOCK) Indicado 
                        INNER JOIN CidadeParticipante (NOLOCK) cp ON (Indicado.CidadeParticipanteID = cp.ID)
                        WHERE (SELECT DATEDIFF(YEAR, Indicado.DataNascimento, @Hoje)) >= 35 AND (SELECT DATEDIFF(YEAR, Indicado.DataNascimento, @Hoje)) <= 60
                        AND cp.Inativo = 0 AND Indicado.Condutor = 1 AND Indicado.Inativo = 0";

            string SQL7 = @"SELECT COUNT (1)
                        FROM IndicadoInterno (NOLOCK) Indicado 
                        INNER JOIN CidadeParticipante (NOLOCK) cp ON (Indicado.CidadeParticipanteID = cp.ID)
                        WHERE Indicado.Genero = 'F'
                        AND cp.Inativo = 0 AND Indicado.Condutor = 1 AND Indicado.Inativo = 0";

            string SQL8 = @"SELECT COUNT (1)
                        FROM IndicadoInterno (NOLOCK) Indicado 
                        INNER JOIN CidadeParticipante (NOLOCK) cp ON (Indicado.CidadeParticipanteID = cp.ID)
                        WHERE Indicado.Genero = 'M'
                        AND cp.Inativo = 0 AND Indicado.Condutor = 1 AND Indicado.Inativo = 0";


            using (DbConnection con = _db.CreateConnection())
            {
                con.Open();
                retorno.SlotsTotais   = con.ExecuteScalar <int>(SQL);
                retorno.SlotsOcupados = con.ExecuteScalar <int>(SQL2);
                retorno.Maior60       = con.ExecuteScalar <int>(SQL3, new
                {
                    Hoje = DateTime.Today
                });
                retorno.Menor18 = con.ExecuteScalar <int>(SQL4, new
                {
                    Hoje = DateTime.Today
                });
                retorno.Entre18_35 = con.ExecuteScalar <int>(SQL5, new
                {
                    Hoje = DateTime.Today
                });
                retorno.Entre35_60 = con.ExecuteScalar <int>(SQL6, new
                {
                    Hoje = DateTime.Today
                });
                retorno.Mulheres = con.ExecuteScalar <int>(SQL7);
                retorno.Homens   = con.ExecuteScalar <int>(SQL8);
                con.Close();
            }

            return(retorno);
        }