Пример #1
0
        /// <summary>
        /// Populates the list of players with players from the database.
        /// </summary>
        private void PopulatePlayerList()
        {
            List <Player> allPlayers = PlayerDb.GetAllPlayers();

            ListBoxAvailablePlayers.Items.Clear();
            foreach (Player p in allPlayers)
            {
                ListBoxAvailablePlayers.Items.Add(p);
            }
        }
Пример #2
0
        private void BtnDeletePlayer_Click(object sender, EventArgs e)
        {
            btnDeletePlayer.DialogResult = DialogResult.Yes;
            lblDeleteHeader.ForeColor    = Color.Green;
            lblDeleteHeader.Text         = $"{string.Join(" & ", playersToBeDeleted)} deleted!";
            foreach (Player player in playersToBeDeleted)
            {
                PlayerDb.Delete(player);
            }
            Timer timer = new Timer(); // Auto close form after 2 seconds.

            timer.Interval = 1000;
            timer.Tick    += new EventHandler(timer_Tick);
            timer.Start();
        }
Пример #3
0
 private void btnSaveChanges_Click(object sender, EventArgs e)
 {
     if (ValidateFormInput())
     {
         btnSaveChanges.DialogResult = DialogResult.Yes;
         P.FirstName = txtboxFName.Text;
         P.LastName  = txtboxLName.Text;
         P.Email     = txtboxEmail.Text;
         P.UserName  = txtboxUsername.Text;
         PlayerDb.Update(P);
         lblEditPlayerHeader.ForeColor = Color.Green;
         lblEditPlayerHeader.Text      = "Saved changes!";
         Timer timer = new Timer(); // Auto close form after 2 seconds.
         timer.Interval = 1000;
         timer.Tick    += new EventHandler(timer_Tick);
         timer.Start();
     }
 }
Пример #4
0
 private void BtnSubmitAdd_Click(object sender, EventArgs e)
 {
     if (ValidateFormInput())
     {
         BtnSubmitAdd.DialogResult = DialogResult.Yes;
         Player p = new Player()
         {
             FirstName = TxtFirstName.Text,
             LastName  = TxtLastName.Text,
             UserName  = TxtUsername.Text,
             Email     = TxtEmail.Text.ToLower()
         };
         NewPlayer = p;
         lblAddResult.ForeColor = Color.Green;
         lblAddResult.Text      = $"{p.UserName} can now play Uno!";
         PlayerDb.Add(p);
         Timer timer = new Timer(); // Auto close form after 2 seconds.
         timer.Interval = 1000;
         timer.Tick    += new EventHandler(timer_Tick);
         timer.Start();
     }
 }