/**
         * <summary>
         * This method gets teams data from DB
         * </summary>
         *
         * @method GetTeams
         * @return {void}
         */
        protected void GetTeams()
        {
            string sortString   = Session["SortColumn"].ToString() + " " + Session["SortDirection"].ToString();
            int    selectedWeek = Convert.ToInt32(Session["SelectedWeek"].ToString());

            // connect to EF
            using (GTConnection db = new GTConnection())
            {
                //query the teams from table using EF and LINQ
                var teams1 = (from allTeams in db.Teams
                              join allGames in db.Games on allTeams.TeamID equals allGames.Team1ID
                              where allGames.Week == selectedWeek
                              select new { TeamID = allTeams.TeamID,
                                           TeamName = allTeams.TeamName,
                                           TeamDescription = allTeams.TeamDescription,
                                           PointsScored = allGames.Team1Score,
                                           PointsLost = allGames.Team2Score });
                var teams2 = (from allTeams in db.Teams
                              join allGames in db.Games on allTeams.TeamID equals allGames.Team2ID
                              where allGames.Week == selectedWeek
                              select new
                {
                    TeamID = allTeams.TeamID,
                    TeamName = allTeams.TeamName,
                    TeamDescription = allTeams.TeamDescription,
                    PointsScored = allGames.Team2Score,
                    PointsLost = allGames.Team1Score
                });
                //combine queries results
                var teams = teams1.Concat(teams2);
                //bind the results to GridView
                TeamsGridView.DataSource = teams.AsQueryable().OrderBy(sortString).ToList();
                TeamsGridView.DataBind();
            }
        }
Beispiel #2
0
        /**
         * <summary>
         * This method gets the teams from the database
         * </summary>
         * @method GetTeams
         * @return {void}
         * */
        protected void GetTeams()
        {
            //connect to EF
            using (GameTrackerConnection db = new GameTrackerConnection())
            {
                //query the teams table using EF and LINQ
                var Teams = (from allTeams in db.Teams select allTeams);

                //bind results to gridview
                TeamsGridView.DataSource = Teams.AsQueryable().ToList();
                TeamsGridView.DataBind();
            }
        }
Beispiel #3
0
        protected void GetTeam()
        {
            //populate teh form with existing data from the database
            int GameID = Convert.ToInt32(Request.QueryString["GameID"]);

            using (ContosoConnection db = new ContosoConnection())
            {
                var Teams = (from team in db.Teams
                             where team.GameID == GameID
                             select team);

                TeamsGridView.DataSource = Teams.ToList();
                TeamsGridView.DataBind();
            }
        }
Beispiel #4
0
        /**
         * @description gets all the teams from the database
         * @method GetTeams
         * @return {void}
         */
        protected void GetTeams()
        {
            // connect to the entity framework

            using (TeamConnection db = new TeamConnection())
            {
                //query the Students table using EF and LINQ
                var teams = (from allTeams in db.Teams
                             select allTeams);

                //bind the result to the gridview
                TeamsGridView.DataSource = teams.ToList();
                TeamsGridView.DataBind();
            }
        }
Beispiel #5
0
        /**
         * <summary>
         * This method pupulate the Gridview with teams list
         * </summary>
         *
         * @method GetTeams
         * @returns
         * */
        protected void GetTeams()
        {
            // populate the form with existing gmae data from the db
            int GameID = Convert.ToInt32(Request.QueryString["GameID"]);

            // connect to EF
            using (GameTrackerConnection db = new GameTrackerConnection())
            {
                // query the games Table using EF and LINQ
                var Teams = (from allTeam in db.Teams
                             where allTeam.GameID == GameID
                             select allTeam);

                // bind the result to the GridView
                TeamsGridView.DataSource = Teams.AsQueryable().ToList();
                TeamsGridView.DataBind();
            }
        }
        /**
         * <summary>
         * This function will get the teams from the database, as well as the applicable data (scores) from the database and bind the data to the gridview
         * </summary>
         *
         * @method GetTeams
         * @returns {void}
         */
        protected void GetTeams()
        {
            //Opens the DB and gets all data from the teams table
            SqlCommand getTeams = new SqlCommand("SELECT * FROM TeamTable", db);

            db.Open();
            reader = getTeams.ExecuteReader();
            teamsData.Load(reader);
            db.Close();

            teamsData.Columns.Add(new DataColumn("GameOneScores", typeof(string)));
            teamsData.Columns.Add(new DataColumn("GameTwoScores", typeof(string)));
            teamsData.Columns.Add(new DataColumn("GameThreeScores", typeof(string)));
            teamsData.Columns.Add(new DataColumn("GameFourScores", typeof(string)));

            //This set of loops will loop through each row in the data table holding the teams information,
            //checking for that team in each game that occured that week. It will then post N/A for games where
            //that team did not participate, or will post the number of points won & lost by that team
            //for all games they participated in that week.
            foreach (DataRow teamsRow in teamsData.Rows)
            {
                foreach (DataRow gameRow in gamesData.Rows)
                {
                    if (teamsRow["TeamID"].ToString() != gameRow["TeamOneID"].ToString() && teamsRow["TeamID"].ToString() != gameRow["TeamTwoID"].ToString())
                    {
                        if (gameRow["GameNum"].ToString() == "Game #1")
                        {
                            teamsRow["GameOneScores"] = "N/A";
                        }
                        else if (gameRow["GameNum"].ToString() == "Game #2")
                        {
                            teamsRow["GameTwoScores"] = "N/A";
                        }
                        else if (gameRow["GameNum"].ToString() == "Game #3")
                        {
                            teamsRow["GameThreeScores"] = "N/A";
                        }
                        else
                        {
                            teamsRow["GameFourScores"] = "N/A";
                        }
                    }
                    else if (teamsRow["TeamID"].ToString() == gameRow["TeamOneID"].ToString())
                    {
                        if (gameRow["GameNum"].ToString() == "Game #1")
                        {
                            teamsRow["GameOneScores"] = "Won " + gameRow["TeamOnePoints"] + " / Lost " + gameRow["TeamTwoPoints"];
                        }
                        else if (gameRow["GameNum"].ToString() == "Game #2")
                        {
                            teamsRow["GameTwoScores"] = "Won " + gameRow["TeamOnePoints"] + " / Lost " + gameRow["TeamTwoPoints"];
                        }
                        else if (gameRow["GameNum"].ToString() == "Game #3")
                        {
                            teamsRow["GameThreeScores"] = "Won " + gameRow["TeamOnePoints"] + " / Lost " + gameRow["TeamTwoPoints"];
                        }
                        else
                        {
                            teamsRow["GameFourScores"] = "Won " + gameRow["TeamOnePoints"] + " / Lost " + gameRow["TeamTwoPoints"];
                        }
                    }
                    else
                    {
                        if (gameRow["GameNum"].ToString() == "Game #1")
                        {
                            teamsRow["GameOneScores"] = "Won " + gameRow["TeamTwoPoints"] + " / Lost " + gameRow["TeamOnePoints"];
                        }
                        else if (gameRow["GameNum"].ToString() == "Game #2")
                        {
                            teamsRow["GameTwoScores"] = "Won " + gameRow["TeamTwoPoints"] + " / Lost " + gameRow["TeamOnePoints"];
                        }
                        else if (gameRow["GameNum"].ToString() == "Game #3")
                        {
                            teamsRow["GameThreeScores"] = "Won " + gameRow["TeamTwoPoints"] + " / Lost " + gameRow["TeamOnePoints"];
                        }
                        else
                        {
                            teamsRow["GameFourScores"] = "Won " + gameRow["TeamTwoPoints"] + " / Lost " + gameRow["TeamOnePoints"];
                        }
                    }
                }
            }

            TeamsGridView.DataSource = teamsData.DefaultView;
            TeamsGridView.DataBind();
        }