/* ----------------- 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();
        }
Beispiel #2
0
        private void Delete_Game()
        {
            // disable foregnkey contraints
            string setQry = FOREIGN_KEY_DISABLE_QRY;

            build.Execute_Query(setQry);

            // delete game from database
            string delQry = string.Format(DELETE_GAME_QRY, myGame.GetId());

            build.Execute_Query(delQry);

            Load_Game_Table_Data();
            Set_Team_Stats();
            Set_Player_Attributes_Stats();
            Set_Labels();
            Load_Player_Table_Data();
            myGame.Clear();
        }
Beispiel #3
0
        /// <summary>
        /// updates information in database
        /// </summary>
        private void Update_Game()
        {
            // get game info from window uesr input
            string oppTeam  = OppNameTB.Text.ToString();
            string gameType = GameTypeCB.Text.ToString();
            string gameLoc  = GameLocCB.Text.ToString();
            string gameDate = string.Format(DATE_FMT, YearTB.Text.ToString(), MonthCB.Text.ToString(), DayCB.Text.ToString());

            // insert new game into game datatable
            string insqry = string.Format(UPDATE_GAME_QRY, oppTeam, gameType, gameLoc, gameDate, myGame.GetId());

            build.Execute_Query(insqry);

            // select inserted game from datatable
            myGame.init();
            myGame.Set_Attributes(build.Execute_DataSet_Query(SELECT_GAME_QRY));
        }