Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                string id = Request.QueryString["id"];

                YouCom.DTO.NoticiaDTO myNoticiaDTO = new YouCom.DTO.NoticiaDTO();
                myNoticiaDTO = YouCom.bll.NoticiaBLL.detalleNoticia(decimal.Parse(id));

                LitNoticiaTitulo.Text  = myNoticiaDTO.NotiTitulo;
                LitNoticiaResumen.Text = myNoticiaDTO.NotiResumen;
                LitNoticiaDetalle.Text = myNoticiaDTO.NotiDetalle;
            }
        }
        catch (Exception ex)
        {
            string script = "'alert('" + ex.Message + "');";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
        }
    }
Example #2
0
    protected void rptNoticia_OnItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        UserControl  wucCondominio = (UserControl)Page.Master.FindControl("ContentPlaceHolder1").FindControl("wucCondominio1");
        DropDownList ddlCondominio = (DropDownList)wucCondominio.FindControl("ddlCondominio");
        DropDownList ddlComunidad  = (DropDownList)wucCondominio.FindControl("ddlComunidad");

        if (e.CommandName == "Editar")
        {
            HiddenField hdnNoticiaId = new HiddenField();
            hdnNoticiaId = (HiddenField)e.Item.FindControl("hdnNoticiaId");

            YouCom.DTO.NoticiaDTO theNoticiaDTO = new YouCom.DTO.NoticiaDTO();
            theNoticiaDTO = YouCom.bll.NoticiaBLL.detalleNoticia(decimal.Parse(hdnNoticiaId.Value));

            this.hdnNoticiaId.Value = theNoticiaDTO.NoticiaId.ToString();
            txtNoticiaTitulo.Text   = theNoticiaDTO.NotiTitulo;
            txtNoticiaResumen.Text  = theNoticiaDTO.NotiResumen;
            FCKeditorDetalle.Value  = theNoticiaDTO.NotiDetalle;
            TxtNotiAutor.Text       = theNoticiaDTO.NotiAutor;

            this.FechaPublicacion.Text = theNoticiaDTO.NotiPublicacion.ToShortDateString();
            this.FechaExpiracion.Text  = theNoticiaDTO.NotiExpiracion.ToShortDateString();

            ddlCondominio.SelectedIndex = ddlCondominio.Items.IndexOf(ddlCondominio.Items.FindByValue(theNoticiaDTO.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(theNoticiaDTO.TheComunidadDTO.IdComunidad.ToString()));

            ddlCategoria.SelectedIndex = ddlCategoria.Items.IndexOf(ddlCategoria.Items.FindByValue(theNoticiaDTO.TheCategoriaDTO.IdCategoria.ToString()));

            RdbNotiExpira.SelectedIndex = RdbNotiExpira.Items.IndexOf(RdbNotiExpira.Items.FindByValue(theNoticiaDTO.NotiExpira.ToString()));

            if (!string.IsNullOrEmpty(theNoticiaDTO.NotiImagen))
            {
                this.lnkImagen.Visible     = true;
                this.chkImagen.Visible     = true;
                this.lnkImagen.NavigateUrl = YouCom.Service.Generales.General.GetPropiedad("UploadsPathNoticiaPub") + theNoticiaDTO.NotiImagen;
            }


            btnGrabar.Visible = false;
            btnEditar.Visible = true;
        }
        if (e.CommandName == "Eliminar")
        {
            HiddenField hdnNoticiaId = new HiddenField();
            hdnNoticiaId = (HiddenField)e.Item.FindControl("hdnNoticiaId");

            NoticiaDTO theNoticiaDTO = new NoticiaDTO();
            theNoticiaDTO.NoticiaId           = decimal.Parse(hdnNoticiaId.Value);
            theNoticiaDTO.UsuarioModificacion = myUsuario.Rut;

            bool respuesta = YouCom.bll.NoticiaBLL.Delete(theNoticiaDTO);
            if (respuesta)
            {
                cargarNoticia();
                if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
                {
                    string script = "alert('Noticia Eliminada correctamente.');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                }
            }
            else
            {
            }
        }
    }
Example #3
0
    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;

        NoticiaDTO theNoticiaDTO = new NoticiaDTO();

        theNoticiaDTO.NoticiaId   = decimal.Parse(this.hdnNoticiaId.Value);
        theNoticiaDTO.NotiTitulo  = this.txtNoticiaTitulo.Text.ToUpper();
        theNoticiaDTO.NotiResumen = this.txtNoticiaResumen.Text.ToUpper();
        theNoticiaDTO.NotiDetalle = this.FCKeditorDetalle.Value;
        theNoticiaDTO.NotiAutor   = this.TxtNotiAutor.Text.ToUpper();

        YouCom.DTO.Seguridad.CondominioDTO myCondominioDTO = new YouCom.DTO.Seguridad.CondominioDTO();
        myCondominioDTO.IdCondominio   = decimal.Parse(ddlCondominio.SelectedValue);
        theNoticiaDTO.TheCondominioDTO = myCondominioDTO;

        YouCom.DTO.Seguridad.ComunidadDTO myComunidadDTO = new YouCom.DTO.Seguridad.ComunidadDTO();
        myComunidadDTO.IdComunidad    = decimal.Parse(ddlComunidad.SelectedValue);
        theNoticiaDTO.TheComunidadDTO = myComunidadDTO;

        YouCom.DTO.CategoriaDTO myCategoriaDTO = new YouCom.DTO.CategoriaDTO();
        myCategoriaDTO.IdCategoria    = decimal.Parse(ddlCategoria.SelectedValue);
        theNoticiaDTO.TheCategoriaDTO = myCategoriaDTO;

        theNoticiaDTO.UsuarioModificacion = myUsuario.Rut;

        if (this.FileImagenNoticia.HasFile)
        {
            theNoticiaDTO.NotiImagen = YouCom.Service.Imagenes.Imagen.ProcessFileResize(FileImagenNoticia, YouCom.Service.Generales.General.GetPropiedad("UploadsPathBann"), 198, 118, Page);
        }
        else
        {
            YouCom.DTO.NoticiaDTO myNoticiaDTO = new YouCom.DTO.NoticiaDTO();
            myNoticiaDTO = YouCom.bll.NoticiaBLL.detalleNoticia(decimal.Parse(hdnNoticiaId.Value));

            theNoticiaDTO.NotiImagen = myNoticiaDTO.NotiImagen;
        }


        theNoticiaDTO.NotiPublicacion = DateTime.ParseExact(this.FechaPublicacion.Text + " " + DateTime.Now.ToString("HH:mm"), "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);
        theNoticiaDTO.NotiInicio      = DateTime.ParseExact(this.FechaPublicacion.Text + " " + DateTime.Now.ToString("HH:mm"), "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);

        theNoticiaDTO.NotiExpira = string.Copy(RdbNotiExpira.SelectedItem.Value);

        if (RdbNotiExpira.SelectedValue.Equals("S"))
        {
            theNoticiaDTO.NotiExpiracion = DateTime.ParseExact(this.FechaExpiracion.Text + " 00:00", "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);
        }
        else
        {
            theNoticiaDTO.NotiExpiracion = DateTime.MaxValue;
        }

        bool respuesta = YouCom.bll.NoticiaBLL.Update(theNoticiaDTO);

        if (respuesta)
        {
            cargarNoticia();
            this.TxtNotiAutor.Text      = string.Empty;
            this.txtNoticiaTitulo.Text  = string.Empty;
            this.txtNoticiaResumen.Text = string.Empty;

            if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
            {
                string script = "alert('Noticia editada correctamente.');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
            }
        }
        else
        {
        }
    }