示例#1
0
        /// <summary>
        /// Adds the guest into the zoo.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addGuestButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Create an account for the guest.
                Account accout = new Account();

                // Create a sample guest for the window.
                Guest guest = new Guest("jimmyboiii", 34, 1738, WalletColor.Black, Gender.Male, accout);

                // Sell a ticket to the guest.
                Ticket ticket = zoo.SellTicket(guest);

                // Add the guest to the window.
                GuestWindow guestWindow = new GuestWindow(guest);

                // If the dialog is shown, add the guest to the zoo, and populate the list box.
                if (guestWindow.ShowDialog() == true)
                {
                    // Adds the guest to the zoo.
                    zoo.AddGuest(guest, ticket);

                    PopulateGuestListBox();
                }
                else
                {
                    // Do nothing...
                }
            }
            catch
            {
            }
        }
示例#2
0
        /// <summary>
        /// Adds the guest into the zoo.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addGuestButton_Click(object sender, RoutedEventArgs e)
        {
            // Create an account for the guest.
            Account accout = new Account();

            // Create a sample guest for the window.
            Guest guest = new Guest("jimmyboiii", 34, 1738, WalletColor.Black, Gender.Male, accout);

            // Try selling a ticket to the guest, and adding the guest into the zoo.
            try
            {
                // Sell a ticket to the guest.
                Ticket ticket = zoo.SellTicket(guest);

                // Add the guest to the window.
                GuestWindow guestWindow = new GuestWindow(guest);

                // If the dialog is shown, add the guest to the zoo, and populate the list box.
                if (guestWindow.ShowDialog() == true)
                {
                    // Adds the guest to the zoo.
                    zoo.AddGuest(guest, ticket);

                    PopulateGuestListBox();
                }
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// Edits the guest on the double-click event.
        /// </summary>
        /// <param name="sender">The object that initiated the event.</param>
        /// <param name="e">The arguments of the event.</param>
        private void guestListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Guest guest = this.guestListBox.SelectedItem as Guest;

            if (guest != null)
            {
                GuestWindow window = new GuestWindow(guest);

                window.ShowDialog();
            }
        }
示例#4
0
        /// <summary>
        /// Edits the selected guest.
        /// </summary>
        /// <param name="sender">The object that initiated the event.</param>
        /// <param name="e">The event arguments of the event.</param>
        private void guestListBox_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Guest guest = (Guest)this.guestListBox.SelectedItem;

            if (guest != null)
            {
                GuestWindow window = new GuestWindow(guest);

                if (window.ShowDialog() == true)
                {
                }
            }
        }
示例#5
0
        /// <summary>
        /// When you double click the combo box you can edit the attributes of the guest.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void guestListBox_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            // Get the selected item and cast it as a guest.
            Guest guest = (Guest)guestListBox.SelectedItem;

            // If guest isn't null then create a new guest window.
            if (guest != null)
            {
                GuestWindow guestWindow = new GuestWindow(guest);

                // If the guest window was created then re-populate the list box.
                if (guestWindow.ShowDialog() == true)
                {
                    PopulateGuestListBox();
                }
            }
        }
示例#6
0
        /// <summary>
        /// Creates a new guest window to allow for editing a pre-existing guest.
        /// </summary>
        /// <param name="sender">System data.</param>
        /// <param name="e">Associated event data.</param>
        private void guestListBox_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            // Get the selected guest in the list box.
            Guest guest = this.guestListBox.SelectedItem as Guest;

            if (guest != null)
            {
                // Create new guest window.
                GuestWindow guestWindow = new GuestWindow(guest);

                // Show the guest window.
                guestWindow.ShowDialog();

                if (guestWindow.DialogResult == true)
                {
                    PopulateGuestListBox();
                }
            }
        }
示例#7
0
        /// <summary>
        /// Adds a new guest to the zoo.
        /// </summary>
        /// <param name="sender">The object that initiated the event.</param>
        /// <param name="e">The event arguments of the event.</param>
        private void addGuestButton_Click(object sender, RoutedEventArgs e)
        {
            Guest guest = new Guest("Guest", 0, 0m, WalletColor.Black, Gender.Female, new Account());

            GuestWindow window = new GuestWindow(guest);

            window.ShowDialog();

            if (window.DialogResult == true)
            {
                try
                {
                    Ticket ticket = this.comoZoo.SellTicket(guest);

                    this.comoZoo.AddGuest(guest, ticket);
                }
                catch (NullReferenceException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
示例#8
0
        /// <summary>
        /// Adds a guest to the guest list in the WPF.
        /// </summary>
        /// <param name="sender">System data.</param>
        /// <param name="e">Associated event data.</param>
        private void addGuestButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Get the selected guest from the list box.
                Guest guest = (Guest)this.guestListBox.SelectedItem;
                guest = new Guest("Max", 13, 25, WalletColor.Indigo, Gender.Male, new Account());

                GuestWindow guestWindow = new GuestWindow(guest);

                guestWindow.ShowDialog();

                if (guestWindow.DialogResult == true)
                {
                    comoZoo.AddGuest(guest, comoZoo.SellTicket(guest));

                    PopulateGuestListBox();
                }
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("The zoo may be out of tickets.");
            }
        }