コード例 #1
0
        private void LoadFixturesGrid()
        {
            DataTable fixturesDataTable = new DataTable();

            fixturesDataTable.Columns.Add(Columns.Round, typeof(byte));
            fixturesDataTable.Columns.Add(Columns.MatchDate, typeof(string));
            fixturesDataTable.Columns.Add(Columns.HomeResult, typeof(Image));
            fixturesDataTable.Columns.Add(Columns.HomeTeamID, typeof(uint));
            fixturesDataTable.Columns.Add(Columns.HomeTeam, typeof(string));
            fixturesDataTable.Columns.Add(Columns.Score, typeof(string));
            fixturesDataTable.Columns.Add(Columns.AwayTeamID, typeof(uint));
            fixturesDataTable.Columns.Add(Columns.AwayTeam, typeof(string));
            fixturesDataTable.Columns.Add(Columns.AwayResult, typeof(Image));

            foreach (HTEntities.LeagueFixtures.Match match in leagueFixtures.matchListField)
            {
                DataRow newDataRow = fixturesDataTable.NewRow();

                newDataRow[Columns.Round]      = match.matchRoundField;
                newDataRow[Columns.MatchDate]  = match.matchDateField.ToString(General.DateTimeFormat);
                newDataRow[Columns.HomeTeamID] = match.homeTeamField.homeTeamIdField;
                newDataRow[Columns.HomeTeam]   = match.homeTeamField.homeTeamNameField;
                newDataRow[Columns.Score]      = string.Format(General.Score, match.homeGoalsField, match.awayGoalsField);
                newDataRow[Columns.AwayTeamID] = match.awayTeamField.awayTeamIdField;
                newDataRow[Columns.AwayTeam]   = match.awayTeamField.awayTeamNameField;

                if (match.matchDateField < leagueFixtures.fetchedDateField)
                {
                    newDataRow[Columns.HomeResult] = GenericFunctions.GetResultImage(match.homeGoalsField, match.awayGoalsField, TeamLocation.Home);
                    newDataRow[Columns.AwayResult] = GenericFunctions.GetResultImage(match.homeGoalsField, match.awayGoalsField, TeamLocation.Away);
                }
                else
                {
                    newDataRow[Columns.HomeResult] = HM.Resources.Properties.Resources.Grey;
                    newDataRow[Columns.AwayResult] = HM.Resources.Properties.Resources.Grey;
                }

                fixturesDataTable.Rows.Add(newDataRow);
            }

            dataGridViewFixtures.DataSource = fixturesDataTable;
        }