Example #1
0
        private bool ValidarNovios()
        {
            CNSacramento objSacramento = new CNSacramento();

            //Se toma los datos del novio para verificar si no essta casado con otra persona.
            CESacramentoPorFeligres objSNovio = new CESacramentoPorFeligres()
            {
                Feligres_Num_Identidad = slueNovio.EditValue.ToString().Trim()
            };

            //Se toma los datos del novia para verificar si no essta casado con otra persona.
            CESacramentoPorFeligres objSNovia = new CESacramentoPorFeligres()
            {
                Feligres_Num_Identidad = slueNovia.EditValue.ToString().Trim()
            };

            if (objSacramento.Existe_Registro(objSNovio, idSacramento))
            {
                slueNovio.ErrorText = "Ya está casado con otra persona.";
                return(false);
            }

            if (objSacramento.Existe_Registro(objSNovia, idSacramento))
            {
                slueNovia.ErrorText = "Ya está casado con otra persona.";
                return(false);
            }

            return(true);
        }
Example #2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            CNSacramento objInsertarRegistro = new CNSacramento();

            CESacramentoPorFeligres objSF = new CESacramentoPorFeligres()
            {
                Feligres_Num_Identidad = slueFeligres.EditValue.ToString().Trim()
            };

            if (objInsertarRegistro.Existe_Registro(objSF, int.Parse(lueSacramentos.EditValue.ToString())))
            {
                XtraMessageBox.Show("Este feligrés ya tiene registrado este sacramento.", "Parroquia", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                this.Validate();
                if (Validar())
                {
                    int idRegistro;
                    int resultado = 1;

                    CESacramento objSacramento = new CESacramento()
                    {
                        Id_Sacramento = int.Parse(lueSacramentos.EditValue.ToString()),
                        Fecha         = deFecha.DateTime.Date,
                        Num_Identidad = slueEmpleado.EditValue.ToString(),
                        Id_Lugar      = int.Parse(lueLugar.EditValue.ToString()),
                        Numero_Libro  = int.Parse(txtNumLibro.EditValue.ToString()),
                        Numero_Pagina = int.Parse(txtNumPagina.EditValue.ToString()),
                        Numero_Acta   = int.Parse(txtNumActa.EditValue.ToString()),
                        Id_Usuario    = Funciones.Funciones.idUsuario,
                        Nota_Marginal = txtNotaMarginal.EditValue.ToString()
                    };

                    idRegistro = objInsertarRegistro.NuevoRegistroSacramento(objSacramento);

                    CESacramentoPorFeligres objSacramentoFeligres = new CESacramentoPorFeligres()
                    {
                        Id_Registro_Sacramento = idRegistro,
                        Feligres_Num_Identidad = slueFeligres.EditValue.ToString()
                    };

                    CEPadrinoPorFeligres objPadrino = new CEPadrinoPorFeligres()
                    {
                        Id_Registro_Sacramento = idRegistro,
                        Feligres_Num_Identidad = sluePadrino.EditValue.ToString(),
                        De_Novio = false
                    };

                    CEPadrinoPorFeligres objMadrina = new CEPadrinoPorFeligres()
                    {
                        Id_Registro_Sacramento = idRegistro,
                        Feligres_Num_Identidad = slueMadrina.EditValue.ToString(),
                        De_Novio = false
                    };

                    if (objInsertarRegistro.RegistroSacramentoPorFeligres(objSacramentoFeligres) > 0)
                    {
                        if (objPadrino.Feligres_Num_Identidad != "")
                        {
                            resultado = objInsertarRegistro.RegistroPadrinoPorFeligres(objPadrino);
                        }

                        if (objMadrina.Feligres_Num_Identidad != "")
                        {
                            resultado = objInsertarRegistro.RegistroPadrinoPorFeligres(objMadrina);
                        }

                        if (resultado > 0)
                        {
                            XtraMessageBox.Show("Registro almacenado satisfactoriamente.", "Parroquia", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            XtraMessageBox.Show("Error al almacenar el registro.", "Parroquia", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        Limpiar();
                        HabilitarControles(true, false, false, false, false, true);
                        LlenarGridSacramentos();
                    }
                    else
                    {
                        XtraMessageBox.Show("Error al almacenar el registro.", "Parroquia", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }