private void AddGuestButton_Click(object sender, EventArgs e) { if (FirstNameTextBox.Text == "" || LastNameTextBox.Text == "") { WarningLabel.DissapearAfterSeconds(3); foreach (Control control in GuestCreationPanel.Controls) { if (control is TextBox && control.Text == "") { (control as CampingTextBox).Flicker(); } } } else { Guest guest = DAL.Instance.CreateGuest(FirstNameTextBox.Text, LastNameTextBox.Text, DateOfBirthPicker.Value); guests.Add(guest); ListViewItem item = new ListViewItem(new string[] { guest.GetFullName(), guest.Age.ToString() }); this.CurrentGuests.Items.Add(item); FirstNameTextBox.Text = ""; LastNameTextBox.Text = ""; DateOfBirthPicker.Value = DateTime.Today.AddYears(-DAL.Instance.AverageAge); } }
private void CustomerIsGuest_CheckedChanged(object sender, EventArgs e) { if (CustomerIsGuest.Checked) { customerAsGuest = DAL.Instance.CreateGuest(customer.FirstName, customer.LastName, customer.DateOfBirth); ListViewItem item = new ListViewItem(new string[] { customerAsGuest.GetFullName() + " 👑", customerAsGuest.Age.ToString() }); this.CurrentGuests.Items.Insert(0, item); guests.Add(customerAsGuest); } else { guests.Remove(customerAsGuest); customerAsGuest.Remove(); customerAsGuest = null; this.CurrentGuests.Items.RemoveAt(0); } }