Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    NoticiaDAL nDAL = new NoticiaDAL();
                    Noticia    n    = nDAL.ObterDadosPorId(Convert.ToInt32(Request.QueryString["idNtc"]));

                    txtTitulo.Text = n.DSTitulo;
                    ckeditor_standard.InnerText = n.DSCorpo;

                    if (n.BTAtiva == true)
                    {
                        radAtivo_N.Checked = false;
                        radAtivo_S.Checked = true;
                    }
                    else
                    {
                        radAtivo_N.Checked = true;
                        radAtivo_S.Checked = false;
                    }
                }
            }
            catch (Exception)
            { throw; }
        }
Exemplo n.º 2
0
        protected string getImagem(int _IdNoticia)
        {
            try
            {
                NoticiaDAL nDAL = new NoticiaDAL();
                Noticia    n    = nDAL.ObterDadosPorId(_IdNoticia);

                if (!string.IsNullOrEmpty(n.DSArquivoImagem))
                {
                    string strExtensao = n.DSArquivoImagem.Substring(n.DSArquivoImagem.Length - 3);

                    ResizeSettings resizeCropSettings_Capa  = new ResizeSettings("width=457&height=343&format=" + strExtensao + "&crop=auto");
                    ResizeSettings resizeCropSettings_Thumb = new ResizeSettings("width=100&height=100&format=" + strExtensao + "&crop=auto");

                    string capa = Path.Combine(ConfigurationManager.AppSettings["path"], System.Guid.NewGuid().ToString());
                    capa = ImageBuilder.Current.Build(ConfigurationManager.AppSettings["path"] + @"\Noticias\" + n.DSArquivoImagem, ConfigurationManager.AppSettings["path"] + "/Noticias/Capas/cp_" + n.IDNoticia, resizeCropSettings_Capa, false, true);

                    string thumb = Path.Combine(ConfigurationManager.AppSettings["path"], System.Guid.NewGuid().ToString());
                    thumb = ImageBuilder.Current.Build(ConfigurationManager.AppSettings["path"] + @"\Noticias\" + n.DSArquivoImagem, ConfigurationManager.AppSettings["path"] + "/Noticias/Thumbs/tb_" + n.IDNoticia, resizeCropSettings_Thumb, false, true);

                    return("<img src=\"" + ConfigurationManager.AppSettings["url"] + "/Arquivos/Noticias/Thumbs/tb_" + n.DSArquivoImagem + "\" />");
                }
                else
                {
                    return("");
                }
            }
            catch (Exception)
            { throw; }
        }
Exemplo n.º 3
0
        public ActionResult Index()
        {
            NoticiaDAL noticiaDAL = new NoticiaDAL();

            ViewBag.Noticias = noticiaDAL.Lista().Take(4).ToList();

            return(View());
        }
Exemplo n.º 4
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int        codigo     = Convert.ToInt32(txtCodigo.Text);
            NoticiaDAL noticiaDAL = new NoticiaDAL();

            noticiaDAL.ExcluirNoticia(codigo);
            LimparDados();
        }
Exemplo n.º 5
0
        protected string getNoticia(int _IdNoticia)
        {
            try
            {
                NoticiaDAL nDAL = new NoticiaDAL();
                Noticia    n    = nDAL.ObterDadosPorId(_IdNoticia);

                return("<li> <a href=\"../Noticias/VisualizarNoticia.aspx?idNtc=" + n.IDNoticia + "\"><img src=\"" + ConfigurationManager.AppSettings["url"] + "/Arquivos/Noticias/Thumbs/tb_" + n.DSArquivoImagem + "\" alt=\"\" /></a> <a href=\"../Noticias/VisualizarNoticia.aspx?idNtc=" + n.IDNoticia + "\" class=\"title\">" + n.DSTitulo + "</a><p>" + n.DSCorpo.Substring(0, 225) + "...</p> </li>");
            }
            catch (Exception)
            { throw; }
        }
Exemplo n.º 6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         // LISTA AS NOTÍCIAS //
         NoticiaDAL nDAL = new NoticiaDAL();
         rptNoticias.DataSource = nDAL.Listar().Cast <Noticia>().Where(a => a.BTAtiva == true);
         rptNoticias.DataBind();
         // FIM //
     }
     catch (Exception)
     { throw; }
 }
Exemplo n.º 7
0
        protected void btnAtualizar_Click(object sender, EventArgs e)
        {
            Noticia noticia = new Noticia();

            noticia.Codigo         = Convert.ToInt32(txtCodigo.Text);
            noticia.Titulo         = txtTitulo.Text;
            noticia.DataPublicacao = Convert.ToDateTime(txtDataPublicacao.Text);
            noticia.Texto          = txtTexto.Text;

            NoticiaDAL noticiaDAL = new NoticiaDAL();

            noticiaDAL.AtualizarNoticia(noticia);
            LimparDados();
        }
Exemplo n.º 8
0
        protected void btnInserir_Click(object sender, EventArgs e)
        {
            Noticia noticia = new Noticia();

            noticia.Titulo         = txtTitulo.Text;
            noticia.DataPublicacao = Convert.ToDateTime(txtDataPublicacao.Text);
            noticia.Texto          = txtTexto.Text;


            NoticiaDAL noticiaDAL = new NoticiaDAL();

            noticiaDAL.InserirNoticia(noticia);
            LimparDados();
        }
Exemplo n.º 9
0
        protected void Alterar(object sender, EventArgs e)
        {
            try
            {
                NoticiaDAL nDAL = new NoticiaDAL();
                Noticia    n    = nDAL.ObterDadosPorId(Convert.ToInt32(Request.QueryString["idNtc"]));

                n.DSTitulo = txtTitulo.Text;
                n.DSCorpo  = ckeditor_standard.InnerText;

                if (radAtivo_N.Checked)
                {
                    n.BTAtiva = false;
                }
                else
                {
                    n.BTAtiva = true;
                }

                nDAL.Alterar(n);

                #region IMAGEM
                if (txtImagem.HasFile)
                {
                    switch (txtImagem.FileName.Substring(txtImagem.FileName.Length - 4))
                    {
                    case ".jpg":
                        string strNome;

                        strNome           = n.IDNoticia + txtImagem.FileName.Substring(txtImagem.FileName.Length - 4);
                        n.DSArquivoImagem = strNome;

                        txtImagem.SaveAs(ConfigurationManager.AppSettings["path"] + @"\Noticias\" + strNome);

                        nDAL.Alterar(n);

                        break;

                    default:
                        break;
                    }
                }
                #endregion

                Response.Write("<script language='JavaScript'>alert('Notícia alterada com sucesso');window.parent.location='ListarNoticias.aspx';</script>");
            }
            catch (Exception)
            { throw; }
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    NoticiaDAL nDAL = new NoticiaDAL();
                    Noticia    n    = nDAL.ObterDadosPorId(Convert.ToInt32(Request.QueryString["idNtc"]));

                    litTitulo.Text = n.DSTitulo;
                    litCorpo.Text  = n.DSCorpo;
                }
            }
            catch (Exception)
            { throw; }
        }
Exemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                NoticiaDAL nDAL = new NoticiaDAL();

                switch (Request.QueryString["act"])
                {
                case "exc":
                    Noticia n = nDAL.ObterDadosPorId(Convert.ToInt32(Request.QueryString["idNtc"]));

                    string strCaminho = ConfigurationManager.AppSettings["path"];

                    if (File.Exists(strCaminho + "/Capas/cp_" + n.DSArquivoImagem))
                    {
                        File.Delete(strCaminho + "/Capas/cp_" + n.DSArquivoImagem);
                    }

                    if (File.Exists(strCaminho + "/Thumbs/tb_" + n.DSArquivoImagem))
                    {
                        File.Delete(strCaminho + "/Thumbs/tb_" + n.DSArquivoImagem);
                    }

                    if (File.Exists(strCaminho + n.DSArquivoImagem))
                    {
                        File.Delete(strCaminho + n.DSArquivoImagem);
                    }

                    nDAL.Excluir(n);
                    Response.Write("<script language='JavaScript'>alert('Notícia excluída com sucesso');location='ListarNoticias.aspx';</script>");
                    break;

                default:
                    break;
                }

                // LISTA AS NOTÍCIAS //
                rptNoticias.DataSource = nDAL.Listar();
                rptNoticias.DataBind();
                // FIM //
            }
            catch (Exception)
            { throw; }
        }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                NoticiaDAL nDAL = new NoticiaDAL();

                // OBTEM A ÚLTIMA NOTÍCIA CADASTRADA //
                Noticia nUltima = nDAL.Listar().Cast <Noticia>().OrderByDescending(i => i.IDNoticia).FirstOrDefault();
                litImagemNoticia.Text = "<a href=\"../Noticias/VisualizarNoticia.aspx?idNtc=" + nUltima.IDNoticia + "\"><img src=\"" + ConfigurationManager.AppSettings["url"] + "/Arquivos/Noticias/Capas/cp_" + nUltima.DSArquivoImagem + "\" alt=\"\" /></a>";
                litTituloNoticia.Text = nUltima.DSTitulo;
                // FIM //

                // LISTA AS ÚLTIMAS NOTÍCIAS //
                rptUltimasNoticias.DataSource = nDAL.Listar().Cast <Noticia>().Where(i => i.IDNoticia != nUltima.IDNoticia).Where(a => a.BTAtiva == true).OrderByDescending(i => i.IDNoticia).Take(6);
                rptUltimasNoticias.DataBind();
                // FIM //
            }
            catch (Exception)
            { throw; }
        }
Exemplo n.º 13
0
        public static bool ActivaNoticia(NoticiaDTO theNoticiaDTO)
        {
            bool respuesta = NoticiaDAL.ActivaNoticia(theNoticiaDTO);

            return(respuesta);
        }
Exemplo n.º 14
0
        public static bool Update(DTO.NoticiaDTO myNoticiaDTO)
        {
            bool resultado = NoticiaDAL.Update(myNoticiaDTO);

            return(resultado);
        }
Exemplo n.º 15
0
        public static bool Insert(DTO.NoticiaDTO myNoticiaDTO)
        {
            bool resultado = NoticiaDAL.Insert(myNoticiaDTO);

            return(resultado);
        }
Exemplo n.º 16
0
 public NoticiaBL()
 {
     this.noticiaDAL = new NoticiaDAL();
 }