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); } } } }
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); } } } }
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); } } } }
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); }
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; } }