コード例 #1
0
ファイル: frmMadre.xaml.cs プロジェクト: hernanUNO6/BJA
        private void cmdAceptar_Click(object sender, RoutedEventArgs e)
        {
            ModeloGrupoFamiliar modelogrupofamiliar = new ModeloGrupoFamiliar();
            GrupoFamiliar       gf = new GrupoFamiliar();

            gf = modelogrupofamiliar.RecuperarTitularHabilitado(IdFamilia);
            bool ok  = false;
            bool OK  = false;
            int  OKM = 0;

            if (!(txtDocumentoIdentidad.Text.Length > 0))
            {
                MessageBox.Show("Se requiere especificar documento de identidad.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if ((Convert.ToInt64(cboTipoDocumentoIdentidad.SelectedIndex) < 0))
            {
                MessageBox.Show("Se requiere especificar tipo de documento de identidad.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if (!(txtPaterno.Text.Length > 0) && !(txtMaterno.Text.Length > 0))
            {
                MessageBox.Show("Se requiere especificar apellidos.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if (!(txtNombres.Text.Length > 0))
            {
                MessageBox.Show("Se requiere especificar nombre.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if (!(txtNombreCompleto.Text.Length > 0))
            {
                MessageBox.Show("Se requiere especificar nombre completo.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if ((Convert.ToInt64(cboDepartamento.SelectedIndex) < 0))
            {
                ok = true;
                MessageBox.Show("Se requiere especificar departamento.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if ((Convert.ToInt64(cboProvincia.SelectedIndex) < 0))
            {
                MessageBox.Show("Se requiere especificar provincia.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if ((Convert.ToInt64(cboMunicipio.SelectedIndex) < 0))
            {
                MessageBox.Show("Se requiere especificar municipio.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if (!(txtLugarNacimiento.Text.Length > 0))
            {
                MessageBox.Show("Se requiere especificar lugar de nacimiento.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }

            if (ok == false)
            {
                if (txtPaterno.Text != txtMaternoFamilia.Text)
                {
                    if (MessageBox.Show("El apellido paterno de la madre no es igual al apellido materno de la familia. ¿Desea continua?", "Advertencia", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                    {
                        ok = true;
                    }
                }
            }

            if (gf == null)
            {
                if (ok == false)
                {
                    switch (MessageBox.Show("¿Desea guardar los datos correspondiente a este madre?", "Consulta", MessageBoxButton.YesNoCancel, MessageBoxImage.Question))
                    {
                    case MessageBoxResult.Yes:
                        OKM = 1;
                        break;

                    case MessageBoxResult.No:
                        OKM = 2;
                        break;

                    case MessageBoxResult.Cancel:
                        OKM = 3;
                        break;
                    }

                    if (OKM == 1)
                    {
                        DateTime FechitaDeNacimiento;
                        DateTime FechitaActual;

                        FechitaDeNacimiento = dtpFechaNacimiento.SelectedDate.Value;
                        FechitaActual       = DateTime.Now;
                        FechitaActual       = FechitaActual.AddYears(-16);

                        if (FechitaDeNacimiento > FechitaActual)
                        {
                            if (MessageBox.Show("La fecha de nacimiento de la madre es: " + string.Format("{0:dd/MM/yyyy}", FechitaDeNacimiento) + ", lo cual a la fecha determina que es menor de edad. ¿Desea registrar ahora un nuevo titular de pago para la familia?", "Advertencia", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                            {
                                this.Cursor = Cursors.Wait;
                                frmTutor objTutorWindow = new frmTutor();
                                objTutorWindow.IdFamilia      = IdFamilia;
                                objTutorWindow.IdSeleccionado = 0;
                                objTutorWindow.TipoAccion     = TipoAccion.Nuevo;
                                objTutorWindow.Owner          = this;
                                objTutorWindow.ShowDialog();
                                this.Cursor = Cursors.Arrow;
                                if (objTutorWindow.Resultado == true)
                                {
                                    GrupoFamiliar grupofamiliar = new GrupoFamiliar();

                                    grupofamiliar = modelogrupofamiliar.RecuperarPorTutorDeFamilia(IdFamilia, objTutorWindow.IdSeleccionado);
                                    grupofamiliar.TitularPagoVigente = true;
                                    modelogrupofamiliar.Editar(grupofamiliar.Id, grupofamiliar);

                                    OK = true;
                                }
                                objTutorWindow = null;
                            }
                        }
                    }
                }
            }
            else
            {
                switch (MessageBox.Show("¿Desea guardar los datos correspondiente a este madre?", "Consulta", MessageBoxButton.YesNoCancel, MessageBoxImage.Question))
                {
                case MessageBoxResult.Yes:
                    OKM = 1;
                    break;

                case MessageBoxResult.No:
                    OKM = 2;
                    break;

                case MessageBoxResult.Cancel:
                    OKM = 3;
                    break;
                }
            }

            if (ok == false)
            {
                switch (OKM)
                {
                case 1:
                    ModeloMadre modelomadre = new ModeloMadre();

                    _madre.DocumentoIdentidad = txtDocumentoIdentidad.Text;
                    switch (cboTipoDocumentoIdentidad.SelectedIndex)
                    {
                    case 0:
                        _madre.TipoDocumentoIdentidad = TipoDocumentoIdentidad.CarnetIdentidad;
                        break;

                    case 1:
                        _madre.TipoDocumentoIdentidad = TipoDocumentoIdentidad.CertificadoNacimiento;
                        break;

                    case 2:
                        _madre.TipoDocumentoIdentidad = TipoDocumentoIdentidad.Pasaporte;
                        break;
                    }
                    _madre.PrimerApellido      = txtPaterno.Text;
                    _madre.SegundoApellido     = txtMaterno.Text;
                    _madre.TercerApellido      = txtConyuge.Text;
                    _madre.Nombres             = txtNombres.Text;
                    _madre.NombreCompleto      = txtNombreCompleto.Text;
                    _madre.FechaNacimiento     = dtpFechaNacimiento.SelectedDate.Value;
                    _madre.Defuncion           = (chkDefuncion.IsChecked == true) ? true : false;
                    _madre.Observaciones       = "";
                    _madre.IdDepartamento      = Convert.ToInt64(cboDepartamento.SelectedValue);
                    _madre.IdProvincia         = Convert.ToInt64(cboProvincia.SelectedValue);
                    _madre.IdMunicipio         = Convert.ToInt64(cboMunicipio.SelectedValue);
                    _madre.LocalidadNacimiento = txtLugarNacimiento.Text;

                    if (IdSeleccionado > 0)
                    {
                        modelomadre.Editar(IdSeleccionado, _madre);
                    }
                    else
                    {
                        modelomadre.Crear(_madre);
                        IdSeleccionado = _madre.Id;

                        _grupofamiliar.IdFamilia         = IdFamilia;
                        _grupofamiliar.IdMadre           = _madre.Id;
                        _grupofamiliar.TipoGrupoFamiliar = TipoGrupoFamiliar.Madre;
                        if (gf == null)
                        {
                            if (OK == false)
                            {
                                _grupofamiliar.TitularPagoVigente = true;
                            }
                        }

                        modelogrupofamiliar.Crear(_grupofamiliar);
                    }

                    Resultado = true;

                    this.Close();
                    break;

                case 3:
                    IdSeleccionado = 0;
                    Resultado      = false;
                    this.Close();
                    break;
                }
            }
        }
コード例 #2
0
        private void cmdAceptar_Click(object sender, RoutedEventArgs e)
        {
            bool ok = false;

            if ((Convert.ToInt64(cboTipoParentesco.SelectedIndex) < 0))
            {
                MessageBox.Show("Se requiere especificar tipo de parentesco.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if (!(txtDocumentoIdentidad.Text.Length > 0))
            {
                MessageBox.Show("Se requiere especificar documento de identidad.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if ((Convert.ToInt64(cboTipoDocumentoIdentidad.SelectedIndex) < 0))
            {
                MessageBox.Show("Se requiere especificar tipo de documento de identidad.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if (!(txtPaterno.Text.Length > 0) && !(txtMaterno.Text.Length > 0))
            {
                MessageBox.Show("Se requiere especificar apellidos.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if (!(txtNombres.Text.Length > 0))
            {
                MessageBox.Show("Se requiere especificar nombre.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if (!(txtNombreCompleto.Text.Length > 0))
            {
                MessageBox.Show("Se requiere especificar nombre completo.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if ((Convert.ToInt64(cboDepartamento.SelectedIndex) < 0))
            {
                MessageBox.Show("Se requiere especificar departamento.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if ((Convert.ToInt64(cboProvincia.SelectedIndex) < 0))
            {
                MessageBox.Show("Se requiere especificar provincia.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if ((Convert.ToInt64(cboMunicipio.SelectedIndex) < 0))
            {
                MessageBox.Show("Se requiere especificar municipio.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if (!(txtLugarNacimiento.Text.Length > 0))
            {
                MessageBox.Show("Se requiere especificar lugar de nacimiento.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }

            if (ok == false)
            {
                switch (MessageBox.Show("¿Desea guardar los datos correspondiente a este titular de pago?", "Consulta", MessageBoxButton.YesNoCancel, MessageBoxImage.Question))
                {
                case MessageBoxResult.Yes:
                    ModeloTutor         modelotutor         = new ModeloTutor();
                    ModeloGrupoFamiliar modelogrupofamiliar = new ModeloGrupoFamiliar();

                    _tutor.DocumentoIdentidad = txtDocumentoIdentidad.Text;
                    switch (cboTipoDocumentoIdentidad.SelectedIndex)
                    {
                    case 0:
                        _tutor.TipoDocumentoIdentidad = TipoDocumentoIdentidad.CarnetIdentidad;
                        break;

                    case 1:
                        _tutor.TipoDocumentoIdentidad = TipoDocumentoIdentidad.CertificadoNacimiento;
                        break;

                    case 2:
                        _tutor.TipoDocumentoIdentidad = TipoDocumentoIdentidad.Pasaporte;
                        break;
                    }
                    _tutor.PrimerApellido      = txtPaterno.Text;
                    _tutor.SegundoApellido     = txtMaterno.Text;
                    _tutor.TercerApellido      = txtConyuge.Text;
                    _tutor.Nombres             = txtNombres.Text;
                    _tutor.NombreCompleto      = txtNombreCompleto.Text;
                    _tutor.FechaNacimiento     = dtpFechaNacimiento.SelectedDate.Value;
                    _tutor.Defuncion           = (chkDefuncion.IsChecked == true) ? true : false;
                    _tutor.Observaciones       = "";
                    _tutor.IdDepartamento      = Convert.ToInt64(cboDepartamento.SelectedValue);
                    _tutor.IdProvincia         = Convert.ToInt64(cboProvincia.SelectedValue);
                    _tutor.IdMunicipio         = Convert.ToInt64(cboMunicipio.SelectedValue);
                    _tutor.LocalidadNacimiento = txtLugarNacimiento.Text;
                    if (rdbFemenino.IsChecked == true)
                    {
                        _tutor.Sexo = "F";
                    }
                    else if (rdbFemenino.IsChecked == false)
                    {
                        _tutor.Sexo = "M";
                    }
                    else
                    {
                        _tutor.Sexo = "-";
                    }

                    _grupofamiliar.IdTipoParentesco = Convert.ToInt64(cboTipoParentesco.SelectedValue);

                    if (IdSeleccionado > 0)
                    {
                        modelotutor.Editar(IdSeleccionado, _tutor);

                        modelogrupofamiliar.Editar(_grupofamiliar.Id, _grupofamiliar);
                    }
                    else
                    {
                        modelotutor.Crear(_tutor);
                        IdSeleccionado = _tutor.Id;

                        _grupofamiliar.IdFamilia         = IdFamilia;
                        _grupofamiliar.IdTutor           = _tutor.Id;
                        _grupofamiliar.TipoGrupoFamiliar = TipoGrupoFamiliar.Tutor;

                        modelogrupofamiliar.Crear(_grupofamiliar);
                    }

                    Resultado = true;

                    this.Close();
                    break;

                case MessageBoxResult.Cancel:
                    IdSeleccionado = 0;
                    Resultado      = false;
                    this.Close();
                    break;
                }
            }
        }
コード例 #3
0
        private void cmdAceptar_Click(object sender, RoutedEventArgs e)
        {
            bool   ok = false;
            string s  = "-";
            string ss = "";

            if (rdbFemenino.IsChecked == true)
            {
                s  = "F";
                ss = "¿Desea guardar los datos correspondiente a esta niña?";
            }
            else if (rdbFemenino.IsChecked == false)
            {
                s  = "M";
                ss = "¿Desea guardar los datos correspondiente a esta niño?";
            }

            if (!(txtDocumentoIdentidad.Text.Length > 0))
            {
                MessageBox.Show("Se requiere especificar documento de identidad.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if ((Convert.ToInt64(cboTipoDocumentoIdentidad.SelectedIndex) < 0))
            {
                MessageBox.Show("Se requiere especificar tipo de documento de identidad.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if (Convert.ToInt32(cboTipoDocumentoIdentidad.SelectedValue) == Convert.ToInt32(TipoDocumentoIdentidad.CertificadoNacimiento))
            {
                if (!(txtOficialia.Text.Length > 0))
                {
                    MessageBox.Show("Se requiere especificar oficialía.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    ok = true;
                }
                else if (!(txtLibro.Text.Length > 0))
                {
                    MessageBox.Show("Se requiere especificar libro.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    ok = true;
                }
                else if (!(txtPartida.Text.Length > 0))
                {
                    MessageBox.Show("Se requiere especificar partida.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    ok = true;
                }
                else if (!(txtFolio.Text.Length > 0))
                {
                    MessageBox.Show("Se requiere especificar folio.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    ok = true;
                }
            }
            else if (!(txtPaterno.Text.Length > 0) && !(txtMaterno.Text.Length > 0))
            {
                MessageBox.Show("Se requiere especificar apellidos.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if (!(txtNombres.Text.Length > 0))
            {
                MessageBox.Show("Se requiere especificar nombre.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if (s == "-")
            {
                MessageBox.Show("Se requiere especificar sexo.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if ((Convert.ToInt64(cboDepartamento.SelectedIndex) < 0))
            {
                MessageBox.Show("Se requiere especificar departamento.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if ((Convert.ToInt64(cboProvincia.SelectedIndex) < 0))
            {
                MessageBox.Show("Se requiere especificar provincia.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if ((Convert.ToInt64(cboMunicipio.SelectedIndex) < 0))
            {
                MessageBox.Show("Se requiere especificar municipio.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }
            else if (!(txtLugarNacimiento.Text.Length > 0))
            {
                MessageBox.Show("Se requiere especificar lugar de nacimiento.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ok = true;
            }

            if (ok == false)
            {
                if ((txtPaterno.Text != txtPaternoFamilia.Text) || (txtMaterno.Text != txtMaternoFamilia.Text))
                {
                    if (MessageBox.Show("El apellido paterno o materno no son iguales a los apellidos paterno o materno de la familia. ¿Desea continua?", "Advertencia", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                    {
                        ok = true;
                    }
                }
            }

            if (ok == false)
            {
                switch (MessageBox.Show(ss, "Consulta", MessageBoxButton.YesNoCancel, MessageBoxImage.Question))
                {
                case MessageBoxResult.Yes:
                    ModeloMenor         modelomenor         = new ModeloMenor();
                    ModeloGrupoFamiliar modelogrupofamiliar = new ModeloGrupoFamiliar();

                    _menor.DocumentoIdentidad = txtDocumentoIdentidad.Text;
                    switch (cboTipoDocumentoIdentidad.SelectedIndex)
                    {
                    case 0:
                        _menor.TipoDocumentoIdentidad = TipoDocumentoIdentidad.CarnetIdentidad;
                        break;

                    case 1:
                        _menor.TipoDocumentoIdentidad = TipoDocumentoIdentidad.CertificadoNacimiento;
                        break;

                    case 2:
                        _menor.TipoDocumentoIdentidad = TipoDocumentoIdentidad.Pasaporte;
                        break;
                    }
                    _menor.Oficialia           = txtOficialia.Text;
                    _menor.Libro               = txtLibro.Text;
                    _menor.Partida             = txtPartida.Text;
                    _menor.Folio               = txtFolio.Text;
                    _menor.PrimerApellido      = txtPaterno.Text;
                    _menor.SegundoApellido     = txtMaterno.Text;
                    _menor.Nombres             = txtNombres.Text;
                    _menor.FechaNacimiento     = dtpFechaNacimiento.SelectedDate.Value;
                    _menor.Defuncion           = (chkDefuncion.IsChecked == true) ? true : false;
                    _menor.Observaciones       = "";
                    _menor.IdDepartamento      = Convert.ToInt64(cboDepartamento.SelectedValue);
                    _menor.IdProvincia         = Convert.ToInt64(cboProvincia.SelectedValue);
                    _menor.IdMunicipio         = Convert.ToInt64(cboMunicipio.SelectedValue);
                    _menor.LocalidadNacimiento = txtLugarNacimiento.Text;
                    _menor.Sexo = s;

                    if (IdSeleccionado > 0)
                    {
                        modelomenor.Editar(IdSeleccionado, _menor);
                    }
                    else
                    {
                        modelomenor.Crear(_menor);
                        IdSeleccionado = _menor.Id;

                        _grupofamiliar.IdFamilia         = IdFamilia;
                        _grupofamiliar.IdMenor           = _menor.Id;
                        _grupofamiliar.TipoGrupoFamiliar = TipoGrupoFamiliar.Menor;

                        modelogrupofamiliar.Crear(_grupofamiliar);
                    }

                    Resultado = true;

                    this.Close();
                    break;

                case MessageBoxResult.Cancel:
                    IdSeleccionado = 0;
                    Resultado      = false;
                    this.Close();
                    break;
                }
            }
        }