Exemple #1
0
        //OPENS CART SELECTION WINDOW TO EDIT CART ITEM
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Cart cartItem = (Cart)(sender as Button).DataContext;

                var newWindow = new CartSelectionWindow(color);
                newWindow.Top          = Window.GetWindow(this).Top;
                newWindow.Left         = Window.GetWindow(this).Left;
                newWindow.Main.Content = new Pages.CartItemSelectionPage(cartItem.TourID, username, color);
                newWindow.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        //OPENS CART SELECTION WINDOW
        private void AddCartButton_Click(object sender, RoutedEventArgs e)
        {
            ObservableCollection <Cart> cartItems = ct.getCartItems();
            bool alreadyInCart         = false;
            CartItemSelectionPage cisp = new CartItemSelectionPage(tourID, username, color);


            foreach (Cart cart in cartItems)
            {
                if (cart.TourID.Equals(tourID))
                {
                    MessageBox.Show("This is already in your cart!", "Note");
                    alreadyInCart = true;
                }
            }

            if (!alreadyInCart)
            {
                if (cisp.getTourAvailability() == false) //if every date in tour date range has 15 slots fully booked
                {
                    MessageBox.Show("Sorry, this tour is fully booked.", "Note");
                }
                else
                {
                    foreach (Window window in App.Current.Windows)
                    {
                        if (!window.IsActive)
                        {
                            window.Hide();
                        }
                    }

                    CartSelectionWindow csw = new CartSelectionWindow(color);
                    csw.Top          = Window.GetWindow(this).Top;
                    csw.Left         = Window.GetWindow(this).Left;
                    csw.Main.Content = cisp;
                    csw.Show();
                }
            }
        }