Exemplo n.º 1
0
        /* ---------------- FUNCTIONAL METHODS ---------------------*/
        /// <summary>
        /// Load most recent data into the player datagrid
        /// </summary>
        private void Load_Table_Data()
        {
            // select all players
            string qry = string.Format(SELECT_PLAYERS_QRY, myTeam.GetId());

            PlayersDT.ItemsSource = build.Execute_DataTable_Qry(qry).DefaultView;
        }
        /* ---------------- HELPER METHODS ---------------- */
        private void Load_Totalstat_Table()
        {
            // get all stats from totalstats table
            string qry = string.Format(SELECT_TOTALSTATS_QRY, myPlayer.GetId());

            TotalStatsDG.ItemsSource = build.Execute_DataTable_Qry(qry).DefaultView;
        }
        /// <summary>
        /// searches for team by name in database
        /// </summary>
        private void Search_Team()
        {
            // get student id from search box
            string teamName = TeamSearchTB.Text.ToString();

            // build and execute select query according to id
            string qry = string.Format(SEARCH_TEAM_QRY, teamName);

            TeamsDT.ItemsSource = build.Execute_DataTable_Qry(qry).DefaultView;
        }
        /* ----------------- HELPER METHODS ------------------- */


        /// <summary>
        /// adds user specified stat to game and to all team and player stat totals
        /// </summary>
        private void Add_Stat()
        {
            // set deafult qtr values
            int qtr = 1;

            // if qtr = OT replace with 5
            if (QtrCB.Text.ToString() == "OT")
            {
                qtr = 5;
            }
            else
            {
                qtr = Int32.Parse(QtrCB.Text.ToString());
            }

            // deafult player id
            int playerId;

            // parse player number from combobox
            int playerNum;

            // if player is opponent, dont parse player value
            if (PlayerCB.Text.ToString() == "Opponent")
            {
                statType  = 'O';
                playerNum = Int32.Parse(PlayerCB.Items[0].ToString());
            }

            // if home team stat, parse player id from player number
            else
            {
                statType  = Set_Stat_Type();
                playerNum = Int32.Parse(PlayerCB.Text.ToString());
            }

            // get player id from player number
            string selqry = string.Format(SELECT_PLAYER_ID_QRY, playerNum, myTeam.GetId());

            DataTable dt = build.Execute_DataTable_Qry(selqry);

            playerId = Int32.Parse(dt.Rows[0]["id"].ToString());

            // insert new game stat into game history and watch the magic happen
            string insqry = string.Format(INSERT_STAT_QRY, qtr, this.statType, playerId, myGame.GetId(), myTeam.GetId());

            build.Execute_Query(insqry);

            // update all tables
            Set_Game_Stats();
            Update_Tables();

            AddStatPNL.Visibility = Visibility.Hidden;
            this.UpdateLayout();
        }
        /// <summary>
        /// loads all stats per game for top data table
        /// </summary>
        private void Load_Gamestat_Table()
        {
            // load team game stats data
            string    qry = string.Format(SELECT_TEAM_GAMESTATS_QRY, myTeam.GetId());
            DataTable dt  = build.Execute_DataTable_Qry(qry);

            // add columns not in datatable
            dt.Columns.Add("win_pct");
            dt.Columns.Add("league_win_pct");
            dt.Columns.Add("shot_pct");

            dt.Rows[0]["win_pct"]        = myTeam.GetWinPct();
            dt.Rows[0]["league_win_pct"] = myTeam.GetLeagueWinPct();
            dt.Rows[0]["shot_pct"]       = myTeam.GetShotPct();

            GameStatsDG.ItemsSource = dt.DefaultView;
        }
Exemplo n.º 6
0
        /// <summary>
        /// updates player data table
        /// </summary>
        private void Load_Player_Table_Data()
        {
            // select all players in current team
            string    qry = string.Format(SELECT_PLAYER_ATT_STATS_QRY, myTeam.GetId());
            DataTable dt  = build.Execute_DataTable_Qry(qry);

            // caculate team highs
            Calculate_Highs();

            // populate datagrid with players datatable
            PlayersDG.ItemsSource = dt.DefaultView;
        }