Ejemplo n.º 1
0
        public void Editar(long Id, Madre madre)
        {
            Madre _madre = null;

              _madre = (from p in context.Madres
                    where p.Id == Id
                    select p).FirstOrDefault();

              _madre.IdSesion = SessionManager.getSessionIdentifier();
              _madre.FechaUltimaTransaccion = DateTime.Now;
              _madre.FechaRegistro = DateTime.Now;
              _madre.EstadoRegistro = TipoEstadoRegistro.VigenteRegistroModificado;
              _madre.EstadoSincronizacion = TipoEstadoSincronizacion.Pendiente;

              _madre.Nombres = madre.Nombres;
              _madre.NombreCompleto = madre.NombreCompleto;
              _madre.PrimerApellido = madre.PrimerApellido;
              _madre.SegundoApellido = madre.SegundoApellido;
              _madre.TercerApellido = madre.TercerApellido;
              _madre.DocumentoIdentidad = madre.DocumentoIdentidad;
              _madre.TipoDocumentoIdentidad = madre.TipoDocumentoIdentidad;
              _madre.FechaNacimiento = madre.FechaNacimiento;
              _madre.IdDepartamento = madre.IdDepartamento;
              _madre.IdProvincia = madre.IdProvincia;
              _madre.IdMunicipio = madre.IdMunicipio;
              _madre.LocalidadNacimiento = madre.LocalidadNacimiento;
              _madre.Defuncion = madre.Defuncion;
              _madre.Observaciones = madre.Observaciones;

              context.SaveChanges();
        }
Ejemplo n.º 2
0
        public List<Madre> BuscarSemejantes(ParametrosBusqueda parBusqueda)
        {
            long identificador = Convert.ToInt64(parBusqueda.Identificador);
            MadreTemporal madreTemp = new MadreTemporal();
            madreTemp = Listar().Where(m => m.Id == identificador).FirstOrDefault();

            Dictionary<string, object> propiedadesBusqueda = ObtenerElementos(parBusqueda, MemberTypes.Property);

            List<Madre> madresCandidatas = new List<Madre>();
            Madre peorSemejanza = new Madre();

            int distanciaCalculada;
            int peorDistancia = -1;

            //string strParametrosMadreTemporal = madreTemp.NombreCompleto;
            string cadenaMadreTemporal = ConstruirParametroMadreTemporal(madreTemp, propiedadesBusqueda);

            //foreach (Madre ma in madre.Listar())
            foreach (Madre ma in db.Madres.ToList())
            {
                distanciaCalculada = Distancia.Levenshtein(cadenaMadreTemporal, ConstruirParametroMadre(ma, propiedadesBusqueda));
                if (madresCandidatas.Count < 10)
                {
                    ma.IdMunicipio = distanciaCalculada;    //**
                    madresCandidatas.Add(ma);
                    if (distanciaCalculada > peorDistancia)
                    {
                        peorDistancia = distanciaCalculada;
                        peorSemejanza = ma;
                    }
                }
                else
                {
                    if (distanciaCalculada < peorDistancia)
                    {
                        ma.IdMunicipio = distanciaCalculada;    //**
                        madresCandidatas.Remove(peorSemejanza);
                        madresCandidatas.Add(ma);

                        // Peor distancia entre los 10
                        peorDistancia = -1;
                        foreach (var item in madresCandidatas)
                        {
                            distanciaCalculada = Distancia.Levenshtein(madreTemp.NombreCompleto, item.NombreCompleto);
                            if (distanciaCalculada > peorDistancia)
                            {
                                peorDistancia = distanciaCalculada;
                                peorSemejanza = item;
                            }
                        }
                    }
                }
            }
            return madresCandidatas.OrderBy(m => m.IdMunicipio).ToList();
        }
Ejemplo n.º 3
0
        public void Crear(Madre madre)
        {
            madre.Id = IdentifierGenerator.NewId();
              madre.IdSesion = SessionManager.getSessionIdentifier();
              madre.FechaUltimaTransaccion = DateTime.Now;
              madre.FechaRegistro = DateTime.Now;
              madre.EstadoRegistro = TipoEstadoRegistro.VigenteNuevoRegistro;
              madre.EstadoSincronizacion = TipoEstadoSincronizacion.Pendiente;
              madre.DescripcionEstadoSincronizacion = "";

              context.Madres.Add(madre);

              context.SaveChanges();
        }
Ejemplo n.º 4
0
        public ActionResult Create(Madre madre)
        {
            if (ModelState.IsValid)
            {
                db.Madres.Add(madre);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.IdDepartamento = new SelectList(db.Departamentos, "Id", "DescripcionEstadoSincronizacion", madre.IdDepartamento);
            ViewBag.IdProvincia = new SelectList(db.Provincias, "Id", "DescripcionEstadoSincronizacion", madre.IdProvincia);
            ViewBag.IdMunicipio = new SelectList(db.Municipios, "Id", "DescripcionEstadoSincronizacion", madre.IdMunicipio);
            return View(madre);
        }
Ejemplo n.º 5
0
        public string Madres()
        {
            ModeloRevisionManual mrm = new ModeloRevisionManual();
            mrm.EliminarTodoMadre();

            string connectionString = "Data Source=HERNAN-PC04;Initial Catalog=BDPersonas_new;User ID=sa; password=123456";
            string queryString = @"select
                                    Nombres,
                                    PrimerApellido,
                                    SegundoApellido,
                                    Nombres+PrimerApellido+SegundoApellido AS 'NombreCompleto',
                                    DocumentoIdentidad,
                                    0 AS 'TipoDocumentoIdentidad',
                                    FechaNacimiento
                                from SECC_1A
                                where idS1_A < 1000 and S1_02 = 2 and FechaNacimiento is not null";

            string resultado = "";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    Madre madre = new Madre();

                    madre.Id = IdentifierGenerator.NewId();
                    madre.IdSesion = 1;
                    madre.FechaUltimaTransaccion = DateTime.Now;
                    madre.FechaRegistro = DateTime.Now;
                    madre.DescripcionEstadoSincronizacion = "";

                    madre.Nombres = reader[0].ToString();
                    madre.PrimerApellido = reader[1].ToString();
                    madre.SegundoApellido = reader[2].ToString();
                    madre.TercerApellido = "";
                    madre.NombreCompleto = madre.Nombres + madre.PrimerApellido + madre.SegundoApellido + madre.TercerApellido;
                    madre.DocumentoIdentidad = reader[4].ToString();
                    madre.TipoDocumentoIdentidad = TipoDocumentoIdentidad.CarnetIdentidad;
                    madre.FechaNacimiento = Convert.ToDateTime(reader[6].ToString());

                    //madre.IdDepartamento = 69;
                    //madre.IdProvincia = 540;
                    //madre.IdMunicipio = 2254;

                    madre.IdDepartamento = 1640861101374000000;
                    madre.IdProvincia = 1640861101405000000;
                    madre.IdMunicipio = 1640861101436000000;
                    madre.LocalidadNacimiento = "";
                    madre.Defuncion = false;

                    mrm.Crear(madre);
                }
                reader.Close();
            }
            return "OK: " + resultado;
        }
Ejemplo n.º 6
0
 private void grdMadre_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     this.Cursor = Cursors.Wait;
     madre = this.grdMadre.SelectedItem as Madre;
     this.Cursor = Cursors.Arrow;
 }
Ejemplo n.º 7
0
        private void cmdTitularTutor_Click(object sender, RoutedEventArgs e)
        {
            if (registrotitularpago != null)
            {
                Button Img = (Button)sender;
                if (Img.Tag != null)
                {
                    Int64 Id = (Int64)Img.Tag;
                    if (Id > 0)
                    {
                        if (registrotitularpago.Titular != "SI")
                        {
                            string NombreCompleto = "";

                            if (registrotitularpago.Tipo == "Madre")
                            {
                                ModeloMadre modelomadre = new ModeloMadre();
                                Madre __madre = new Madre();
                                __madre = modelomadre.Recuperar(Id);
                                NombreCompleto = __madre.NombreCompleto;
                            }
                            else
                            {
                                ModeloTutor modelotutor = new ModeloTutor();
                                Tutor __tutor = new Tutor();
                                __tutor = modelotutor.Recuperar(Id);
                                NombreCompleto = __tutor.NombreCompleto;
                            }

                            if (MessageBox.Show("¿Desea establecer a " + NombreCompleto + " como titular de pago para esta familia?", "Advertencia", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                            {
                                ModeloGrupoFamiliar modelogrupofamiliar = new ModeloGrupoFamiliar();
                                modelogrupofamiliar.EstablecerTitularDePagoVigenteDeFamilia(IdSeleccionado, registrotitularpago.IdGrupoFamiliar);
                                RecuperarMadresYTutoresALaVez();
                            }
                        }
                        else
                            MessageBox.Show("Esta persona ya se halla establecida como titular de pago de esta familia.", "Mensaje", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ControlPreliminar = false;

            SoporteCombo.cargarEnumerador(cboTipoDocumentoIdentidad, typeof(TipoDocumentoIdentidad));
            ModeloDepartamento modelodepartamento = new ModeloDepartamento();

            this.cboDepartamento.ItemsSource = modelodepartamento.Listar();
            this.cboDepartamento.DisplayMemberPath = "Descripcion";
            this.cboDepartamento.SelectedValuePath = "Id";

            if (IdFamilia > 0)
            {
                ModeloFamilia modelofamilia = new ModeloFamilia();
                Familia familia = new Familia();

                familia = modelofamilia.Recuperar(IdFamilia);
                this.txtPaternoFamilia.Text = familia.PrimerApellido;
                this.txtMaternoFamilia.Text = familia.SegundoApellido;
            }

            if (IdSeleccionado == 0)
            {
                this.cboTipoDocumentoIdentidad.SelectedIndex = -1;
                this.dtpFechaNacimiento.SelectedDate = DateTime.Today;
                this.cboDepartamento.SelectedIndex = -1;
            }
            else
            {
                ModeloMadre modelomadre = new ModeloMadre();

                _madre = modelomadre.Recuperar(IdSeleccionado);
                txtDocumentoIdentidad.Text = _madre.DocumentoIdentidad;
                switch (_madre.TipoDocumentoIdentidad)
                {
                    case TipoDocumentoIdentidad.CarnetIdentidad:
                        cboTipoDocumentoIdentidad.SelectedIndex = 0;
                        break;
                    case TipoDocumentoIdentidad.CertificadoNacimiento:
                        cboTipoDocumentoIdentidad.SelectedIndex = 1;
                        break;
                    case TipoDocumentoIdentidad.Pasaporte:
                        cboTipoDocumentoIdentidad.SelectedIndex = 2;
                        break;
                }
                txtPaterno.Text = _madre.PrimerApellido;
                txtMaterno.Text = _madre.SegundoApellido;
                txtNombres.Text = _madre.Nombres;
                txtNombreCompleto.Text = _madre.NombreCompleto;
                dtpFechaNacimiento.SelectedDate = _madre.FechaNacimiento;
                if (_madre.Defuncion == true)
                    chkDefuncion.IsChecked = true;
                txtLugarNacimiento.Text = _madre.LocalidadNacimiento;
                cboDepartamento.SelectedValue = _madre.IdDepartamento;
                RecuperarProvincias(_madre.IdDepartamento.ToString());
                cboProvincia.SelectedValue = _madre.IdProvincia;
                RecuperarMunicipios(_madre.IdProvincia.ToString());
                cboMunicipio.SelectedValue = _madre.IdMunicipio;

                ModeloGrupoFamiliar modelogrupofamiliar = new ModeloGrupoFamiliar();

                _grupofamiliar = modelogrupofamiliar.RecuperarPorMadreDeFamilia(IdFamilia, IdSeleccionado);

                if (TipoAccion == TipoAccion.Detalle)
                {
                    txtDocumentoIdentidad.IsEnabled = false;
                    cboTipoDocumentoIdentidad.IsEnabled = false;
                    txtPaterno.IsEnabled = false;
                    txtMaterno.IsEnabled = false;
                    txtConyuge.IsEnabled = false;
                    txtNombres.IsEnabled = false;
                    txtNombreCompleto.IsEnabled = false;
                    dtpFechaNacimiento.IsEnabled = false;
                    chkDefuncion.IsEnabled = false;
                    txtLugarNacimiento.IsEnabled = false;
                    cboDepartamento.IsEnabled = false;
                    cboProvincia.IsEnabled = false;
                    cboMunicipio.IsEnabled = false;
                    cmdAceptar.IsEnabled = false;
                }
            }
            ControlPreliminar = true;
            if ((TipoAccion == TipoAccion.Nuevo) || (TipoAccion == TipoAccion.Edicion))
                this.txtDocumentoIdentidad.Focus();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            CantidadDeControles = 4;

            ////this.lblDepartamento.Content = "";
            ////this.lblEstablecimiento.Content = "";

            ModeloMadre modelomadre = new ModeloMadre();
            Madre madre = new Madre();

            madre = modelomadre.Recuperar(IdSeleccionado);

            if (madre != null)
            {
                this.lblNombresMadre.Content = madre.NombreCompleto;
                this.lblFechaNacimientoMadre.Content = string.Format("{0:dd/MM/yyyy}", madre.FechaNacimiento);
            }
            else
            {
                this.lblNombresMadre.Content = "";
                this.lblFechaNacimientoMadre.Content = "";
            }

            ModeloGrupoFamiliar modelogrupofamiliar = new ModeloGrupoFamiliar();

            _grupofamiliar = modelogrupofamiliar.RecuperarPorMadreDeFamilia(IdFamilia, IdSeleccionado);

            if (_grupofamiliar.TitularPagoVigente == true)
            {
                this.lblNombreTitular.Content = this.lblNombresMadre.Content;
                this.lblParentesco.Content = "";
                this.lblParentescoTitular.Content = "MADRE GESTANTE";
            }
            else
            {
                _grupofamiliar = modelogrupofamiliar.RecuperarTitularHabilitado(IdFamilia);

                if (_grupofamiliar != null)
                {
                    ModeloTutor modelotutor = new ModeloTutor();
                    Tutor tutor = new Tutor();
                    tutor = modelotutor.Recuperar(_grupofamiliar.IdTutor.Value);
                    this.lblNombreTitular.Content = tutor.NombreCompleto;

                    ModeloTipoParentesco modelotipoparentesco = new ModeloTipoParentesco();
                    TipoParentesco tipoparentesco = new TipoParentesco();

                    tipoparentesco = modelotipoparentesco.Recuperar(_grupofamiliar.IdTipoParentesco.Value);
                    this.lblParentescoTitular.Content = tipoparentesco.Descripcion;
                }
                else
                {
                    this.lblNombreTitular.Content = "";
                    this.lblParentescoTitular.Content = "";
                }
            }

            ModeloCorresponsabilidadMadre modelocorresponsabilidadmadre = new ModeloCorresponsabilidadMadre();

            IdCorresponsabilidadMadre = modelocorresponsabilidadmadre.RecuperarLaUltimaCorresponsabilidadValidaDeMadre(IdSeleccionado);

            ValoresPorDefecto();

            if (IdCorresponsabilidadMadre > 0)
                RecuperarCorresponsabilidadMadre();
            else
            {
                this.txtCodigoFormulario.IsEnabled = true;
                this.dtpFechaFUM.IsEnabled = true;
                this.dtpFechaInscripcion.IsEnabled = true;
                this.dtpFechaUltimoParto.IsEnabled = true;
                this.txtNumeroEmbarazo.IsEnabled = true;
                this.chkARO.IsEnabled = true;
                this.rdbNueva.IsEnabled = true;
                this.rdbTransferencia.IsEnabled = true;
                this.cmdGuardar.IsEnabled = true;
            }

            if (TipoAccion == TipoAccion.Detalle)
            {
                this.txtCodigoFormulario.IsEnabled = false;
                this.dtpFechaFUM.IsEnabled = false;
                this.dtpFechaInscripcion.IsEnabled = false;
                this.dtpFechaSalida.IsEnabled = false;
                this.dtpFechaUltimoParto.IsEnabled = false;
                this.txtNumeroEmbarazo.IsEnabled = false;
                this.chkARO.IsEnabled = false;
                this.chkSalida.IsEnabled = false;
                this.rdbAborto.IsEnabled = false;
                this.rdbCumplimiento.IsEnabled = false;
                this.rdbFallecimiento.IsEnabled = false;
                this.rdbIncumplimiento.IsEnabled = false;
                this.rdbNueva.IsEnabled = false;
                this.rdbObitoFetal.IsEnabled = false;
                this.rdbTransferencia.IsEnabled = false;
                this.rdbTransferenciaSalida.IsEnabled = false;
                this.txtAutorizado.IsEnabled = false;
                this.txtCargo.IsEnabled = false;
                this.cmdGuardar.IsEnabled = false;
            }
        }
Ejemplo n.º 10
0
 private string ConstruirParametroMadre(Madre madre, Dictionary<string, object> propiedadesObejtoBusqueda)
 {
     string cadenaB = "";
     foreach (var item in propiedadesObejtoBusqueda)
     {
         if (item.Key == "Identificador") continue;
         if ((bool)item.Value)
         {
             switch (item.Key)
             {
                 case "Nombres": cadenaB += madre.Nombres; break;
                 case "PrimerApellido": cadenaB += madre.PrimerApellido; break;
                 case "SegundoApellido": cadenaB += madre.SegundoApellido; break;
                 case "TercerApellido": cadenaB += madre.TercerApellido; break;
                 case "NombreCompleto": cadenaB += madre.NombreCompleto; break;
                 case "DocumentoIdentidad": cadenaB += madre.DocumentoIdentidad; break;
                 case "FechaNacimiento": cadenaB += madre.FechaNacimiento; break;
                 case "LocalidadNacimiento": cadenaB += madre.LocalidadNacimiento; break;
             }
         }
     }
     return cadenaB;
 }
Ejemplo n.º 11
0
        private void grdMadre_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.Cursor = Cursors.Wait;
            madre = this.grdMadre.SelectedItem as Madre;

            if (OpcionDeBusquedaAsignada == 1)
            {
                this.grdCorresponsabilidadMadre.ItemsSource = null;
                this.grdControlMadre.ItemsSource = null;
                this.grdTutorMadre.ItemsSource = null;
                this.grdMenor.ItemsSource = null;
                this.grdCorresponsabilidadMenor.ItemsSource = null;
                this.grdControlMenor.ItemsSource = null;
                this.grdTutorMenor.ItemsSource = null;

                if (madre != null)
                {
                    this.grdMenor.ItemsSource = modelomenor.ListarHijosDeMadreATravesDeCorresponsabilidadDeMenor(madre.Id);
                    if (this.grdMenor.Items.Count > 0)
                        this.grdMenor.SelectedIndex = 0;
                }
            }

            if (madre != null)
            {
                this.grdCorresponsabilidadMadre.ItemsSource = modelocorresponsabilidadmadre.ListarCorresponsabilidadesDeMadre(madre.Id);
                if (this.grdCorresponsabilidadMadre.Items.Count > 0)
                    this.grdCorresponsabilidadMadre.SelectedIndex = 0;
            }
            this.Cursor = Cursors.Arrow;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            CantidadDeControles = 12;

            ////this.lblDepartamento.Content = "";
            ////this.lblEstablecimiento.Content = "";

            ModeloMenor modelomenor = new ModeloMenor();
            Menor menor = new Menor();

            menor = modelomenor.Recuperar(IdSeleccionado);

            if (menor != null)
            {
                this.lblNombresMenor.Content = menor.PrimerApellido + " " + menor.SegundoApellido + " " + menor.Nombres;
                this.lblFechaNacimientoMenor.Content = string.Format("{0:dd/MM/yyyy}", menor.FechaNacimiento);
            }
            else
            {
                this.lblNombresMenor.Content = "";
                this.lblFechaNacimientoMenor.Content = "";
            }

            ModeloGrupoFamiliar modelogrupofamiliar = new ModeloGrupoFamiliar();

            _grupofamiliar = modelogrupofamiliar.RecuperarTitularHabilitado(IdFamilia);
            _grupofamiliarmadre = modelogrupofamiliar.RecuperarMadreDeFamilia(IdFamilia);

            if (_grupofamiliar != null)
            {
                if (_grupofamiliar.TipoGrupoFamiliar == TipoGrupoFamiliar.Madre)
                {
                    ModeloMadre modelomadre = new ModeloMadre();
                    Madre madre = new Madre();

                    madre = modelomadre.Recuperar(_grupofamiliar.IdMadre.Value);
                    this.lblNombreTitular.Content = madre.NombreCompleto;

                    this.lblParentescoTitular.Content = "MADRE";
                }
                else if (_grupofamiliar.TipoGrupoFamiliar == TipoGrupoFamiliar.Tutor)
                {
                    ModeloTutor modelotutor = new ModeloTutor();
                    Tutor tutor = new Tutor();
                    tutor = modelotutor.Recuperar(_grupofamiliar.IdTutor.Value);
                    this.lblNombreTitular.Content = tutor.NombreCompleto;

                    ModeloTipoParentesco modelotipoparentesco = new ModeloTipoParentesco();
                    TipoParentesco tipoparentesco = new TipoParentesco();

                    tipoparentesco = modelotipoparentesco.Recuperar(_grupofamiliar.IdTipoParentesco.Value);
                    this.lblParentescoTitular.Content = tipoparentesco.Descripcion;
                }
                else
                {
                    this.lblNombreTitular.Content = "";
                    this.lblParentescoTitular.Content = "";
                }
            }
            else
            {
                this.lblNombreTitular.Content = "";
                this.lblParentescoTitular.Content = "";
            }

            ModeloCorresponsabilidadMenor modelocorresponsabilidadmenor = new ModeloCorresponsabilidadMenor();

            IdCorresponsabilidadMenor = modelocorresponsabilidadmenor.RecuperarLaUltimaCorresponsabilidadValidaDeMenor(IdSeleccionado);

            ValoresPorDefecto();

            if (IdCorresponsabilidadMenor > 0)
                RecuperarCorresponsabilidadMenor();
            else
            {
                this.txtCodigoFormulario.IsEnabled = true;
                this.dtpFechaInscripcion.IsEnabled = true;
                this.rdbNueva.IsEnabled = true;
                this.rdbTransferencia.IsEnabled = true;
                this.cmdGuardar.IsEnabled = true;
            }

            if (TipoAccion == TipoAccion.Detalle)
            {
                this.txtCodigoFormulario.IsEnabled = false;
                this.dtpFechaInscripcion.IsEnabled = false;
                this.dtpFechaSalida.IsEnabled = false;
                this.chkSalida.IsEnabled = false;
                this.rdbCumplimiento.IsEnabled = false;
                this.rdbFallecimiento.IsEnabled = false;
                this.rdbIncumplimiento.IsEnabled = false;
                this.rdbNueva.IsEnabled = false;
                this.rdbTransferencia.IsEnabled = false;
                this.rdbTransferenciaSalida.IsEnabled = false;
                this.txtAutorizado.IsEnabled = false;
                this.txtCargo.IsEnabled = false;
                this.cmdGuardar.IsEnabled = false;
            }
        }
Ejemplo n.º 13
0
 public void Crear(Madre madre)
 {
     db.Madres.Add(madre);
     db.SaveChanges();
 }