protected void Page_Load(object sender, EventArgs e) { int iCategoryID = 0; string keyword = ""; LLMS LiquorLakeManager = new LLMS(); List <Product> products = new List <Product>(); if (Request.QueryString["keyword"] != null) { keyword = Request.QueryString["keyword"].ToString(); products = LiquorLakeManager.SearchProduct(keyword); } else if (Request.QueryString["category"] != null) { iCategoryID = int.Parse(Request.QueryString["category"]); products = LiquorLakeManager.FindProducts(iCategoryID); } else { products = LiquorLakeManager.FindProducts(); } GenerateProducts(products); }
private void ListProducts() { LLMS requestDirector = new LLMS(); List <Product> products = requestDirector.SearchProduct(tbSearchProduct.Text); TableRow tr = new TableRow(); TableCell tc = new TableCell(); tc = new TableCell(); tc.Text = ""; tr.Cells.Add(tc); tc = new TableCell(); tc.Text = "UPC"; tr.Cells.Add(tc); tc = new TableCell(); tc.Text = "Category ID"; tr.Cells.Add(tc); tc = new TableCell(); tc.Text = "Name"; tr.Cells.Add(tc); tc = new TableCell(); tc.Text = "Price"; tr.Cells.Add(tc); tc = new TableCell(); tc.Text = "Size(ml)"; tr.Cells.Add(tc); tc = new TableCell(); tc.Text = "CountryOfOrigin"; tr.Cells.Add(tc); tc = new TableCell(); tc.Text = "WineSweetnessIndex"; tr.Cells.Add(tc); tc = new TableCell(); tc.Text = "Image"; tr.Cells.Add(tc); tc = new TableCell(); tc.Text = "Company"; tr.Cells.Add(tc); tc = new TableCell(); tc.Text = "Description"; tr.Cells.Add(tc); ProductsTable.Rows.Add(tr); foreach (Product p in products) { tr = new TableRow(); TableCell buttonCell = new TableCell(); Button updateButton = new Button() { Text = "DETAILS", CssClass = "button", CommandArgument = p.UPC }; updateButton.Click += new EventHandler(Update_Click); buttonCell.Controls.Add(updateButton); tr.Cells.Add(buttonCell); tc = new TableCell(); tc.Text = p.UPC; tr.Cells.Add(tc); tc = new TableCell(); tc.Text = p.CategoryID.ToString(); tr.Cells.Add(tc); tc = new TableCell(); tc.Text = p.Name; tr.Cells.Add(tc); tc = new TableCell(); tc.Text = p.Price.ToString(); tr.Cells.Add(tc); tc = new TableCell(); tc.Text = p.Size.ToString(); tr.Cells.Add(tc); tc = new TableCell(); tc.Text = p.CountryOfOrigin; tr.Cells.Add(tc); tc = new TableCell(); tc.Text = p.WineSweetnessIndex; tr.Cells.Add(tc); Image i = new Image(); i.ImageUrl = "/Images/" + p.CategoryName + "/" + p.ImageUrl; i.Width = 100; i.Height = 100; tc = new TableCell(); tc.Controls.Add(i); tr.Cells.Add(tc); tc = new TableCell(); tc.Text = p.Company; tr.Cells.Add(tc); tc = new TableCell(); tc.Text = p.Description; tr.Cells.Add(tc); ProductsTable.Rows.Add(tr); } }