コード例 #1
0
 void LoadBooks(String category)
 {
     foreach (Product item in products)
     {
         if (item is Book)
         {
             Book book = (Book)item;
             if (category == book.Type.ToString())
             {
                 currentProducts.Add(item);
                 ProductPanel productPanel = ProductPanelCreator.CreatePanel(item);
                 flPanel.Controls.Add(productPanel);
             }
         }
     }
 }
コード例 #2
0
 void LoadMagazine(String category)
 {
     foreach (Product item in products)
     {
         if (item is Magazine)
         {
             Magazine magazine = (Magazine)item;
             if (category == magazine.Type.ToString())
             {
                 currentProducts.Add(item);
                 ProductPanel productPanel = ProductPanelCreator.CreatePanel(item);
                 flPanel.Controls.Add(productPanel);
             }
         }
     }
 }
コード例 #3
0
        void LoadMusicCD(String category)
        {
            foreach (Product item in products)
            {
                if (item is MusicCD)
                {
                    MusicCD musicCD = (MusicCD)item;

                    if (category == musicCD.Type.ToString())
                    {
                        currentProducts.Add(item);
                        ProductPanel productPanel = ProductPanelCreator.CreatePanel(item);
                        flPanel.Controls.Add(productPanel);
                    }
                }
            }
        }
コード例 #4
0
        private void mainMenu_Load(object sender, EventArgs e)
        {
            shoppingcart.CustomerID = customer.CustomerID;
            ProductPanelCreator panelcreator = new ProductPanelCreator();

            Data.GetProduct(products);
            if (customer.IsAdmin)
            {
                btnAdminInterface.Visible = true;
            }
            if (customer.IsAdmin == false)
            {
                btnAdminInterface.Visible = false;
            }
            cmbProductType.SelectedIndex = 0;
            lblusername.Text             = customer.Username;
            lblemail.Text = customer.Email;
            lblID.Text    = customer.CustomerID.ToString();
        }
コード例 #5
0
        private void LoadProduct(ProductNames ProductName, string category)
        {
            switch (ProductName)
            {
            case ProductNames.All:
                foreach (Product item in products)
                {
                    currentProducts.Add(item);
                    ProductPanel productPanel = ProductPanelCreator.CreatePanel(item);
                    flPanel.Controls.Add(productPanel);
                }
                break;

            case ProductNames.Magazine:
                if (category == "All")
                {
                    foreach (Product item in products)
                    {
                        if (item is Magazine)
                        {
                            currentProducts.Add(item);
                            ProductPanel productPanel = ProductPanelCreator.CreatePanel(item);
                            flPanel.Controls.Add(productPanel);
                        }
                    }
                }
                else
                {
                    LoadMagazine(category);
                }
                break;

            case ProductNames.MusicCD:
                if (category == "All")
                {
                    foreach (Product item in products)
                    {
                        if (item is MusicCD)
                        {
                            currentProducts.Add(item);
                            ProductPanel productPanel = ProductPanelCreator.CreatePanel(item);
                            flPanel.Controls.Add(productPanel);
                        }
                    }
                }
                else
                {
                    LoadMusicCD(category);
                }
                break;

            case ProductNames.Book:
                if (category == "All")
                {
                    foreach (Product item in products)
                    {
                        if (item is Book)
                        {
                            currentProducts.Add(item);
                            ProductPanel productPanel = ProductPanelCreator.CreatePanel(item);
                            flPanel.Controls.Add(productPanel);
                        }
                    }
                }
                else
                {
                    LoadBooks(category);
                }
                break;

            default:
                break;
            }
        }