Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int nb = 0;

        int.TryParse("" + objModules.GetModuleSettings(ModuleId)["nbnews"], out nb);

        int cric = -1;
        var news = new List <News>();

        if (categorie == "clubCourant")
        {
            string seo = Request.QueryString["sn"];
            if (seo != null && seo != "")
            {
                Club club = DataMapping.GetClubBySeo(seo);
                cric = club.cric;
            }



            news = DataMapping.ListNews_EN(cric: cric != -1 ? cric : 0, onlyvisible: true, category: "Clubs", tri: "dt desc", tags_included: "" + objModules.GetModuleSettings(ModuleId)["tags_included"], tags_excluded: "" + objModules.GetModuleSettings(ModuleId)["tags_excluded"]);
        }
        else if (categorie == "selectedClub")
        {
            cric = Functions.CurrentCric;
            if (cric == 0)
            {
                lbl_noClubSelected.Visible = false;
            }
            else
            {
                news = DataMapping.ListNews_EN(cric: cric, onlyvisible: true, category: "Clubs", tri: "dt desc", tags_included: "" + objModules.GetModuleSettings(ModuleId)["tags_included"], tags_excluded: "" + objModules.GetModuleSettings(ModuleId)["tags_excluded"]);
            }
        }
        else
        {
            news = DataMapping.ListNews_EN(cric: 0, onlyvisible: true, category: categorie, tri: "dt asc", where : "dt>getdate()", tags_included: "" + objModules.GetModuleSettings(ModuleId)["tags_included"], tags_excluded: "" + objModules.GetModuleSettings(ModuleId)["tags_excluded"]);
        }



        List <News> TheNews = new List <News>();

        for (int i = 0; i < Math.Min(nb, news.Count); i++)
        {
            TheNews.Add(news[i]);
        }


        if (TheNews.Count == 0)
        {
            lbl_noNews.Visible = true;
        }
        LI_News.DataSource = TheNews;
        LI_News.DataBind();
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int cric = 0;

        int.TryParse("" + Request.QueryString["cric"], out cric);
        newsid = "" + Request.QueryString["newsid"];
        List <News> news = AIS.DataMapping.ListNews(onlyvisible: true, category: (cric == 0?"District":"Clubs"), cric: cric, top: "top 10");

        LI_News.DataSource = news;
        //if (newsid == "")
        //{
        //    if (news.Count > 0)
        //    {
        //        newsid = news[0].id.ToString();
        //        Response.Redirect(Functions.UrlAddParam(Request.Url.ToString(), "newsid", newsid));
        //        return;
        //    }
        //}
        LI_News.DataBind();
    }
Exemple #3
0
    protected void LI_News_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        news = AIS.DataMapping.ListNews_EN(tri: "ord", onlyvisible: true, category: categorie, tags_included: "" + objModules.GetModuleSettings(ModuleId)["tags_included"], tags_excluded: "" + objModules.GetModuleSettings(ModuleId)["tags_excluded"]);
        if (e.CommandSource == e.Item.FindControl("btn_up"))
        {
            News theNews = DataMapping.GetNews(e.CommandName);
            if (theNews.ord > 10)
            {
                News newsOnTop = null;
                foreach (News n in news)
                {
                    if (n.ord == theNews.ord - 10)
                    {
                        newsOnTop = n;
                        break;
                    }
                }
                if (newsOnTop == null)
                {
                    throw new Exception("Error news on top");
                }

                int tempOrd = theNews.ord;
                theNews.ord   = newsOnTop.ord;
                newsOnTop.ord = tempOrd;

                if (!DataMapping.UpdateNews_EN(theNews))
                {
                    throw new Exception("Error update news");
                }

                if (!DataMapping.UpdateNews_EN(newsOnTop))
                {
                    throw new Exception("Error update news on top");
                }
            }
        }
        else if (e.CommandSource == e.Item.FindControl("btn_down"))
        {
            News theNews = DataMapping.GetNews(e.CommandName);
            if (theNews.ord < news.Count * 10)
            {
                News newsOnBot = null;
                foreach (News n in news)
                {
                    if (n.ord == theNews.ord + 10)
                    {
                        newsOnBot = n;
                        break;
                    }
                }
                if (newsOnBot == null)
                {
                    throw new Exception("Error news on bottom");
                }

                int tempOrd = theNews.ord;
                theNews.ord   = newsOnBot.ord;
                newsOnBot.ord = tempOrd;

                if (!DataMapping.UpdateNews_EN(theNews))
                {
                    throw new Exception("Error update news");
                }

                if (!DataMapping.UpdateNews_EN(newsOnBot))
                {
                    throw new Exception("Error update news on bottom");
                }
            }
        }
        else if (e.CommandSource == e.Item.FindControl("lbt_delete"))
        {
            LinkButton lbt_delete = (LinkButton)e.Item.FindControl("lbt_delete");

            if (!DataMapping.DeleteNews(lbt_delete.CommandArgument))
            {
                throw new Exception("Error deleting");
            }
        }
        news = AIS.DataMapping.ListNews_EN(tri: "ord", onlyvisible: true, category: categorie, tags_included: "" + objModules.GetModuleSettings(ModuleId)["tags_included"], tags_excluded: "" + objModules.GetModuleSettings(ModuleId)["tags_excluded"]);
        LI_News.DataSource = news;
        LI_News.DataBind();
    }
Exemple #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            newsid = ("" + Request.QueryString["newsid"]);



            if (HasPermission() && Request.QueryString["id"] != null && Request.QueryString["id"] != "" && (Request.QueryString["modif"] != null || Request.QueryString["modif"] == "true"))
            {
                LI_News.Visible = false;
                btn_add.Visible = false;
                pnl_add.Visible = true;
                News theNews = DataMapping.GetNews_EN(Request.QueryString["id"]);
                if (tbx_titre.Text == "")
                {
                    tbx_titre.Text = theNews.title;
                }
                if (theNews.photo != "")
                {
                    btn_image.Text = "Changer l'image";
                }

                switch (theNews.tag2)
                {
                case "BlocNoPhoto":
                    if (tbx_contenu.Text == "")
                    {
                        tbx_contenu.Text = theNews.text;
                    }
                    pnl_image.Visible   = false;
                    pnl_video.Visible   = false;
                    tbx_contenu.Visible = true;
                    break;

                case "BlocVideo":
                    Video vid = new Video();
                    vid = (Video)Functions.Deserialize(theNews.text, vid.GetType());
                    if (tbx_url.Text == "")
                    {
                        tbx_url.Text = vid.Url;
                    }
                    pnl_video.Visible   = true;
                    pnl_image.Visible   = false;
                    tbx_contenu.Visible = false;
                    break;

                default:
                    if (tbx_contenu.Text == "")
                    {
                        tbx_contenu.Text = theNews.text;
                    }
                    if (hfd_image.Value == "")
                    {
                        hfd_image.Value = theNews.photo;
                    }
                    if (img.ImageUrl == "")
                    {
                        img.ImageUrl = theNews.photo;
                    }
                    pnl_image.Visible   = true;
                    tbx_contenu.Visible = true;
                    pnl_video.Visible   = false;
                    break;
                }
                foreach (ListItem li in rbl_type.Items)
                {
                    if ("Bloc" + li.Value == theNews.tag2)
                    {
                        li.Selected = true;
                        break;
                    }
                }
            }



            int nb = 0;
            int.TryParse("" + objModules.GetModuleSettings(ModuleId)["nbnews"], out nb);
            //var news = (from n in AIS.DataMapping.ListeNews(onlyvisible: true, categorie: categorie, tags_inclus: "" + objModules.GetModuleSettings(ModuleId)["tags_inclus"], tags_exclus: "" + objModules.GetModuleSettings(ModuleId)["tags_exclus"]) orderby n.dt ascending where n.dt.CompareTo( DateTime.Now.AddDays(-1))>0 select n );

            //List<News> news = DataMapping.ListNews(sort: "ord");

            news = AIS.DataMapping.ListNews_EN(tri: "ord", onlyvisible: true, category: categorie, tags_included: "" + objModules.GetModuleSettings(ModuleId)["tags_included"], tags_excluded: "" + objModules.GetModuleSettings(ModuleId)["tags_excluded"]);

            LI_News.DataSource = news;
            if (HasPermission() && Request.QueryString["delete"] != null && Request.QueryString["delete"] == "true")
            {
                List <News> newsToDelete = new List <News>();
                pnl_delete.Visible = true;
                btn_add.Visible    = false;
                foreach (News n in news)
                {
                    if (n.id == Request.QueryString["id"])
                    {
                        newsToDelete.Add(n);
                    }
                }
                LI_News.DataSource = newsToDelete;
            }
            LI_News.DataBind();
            btn_add.Visible = HasPermission() && LI_News.Visible && (Request.QueryString["modif"] == null || Request.QueryString["modif"] == "") && (Request.QueryString["delete"] == null || Request.QueryString["delete"] == "");
        }
    }