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