コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        leagueID = (int)((SiteMaster)this.Master).LeagueID;
        //Menu test  = ((Menu)((SiteMaster)this.Master).FindControl("NavigationMenu"));
        //test.FindItem("Stats").Selected = true;

        int currentSeasonID = DatabaseFunctions.GetCurrentSeasonID(leagueID.ToString());

        if (!Page.IsPostBack)
        {
            currentSeasonID = DatabaseFunctions.GetCurrentSeasonID(leagueID.ToString());
            List <Season> seasons   = DatabaseFunctions.GetSeasons(leagueID);
            List <int>    CourseIDs = DatabaseFunctions.GetCourseIDs(leagueID);

            //Populate Dropdowns
            ListItem newItem = new ListItem("All", "0");
            Dropdown_Seasons.Items.Add(newItem);

            foreach (Season season in seasons)
            {
                newItem = new ListItem(season.SeasonName, season.SeasonID.ToString());
                Dropdown_Seasons.Items.Add(newItem);
            }

            int selectedSeasonValue = Session["StatsSeasonDropdownValue"] == null ? 0 : int.Parse((string)Session["StatsSeasonDropdownValue"]);
            Dropdown_Seasons.SelectedValue = selectedSeasonValue.ToString();;

            Dictionary <int, string> golfers = DatabaseFunctions.GetGolferNamesAndIDs(leagueID.ToString());
            newItem = new ListItem("Select Player", "0");
            DropDown_PlayerSelect.Items.Add(newItem);

            foreach (int golferID in golfers.Keys)
            {
                newItem = new ListItem(golfers[golferID], golferID.ToString());
                DropDown_PlayerSelect.Items.Add(newItem);
            }

            int selectedPlayerValue = Session["StatsPlayerDropdownValue"] == null ? 0 : int.Parse((string)Session["StatsPlayerDropdownValue"]);
            DropDown_PlayerSelect.SelectedValue = selectedPlayerValue.ToString();

            //UpdateContent();
            //Dropdown_Season_SelectedIndexChanged(null, null);
            Scoring.LeagueStats LeagueStats = null;
            if (Session["LeagueStats"] == null)
            {
                LeagueStats            = Scoring.GetSeasonStats(leagueID, 0, CourseIDs);
                Session["LeagueStats"] = LeagueStats;
            }
            else
            {
                LeagueStats = (Scoring.LeagueStats)Session["LeagueStats"];
            }

            UpdateContent(LeagueStats, CourseIDs, leagueID);
        }
        showCurrentlySelectedView();
    }
コード例 #2
0
    protected void StatsMenu_MenuItemClick(Object sender, MenuEventArgs e)
    {
        int selectedSeason = int.Parse(Dropdown_Seasons.SelectedValue);
        int selectedPlayer = int.Parse(DropDown_PlayerSelect.SelectedValue);

        //Check dropdowns to see if they have changed since they were last saved.
        if (DropdownsChangedOrNotIinitialized())
        {
            Scoring.LeagueStats LeagueStats = null;
            List <int>          CourseIDs   = DatabaseFunctions.GetCourseIDs(leagueID);
            LeagueStats            = Scoring.GetSeasonStats(leagueID, selectedSeason, CourseIDs);
            Session["LeagueStats"] = LeagueStats;
            UpdateContent(LeagueStats, CourseIDs, leagueID);
            Session["StatsSeasonDropdownValue"] = Dropdown_Seasons.SelectedValue;
            Session["StatsPlayerDropdownValue"] = DropDown_PlayerSelect.SelectedValue;
        }

        if (e.Item.Value == "AvgAll")
        {
            Session["SelectedStatView"] = "AvgAll";
        }
        else if (e.Item.Value == "LowNet")
        {
            //Table_LowestNetSingleRoundScores.Style.Remove("display");
            Session["SelectedStatView"] = "LowNet";
        }
        else if (e.Item.Value == "LowGross")
        {
            Session["SelectedStatView"] = "LowGross";
        }
        else if (e.Item.Value == "IndvPts")
        {
            //Table_.Style.Add("display", "block");
        }
        else if (e.Item.Value == "Skins")
        {
            Table_Skins.Style.Clear();
            Session["SelectedStatView"] = "Skins";
        }
        else if (e.Item.Value == "Birdies")
        {
            Session["SelectedStatView"] = "Birdies";
        }
        else if (e.Item.Value == "Pars")
        {
            Session["SelectedStatView"] = "Pars";
        }
        else if (e.Item.Value == "Bogeys")
        {
            Session["SelectedStatView"] = "Bogeys";
        }
        else if (e.Item.Value == "DoubleBogeys")
        {
            Session["SelectedStatView"] = "DoubleBogeys";
        }
        else if (e.Item.Value == "Eagles")
        {
            Session["SelectedStatView"] = "Eagles";
        }
        else if (e.Item.Value == "Par3")
        {
            Session["SelectedStatView"] = "Par3";
        }
        else if (e.Item.Value == "Par4")
        {
            Session["SelectedStatView"] = "Par4";
        }
        else if (e.Item.Value == "Par5")
        {
            Session["SelectedStatView"] = "Par5";
        }
        else if (e.Item.Value == "Handicaps")
        {
            Session["SelectedStatView"] = "Handicaps";
        }
        else if (e.Item.Value == "CourseStats")
        {
            Session["SelectedStatView"] = "CourseStats";
        }
        else if (e.Item.Value == "Graph")
        {
            Session["SelectedStatView"] = "Graph";
        }
        else if (e.Item.Value == "EventScores")
        {
            Session["SelectedStatView"] = "EventScores";
        }
        else if (e.Item.Value == "IndividualHoles")
        {
            Session["SelectedStatView"] = "IndividualHoles";
        }

        Response.Redirect("~/stats.aspx");
    }
コード例 #3
0
    private void UpdateContent(Scoring.LeagueStats LeagueStats, List <int> CourseIDs, int LeagueID)
    {
        Table averageScoresByCourseTable = new Table();

        averageScoresByCourseTable.CellPadding = 5;
        TableRow  titleRow  = new TableRow();
        TableCell titleCell = AddCell(titleRow, "Scoring Averages by Course");

        titleCell.ColumnSpan      = CourseIDs.Count;
        titleCell.HorizontalAlign = HorizontalAlign.Center;
        titleCell.Font.Bold       = true;
        titleCell.Font.Size       = 16;
        averageScoresByCourseTable.Rows.Add(titleRow);

        Table ScoreCardsTable = new Table();

        ScoreCardsTable.CellPadding = 40;

        TableRow tr = new TableRow();

        //Add Scorecards for each course
        foreach (int courseID in CourseIDs)
        {
            CourseInfo courseInfo = DatabaseFunctions.GetCourseInfoFromCourseID(courseID);

            Table scoreCardTable = BuildEmptyScoreCardTable(courseInfo);
            scoreCardTable.BorderStyle = BorderStyle.Solid;
            scoreCardTable.BorderWidth = 5;
            AddScoreCardRows(scoreCardTable, LeagueStats.LeagueHoleAveragesByCourse[courseID], LeagueStats.LeagueRingerNineByCourse[courseID], LeagueStats.LeagueHighScoreByCourse[courseID]);
            TableRow  scoreCardHolderRow  = new TableRow();
            TableCell scoreCardHolderCell = new TableCell();
            scoreCardHolderCell.Controls.Add(scoreCardTable);
            scoreCardHolderRow.Cells.Add(scoreCardHolderCell);
            ScoreCardsTable.Rows.Add(scoreCardHolderRow);


            Table bestScoresTable = new Table();
            BuildAvgScoreTable(bestScoresTable, courseInfo.name, LeagueStats.AverageScoreByCourse[courseID], LeagueStats.NumRoundsByGolferAndCourse[courseID], 12);
            TableCell tc = new TableCell();
            tc.VerticalAlign = VerticalAlign.Top;
            tc.Controls.Add(bestScoresTable);
            tr.Cells.Add(tc);
        }
        averageScoresByCourseTable.Rows.Add(tr);
        Panel_AverageScoresByCourse.Controls.Add(averageScoresByCourseTable);
        Panel_HoleScores.Controls.Add(ScoreCardsTable);

        BuildAvgScoreTable(Table_AverageScores, "Average Score All Courses", LeagueStats.AvgScores, LeagueStats.NumberOfEventsPlayed, 16);
        BuildBestScoreTable(Table_LowestGrossSingleRoundScores, "Lowest Rounds (gross)", LeagueStats.LowestGrossSingleRoundScores, 30);
        BuildBestScoreTable(Table_LowestNetSingleRoundScores, "Lowest Rounds (Net)", LeagueStats.LowestNetSingleRoundScores, 30);
        BuildHighestTotalTable(Table_Skins, "Skins", LeagueStats.Skins, LeagueStats.NumberOfEventsPlayed);
        BuildHighestTotalTable(Table_Birdies, "Birdies", LeagueStats.Birdies, LeagueStats.NumberOfEventsPlayed);
        BuildHighestTotalTable(Table_Pars, "Pars", LeagueStats.Pars, LeagueStats.NumberOfEventsPlayed);
        BuildHighestTotalTable(Table_Bogeys, "Bogeys", LeagueStats.Bogeys, LeagueStats.NumberOfEventsPlayed);
        BuildHighestTotalTable(Table_DoubleBogeys, "Double Bogeys", LeagueStats.DoubleBogeys, LeagueStats.NumberOfEventsPlayed);
        BuildAvgScoreTable(Table_Par3Scoring, "Par 3 Scoring Averages", LeagueStats.ParThreeScoringAvg, 16, "Number of Par3's Played");
        BuildAvgScoreTable(Table_Par4Scoring, "Par 4 Scoring Averages", LeagueStats.ParFourScoringAvg, 16, "Number of Par4's Played");
        BuildAvgScoreTable(Table_Par5Scoring, "Par 5 Scoring Averages", LeagueStats.ParFiveScoringAvg, 16, "Number of Par5's Played");

        try
        {
            int lastEventID = DatabaseFunctions.GetMostRecentEventWithScoresPosted(LeagueID.ToString()).EventID;
            BuildHighestTotalTable(Table_Handicaps, "Handicaps", Scoring.GetHandicapsForEventFromHandicapByGolferIDDictionary(LeagueStats.handicaps, lastEventID), LeagueStats.NumberOfEventsPlayed);
        }
        catch { }
        //BuildHighestTotalTable(Table_Eagles, "Eagles", LeagueStats.Eagles, LeagueStats.NumberOfEventsPlayed);


        //BuildBestScoreTable(Table_LowestNetSingleRoundScores, "Lowest Rounds (net)", LeagueStats.LowestNetSingleRoundScores);

        UpdatePlayerContent();
    }
コード例 #4
0
    private void UpdatePlayerContent()
    {
        int golferID = int.Parse(DropDown_PlayerSelect.SelectedValue);

        if (golferID == 0)
        {
            return;
        }
        string golferName = DatabaseFunctions.GetGolferName(golferID);

        Scoring.LeagueStats LeagueStats = (Scoring.LeagueStats)Session["LeagueStats"];
        List <int>          CourseIDs   = DatabaseFunctions.GetCourseIDs(leagueID);

        //Build Course Statistics
        Table ScoreCardsTable = new Table();

        ScoreCardsTable.CellPadding = 40;
        foreach (int courseID in CourseIDs)
        {
            if (LeagueStats.NumRoundsByGolferAndCourse[courseID][golferID] == 0)
            {
                break;
            }
            CourseInfo courseInfo = DatabaseFunctions.GetCourseInfoFromCourseID(courseID);

            Table scoreCardTable = BuildEmptyScoreCardTable(courseInfo);

            //Title Row
            TableRow  titleRow = new TableRow();
            TableCell cell     = AddCell(titleRow, "Number of Rounds Played : " + LeagueStats.NumRoundsByGolferAndCourse[courseID][golferID]);//DatabaseFunctions.GetGolferName(golferID) +
            cell.ColumnSpan = 11;
            cell.Font.Size  = 18;
            cell.Font.Bold  = true;
            titleRow.Cells.Add(cell);
            scoreCardTable.Rows.AddAt(1, titleRow);

            scoreCardTable.BorderStyle = BorderStyle.Solid;
            scoreCardTable.BorderWidth = 5;

            AddScoreCardRow(scoreCardTable, "Best Score", LeagueStats.BestScoresByHole[courseID][golferID]);
            AddScoreCardRow(scoreCardTable, "Worst Score", LeagueStats.WorstScoresByHole[courseID][golferID]);
            AddScoreCardRow(scoreCardTable, "Average Score", roundDecimalList(LeagueStats.AverageScoresByHole[courseID][golferID]));
            AddScoreCardRow(scoreCardTable, "Skins Won", listOfIntToByte(LeagueStats.SkinsByCourseID[courseID][golferID]));

            TableRow  scoreCardHolderRow  = new TableRow();
            TableCell scoreCardHolderCell = new TableCell();
            scoreCardHolderCell.Controls.Add(scoreCardTable);
            scoreCardHolderRow.Cells.Add(scoreCardHolderCell);
            ScoreCardsTable.Rows.Add(scoreCardHolderRow);
        }
        CourseStats.Controls.Add(ScoreCardsTable);

        //Build Graph for scores and handicaps

        FontFamily fontFamily = new FontFamily("Arial");
        Font       titlefont  = new Font(fontFamily, 16, FontStyle.Bold, GraphicsUnit.Pixel);

        Chart chartScores = new Chart();

        chartScores.Width            = 800;
        chartScores.Height           = 500;
        chartScores.ImageStorageMode = ImageStorageMode.UseImageLocation;
        //chartScores.Legends.Add(new Legend("Default"));
        //chartScores.Legends["Default"].Docking = Docking.Bottom;
        //chartScores.Legends["Default"].Font = new System.Drawing.Font("Arial", 16, FontStyle.Bold);
        chartScores.BorderSkin           = new BorderSkin();
        chartScores.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
        chartScores.BorderSkin.PageColor = Color.Transparent;
        chartScores.Titles.Add(new Title("Scores for " + golferName, Docking.Top, titlefont, Color.Black));
        ChartArea chartArea = new ChartArea();

        chartArea.Name = "ChartArea1";
        chartArea.AxisX.ScaleBreakStyle.Enabled = true;
        chartArea.AxisY.IsStartedFromZero       = false;
        chartScores.ChartAreas.Add(chartArea);


        Chart chartHandicaps = new Chart();

        chartHandicaps.Width            = 800;
        chartHandicaps.Height           = 500;
        chartHandicaps.ImageStorageMode = ImageStorageMode.UseImageLocation;
        //chartHandicaps.Legends.Add(new Legend("Default"));
        //chartHandicaps.Legends["Default"].Docking = Docking.Bottom;
        //chartHandicaps.Legends["Default"].Font = new System.Drawing.Font("Arial", 16, FontStyle.Bold);
        chartHandicaps.BorderSkin           = new BorderSkin();
        chartHandicaps.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
        chartHandicaps.BorderSkin.PageColor = Color.Transparent;
        chartHandicaps.Titles.Add(new Title("Handicap for " + golferName, Docking.Top, titlefont, Color.Black));
        ChartArea chartArea2 = new ChartArea();

        chartArea2.Name = "ChartArea2";
        chartArea2.AxisX.ScaleBreakStyle.Enabled = true;
        chartArea2.AxisX.ScaleBreakStyle.CollapsibleSpaceThreshold = 10;
        chartHandicaps.ChartAreas.Add(chartArea2);

        Series series = new Series("Handicap");

        series.ChartType   = SeriesChartType.Point;
        series.XValueType  = ChartValueType.Date;
        series.MarkerSize  = 20;
        series.MarkerStyle = MarkerStyle.Diamond;
        chartHandicaps.Series.Add(series);

        series             = new Series("Scores");
        series.ChartType   = SeriesChartType.Point;
        series.XValueType  = ChartValueType.Date;
        series.MarkerSize  = 20;
        series.MarkerStyle = MarkerStyle.Star6;
        chartScores.Series.Add(series);

        //List<int> scores = new List<int>();
        //List<int> handicaps = new List<int>();
        //List<DateTime> dates = new List<DateTime>();

        List <IndividualScore>      scores     = new List <IndividualScore>();
        Dictionary <int, EventInfo> eventInfos = DatabaseFunctions.GetEventsWithScores(leagueID);

        foreach (int eventID in LeagueStats.ScoreByEvent[golferID].Keys)
        {
            IndividualScore score = new IndividualScore();
            //DateTime? eventDateTime = DatabaseFunctions.GetEventDate(eventID);
            DateTime  eventDateTime = DateTime.Parse(eventInfos[eventID].Date);
            DataPoint point         = new DataPoint();
            point.SetValueXY(eventDateTime, LeagueStats.ScoreByEvent[golferID][eventID]);
            chartScores.Series["Scores"].Points.Add(point);

            DataPoint point2 = new DataPoint();
            point2.SetValueXY(eventDateTime, LeagueStats.handicaps[golferID][eventID]);
            chartHandicaps.Series["Handicap"].Points.Add(point2);

            score.Handicap   = LeagueStats.handicaps[golferID][eventID];
            score.Score      = LeagueStats.ScoreByEvent[golferID][eventID];
            score.date       = eventDateTime;
            score.CourseName = eventInfos[eventID].CourseName;
            score.SeasonName = eventInfos[eventID].SeasonName;
            score.EventName  = eventInfos[eventID].EventName;

            scores.Add(score);
            //dates.Add((DateTime)eventDateTime);
            //scores.Add(LeagueStats.ScoreByEvent[golferID][eventID]);
            //handicaps.Add(LeagueStats.handicaps[golferID][eventID]);
        }

        Graph.Controls.Add(chartScores);
        Graph.Controls.Add(chartHandicaps);

        //BuildPlayerHandicapTable(scores, handicaps, dates);
        PopulateScoreGrid(scores.OrderBy(x => x.date).ToList());
        lbGridTitle.Text = "Scores for " + golferName;
    }