Exemplo n.º 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);
             }
         }
     }
 }
Exemplo n.º 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);
             }
         }
     }
 }
Exemplo n.º 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);
                    }
                }
            }
        }
Exemplo n.º 4
0
        static public ProductPanel CreatePanel(Product p)
        {
            ProductPanel panel = null;

            if (p is Book)
            {
                panel = new BookPanel((Book)p);
            }
            else if (p is Magazine)
            {
                panel = new MagazinePanel((Magazine)p);
            }
            else
            {
                panel = new MusicCDPanel((MusicCD)p);
            }

            return(panel);
        }
Exemplo n.º 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;
            }
        }