Esempio n. 1
0
        //menu update work same as update button
        private void mnuUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (lstBasketballPlayers.SelectedItem == null)
            {
                MessageBox.Show("Please select the player!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                int game, fieldGoals, threePointers;
                if (Int32.TryParse(txtBBPGames.Text, out game) && Int32.TryParse(txtBBPFieldGoals.Text, out fieldGoals) && Int32.TryParse(txtBBPThreePointers.Text, out threePointers))
                {
                    var result = MessageBox.Show("You sure you want to update the players? ", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);

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

                        BasketballPlayer bbp = pla[index];

                        bbp.PlayerName    = txtBBPName.Text;
                        bbp.TeamName      = txtBBPTeam.Text;
                        bbp.GamesPlayed   = int.Parse(txtBBPGames.Text);
                        bbp.FieldsGoals   = int.Parse(txtBBPFieldGoals.Text);
                        bbp.ThreePointers = int.Parse(txtBBPThreePointers.Text);
                    }
                }
                else
                {
                    MessageBox.Show("Invalid Input! Please try again!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            Reload();
        }
Esempio n. 2
0
        //menu insert work same as insert button
        private void mnuInsert_Click(object sender, RoutedEventArgs e)
        {
            if (txtBBPName.Text.Length == 0 || txtBBPTeam.Text.Length == 0 || txtBBPGames.Text.Length == 0 || txtBBPFieldGoals.Text.Length == 0 || txtBBPThreePointers.Text.Length == 0)
            {
                MessageBox.Show("Please select the player!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                int game, fieldGoals, threePointers;
                if (Int32.TryParse(txtBBPGames.Text, out game) && Int32.TryParse(txtBBPFieldGoals.Text, out fieldGoals) && Int32.TryParse(txtBBPThreePointers.Text, out threePointers))
                {
                    BasketballPlayer p1 = new BasketballPlayer(PlayerType.BasketballPlayer, pla.Count, txtBBPName.Text, txtBBPTeam.Text, int.Parse(txtBBPGames.Text), int.Parse(txtBBPFieldGoals.Text), int.Parse(txtBBPThreePointers.Text));

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