/// <summary>
        /// Creates a new player. The data is retrieved from the text boxes and parsed in to the Player object's properties.
        /// </summary>
        private void CreateNewPlayer()
        {
            Player player = new Player();
            player.FirstName = txtbxFirstName.Text;
            player.LastName = txtbxLastName.Text;
            double cost;
            if (!Double.TryParse(txtbxCost.Text, out cost))
            {
                cost = 0.0;
            }
            player.Cost = cost;
            player.Team = cmbxTeam.Text;

            if ((player.FirstName == "" && player.LastName == "") || player.Team == "")
            {
                MessageBox.Show("Give some information first.");
                this.ShowStatusBarNotification("More information about the player needed.");
                return;
            }

            this.players.Add(player);
            this.UpdateList();
            this.ClearInputs();
            this.ShowStatusBarNotification("New player created.");
        }
Esempio n. 2
0
        private void buttonCreatePlayer_Click(object sender, RoutedEventArgs e)
        {
            Team team = (Team)this.comboBoxTeam.SelectedItem;
            Player player = new Player(team);
            player.FName = this.textBoxFName.Text;
            player.LName = this.textBoxLName.Text;
            player.Price = int.Parse((this.textBoxPrice.Text.Length > 0) ? this.textBoxPrice.Text : "0");

            if (player.FName.Length > 0 && player.LName.Length > 0)
            {
                this.players.Add(player);
                this.listBoxPlayers.SelectedItem = player;
                this.changeStatus("Pelaaja lisätty.");
            }
            else
            {
                this.changeStatus("Virhe: Pelaajalle täytyy syöttää etu- ja sukunimi.");
            }
        }