protected void rptOcupacion_OnItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "Editar") { HiddenField HdnIdOcupacion = new HiddenField(); HdnIdOcupacion = (HiddenField)e.Item.FindControl("HdnIdOcupacion"); YouCom.DTO.Propietario.OcupacionDTO theOcupacionDTO = new YouCom.DTO.Propietario.OcupacionDTO(); theOcupacionDTO = YouCom.bll.OcupacionBLL.detalleOcupacion(decimal.Parse(HdnIdOcupacion.Value)); this.HdnIdOcupacion.Value = theOcupacionDTO.IdOcupacion.ToString(); txtNombre.Text = theOcupacionDTO.NombreOcupacion; btnGrabar.Visible = false; btnEditar.Visible = true; } if (e.CommandName == "Eliminar") { HiddenField HdnIdOcupacion = new HiddenField(); HdnIdOcupacion = (HiddenField)e.Item.FindControl("HdnIdOcupacion"); OcupacionDTO theOcupacionDTO = new OcupacionDTO(); theOcupacionDTO.IdOcupacion = decimal.Parse(HdnIdOcupacion.Value); theOcupacionDTO.UsuarioModificacion = myUsuario.Rut; bool validacionIntegridad = YouCom.bll.OcupacionBLL.ValidaEliminacionOcupacion(theOcupacionDTO); if (validacionIntegridad) { string script = "alert(' No es posible eliminar una ocupacion con información asociada.');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true); return; } else { bool respuesta = YouCom.bll.OcupacionBLL.Delete(theOcupacionDTO); if (respuesta) { cargarOcupacion(); if (!Page.ClientScript.IsClientScriptBlockRegistered("SET")) { string script = "alert('Ocupacion Eliminada correctamente.');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true); } } else { } } } }
protected void btnGrabar_Click(object sender, EventArgs e) { UserControl wucCondominio = (UserControl)Page.Master.FindControl("ContentPlaceHolder1").FindControl("wucCondominio1"); DropDownList ddlCondominio = (DropDownList)wucCondominio.FindControl("ddlCondominio"); DropDownList ddlComunidad = (DropDownList)wucCondominio.FindControl("ddlComunidad"); List <FamiliaDTO> familia = new List <FamiliaDTO>(); familia = (Session["familia"] as List <FamiliaDTO>); FamiliaDTO theFamiliaDTO = new FamiliaDTO(); theFamiliaDTO.RutFamilia = this.txtRut.Text.ToUpper(); theFamiliaDTO.NombreFamilia = this.txtNombre.Text.ToUpper(); theFamiliaDTO.ApellidoPaternoFamilia = this.txtApellidoPaterno.Text.ToUpper(); theFamiliaDTO.ApellidoMaternoFamilia = this.txtApellidoMaterno.Text.ToUpper(); theFamiliaDTO.TelefonoFamilia = this.txtTelefono.Text; theFamiliaDTO.EmailFamilia = this.txtEmail.Text; theFamiliaDTO.CelularFamilia = this.txtCelular.Text; YouCom.DTO.Seguridad.CondominioDTO myCondominioDTO = new YouCom.DTO.Seguridad.CondominioDTO(); myCondominioDTO.IdCondominio = decimal.Parse(ddlCondominio.SelectedValue); theFamiliaDTO.TheCondominioDTO = myCondominioDTO; YouCom.DTO.Seguridad.ComunidadDTO myComunidadDTO = new YouCom.DTO.Seguridad.ComunidadDTO(); myComunidadDTO.IdComunidad = decimal.Parse(ddlComunidad.SelectedValue); theFamiliaDTO.TheComunidadDTO = myComunidadDTO; YouCom.DTO.Propietario.ParentescoDTO myParentescoDTO = new YouCom.DTO.Propietario.ParentescoDTO(); myParentescoDTO.IdParentesco = decimal.Parse(ddlParentesco.SelectedValue); theFamiliaDTO.TheParentescoDTO = myParentescoDTO; YouCom.DTO.Propietario.OcupacionDTO myOcupacionDTO = new YouCom.DTO.Propietario.OcupacionDTO(); myOcupacionDTO.IdOcupacion = decimal.Parse(ddlOcupacion.SelectedValue); theFamiliaDTO.TheOcupacionDTO = myOcupacionDTO; YouCom.DTO.Propietario.CasaDTO myCasaDTO = new YouCom.DTO.Propietario.CasaDTO(); myCasaDTO.IdCasa = decimal.Parse(ddlCasa.SelectedValue); theFamiliaDTO.TheCasaDTO = myCasaDTO; theFamiliaDTO.UsuarioIngreso = myUsuario.Rut; familia = familia.Where(x => x.NombreFamilia == theFamiliaDTO.NombreFamilia).ToList(); if (familia.Any()) { foreach (var item in familia) { if (item.Estado == "2") { string script = "alert('Familia Existe pero Fue Eliminado Para Activarlo dirigase a Papelera.');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true); return; } else { string script = "alert('Familia ya Existe .');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true); return; } } } bool respuesta = YouCom.bll.FamiliaBLL.Insert(theFamiliaDTO); if (respuesta) { this.txtNombre.Text = string.Empty; this.txtRut.Text = string.Empty; this.txtApellidoPaterno.Text = string.Empty; this.txtApellidoMaterno.Text = string.Empty; this.txtTelefono.Text = string.Empty; this.txtEmail.Text = string.Empty; this.txtCelular.Text = string.Empty; this.ddlCasa.ClearSelection(); this.ddlOcupacion.ClearSelection(); this.ddlParentesco.ClearSelection(); string script = "alert('Familia Ingresada correctamente.');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true); cargarFamilia(); } else { } }
protected void btnEditar_Click(object sender, EventArgs e) { UserControl wucCondominio = (UserControl)Page.Master.FindControl("ContentPlaceHolder1").FindControl("wucCondominio1"); DropDownList ddlCondominio = (DropDownList)wucCondominio.FindControl("ddlCondominio"); DropDownList ddlComunidad = (DropDownList)wucCondominio.FindControl("ddlComunidad"); btnEditar.Visible = false; btnGrabar.Visible = true; FamiliaDTO theFamiliaDTO = new FamiliaDTO(); theFamiliaDTO.IdFamilia = decimal.Parse(this.hdnIdFamilia.Value); theFamiliaDTO.RutFamilia = YouCom.Service.Generales.Formato.LimpiarRut(this.txtRut.Text.ToUpper()); theFamiliaDTO.NombreFamilia = this.txtNombre.Text.ToUpper(); theFamiliaDTO.ApellidoPaternoFamilia = this.txtApellidoPaterno.Text.ToUpper(); theFamiliaDTO.ApellidoMaternoFamilia = this.txtApellidoMaterno.Text.ToUpper(); theFamiliaDTO.EmailFamilia = this.txtEmail.Text.ToUpper(); theFamiliaDTO.TelefonoFamilia = this.txtTelefono.Text.ToUpper(); theFamiliaDTO.CelularFamilia = this.txtCelular.Text; YouCom.DTO.Seguridad.CondominioDTO myCondominioDTO = new YouCom.DTO.Seguridad.CondominioDTO(); myCondominioDTO.IdCondominio = decimal.Parse(ddlCondominio.SelectedValue); theFamiliaDTO.TheCondominioDTO = myCondominioDTO; YouCom.DTO.Seguridad.ComunidadDTO myComunidadDTO = new YouCom.DTO.Seguridad.ComunidadDTO(); myComunidadDTO.IdComunidad = decimal.Parse(ddlComunidad.SelectedValue); theFamiliaDTO.TheComunidadDTO = myComunidadDTO; YouCom.DTO.Propietario.ParentescoDTO myParentescoDTO = new YouCom.DTO.Propietario.ParentescoDTO(); myParentescoDTO.IdParentesco = decimal.Parse(ddlParentesco.SelectedValue); theFamiliaDTO.TheParentescoDTO = myParentescoDTO; YouCom.DTO.Propietario.OcupacionDTO myOcupacionDTO = new YouCom.DTO.Propietario.OcupacionDTO(); myOcupacionDTO.IdOcupacion = decimal.Parse(ddlOcupacion.SelectedValue); theFamiliaDTO.TheOcupacionDTO = myOcupacionDTO; YouCom.DTO.Propietario.CasaDTO myCasaDTO = new YouCom.DTO.Propietario.CasaDTO(); myCasaDTO.IdCasa = decimal.Parse(ddlCasa.SelectedValue); theFamiliaDTO.TheCasaDTO = myCasaDTO; theFamiliaDTO.UsuarioModificacion = myUsuario.Rut; bool respuesta = YouCom.bll.FamiliaBLL.Update(theFamiliaDTO); if (respuesta) { cargarFamilia(); this.txtNombre.Text = string.Empty; this.txtRut.Text = string.Empty; this.txtApellidoPaterno.Text = string.Empty; this.txtApellidoMaterno.Text = string.Empty; this.txtTelefono.Text = string.Empty; this.txtEmail.Text = string.Empty; this.txtCelular.Text = string.Empty; this.ddlCasa.ClearSelection(); this.ddlOcupacion.ClearSelection(); this.ddlParentesco.ClearSelection(); if (!Page.ClientScript.IsClientScriptBlockRegistered("SET")) { string script = "alert('Familia editada correctamente.');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true); } } else { } }