Example #1
0
 private void buttonAddPlayer_Click(object sender, EventArgs e)
 {
     // check to see if the form is open
     if ((Application.OpenForms["FormAddEditPlayers"] as FormAddEditPlayers) != null)
     {
         // if it is then select the right form
         foreach (Form form in Application.OpenForms)
         {
             if (form.Name == "FormAddEditPlayers")
             {
                 // activate it
                 form.Activate();
                 if (form.WindowState == FormWindowState.Minimized)
                 {
                     form.WindowState = FormWindowState.Normal;
                 }
             }
         }
     }
     else
     {
         // otherwise create a new instance of the form and show it
         FormAddEditPlayers formAddEditPlayers = new FormAddEditPlayers();
         formAddEditPlayers.Show();
     }
 }
Example #2
0
        // bring up the edit player window WITH the selected players info included
        private void buttonEditThisPlayer_Click(object sender, EventArgs e)
        {
            if (listBoxSelectPlayer.SelectedIndex != -1)
            {
                foreach (PlayersDBDataSet.PlayersRow selectedPlayer in playersDBDataSet.Players)
                {
                    if (this.listBoxSelectPlayer.SelectedItem.ToString() == selectedPlayer.PlayerPoolName)
                    {
                        PublicVariables.PublicPlayer = selectedPlayer;
                    }
                }
            }
            else
            {
                MessageBox.Show("No player was selected.");
                return;
            }

            // check to see if the form is open
            if ((Application.OpenForms["FormAddEditPlayers"] as FormAddEditPlayers) != null)
            {
                // if it is then select the right form
                foreach (Form form in Application.OpenForms)
                {
                    if (form.Name == "FormAddEditPlayers")
                    {
                        // activate it
                        form.Activate();
                        if (form.WindowState == FormWindowState.Minimized)
                        {
                            form.WindowState = FormWindowState.Normal;
                        }
                    }
                }
            }
            else
            {
                // otherwise create a new instance of the form and show it
                FormAddEditPlayers formAddEditPlayers = new FormAddEditPlayers();
                formAddEditPlayers.Show();
            }
        }