//update button to update the player information in list

        private void btnBPUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (lstBaseballPlayers.SelectedItem == null)
            {
                MessageBox.Show("Please select the player!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                int game, runs, homeRuns;
                if (Int32.TryParse(txtBPGames.Text, out game) && Int32.TryParse(txtBPRuns.Text, out runs) && Int32.TryParse(txtBPHomeRuns.Text, out homeRuns))
                {
                    var result = MessageBox.Show("You sure you want to update the players? ", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                    if (result == MessageBoxResult.Yes)
                    {
                        int index = lstBaseballPlayers.SelectedIndex;

                        BaseballPlayer bp = pla[index];

                        bp.PlayerName  = txtBPName.Text;
                        bp.TeamName    = txtBPTeam.Text;
                        bp.GamesPlayed = int.Parse(txtBPGames.Text);
                        bp.Runs        = int.Parse(txtBPRuns.Text);
                        bp.HomeRuns    = int.Parse(txtBPHomeRuns.Text);
                    }
                }
                else
                {
                    MessageBox.Show("Invalid Input! Please try again!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            Reload();
        }
        //insert method to add player in list

        private void btnBPInsert_Click(object sender, RoutedEventArgs e)
        {
            if (txtBPName.Text.Length == 0 || txtBPTeam.Text.Length == 0 || txtBPGames.Text.Length == 0 || txtBPRuns.Text.Length == 0 || txtBPHomeRuns.Text.Length == 0)
            {
                MessageBox.Show("Please select the player!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                int game, runs, homeRuns;
                if (Int32.TryParse(txtBPGames.Text, out game) && Int32.TryParse(txtBPRuns.Text, out runs) && Int32.TryParse(txtBPHomeRuns.Text, out homeRuns))
                {
                    BaseballPlayer p1 = new BaseballPlayer(PlayerType.BaseballPlayer, pla.Count, txtBPName.Text, txtBPTeam.Text, int.Parse(txtBPGames.Text), int.Parse(txtBPRuns.Text), int.Parse(txtBPHomeRuns.Text));

                    pla.Add(p1);
                }
                else
                {
                    MessageBox.Show("Invalid Input! Please try again!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            Reload();
        }