/// <summary>
        /// sets home and away goals of game upon returning to team main window
        /// </summary>
        private void Set_Game_Stats()
        {// TODO update game goals when user leaves the screen
            // TODO update score in this window when a goal is scoredn
            // set home and opponent goals of mygame
            string selqry = string.Format(SELECT_GOALS_QRY, myGame.GetId());

            // fill game stats
            myGame.Set_Stats(build.Execute_DataSet_Query(selqry));
        }
        /* ---------- HELPER METHODS ----------------*/

        /* ---------- TEAM HELPER METHODS ------------- */

        /// <summary>
        /// takes user to main window of selected team
        /// </summary>
        private void View_Team()
        {
            if (myTeam.HasInfo())
            {
                // select all teams
                string qry = string.Format(SELECT_TEAM_STATS_QRY, myTeam.GetId());
                myTeam.Set_Stats(build.Execute_DataSet_Query(qry));

                // open team main window
                TeamMainWindow tmw = new TeamMainWindow(this, myTeam, myPlayer, build);
                this.Hide();
                tmw.Show();
            }
            else
            {
                MessageBox.Show(SELECT_TEAM_MSG);
            }
        }
Exemplo n.º 3
0
        /* --------------- PLAYER HELPER METHODS -------------------- */
        /// <summary>
        /// fills myplayer attributes and stats of selected player
        /// </summary>
        private void Set_Player_Attributes_Stats()
        {
            // set team name and id if a team is selected
            if (PlayersDG.SelectedItems.Count == 1)
            {
                var items = PlayersDG.SelectedItems;
                foreach (DataRowView item in items)
                {
                    int id = Int32.Parse(item["id"].ToString());

                    // get player stats from player id
                    string statqry = string.Format(SELECT_PLAYER_STATS_QRY, id);
                    string attrqry = string.Format(SELECT_PLAYER_ATTR_QRY, id);

                    myPlayer.Set_Stats(build.Execute_DataSet_Query(statqry));
                    myPlayer.Set_Attributes(build.Execute_DataSet_Query(attrqry));
                }
            }
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
0
        /// <summary>
        /// sets myplayer attributes from textbox inputs
        /// </summary>
        private void Set_Highlighted_Player_Attributes()
        {
            // get all player attributes from data grid
            if (PlayersDT.SelectedItems.Count == 1)
            {
                var items = PlayersDT.SelectedItems;
                foreach (DataRowView item in items)
                {
                    // get playerId
                    string playerIdStr = item["id"].ToString();
                    int    playerId    = Int32.Parse(playerIdStr);

                    // build dataset from playey id
                    string qry = string.Format(SEARCH_PLAYER_BY_ID_QRY, playerId);
                    myPlayer.Set_Attributes(build.Execute_DataSet_Query(qry));
                }
            }
        }
        private void Update_Player_Attributes()
        {
            // get text from textboxes
            int    playerNum    = Int32.Parse(NumberTB.Text.ToString());
            string playerName   = NameTB.Text.ToString();
            string playerPos    = PosCB.Text.ToString();
            int    playerYear   = Int32.Parse(YearCB.Text.ToString());
            int    playerHeight = Int32.Parse(HeightTB.Text.ToString());
            int    playerWeight = Int32.Parse(WeightTB.Text.ToString());

            // update player info
            string updqry = string.Format(UPDATE_PLAYER_QRY, playerNum, playerName, playerPos, playerYear, playerHeight, playerWeight, myPlayer.GetId());

            build.Execute_Query(updqry);

            // update myplayer data fields
            string selqry = string.Format(SELECT_PLAYER_QRY, myPlayer.GetId());

            myPlayer.Set_Attributes(build.Execute_DataSet_Query(selqry));
        }
Exemplo n.º 7
0
        /* ------------- HELPER METHODS ------------ */
        /// <summary>
        /// fills myteam with attributes and stats and inserts into datatable
        /// navigates user to team editor of new team
        /// </summary>
        private void Create_Team()
        {
            if (Is_TB_Empty())
            {
                MessageBox.Show(FILL_TEXT_MSG);
                return;
            }

            // get teamname
            string teamName = TeamNameTB.Text.ToString();

            // ensure team year is formatted correctly then parse
            if (TeamYearTB1.Text.Length == 4 && TeamYearTB2.Text.Length == 4)
            {
                // format team year string
                string teamYear = TeamYearTB1.Text.ToString() + "-" + TeamYearTB2.Text.ToString();

                // add team to database
                AddTeam(teamName, teamYear);

                // get team info from data table
                string qry = string.Format(SELECT_RECENT_TEAM_QRY);

                // set team attributes from dataset
                myTeam.SetAttributes(build.Execute_DataSet_Query(qry));

                // navigate user to team editor of new team
                EditTeamWindow etw = new EditTeamWindow(mainWindow, myTeam, mainWindow.GetMyPlayer(), build);
                etw.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show(YEAR_FORMAT_MSG);
            }
        }