Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            standingData = cmpController.GetCompetitionPointsByCompetitionID(CompetitionId);

            var distinctIds = standingData.AsEnumerable()
                              .Select(s => new
            {
                id = s.Field <int>("CompetitionGroupID"),
            })
                              .Distinct().ToList();

            if (distinctIds.Count > 1)
            {
                //for grouped competition, remove records that have not been assigned a group
                DataView dv = standingData.AsDataView();
                dv.RowFilter = "CompetitionGroupID <> 0";
                dv.RowFilter = "CompetitionGroupID IS NOT NULL";
                standingData = dv.ToTable();
            }

            if (distinctIds != null)
            {
                rptrGroups.DataSource = distinctIds;
                rptrGroups.DataBind();
            }
        }
        protected void rptrCompetitionList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Literal     ltrlTotalGroup   = e.Item.FindControl("ltrlTotalGroup") as Literal;
                Literal     ltrlTotalTeam    = e.Item.FindControl("ltrlTotalTeam") as Literal;
                HiddenField hdnCompId        = e.Item.FindControl("hdnCompId") as HiddenField;
                HyperLink   hlnkCompTitle    = e.Item.FindControl("hlnkCompTitle") as HyperLink;
                HyperLink   comp_group_view  = e.Item.FindControl("comp_group_view") as HyperLink;
                HyperLink   comp_sch_view    = e.Item.FindControl("comp_sch_view") as HyperLink;
                HyperLink   comp_res_view    = e.Item.FindControl("comp_res_view") as HyperLink;
                HyperLink   comp_newslink    = e.Item.FindControl("comp_newslink") as HyperLink;
                HyperLink   comp_videolink   = e.Item.FindControl("comp_videolink") as HyperLink;
                HyperLink   comp_gallerylink = e.Item.FindControl("comp_gallerylink") as HyperLink;


                int cid = 0;
                int.TryParse(hdnCompId.Value, out cid);

                #region For Hyperlink Visibility

                DataTable tbcheckData = new DataTable();

                tbcheckData = cmpController.GetCompetitionFixturesByCompetitionID(cid);

                if (tbcheckData.Rows.Count != 0)
                {
                    comp_sch_view.Visible = true;
                }

                tbcheckData = cmpController.GetCompetitionResultsByCompetitionID(cid);

                if (tbcheckData.Rows.Count != 0)
                {
                    comp_res_view.Visible = true;
                }

                tbcheckData = cmpController.GetCompetitionPointsByCompetitionID(cid);

                if (tbcheckData.Rows.Count != 0)
                {
                    comp_group_view.Visible = true;
                }

                tbcheckData = cmpController.GetCompetitionPhotoByCompetitionID(cid);

                if (tbcheckData.Rows.Count != 0)
                {
                    comp_gallerylink.Visible = true;
                }

                tbcheckData = cmpController.GetCompetitionVideoByCompetitionIDCheck(cid);

                if (tbcheckData.Rows.Count != 0)
                {
                    comp_videolink.Visible = true;
                }

                tbcheckData = cmpController.GetNewsByCompetitionId(cid, PortalId);

                if (tbcheckData.Rows.Count != 0)
                {
                    comp_newslink.Visible = true;
                }

                #endregion For Hyperlink Visibility

                if (hlnkCompTitle != null && cid > 0)
                {
                    hlnkCompTitle.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "conCompetitionAllDetail", "CompetitionID=" + cid);
                }

                if (comp_newslink != null && cid > 0)
                {
                    comp_newslink.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "conCompetitionAllDetail", "CompetitionID=" + cid, "CompTabID=4");
                }

                if (comp_videolink != null && cid > 0)
                {
                    comp_videolink.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "conCompetitionAllDetail", "CompetitionID=" + cid, "CompTabID=5");
                }

                if (comp_gallerylink != null && cid > 0)
                {
                    comp_gallerylink.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "conCompetitionAllDetail", "CompetitionID=" + cid, "CompTabID=6");
                }

                if (comp_group_view != null && cid > 0)
                {
                    comp_group_view.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "conCompetitionAllDetail", "CompetitionID=" + cid, "CompTabID=1");
                }

                if (comp_sch_view != null && cid > 0)
                {
                    comp_sch_view.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "conCompetitionAllDetail", "CompetitionID=" + cid, "CompTabID=2");
                }

                if (comp_res_view != null && cid > 0)
                {
                    comp_res_view.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "conCompetitionAllDetail", "CompetitionID=" + cid, "CompTabID=3");
                }

                StringBuilder sb = new StringBuilder();
                sb.Append("<div class=\"competition-allteam\">");

                if (ltrlTotalTeam.Text == "0" || ltrlTotalTeam.Text == String.Empty)
                {
                    ltrlTotalTeam.Visible = false;
                }
                else
                {
                    ltrlTotalTeam.Text = "Teams : <font color=\"Black\">" + ltrlTotalTeam.Text + "</font>";
                }

                if (ltrlTotalGroup.Text == "0" || ltrlTotalGroup.Text == String.Empty)
                {
                    ltrlTotalGroup.Visible = false;
                    //ltrlGroupText.Visible = false;

                    DataTable dt = cmpController.GetDetailAllTeamCompetitionGroupByCompetitionId(cid);

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            sb.Append("<div class=\"nogroup competition-groupcontainer\">");
                            sb.Append("<ul class=\"competition-group\">");
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                sb.Append("<li class=\"competition-team\">");
                                sb.Append("<a href='" + Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "TeamAllDetail", "TeamID=" + dt.Rows[i]["TeamID"]) + "' >");
                                string imagePath = "/Images/Team_Logo.png";

                                if (dt.Rows[i]["TeamLogo"] != null)
                                {
                                    if (System.IO.File.Exists(Server.MapPath("DesktopModules\\ThSport\\" + dt.Rows[i]["TeamLogo"].ToString())))
                                    {
                                        sb.Append("<img alt=\"\" src=\"\\DesktopModules\\ThSport\\" + dt.Rows[i]["TeamLogo"] + "\" class=\"flag\">");
                                    }
                                    else
                                    {
                                        sb.Append("<img alt=\"\" src=\"\\DesktopModules\\ThSport\\" + imagePath + "\" class=\"flag\">");
                                    }
                                }

                                if (dt.Rows[i]["TeamName"] != null)
                                {
                                    sb.Append("<span class=\"competition-team-name\">" + dt.Rows[i]["TeamName"] + "</span>");
                                }
                                sb.Append("</a>");
                                sb.Append("</li>");
                            }
                            sb.Append("</ul>");
                            sb.Append("</div>");
                        }
                    }
                }
                else
                {
                    ltrlTotalGroup.Text = "Groups: <font color=\"Black\">" + ltrlTotalGroup.Text + "</font>";
                    DataTable dt = cmpController.GetDetailAllTeamCompetitionGroupByCompetitionId(cid);
                    DataView  dv = dt.AsDataView();
                    dv.RowFilter = "CompetitionGroupName IS NOT NULL";
                    dt           = dv.ToTable();
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (i == 0)
                            {
                                string groupname = dt.Rows[i]["CompetitionGroupName"] == null ? String.Empty : dt.Rows[i]["CompetitionGroupName"].ToString();
                                sb.Append("<div class=\"competition-groupcontainer\">");
                                sb.Append("<ul class=\"competition-group\">");
                                sb.Append("<li class=\"competition-group-name\">" + dt.Rows[i]["CompetitionGroupName"].ToString() + "</a></li>");
                            }
                            else if (dt.Rows[i]["CompetitionGroupName"].ToString() != dt.Rows[i - 1]["CompetitionGroupName"].ToString())
                            {
                                string groupname = dt.Rows[i]["CompetitionGroupName"] == null ? String.Empty : dt.Rows[i]["CompetitionGroupName"].ToString();
                                sb.Append("</div><div class=\"competition-groupcontainer\">");
                                sb.Append("</ul><ul class=\"competition-group\">");
                                sb.Append("<li class=\"competition-group-name\">" + dt.Rows[i]["CompetitionGroupName"].ToString() + "</li>");
                            }

                            sb.Append("<li class=\"competition-team\">");
                            sb.Append("<a href='" + Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "TeamAllDetail", "TeamID=" + dt.Rows[i]["TeamID"]) + "' >");

                            string imagePath = "/Images/Team_Logo.png";

                            if (dt.Rows[i]["TeamLogo"] != null)
                            {
                                if (System.IO.File.Exists(Server.MapPath("DesktopModules\\ThSport\\" + dt.Rows[i]["TeamLogo"].ToString())))
                                {
                                    sb.Append("<img alt=\"\" src=\"\\DesktopModules\\ThSport\\" + dt.Rows[i]["TeamLogo"] + "\" class=\"flag\">");
                                }
                                else
                                {
                                    sb.Append("<img alt=\"\" src=\"\\DesktopModules\\ThSport\\" + imagePath + "\" class=\"flag\">");
                                }
                            }

                            if (dt.Rows[i]["TeamName"] != null)
                            {
                                sb.Append("<span class=\"competition-team-name\">" + dt.Rows[i]["TeamName"] + "</span>");
                            }
                            sb.Append("</a>");
                            sb.Append("</li>");
                        }

                        sb.Append("</ul>");
                        sb.Append("</div>");
                    }
                }

                sb.Append("</div>");
                Literal ltrlTeams = e.Item.FindControl("ltrlTeams") as Literal;
                ltrlTeams.Text = sb.ToString();
            }
        }