Example #1
0
    private void Salvar()
    {
        try
        {
            this.CarregarObjetos(Utilitarios.TipoTransacao.Salvar, gobjNoticia);

            if (hdnNoticiaId.Value == "0")
            {
                gobjNoticia = DONoticia.Inserir(gobjNoticia);

                if (gobjNoticia.ID > 0)
                {
                    hdnNoticiaId.Value = gobjNoticia.ID.ToString();
                }

                Response.Redirect(string.Format("EditarNoticia.aspx?Noticia={0}&sucesso=1", gobjNoticia.ID));
            }
            else
            {
                if (DOModNoticia.Alterar(gobjNoticia) > 0)
                {
                    Response.Redirect(string.Format("EditarNoticia.aspx?Noticia={0}&sucesso=2", gobjNoticia.ID));
                }
            }
        }
        catch (Exception ex)
        {
            //Chama o método para gravar erro
            ((Modulos_Modulos)Master).ExibirAlerta(ex);
        }
    }
    private void CarregarObjetosListagem()
    {
        try
        {
            CarregarTipoNoticia();
            List <ModNoticia> objListModNoticia = new List <ModNoticia>();

            objListModNoticia = DOModNoticia.ListarNoticiasModulos(IdConteudo, null);

            List <Noticia> lstNoticia = new List <Noticia>();

            foreach (ModNoticia modNoticia in objListModNoticia)
            {
                lstNoticia.Add(DONoticia.Obter(new Noticia()
                {
                    ID = modNoticia.IdNoticia
                }));
            }

            grvNoticias.DataSource = lstNoticia;
            grvNoticias.DataBind();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Example #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (UsuarioLogado() == null)
            {
                Response.Redirect("/Manager/Login.aspx", true);
            }

            if ((Request.QueryString["Sucesso"] == "1"))
            {
                ((Modulos_Modulos)Master).ExibirMensagem(Resources.Textos.Mensagem_Salva_Sucesso);
            }
            else if ((Request.QueryString["Sucesso"] == "2"))
            {
                ((Modulos_Modulos)Master).ExibirMensagem(Resources.Textos.Mensagem_Atualizado_Sucesso);
            }

            noticia            = Convert.ToInt32(Request.QueryString["Noticia"]);
            hdnNoticiaId.Value = noticia.ToString();
            this.IniciaTela();
            CarregarObjetos(Utilitarios.TipoTransacao.Limpar);

            if (noticia > 0)
            {
                gobjNoticia = DONoticia.Obter(new Noticia()
                {
                    ID = noticia
                });
                CarregarObjetos(Utilitarios.TipoTransacao.Carregar, gobjNoticia);
            }
        }
    }
    protected void btnVincularModuloNoticia_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            if (ddlTipoNoticia.SelectedIndex > 0 && ddlNoticia.SelectedIndex > 0)
            {
                List <Noticia> lNoticia = new List <Noticia>();
                lNoticia = (List <Noticia>)Session["sNoticia"];

                var noticia = DONoticia.Obter(new Noticia()
                {
                    ID = Convert.ToInt32(ddlNoticia.SelectedValue), TipoNoticia = new TipoNoticia()
                    {
                        ID = Convert.ToInt32(ddlTipoNoticia.SelectedValue)
                    }
                });
                lNoticia.Add(noticia);

                grvNoticias.DataSource = lNoticia;
                grvNoticias.DataBind();

                Session["sNoticia"] = lNoticia;
            }
            else
            {
                MostrarMensagem("Selecione o tipo de noticia e a noticia");
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Example #5
0
    protected void btnExcluir_Click(object sender, EventArgs e)
    {
        var registroExcluido = false;

        try
        {
            foreach (GridViewRow item in grdDados.Rows)
            {
                if (item.RowType == DataControlRowType.DataRow)
                {
                    CheckBox chk = (CheckBox)item.FindControl("chkSeleciona");
                    if (chk.Checked)
                    {
                        try
                        {
                            var noticia = new Noticia()
                            {
                                ID = int.Parse(item.Cells[1].Text)
                            };
                            if (DONoticia.Excluir(noticia) > 0)
                            {
                                registroExcluido = true;
                            }
                            else
                            {
                                registroExcluido = false;
                            }
                        }
                        catch (Exception ex)
                        {
                            if (ex.Message.IndexOf("conflicted", StringComparison.InvariantCultureIgnoreCase) > -1)
                            {
                                ((Modulos_Modulos)Master).ExibirMensagem(Resources.Textos.Mensagem_Erro_FK); break;
                            }
                        }
                    }
                }
            }
            if (registroExcluido)
            {
                ((Modulos_Modulos)Master).ExibirMensagem(Resources.Textos.Mensagem_Exclusao_sucesso);
                LerDados();
            }
            else
            {
                ((Modulos_Modulos)Master).ExibirMensagem(Resources.Textos.Mensagem_Exclusao_Erro);
            }
        }
        catch (Exception ex)
        {
            ((Modulos_Modulos)Master).ExibirAlerta(ex);
        }
    }
    private void CarregaNoticia(int pTipoNoticiaId)
    {
        try
        {
            ddlNoticia.DataSource = DONoticia.Listar(new Noticia()
            {
                TipoNoticia = new TipoNoticia()
                {
                    ID = pTipoNoticiaId
                }
            });
            ddlNoticia.DataTextField  = "Titulo";
            ddlNoticia.DataValueField = "Id";
            ddlNoticia.DataBind();

            ddlNoticia.Items.Insert(0, new ListItem("Selecione a notícia", "-1"));
            ddlNoticia.SelectedIndex = 0;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
 private void CarregaDestaque(int pTipoArquivoId)
 {
     try
     {
         Noticia noticia = DONoticia.ObterDestaqueHome(new Noticia()
         {
             Destaque = true, TipoArquivo = new TipoArquivo()
             {
                 Id = pTipoArquivoId
             }
         });
         lblSubTipoDestaqueInterna.Text = noticia.TipoNoticia.Descricao;
         lblTituloDestaqueInterna.Text  = noticia.Titulo;
         lblResumoDestaqueInterna.Text  = noticia.Resumo;
         divBackGround.Attributes.Add("style", "height: 432px; background-image:url('" + DOArquivos.Obter(new Arquivos()
         {
             Id = noticia.Capa.Id
         }).Caminho + "')");
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #8
0
    private void ObterConteudo()
    {
        IdConteudo = Convert.ToInt32(this.Parent.ID.Replace("CTT_", string.Empty));
        IdIdioma   = 1;

        HttpCookie cookie = Request.Cookies["_culture"];

        if (cookie != null)
        {
            IdIdioma = Convert.ToInt32(cookie.Value);
        }

        List <ModNoticia> lModNoticia = DOModNoticia.ListarNoticiasModulos(IdConteudo, null);

        List <Noticia> lNoticia = new List <Noticia>();

        foreach (ModNoticia item in lModNoticia)
        {
            Noticia noticia = new Noticia();
            noticia.ID = item.IdNoticia;
            noticia    = DONoticia.Obter(noticia);
            lNoticia.Add(noticia);
        }

        List <int> lstAno = new List <int>();

        foreach (var item in lNoticia)
        {
            if (!lstAno.Contains(item.DataNoticia.Year))
            {
                lstAno.Add(item.DataNoticia.Year);
            }
        }

        ddlAno.DataSource = lstAno;
        ddlAno.DataBind();


        Session.Add("sNoticias", lNoticia);

        pnlNoticiaHome.Visible     = false;
        pnlNoticiaInterna.Visible  = false;
        pnlNoticiaDestaque.Visible = false;

        if (lModNoticia.Count > 0)
        {
            if (lModNoticia[0].Home)
            {
                pnlNoticiaHome.Visible = true;
                CarregarDadosHome(lModNoticia);
            }
            else if (lModNoticia[0].Listagem)
            {
                pnlNoticiaInterna.Visible = true;
                BindNoticias();
            }
            else if (lModNoticia[0].Destaque)
            {
                pnlNoticiaDestaque.Visible = true;
                CarregarDadosDestaque(lModNoticia);
            }

            divSemConteudo.Visible = false;
            divConteudo.Visible    = true;
        }
        else
        {
            divSemConteudo.Visible     = true;
            pnlNoticiaHome.Visible     = false;
            pnlNoticiaInterna.Visible  = false;
            pnlNoticiaDestaque.Visible = false;
            divConteudo.Visible        = false;
        }
    }
    private int BindNoticias()
    {
        int retorno = 0;

        try
        {
            List <Noticia> lst = new List <Noticia>();
            lst = (List <Noticia>)Session["sNoticias"];

            if (lst[0] != null && lst[0].ID > 0)
            {
                CarregaDestaque(lst[0].TipoArquivo.Id);

                lst = FiltrosNoticia(DONoticia.Listar(new Noticia()
                {
                    TipoArquivo = new TipoArquivo()
                    {
                        Id = lst[0].TipoArquivo.Id
                    }
                }));

                PagedDataSource pds = new PagedDataSource();
                pds.DataSource = lst.OrderByDescending(x => x.DataNoticia).ToList();

                pds.AllowPaging = true;
                pds.PageSize    = 3;

                int count = pds.PageCount;
                pds.CurrentPageIndex = CurrentPage;

                if (pds.Count > 0)
                {
                    lbtnPrev.Visible  = true;
                    lbtnNext.Visible  = true;
                    lbtnFirst.Visible = true;
                    lbtnLast.Visible  = true;

                    lblStatus.Text = "| Página " + Convert.ToString(CurrentPage + 1) + " de " + Convert.ToString(pds.PageCount);
                }

                else
                {
                    lbtnPrev.Visible  = false;
                    lbtnNext.Visible  = false;
                    lbtnFirst.Visible = false;
                    lbtnLast.Visible  = false;
                }

                lbtnPrev.Enabled  = !pds.IsFirstPage;
                lbtnNext.Enabled  = !pds.IsLastPage;
                lbtnFirst.Enabled = !pds.IsFirstPage;
                lbtnLast.Enabled  = !pds.IsLastPage;

                rptNoticia.DataSource = pds;
                rptNoticia.DataBind();

                retorno = count;
            }
            return(retorno);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    private void CarregarDadosHome(List <ModNoticia> objListModNoticia)
    {
        try
        {
            if (objListModNoticia.Count > 0)
            {
                foreach (ModNoticia mNoticia in objListModNoticia)
                {
                    Noticia noticia = DONoticia.Obter(new Noticia()
                    {
                        ID = mNoticia.IdNoticia
                    });
                    //DONoticia.ObterDestaqueHome(new Noticia() { TipoArquivo = new TipoArquivo() { Id = mNoticia.TipoArquivoId },  Destaque = true });
                    //Noticia noticia = DOModNoticia.Obter(new Noticia() { ID = mNoticia.IdNoticia });
                    if (noticia.ID > 0)
                    {
                        switch (mNoticia.TipoNoticiaId)
                        {
                        case ((int)(Utilitarios.TipoNoticia.Esquerdo)):
                            divEsquerdoHome.Attributes.Add("style", "background-image:url('" + DOArquivos.Obter(new Arquivos()
                            {
                                Id = noticia.Capa.Id
                            }).Caminho + "')");
                            lblSubTipoEsquerdo.Text = DoTipoNoticia.Obter(noticia.TipoNoticia).Descricao;
                            lblTituloEsquerdo.Text  = noticia.Titulo;
                            lblResumoEsquerdo.Text  = noticia.Resumo;
                            break;

                        case ((int)(Utilitarios.TipoNoticia.DireitoSuperior)):
                            divDireitaSuperiorHome.Attributes.Add("style", "background-image:url('" + DOArquivos.Obter(new Arquivos()
                            {
                                Id = noticia.Capa.Id
                            }).Caminho + "')");
                            lblSubTipoDireitoSuperior.Text = DoTipoNoticia.Obter(noticia.TipoNoticia).Descricao;
                            lblTituloDireitoSuperior.Text  = noticia.Titulo;
                            break;

                        case ((int)(Utilitarios.TipoNoticia.DireitoCentral)):
                            divDireitaCentralHome.Attributes.Add("style", "background-image:url('" + DOArquivos.Obter(new Arquivos()
                            {
                                Id = noticia.Capa.Id
                            }).Caminho + "')");
                            lblSubTipoDireitoCentral.Text = DoTipoNoticia.Obter(noticia.TipoNoticia).Descricao;
                            lblTituloDireitoCentral.Text  = noticia.Titulo;
                            break;

                        case ((int)(Utilitarios.TipoNoticia.DireitoInferior)):
                            divDireitaInferiorHome.Attributes.Add("style", "background-image:url('" + DOArquivos.Obter(new Arquivos()
                            {
                                Id = noticia.Capa.Id
                            }).Caminho + "')");
                            lblSubTipoDireitoInferior.Text = DoTipoNoticia.Obter(noticia.TipoNoticia).Descricao;
                            lblTituloDireitoInferior.Text  = noticia.Titulo;
                            lblResumoDireitoInferior.Text  = noticia.Resumo;
                            break;
                        }
                    }
                }
                divSemConteudo.Visible = false;
                divConteudo.Visible    = true;
            }
            else
            {
                divSemConteudo.Visible    = true;
                divConteudo.Visible       = false;
                pnlNoticiaHome.Visible    = false;
                pnlNoticiaInterna.Visible = false;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }