Exemplo n.º 1
0
        protected override void OnLoad(EventArgs e)
        {
            Text = (DescriptionText == null) ? String.Empty : (DescriptionText + "<br />");

            using (SqlCommand cmd = DatabaseManager.Current.CreateCommand("SELECT * FROM Clubs WHERE Weekday=@weekday AND status=1 ORDER BY Name ASC"))
            {
                if (ShowAll)
                {
                    for (int i = 0; i < 7; i++)
                    {
                        if (cmd.Parameters.Contains("@weekday"))
                            cmd.Parameters.RemoveAt("@weekday");
                        cmd.Parameters.AddWithValue("@weekday", i);
                        using (SqlDataReader r = cmd.ExecuteReader())
                        {
                            if (r.HasRows)
                            {
                                Text += "<h2>" + dayNames[i] + "</h2><ul>";
                                while (r.Read())
                                {
                                    Club c = new Club(DatabaseManager.Current, r);
                                    Text += "<li><a href=\"ClubInfo.aspx?id=" + c.Id + "\">" + c.Name + " - " + c.Location + ((c.AfterSchool) ? " (After school)" : "") + "</a></li>";
                                }
                                Text += "</ul>";
                            }
                        }
                    }
                }
                else
                {
                    cmd.Parameters.AddWithValue("@weekday", DateTime.Today.DayOfWeek);
                    Text += "<ul>";
                    using (SqlDataReader r = cmd.ExecuteReader())
                    {
                        if (r.HasRows)
                        {
                            while (r.Read())
                            {
                                Club c = new Club(DatabaseManager.Current, r);
                                Text += "<li><a href=\"ClubInfo.aspx?id=" + c.Id + "\">" + c.Name + " - " + c.Location + ((c.AfterSchool) ? " (After school)" : "") + "</a></li>";
                            }
                        }
                        else
                        {
                            Text += "<li><em>No clubs are running today</em></li>";
                        }
                    }
                    Text += "</ul><a href=\"ClubList.aspx\">See all clubs</a>";
                }
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["id"] == null)
            {
                Response.Redirect("Default.aspx", true);
            }
            else
            {
                int id;
                try
                {
                    id = Int32.Parse(Request.Params["id"]);
                }
                catch (FormatException)
                {
                    Response.Redirect("Default.aspx", true);
                    return;
                }

                using (SqlCommand cmd = DatabaseManager.Current.CreateCommand("SELECT * FROM Clubs WHERE Id=@id AND Status=1"))
                {
                    cmd.Parameters.AddWithValue("@id", id);
                    Club c = null;
                    using (SqlDataReader r = cmd.ExecuteReader())
                    {
                        if (r.HasRows)
                        {
                            r.Read();
                            c = new Club(DatabaseManager.Current, r);
                        }
                    }
                    if (c != null)
                    {
                        ClubBox.Club = c;
                    }
                    else
                    {
                        Response.Redirect("Default.aspx", true);
                    }
                }
            }
        }
Exemplo n.º 3
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (Request.Params["id"] != null)
            {
                try
                {
                    info = Club.FromDatabase(DatabaseManager.Current, Int32.Parse(Request.Params["id"]));
                    if (info == null)
                        Response.Redirect("ClubList.aspx", true);
                }
                catch (FormatException)
                {
                    Response.Redirect("ClubList.aspx", true);
                }
            }
            else
            {
                info = new Club(DatabaseManager.Current);
            }

            if (!CurrentUser.SecurityAccess["CanAccessBackend"])
            {
                Response.Redirect("403.aspx", true);
            }

            if (info.Id > 0 && info.CreatorId != CurrentUser.Profile.Id && !CurrentUser.SecurityAccess["CanViewAllClub"])
                Response.Redirect("ClubList.aspx", true);
        }