Beispiel #1
0
      protected void Page_Load(object sender, EventArgs e)
      {
         if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated || !System.Web.HttpContext.Current.User.IsInRole("NOTICIA"))
         {
            plhInserir.Visible = false;
         }

         if (!IsPostBack)
         {
            Noticia noticia = new Noticia();
            noticia.CarregaNoticias(rptNoticia);

            if (rptNoticia.Items.Count == 0)
            {
               rptNoticia.Visible = false;
               plhInfo.Visible = true;
               lblInfo.Text = "Nenhuma notícia foi incluída";
            }
            else
            {
               rptNoticia.Visible = true;
               plhInfo.Visible = false;
            }
         }
      }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated || !System.Web.HttpContext.Current.User.IsInRole("NOTICIA"))
                Response.Redirect("~/Default.aspx");

            Int64 idNoticia = Convert.ToInt64(HttpUtility.HtmlDecode(Request.QueryString["IdNoticia"]));

            if (!IsPostBack)
            {
                if (idNoticia > 0)
                {
                    Noticia noticia = new Noticia();
                    noticia.CarregaNoticia(idNoticia);

                    if (noticia.IdNoticia == 0)
                        Response.Redirect("~/Default.aspx");

                    TextBoxNoticia.Text = noticia.TextoNoticia;
                    TextBoxLink.Text = noticia.LinkNoticia;
                }
            }
        }
Beispiel #3
0
        protected void ButtonEnviar_Click(object sender, EventArgs e)
        {

            Noticia noticia = new Noticia();
            noticia.TextoNoticia = TextBoxNoticia.Text;
            noticia.LinkNoticia = TextBoxLink.Text;
            noticia.UserName = System.Web.HttpContext.Current.User.Identity.Name;

            if (Request.QueryString["IdNoticia"] != null)
            {
                noticia.IdNoticia = Convert.ToInt64(HttpUtility.HtmlDecode(Request.QueryString["IdNoticia"]));
                noticia.AtualizaNoticia();

                if (FileUpload.HasFile)
                {
                    ResizeImage(noticia.IdNoticia);
                }
            }
            else
            {
                if (!FileUpload.HasFile)
                {
                    AnexoValidator.ErrorMessage = "Imagem da notícia não informada.";
                    AnexoValidator.IsValid = false;
                    return;
                }

                noticia.ImagemNoticia = FileUpload.FileName;
                noticia.InsereNoticia();

                ResizeImage(noticia.IdNoticia);
            }

            Cache.Remove("tableNoticias");

            Response.Redirect("~/Noticias.aspx");
        }