protected void BtnEnviar_Click(object sender, EventArgs e) { try { if (Page.IsValid) { YouCom.DTO.Propuesta.VotacionPropuestaRespuestaDTO myVotacionPropuestaRespuestaDTO = new YouCom.DTO.Propuesta.VotacionPropuestaRespuestaDTO(); YouCom.DTO.Propietario.FamiliaDTO myFamiliaDTO = new YouCom.DTO.Propietario.FamiliaDTO(); myFamiliaDTO = YouCom.bll.FamiliaBLL.detalleFamiliabyRut(myUsuario.Rut); myVotacionPropuestaRespuestaDTO.TheFamiliaDTO = myFamiliaDTO; YouCom.DTO.Propuesta.VotacionPropuestaDTO myVotacionPropuestaDTO = new YouCom.DTO.Propuesta.VotacionPropuestaDTO(); myVotacionPropuestaDTO.IdVotacionPropuesta = decimal.Parse(this.hdnVotacionPropuestaId.Value); myVotacionPropuestaRespuestaDTO.TheVotacionPropuestaDTO = myVotacionPropuestaDTO; myVotacionPropuestaRespuestaDTO.EleccionVotacion = rdbSeleccion.SelectedValue; myVotacionPropuestaRespuestaDTO.FechaVotacion = DateTime.Now; bool respuesta = YouCom.bll.VotacionPropuestaRespuestaBLL.Insert(myVotacionPropuestaRespuestaDTO); if (respuesta) { if (!Page.ClientScript.IsClientScriptBlockRegistered("SET")) { string script = "alert('Estimado Cliente, hemos recibido su votación, en breve nos contactaremos con usted.');"; script += "parent.location = '" + retorno1 + "';"; Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true); } } else { if (!Page.ClientScript.IsClientScriptBlockRegistered("SET")) { string script = "alert('A ocurrido un error. Favor envíe su solicitud al mail [email protected] intente más tarde.');"; script += "parent.location = '" + retorno1 + "';"; Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true); } } } } catch (Exception ex) { Response.Write(ex.Message); } }
protected void rptVotacionPropuesta_OnItemCommand(object sender, RepeaterCommandEventArgs e) { UserControl wucCondominio = (UserControl)Page.Master.FindControl("ContentPlaceHolder1").FindControl("wucCondominioCasaFamilia1"); DropDownList ddlCondominio = (DropDownList)wucCondominio.FindControl("ddlCondominio"); DropDownList ddlComunidad = (DropDownList)wucCondominio.FindControl("ddlComunidad"); DropDownList ddlCasa = (DropDownList)wucCondominio.FindControl("ddlCasa"); DropDownList ddlFamilia = (DropDownList)wucCondominio.FindControl("ddlFamilia"); if (e.CommandName == "Editar") { HiddenField hdnVotacionPropuestaId = new HiddenField(); hdnVotacionPropuestaId = (HiddenField)e.Item.FindControl("hdnVotacionPropuestaId"); YouCom.DTO.Propuesta.PropuestaDTO myPropuestaDTO = new PropuestaDTO(); YouCom.DTO.Propuesta.VotacionPropuestaDTO theVotacionPropuestaDTO = new YouCom.DTO.Propuesta.VotacionPropuestaDTO(); theVotacionPropuestaDTO = YouCom.bll.VotacionPropuestaBLL.detalleVotacionPropuesta(decimal.Parse(hdnVotacionPropuestaId.Value)); myPropuestaDTO = YouCom.bll.PropuestaBLL.detallePropuesta(theVotacionPropuestaDTO.ThePropuestaDTO.IdPropuesta); this.hdnVotacionPropuestaId.Value = theVotacionPropuestaDTO.IdVotacionPropuesta.ToString(); this.txtVotacionPropuestaNombre.Text = theVotacionPropuestaDTO.ThePropuestaDTO.NombrePropuesta; this.txtVotacionPropuestaDescripcion.Text = theVotacionPropuestaDTO.ThePropuestaDTO.DescripcionPropuesta; this.FechaTermino.Text = theVotacionPropuestaDTO.FechaTerminoVotacionPropuesta.ToShortDateString(); this.FechaIngreso.Text = theVotacionPropuestaDTO.FechaInicioVotacionPropuesta.ToShortDateString(); ddlCondominio.SelectedIndex = ddlCondominio.Items.IndexOf(ddlCondominio.Items.FindByValue(theVotacionPropuestaDTO.TheCondominioDTO.IdCondominio.ToString())); ddlComunidad.DataSource = YouCom.bll.ComunidadBLL.getListadoComunidadByCondominio(decimal.Parse(ddlCondominio.SelectedValue)); ddlComunidad.DataTextField = "NombreComunidad"; ddlComunidad.DataValueField = "IdComunidad"; ddlComunidad.DataBind(); ddlComunidad.Items.Insert(0, new ListItem("Seleccione Comunidad", string.Empty)); ddlComunidad.SelectedIndex = ddlComunidad.Items.IndexOf(ddlComunidad.Items.FindByValue(theVotacionPropuestaDTO.TheComunidadDTO.IdComunidad.ToString())); YouCom.DTO.Propietario.FamiliaDTO myFamiliaDTO = new YouCom.DTO.Propietario.FamiliaDTO(); myFamiliaDTO = YouCom.bll.FamiliaBLL.detalleFamilia(myPropuestaDTO.TheFamiliaDTO.IdFamilia); ddlCasa.DataSource = YouCom.bll.CasaBLL.getListadoCasaByComunidad(decimal.Parse(ddlComunidad.SelectedValue)); ddlCasa.DataTextField = "NombreCasa"; ddlCasa.DataValueField = "IdCasa"; ddlCasa.DataBind(); ddlCasa.Items.Insert(0, new ListItem("Seleccione Casa", string.Empty)); ddlCasa.SelectedIndex = ddlCasa.Items.IndexOf(ddlCasa.Items.FindByValue(myFamiliaDTO.TheCasaDTO.IdCasa.ToString())); ddlFamilia.DataSource = YouCom.bll.FamiliaBLL.getListadoFamiliaByCasa(decimal.Parse(ddlCasa.SelectedValue)); ddlFamilia.DataTextField = "NombreCompleto"; ddlFamilia.DataValueField = "IdFamilia"; ddlFamilia.DataBind(); ddlFamilia.Items.Insert(0, new ListItem("Seleccione Familia", string.Empty)); ddlFamilia.SelectedIndex = ddlFamilia.Items.IndexOf(ddlFamilia.Items.FindByValue(myPropuestaDTO.TheFamiliaDTO.IdFamilia.ToString())); ddlEstado.SelectedIndex = ddlEstado.Items.IndexOf(ddlEstado.Items.FindByValue(theVotacionPropuestaDTO.TheVotacionPropuestaEstadoDTO.IdVotacionPropuestaEstado.ToString())); this.HdnPropuestaId.Value = theVotacionPropuestaDTO.ThePropuestaDTO.IdPropuesta.ToString(); IList <VotacionPropuestaRespuestaDTO> theVotacionPropuestaRespuestaDTO = new List <VotacionPropuestaRespuestaDTO>(); theVotacionPropuestaRespuestaDTO = YouCom.bll.VotacionPropuestaRespuestaBLL.getListadoVotacionPropuestaRespuestaByVotacion(decimal.Parse(hdnVotacionPropuestaId.Value)); LitCantidadSi.Text = theVotacionPropuestaRespuestaDTO.Where(x => x.EleccionVotacion == "SI").Count().ToString(); LitCantidadNo.Text = theVotacionPropuestaRespuestaDTO.Where(x => x.EleccionVotacion == "NO").Count().ToString(); btnGrabar.Visible = false; btnEditar.Visible = true; } if (e.CommandName == "Eliminar") { HiddenField hdnVotacionPropuestaId = new HiddenField(); hdnVotacionPropuestaId = (HiddenField)e.Item.FindControl("hdnVotacionPropuestaId"); VotacionPropuestaDTO theVotacionPropuestaDTO = new VotacionPropuestaDTO(); theVotacionPropuestaDTO.IdVotacionPropuesta = decimal.Parse(hdnVotacionPropuestaId.Value); theVotacionPropuestaDTO.UsuarioModificacion = myUsuario.Rut; bool respuesta = YouCom.bll.VotacionPropuestaBLL.Delete(theVotacionPropuestaDTO); if (respuesta) { cargarVotacionPropuesta(); if (!Page.ClientScript.IsClientScriptBlockRegistered("SET")) { string script = "alert('VotacionPropuesta Eliminado correctamente.');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true); } } else { } } if (e.CommandName == "Votaciones") { HiddenField hdnVotacionPropuestaId = new HiddenField(); hdnVotacionPropuestaId = (HiddenField)e.Item.FindControl("hdnVotacionPropuestaId"); pnlAdministracionVotacionPropuesta.Visible = false; pnlVotaciones.Visible = true; IList <VotacionPropuestaRespuestaDTO> theVotacionPropuestaRespuestaDTO = new List <VotacionPropuestaRespuestaDTO>(); theVotacionPropuestaRespuestaDTO = YouCom.bll.VotacionPropuestaRespuestaBLL.getListadoVotacionPropuestaRespuestaByVotacion(decimal.Parse(hdnVotacionPropuestaId.Value)); rptVotaciones.DataSource = theVotacionPropuestaRespuestaDTO; rptVotaciones.DataBind(); } }