public bool ExisteRegistro(CESacramentoPorFeligres objS, int idSacramento) { SqlCommand cmd; try { cmd = new SqlCommand("Sp_Existe_Sacramento_Feligres", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Id_Sacramento", SqlDbType.Int).Value = idSacramento; cmd.Parameters.Add("@Feligres_Num_Identidad", SqlDbType.Char, 15).Value = objS.Feligres_Num_Identidad; ConectarBD(); int count = Convert.ToInt32(cmd.ExecuteScalar()); if (count == 0) { return(false); } else { return(true); } } catch (Exception ex) { throw new Exception("Error al solicitar los datos. ", ex); } finally { CerrarBD(); } }
public CESacramentoPorFeligres MostrarUnFeligresSacramento(int Id_Registro_Sacramento) { SqlCommand cmd; SqlDataReader dr; CESacramentoPorFeligres objSacramentoFeligres = new CESacramentoPorFeligres(); try { ConectarBD(); cmd = new SqlCommand("Sp_Mostrar_Feligres_Sacramento", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Id_Registro_Sacramento", SqlDbType.Int).Value = Id_Registro_Sacramento; dr = cmd.ExecuteReader(); if (dr.Read()) { objSacramentoFeligres.Id_Registro_Sacramento = int.Parse(dr["Id_Registro_Sacramento"].ToString()); objSacramentoFeligres.Feligres_Num_Identidad = dr["Feligres_Num_Identidad"].ToString(); } return(objSacramentoFeligres); } catch (Exception ex) { throw new Exception("Error al solicitar los datos", ex); } finally { CerrarBD(); } }
public List <CESacramentoPorFeligres> SeleccionarNovios(int Id_Registro_Sacramento) { SqlCommand cmd; SqlDataReader dr; List <CESacramentoPorFeligres> lista = new List <CESacramentoPorFeligres>(); try { ConectarBD(); cmd = new SqlCommand("Sp_Seleccionar_Novios", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Id_Registro_Sacramento", SqlDbType.Int).Value = Id_Registro_Sacramento; dr = cmd.ExecuteReader(); while (dr.Read()) { CESacramentoPorFeligres objNovios = new CESacramentoPorFeligres(); objNovios.Id_Registro_Sacramento = int.Parse(dr.GetValue(0).ToString().Trim()); objNovios.Feligres_Num_Identidad = dr.GetValue(1).ToString().Trim(); lista.Add(objNovios); } return(lista); } catch (Exception ex) { throw new Exception("Error al solicitar los datos", ex); } finally { CerrarBD(); } }
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); }
public int ActualizarSacramentoPorFeligres(CESacramentoPorFeligres objS) { int resultado; try { SqlCommand cmd = new SqlCommand("Sp_Actualizar_Sacramento_Por_Feligres", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Id_Registro_Sacramento", SqlDbType.Int).Value = objS.Id_Registro_Sacramento; cmd.Parameters.Add("@Feligres_Num_Identidad", SqlDbType.Char, 15).Value = objS.Feligres_Num_Identidad; ConectarBD(); resultado = cmd.ExecuteNonQuery(); cmd.Dispose(); } catch (Exception ex) { throw new Exception("Error al tratar de almacenar el registro.", ex); } finally { CerrarBD(); } return(resultado); }
private void MostrarDatosMatrinmonio(int id) { CNFeligres objfeligres = new CNFeligres(); CNSacramento objObtenerSacramento = new CNSacramento(); CESacramento objSacramento = objObtenerSacramento.ObtenerSacramento(id); List <CEPadrinoPorFeligres> objPadrinos = objObtenerSacramento.ObtenerPadrinosFeligres(id); List <CESacramentoPorFeligres> objNovios = objObtenerSacramento.SeleccionarNoviosMatrimonio(id); CESacramentoPorFeligres objFeligres = objObtenerSacramento.ObtenerFeligresSacramento(id); CEPadrinoPorFeligres objPadrinoH = new CEPadrinoPorFeligres(); CEPadrinoPorFeligres objMadrinaH = new CEPadrinoPorFeligres(); CEPadrinoPorFeligres objPadrinoM = new CEPadrinoPorFeligres(); CEPadrinoPorFeligres objMadrinaM = new CEPadrinoPorFeligres(); txtIdRegistro.EditValue = objSacramento.Id_Registro_Sacramento; deFecha.EditValue = objSacramento.Fecha; slueEmpleado.EditValue = objSacramento.Num_Identidad.ToString().Trim(); lueLugar.EditValue = objSacramento.Id_Lugar; txtNumLibro.EditValue = objSacramento.Numero_Libro; txtNumPagina.EditValue = objSacramento.Numero_Pagina; txtNumActa.EditValue = objSacramento.Numero_Acta; slueNovio.EditValue = objNovios[0].Feligres_Num_Identidad.ToString(); slueNovia.EditValue = objNovios[1].Feligres_Num_Identidad.ToString(); foreach (CEPadrinoPorFeligres padrino in objPadrinos) { if (padrino.De_Novio) { if (objfeligres.ObtenerFeligres(padrino.Feligres_Num_Identidad).IdSexo == 1) { objMadrinaH = padrino; } else { objPadrinoH = padrino; } } else { if (objfeligres.ObtenerFeligres(padrino.Feligres_Num_Identidad).IdSexo == 1) { objMadrinaM = padrino; } else { objPadrinoM = padrino; } } } slueMadrinaNovio.EditValue = objMadrinaH.Feligres_Num_Identidad; sluePadrinoNovio.EditValue = objPadrinoH.Feligres_Num_Identidad; slueMadrinaNovia.EditValue = objMadrinaM.Feligres_Num_Identidad; sluePadrinoNovia.EditValue = objPadrinoM.Feligres_Num_Identidad; }
private void MostrarUnSacramento(int id) { CNFeligres feligres = new CNFeligres(); CNSacramento objObtenerSacramento = new CNSacramento(); CESacramento objSacramento = objObtenerSacramento.ObtenerSacramento(id); List <CEPadrinoPorFeligres> objPadrinos = objObtenerSacramento.ObtenerPadrinosFeligres(id); CESacramentoPorFeligres objFeligres = objObtenerSacramento.ObtenerFeligresSacramento(id); txtIdRegistro.EditValue = objSacramento.Id_Registro_Sacramento; lueSacramentos.EditValue = objSacramento.Id_Sacramento; deFecha.EditValue = objSacramento.Fecha; slueEmpleado.EditValue = objSacramento.Num_Identidad.ToString().Trim(); lueLugar.EditValue = objSacramento.Id_Lugar; txtNumLibro.EditValue = objSacramento.Numero_Libro; txtNumPagina.EditValue = objSacramento.Numero_Pagina; txtNumActa.EditValue = objSacramento.Numero_Acta; txtNotaMarginal.EditValue = objSacramento.Nota_Marginal == null ? "" : objSacramento.Nota_Marginal.ToString(); slueFeligres.EditValue = objFeligres.Feligres_Num_Identidad.ToString().Trim(); if (objPadrinos.Count == 1) { CEFeligres padrino = feligres.ObtenerFeligres(objPadrinos[0].Feligres_Num_Identidad); if (padrino.IdSexo == 1) { slueMadrina.EditValue = objPadrinos[0].Feligres_Num_Identidad; } else { sluePadrino.EditValue = objPadrinos[0].Feligres_Num_Identidad; } } else if (objPadrinos.Count == 2) { CEFeligres padrino = feligres.ObtenerFeligres(objPadrinos[0].Feligres_Num_Identidad); if (padrino.IdSexo == 1) { slueMadrina.EditValue = objPadrinos[0].Feligres_Num_Identidad; sluePadrino.EditValue = objPadrinos[1].Feligres_Num_Identidad; } else { sluePadrino.EditValue = objPadrinos[0].Feligres_Num_Identidad; slueMadrina.EditValue = objPadrinos[1].Feligres_Num_Identidad; } } }
private void btnActualizar_Click(object sender, EventArgs e) { this.Validate(); if (Validar()) { int idRegistro; CNSacramento objActualizarRegistro = new CNSacramento(); CESacramento objSacramento = new CESacramento() { Id_Registro_Sacramento = int.Parse(txtIdRegistro.EditValue.ToString()), 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 = int.Parse(txtIdRegistro.EditValue.ToString()); 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() }; CEPadrinoPorFeligres objMadrina = new CEPadrinoPorFeligres() { Id_Registro_Sacramento = idRegistro, Feligres_Num_Identidad = slueMadrina.EditValue.ToString() }; if (objActualizarRegistro.ActualizarRegistroSacramento(objSacramento) > 0) { if (objPadrino.Feligres_Num_Identidad != "" && String.IsNullOrEmpty(padrinoAnterior)) { objActualizarRegistro.InsertarPadrinoPorFeligresNovios(objPadrino); } else if (objPadrino.Feligres_Num_Identidad != "") { objActualizarRegistro.ActualizarPadrinosPorFeligres(objPadrino, padrinoAnterior); } if (objMadrina.Feligres_Num_Identidad != "" && String.IsNullOrEmpty(madrinaAnterior)) { objActualizarRegistro.InsertarPadrinoPorFeligresNovios(objMadrina); } else if (objMadrina.Feligres_Num_Identidad != "") { objActualizarRegistro.ActualizarPadrinosPorFeligres(objMadrina, madrinaAnterior); } XtraMessageBox.Show("Registro actualizado satisfactoriamente.", "Parroquia", MessageBoxButtons.OK, MessageBoxIcon.Information); Limpiar(); HabilitarControles(true, false, false, false, false, true); slueFeligres.Enabled = true; LlenarGridSacramentos(); } else { XtraMessageBox.Show("Error al almacenar el registro.", "Parroquia", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
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); } } } }
private void btnGuardar_Click(object sender, EventArgs e) { if (!ValidarNovios()) { XtraMessageBox.Show("Uno de los novios ya está casado con otra persona."); } else { this.Validate(); if (Validar()) { int idRegistro; CNSacramento objInsertarRegistro = new CNSacramento(); CESacramento objSacramento = new CESacramento() { Id_Sacramento = idSacramento, 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 = 6 }; if (nuevoRegistro) { idRegistro = objInsertarRegistro.NuevoRegistroSacramento(objSacramento); } else { idRegistro = int.Parse(txtIdRegistro.EditValue.ToString()); } CESacramentoPorFeligres objNovio = new CESacramentoPorFeligres() { Id_Registro_Sacramento = idRegistro, Feligres_Num_Identidad = slueNovio.EditValue.ToString() }; CESacramentoPorFeligres objNovia = new CESacramentoPorFeligres() { Id_Registro_Sacramento = idRegistro, Feligres_Num_Identidad = slueNovia.EditValue.ToString() }; CEPadrinoPorFeligres objPadrinoNovio = new CEPadrinoPorFeligres() { Id_Registro_Sacramento = idRegistro, Feligres_Num_Identidad = sluePadrinoNovio.EditValue.ToString(), De_Novio = true }; CEPadrinoPorFeligres objMadrinaNovio = new CEPadrinoPorFeligres() { Id_Registro_Sacramento = idRegistro, Feligres_Num_Identidad = slueMadrinaNovio.EditValue.ToString(), De_Novio = true }; CEPadrinoPorFeligres objPadrinoNovia = new CEPadrinoPorFeligres() { Id_Registro_Sacramento = idRegistro, Feligres_Num_Identidad = sluePadrinoNovia.EditValue.ToString(), De_Novio = false }; CEPadrinoPorFeligres objMadrinaNovia = new CEPadrinoPorFeligres() { Id_Registro_Sacramento = idRegistro, Feligres_Num_Identidad = slueMadrinaNovia.EditValue.ToString(), De_Novio = false }; if (objInsertarRegistro.RegistroSacramentoPorFeligres(objNovio) > 0 && objInsertarRegistro.RegistroSacramentoPorFeligres(objNovia) > 0) { if (objInsertarRegistro.InsertarPadrinoPorFeligresNovios(objPadrinoNovio) > 0 && objInsertarRegistro.InsertarPadrinoPorFeligresNovios(objMadrinaNovio) > 0 && objInsertarRegistro.InsertarPadrinoPorFeligresNovios(objPadrinoNovia) > 0 && objInsertarRegistro.InsertarPadrinoPorFeligresNovios(objMadrinaNovia) > 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); this.Close(); } else { XtraMessageBox.Show("Error al almacenar el registro.", "Parroquia", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public int ActualizarSacramentoPorFeligres(CESacramentoPorFeligres objSacramentoF) { return(objS.ActualizarSacramentoPorFeligres(objSacramentoF)); }
public int RegistroSacramentoPorFeligres(CESacramentoPorFeligres objSacramentoF) { return(objS.InsertarSacramentoPorFeligres(objSacramentoF)); }
public bool Existe_Registro(CESacramentoPorFeligres objSF, int idSacramento) { return(objS.ExisteRegistro(objSF, idSacramento)); }