Esempio n. 1
0
        private void LstBoxNickName_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (LstBoxNickName.SelectedIndex != -1)
            {
                var playerRepo = new PlayerRepository();
                ClassLibrary2.Player playerSelected = playerRepo.GetById(LstBoxNickName.Text);


                // this event is apparently being triggered @ setup ... the test value is "Classlibrary1.Player"
                // this value is displayed in the list box entries when the Messagebox is in play
                // bust is overwritten and invisible when it is not.

                if (playerSelected == null)
                {
                    ;
                }                                        // Null statement.
                else
                {
                    lblNickname.Visible = true;
                    lblSurname.Visible  = true;
                    lblForename.Visible = true;
                    lblHandicap.Visible = true;
                    lblEmail.Visible    = true;

                    txtNickname.Visible = true;
                    txtNickname.Enabled = false;
                    txtSurname.Visible  = true;
                    txtForename.Visible = true;
                    txtHandicap.Visible = true;
                    txtEmail.Visible    = true;

                    txtNickname.Text = LstBoxNickName.Text;

                    txtSurname.Text  = playerSelected.Surname;
                    txtForename.Text = playerSelected.Forename;
                    txtHandicap.Text = playerSelected.Handicap.ToString();
                    txtEmail.Text    = playerSelected.EmailAddress;
                }
            }
        }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            short handicap = 0;

            if (Int16.TryParse(txtHandicap.Text, out handicap))
            {
                if ((handicap > 0) && (handicap < 40))
                {
                    ;
                }
                else
                {
                    MessageBox.Show("Handicaps must be reasonable!");
                };
            }
            else
            {
                MessageBox.Show("Handicaps must be integers!");
            };

            if ((handicap > 0) && (handicap < 40))
            {
                ClassLibrary2.Player player = new ClassLibrary2.Player();

                player.PlayerId     = txtNickname.Text;
                player.Surname      = txtSurname.Text;
                player.Forename     = txtForename.Text;
                player.Handicap     = handicap;
                player.EmailAddress = txtEmail.Text;

                var playerRepo = new PlayerRepository();
                playerRepo.Update(player);

                refreshPlayerPlayerIdListBox();
            }
        }