Exemplo n.º 1
0
        /* Consulta información procesada de las tres categorias: subregistro, registrados y extemporáneos. */
        public SubregistroNacimientosRespuesta ConsultaSubregistroNacimientos(ConsultarViewModel consultarViewModel)
        {
            Servicio            servicio            = new Servicio();
            ConsultasViewModel  modelView           = new ConsultasViewModel();
            SubregistroPeticion solicitudDeConsulta = new SubregistroPeticion();
            /* Tomando datos de web. */
            Collection <string>    ColAnos       = new Collection <string>();
            Collection <string>    ColMeses      = new Collection <string>();
            Collection <Municipio> ColMunicipios = new Collection <Municipio>();

            /* Pasando valores. */
            foreach (string anio in consultarViewModel.AniosSeleccionados)
            {
                ColAnos.Add(anio);
            }

            foreach (string mes in consultarViewModel.MesesSeleccionados)
            {
                ColMeses.Add(mes);
            }

            foreach (string municipioId in consultarViewModel.MunicipiosSeleccionados)
            {
                Municipio municipio = new Municipio();
                municipio.MpioId = int.Parse(municipioId);
                ColMunicipios.Add(municipio);
            }
            solicitudDeConsulta.ColAnos       = ColAnos;
            solicitudDeConsulta.ColMeses      = ColMeses;
            solicitudDeConsulta.ColMunicipios = ColMunicipios;
            /* Obtiene resultados de la consulta. */
            SubregistroNacimientosRespuesta respuestaDeConsulta = servicio.ConsultaSubregistroNacimientos(solicitudDeConsulta);

            return(respuestaDeConsulta);
        }
Exemplo n.º 2
0
        public SubregistroNacimientosRespuesta ConsultaSubregistroNacimientos(Collection <string> colAnos, Collection <string> colMeses, Collection <Municipio> colMunicipios)
        {
            SubregistroNacimientosRespuesta respuesta = new SubregistroNacimientosRespuesta();

            try
            {
                IList <string> anosLista = new List <string>(colAnos);
                string         anosUnion = string.Join(",", anosLista);

                IList <string> mesesLista = new List <string>(colMeses);
                string         mesesUnion = string.Join(",", mesesLista);

                IList <string> municipiosLista = new List <string>();
                foreach (Municipio m in colMunicipios)
                {
                    municipiosLista.Add(m.MpioId.ToString());
                }
                string municipiosUnion = string.Join(",", municipiosLista);

                respuesta = reporteDAO.ConsultaDTSubregistroNacimientos(anosUnion, mesesUnion, municipiosUnion);

                int total = 0;
                int totalConDuplicados = 0;
                foreach (SubregistroTotal s in respuesta.ColTotales)
                {
                    if (s.IdGrupo < Constantes.REGISTRO_DUPLICADO)
                    {
                        total += s.Total;
                    }
                    totalConDuplicados += s.Total;
                }

                respuesta.Total = totalConDuplicados;
                decimal d = (decimal)totalConDuplicados * 100 / total;
                respuesta.TotalPorcentaje = Math.Round(d, 2);

                foreach (SubregistroTotal s in respuesta.ColTotales)
                {
                    //if (s.IdGrupo < Constantes.REGISTRO_DUPLICADO)
                    //{
                    d = (decimal)s.Total * 100 / total;
                    s.TotalPorcentaje = Math.Round(d, 2);

                    int caseSwitch = s.IdGrupo;

                    switch (caseSwitch)
                    {
                    case Constantes.SUBREGISTRO:
                        respuesta.TotalSubregistro      = s.Total;
                        respuesta.PorcentajeSubregistro = s.TotalPorcentaje;
                        break;

                    case Constantes.REGISTRO_OPORTUNO:
                        respuesta.TotalRegistroOportuno      = s.Total;
                        respuesta.PorcentajeRegistroOportuno = s.TotalPorcentaje;
                        break;

                    case Constantes.REGISTRO_EXTEMPORANEO:
                        respuesta.TotalRegistroExtemporaneo      = s.Total;
                        respuesta.PorcentajeRegistroExtemporaneo = s.TotalPorcentaje;
                        break;

                    case Constantes.REGISTRO_DUPLICADO:
                        respuesta.TotalRegistroDuplicado      = s.Total;
                        respuesta.PorcentajeRegistroDuplicado = s.TotalPorcentaje;
                        break;

                    default:
                        Console.WriteLine("Default case");
                        break;
                    }
                    //}
                }

                return(respuesta);
            }
            catch (DAOException e)
            {
                Bitacora.Error(e.Message);
                if (e.Codigo == 1)
                {
                    throw new BusinessException(e.Message);
                }
                else
                {
                    throw new BusinessException("No se completó la consulta de subregistro, favor de intentar nuevamente: " + e.Message);
                }
            }
        }
        public ActionResult SubRegistroInformacion(string AniosJson, string MesesJson, string MpiosJson, string MesesDesc, string AniosDesc, string MpiosDesc)
        {
            Servicio servicio = new Servicio();
            dynamic  anios    = JsonConvert.DeserializeObject(AniosJson);
            dynamic  meses    = JsonConvert.DeserializeObject(MesesJson);
            dynamic  mpios    = JsonConvert.DeserializeObject(MpiosJson);

            SubregistroPeticion peticionSubRegistro           = new SubregistroPeticion();
            ReporteTotalesSubregistroPeticion peticionReporte = new ReporteTotalesSubregistroPeticion();

            peticionSubRegistro.ColAnos = new Collection <string>();
            peticionReporte.ColAnos     = new Collection <string>();
            foreach (string anio in anios)
            {
                peticionSubRegistro.ColAnos.Add(anio);
                peticionReporte.ColAnos.Add(anio);
            }

            peticionSubRegistro.ColMeses = new Collection <string>();
            peticionReporte.ColMeses     = new Collection <string>();
            foreach (string mes in meses)
            {
                peticionSubRegistro.ColMeses.Add(mes);
                peticionReporte.ColMeses.Add(mes);
            }

            peticionSubRegistro.ColMunicipios = new Collection <Municipio>();
            peticionReporte.ColMunicipios     = new Collection <Municipio>();
            foreach (string mpio in mpios)
            {
                Municipio municipio = new Municipio
                {
                    MpioId = Convert.ToInt32(mpio)
                };

                peticionSubRegistro.ColMunicipios.Add(municipio);
                peticionReporte.ColMunicipios.Add(municipio);
            }

            SubregistroNacimientosRespuesta SubregistroRespuesta = servicio.ConsultaSubregistroNacimientos(peticionSubRegistro);

            ReporteSubregistroRespuesta reporteRespuesta = servicio.ConsultarReporteTotalesSubregistro(peticionReporte);

            dynamic model = new ExpandoObject();

            model.TotalSubregistro      = SubregistroRespuesta.TotalSubregistro;
            model.PorcentajeSubregistro = SubregistroRespuesta.PorcentajeSubregistro;

            model.TotalRegistroOportuno      = SubregistroRespuesta.TotalRegistroOportuno;
            model.PorcentajeRegistroOportuno = SubregistroRespuesta.PorcentajeRegistroOportuno;

            model.TotalRegistroExtemporaneo      = SubregistroRespuesta.TotalRegistroExtemporaneo;
            model.PorcentajeRegistroExtemporaneo = SubregistroRespuesta.PorcentajeRegistroExtemporaneo;

            model.TotalRegistroDuplicado      = SubregistroRespuesta.TotalRegistroDuplicado;
            model.PorcentajeRegistroDuplicado = SubregistroRespuesta.PorcentajeRegistroDuplicado;

            model.TotalGeneral      = SubregistroRespuesta.Total;
            model.PorcentajeGeneral = SubregistroRespuesta.TotalPorcentaje;

            model.ColDataTables = SubregistroRespuesta.ColDataTables;

            model.ColCabeceros = reporteRespuesta.ColCabeceros;
            model.ColFilas     = reporteRespuesta.ColFilas;

            model.FechaReporte = DateTime.Now.ToString("dd/MM/yyyy h:mm tt", CultureInfo.InvariantCulture);
            model.MesesReporte = string.IsNullOrEmpty(MesesDesc) ? "Todos": MesesDesc;
            model.AniosReporte = string.IsNullOrEmpty(AniosDesc) ? "Todos" : AniosDesc;
            model.MpiosReporte = string.IsNullOrEmpty(MpiosDesc) ? "Todos" : MpiosDesc;

            //if (Request.IsAjaxRequest())
            return(PartialView(model));
        }
Exemplo n.º 4
0
        public SubregistroNacimientosRespuesta ConsultaSubregistroNacimientos(string anosUnion, string mesesUnion, string municipiosUnion)
        {
            SubregistroNacimientosRespuesta SubregistroNacimientosRespuesta = new SubregistroNacimientosRespuesta();

            try
            {
                using (DataSet dataSet = new DataSet())
                {
                    dataSet.Locale = CultureInfo.InvariantCulture;

                    EjecutaProcedimiento(PRN_CONSULTA_SUBREGISTRO_NACIMIENTOS, CreaParametrosSubregistroNacimientos(anosUnion, mesesUnion, municipiosUnion), dataSet);

                    if (this.Codigo == 0)
                    {
                        //if (dataSet != null && dataSet.Tables.Count > 0
                        //    && dataSet.Tables[0].Rows.Count > 0)
                        //{

                        //    SubregistroNacimientosRespuesta.ColTotales = new Collection<SubregistroTotal>();

                        //    foreach (DataRow r in dataSet.Tables[0].Rows)
                        //    {
                        //        SubregistroTotal sub = new SubregistroTotal
                        //        {
                        //            IdGrupo = r.Field<int>("IdGrupo"),
                        //            NombreGrupo = r.Field<string>("NombreGrupo"),
                        //            Total = r.Field<int>("Total")
                        //        };

                        //        SubregistroNacimientosRespuesta.ColTotales.Add(sub);
                        //    }
                        //}

                        if (dataSet != null && dataSet.Tables.Count > 0 &&
                            dataSet.Tables[1].Rows.Count > 0)
                        {
                            SubregistroNacimientosRespuesta.ColSubregistros = new Collection <Subregistro>();

                            foreach (DataRow r in dataSet.Tables[1].Rows)
                            {
                                Subregistro sub = new Subregistro
                                {
                                    Folio           = r.Field <string>("Folio"),
                                    FechaNacimiento = r.Field <string>("FechaNacimiento"),
                                    HoraNacimiento  = r.Field <string>("HoraNacimiento"),
                                    SexoId          = r.Field <int>("SexoId"),
                                    SexoDesc        = r.Field <string>("SexoDesc"),
                                    EdoId           = r.Field <int>("EdoId"),
                                    EdoDesc         = r.Field <string>("EdoDesc"),
                                    MpioId          = r.Field <int>("MpioId"),
                                    MpioDesc        = r.Field <string>("MpioDesc"),
                                    LocId           = r.Field <int>("LocId"),
                                    LocDesc         = r.Field <string>("LocDesc"),
                                    Calle           = r.Field <string>("Calle"),
                                    NoExt           = r.Field <string>("NoExt"),
                                    NoInt           = r.Field <string>("NoInt"),
                                    Edad            = r.Field <int>("Edad"),
                                    NumNacimiento   = r.Field <int>("NumNacimiento"),
                                    Ocupacion       = r.Field <string>("Ocupacion"),
                                    EdoCivilId      = r.Field <int>("EdoCivilId"),
                                    EdoCivilDesc    = r.Field <string>("EdoCivilDesc"),
                                    EscolId         = r.Field <int>("EscolId"),
                                    EscolDesc       = r.Field <string>("EscolDesc")
                                };

                                SubregistroNacimientosRespuesta.ColSubregistros.Add(sub);
                            }
                        }

                        if (dataSet != null && dataSet.Tables.Count > 0 &&
                            dataSet.Tables[2].Rows.Count > 0)
                        {
                            SubregistroNacimientosRespuesta.ColOportunos = new Collection <Subregistro>();

                            foreach (DataRow r in dataSet.Tables[2].Rows)
                            {
                                Subregistro sub = new Subregistro
                                {
                                    Folio           = r.Field <string>("Folio"),
                                    FechaNacimiento = r.Field <string>("FechaNacimiento"),
                                    HoraNacimiento  = r.Field <string>("HoraNacimiento"),
                                    SexoId          = r.Field <int>("SexoId"),
                                    SexoDesc        = r.Field <string>("SexoDesc"),
                                    EdoId           = r.Field <int>("EdoId"),
                                    EdoDesc         = r.Field <string>("EdoDesc"),
                                    MpioId          = r.Field <int>("MpioId"),
                                    MpioDesc        = r.Field <string>("MpioDesc"),
                                    LocId           = r.Field <int>("LocId"),
                                    LocDesc         = r.Field <string>("LocDesc"),
                                    Calle           = r.Field <string>("Calle"),
                                    NoExt           = r.Field <string>("NoExt"),
                                    NoInt           = r.Field <string>("NoInt"),
                                    Edad            = r.Field <int>("Edad"),
                                    NumNacimiento   = r.Field <int>("NumNacimiento"),
                                    Ocupacion       = r.Field <string>("Ocupacion"),
                                    EdoCivilId      = r.Field <int>("EdoCivilId"),
                                    EdoCivilDesc    = r.Field <string>("EdoCivilDesc"),
                                    EscolId         = r.Field <int>("EscolId"),
                                    EscolDesc       = r.Field <string>("EscolDesc")
                                };

                                SubregistroNacimientosRespuesta.ColOportunos.Add(sub);
                            }
                        }

                        if (dataSet != null && dataSet.Tables.Count > 0 &&
                            dataSet.Tables[3].Rows.Count > 0)
                        {
                            SubregistroNacimientosRespuesta.ColExtemporaneos = new Collection <Subregistro>();

                            foreach (DataRow r in dataSet.Tables[3].Rows)
                            {
                                Subregistro sub = new Subregistro
                                {
                                    Folio           = r.Field <string>("Folio"),
                                    FechaNacimiento = r.Field <string>("FechaNacimiento"),
                                    HoraNacimiento  = r.Field <string>("HoraNacimiento"),
                                    SexoId          = r.Field <int>("SexoId"),
                                    SexoDesc        = r.Field <string>("SexoDesc"),
                                    EdoId           = r.Field <int>("EdoId"),
                                    EdoDesc         = r.Field <string>("EdoDesc"),
                                    MpioId          = r.Field <int>("MpioId"),
                                    MpioDesc        = r.Field <string>("MpioDesc"),
                                    LocId           = r.Field <int>("LocId"),
                                    LocDesc         = r.Field <string>("LocDesc"),
                                    Calle           = r.Field <string>("Calle"),
                                    NoExt           = r.Field <string>("NoExt"),
                                    NoInt           = r.Field <string>("NoInt"),
                                    Edad            = r.Field <int>("Edad"),
                                    NumNacimiento   = r.Field <int>("NumNacimiento"),
                                    Ocupacion       = r.Field <string>("Ocupacion"),
                                    EdoCivilId      = r.Field <int>("EdoCivilId"),
                                    EdoCivilDesc    = r.Field <string>("EdoCivilDesc"),
                                    EscolId         = r.Field <int>("EscolId"),
                                    EscolDesc       = r.Field <string>("EscolDesc")
                                };

                                SubregistroNacimientosRespuesta.ColExtemporaneos.Add(sub);
                            }
                        }
                    }
                    else
                    {
                        throw new EmptyDataException(this.Mensaje);
                    }
                }
            }
            catch (Exception de)
            {
                Bitacora.Error(de.Message);
                if (de is EmptyDataException)
                {
                    throw new DAOException(1, de.Message);
                }
                throw new DAOException(-1, de.Message);
            }

            return(SubregistroNacimientosRespuesta);
        }