Esempio n. 1
0
        public List <EstadisticaEntity> ConsultarEstadisticas(int codigoCliente)
        {
            List <EstadisticaEntity> respuesta = new List <EstadisticaEntity>();

            try
            {
                List <SqlParameter> listParameter = new List <SqlParameter>();

                listParameter.Add(new SqlParameter
                {
                    ParameterName = "@CODIGO_CLIENTE",
                    SqlDbType     = SqlDbType.Int,
                    Value         = codigoCliente
                });

                DataSet resultado = GetDataBaseHelper().ExecuteProcedureToDataSet("SP_CONSULTAR_ESTADISTICAS", listParameter);
                foreach (DataRow row in resultado.Tables[0].Rows)
                {
                    EstadisticaEntity estadistica = new EstadisticaEntity();
                    if (row["PRECIO"] != DBNull.Value)
                    {
                        estadistica.Precio = float.Parse(row["PRECIO"].ToString());
                    }
                    if (row["PROVEEDOR"] != DBNull.Value)
                    {
                        estadistica.Proveedor = row["PROVEEDOR"].ToString();
                    }
                    if (row["CATALOGO"] != DBNull.Value)
                    {
                        estadistica.Catalogo = row["CATALOGO"].ToString();
                    }
                    if (row["COMPLETO"] != DBNull.Value)
                    {
                        estadistica.Completo = row["COMPLETO"].ToString();
                    }

                    respuesta.Add(estadistica);
                }
            }
            catch (Exception exc)
            {
                throw new Exception(exc.Message);
            }

            return(respuesta);
        }
Esempio n. 2
0
        //public abstract List<EstadisticaEntity> GetEstadisticasEncuestas(int plaza, int idencuesta, DateTime finicio, DateTime ffin);



        /// <summary>
        /// Converts data from reader to entity
        /// </summary>
        protected virtual EstadisticaEntity GetEstadisticaFromReader(IDataReader reader)
        {
            EstadisticaEntity entity_Estadistica = null;

            try
            {
                entity_Estadistica = new EstadisticaEntity();
                entity_Estadistica.IdEstadistica  = (int?)(GetFromReader(reader, "IdEstadistica"));
                entity_Estadistica.NombreEncuesta = (String)(GetFromReader(reader, "NombreEncuesta", IsString: true));
                entity_Estadistica.Pregunta       = (String)(GetFromReader(reader, "Pregunta", IsString: true));
                entity_Estadistica.Respuesta      = (String)(GetFromReader(reader, "Respuesta", IsString: true));
                entity_Estadistica.Cantidad       = (int?)(GetFromReader(reader, "Cantidad"));
            }
            catch (Exception ex)
            {
                throw new Exception("Error converting Estadistica data to entity", ex);
            }
            return(entity_Estadistica);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets all Estadistica
        ///</summary>
        //public override List<EstadisticaEntity> GetEstadistica()
        //{
        //    List<EstadisticaEntity> EstadisticaList = new List<EstadisticaEntity>();
        //    using (SqlConnection connection = new SqlConnection(SoftvSettings.Settings.Estadistica.ConnectionString))
        //    {

        //        SqlCommand comandoSql = CreateCommand("Softv_EstadisticaGet", connection);
        //        IDataReader rd = null;
        //        try
        //        {
        //            if (connection.State == ConnectionState.Closed)
        //                connection.Open();
        //            rd = ExecuteReader(comandoSql);

        //            while (rd.Read())
        //            {
        //                EstadisticaList.Add(GetEstadisticaFromReader(rd));
        //            }
        //        }
        //        catch (Exception ex)
        //        {
        //            throw new Exception("Error getting data Estadistica " + ex.Message, ex);
        //        }
        //        finally
        //        {
        //            if (connection != null)
        //                connection.Close();
        //            if (rd != null)
        //                rd.Close();
        //        }
        //    }
        //    return EstadisticaList;
        //}



        public override List <EstadisticaEntity> GetEstadistica(int?IdUniverso, int?IdEncuesta, string Inicio, string Fin)
        {
            List <EstadisticaEntity> EncuestaList = new List <EstadisticaEntity>();

            using (SqlConnection connection = new SqlConnection(SoftvSettings.Settings.Estadistica.ConnectionString))
            {
                SqlCommand comandoSql = CreateCommand("GraficasPreguntas", connection);
                AssingParameter(comandoSql, "@IdEncuesta", IdEncuesta);
                AssingParameter(comandoSql, "@IdUniverso", IdUniverso);
                AssingParameter(comandoSql, "@FechaI", Inicio);
                AssingParameter(comandoSql, "@FechaF", Fin);
                IDataReader rd = null;
                try
                {
                    if (connection.State == ConnectionState.Closed)
                    {
                        connection.Open();
                    }
                    rd = ExecuteReader(comandoSql);
                    int total = rd.FieldCount;
                    while (rd.Read())
                    {
                        EstadisticaEntity a = new EstadisticaEntity();
                        a.Cantidad         = Int32.Parse(rd[6].ToString());
                        a.NombreEncuesta   = rd[0].ToString();
                        a.IdTipoPregunta   = Int32.Parse(rd[2].ToString());
                        a.IdPregunta       = Int32.Parse(rd[1].ToString());
                        a.Pregunta         = rd[3].ToString();
                        a.Respuesta        = rd[5].ToString();
                        a.RespuestaAbierta = rd[4].ToString();
                        a.RespuestaAbierta = rd[4].ToString();
                        EncuestaList.Add(a);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Error getting data Encuesta " + ex.Message, ex);
                }
                finally
                {
                    if (connection != null)
                    {
                        connection.Close();
                    }
                    if (rd != null)
                    {
                        rd.Close();
                    }
                }
            }

            //List<pregunta> pregunta = new List<pregunta>();


            //  var r=  EncuestaList.GroupBy(o=>o.IdPregunta).Select(o=>o.Key);
            //  foreach (var d in r)
            //  {
            //      var e = EncuestaList.Where(i=>i.IdPregunta==d.Value);

            //      foreach(var  f in e){

            //           pregunta p = new pregunta();
            //          p.titulo = f.Pregunta;
            //           List<respuestas> l = new List<respuestas>();
            //          foreach (var a in EncuestaList.Where(o => o.IdPregunta == f.IdPregunta))
            //          {
            //              respuestas r1 =new respuestas();
            //              r1.cuantos=a.Cantidad.Value;
            //              r1.respuesta = a.Respuesta;
            //              l.Add(r1);
            //          }
            //          p.respuesta = l;

            //          pregunta.Add(p);
            //      }
            //  }


            return(EncuestaList);
        }