protected void AddProductButton_Click(object sender, EventArgs e) { if (UploadedImage.AlternateText != "") { Product newProduct = new Product(); newProduct.UPC = UPCTB.Text; newProduct.CategoryID = int.Parse(CategoryDropDownList.SelectedValue); newProduct.CategoryName = CategoryDropDownList.SelectedItem.Text; newProduct.Name = ProductNameTB.Text; newProduct.Size = int.Parse(SizeTB.Text); newProduct.Price = decimal.Parse(PriceTB.Text); newProduct.CountryOfOrigin = CountryOfOriginTB.Text; newProduct.WineSweetnessIndex = WineSweetnessIndexDropDownList.SelectedValue; newProduct.Company = CompanyTB.Text; newProduct.Description = DescriptionTB.Text; newProduct.ImageUrl = Server.MapPath("~/UploadImage/" + UploadedImage.AlternateText); LLMS LiquorLakeManager = new LLMS(); bool Confirmation = LiquorLakeManager.InsertProduct(newProduct, UploadedImage.AlternateText); if (!File.Exists(Server.MapPath("~/Images/" + newProduct.CategoryName + "/" + UploadedImage.AlternateText))) { File.Copy(Server.MapPath(UploadedImage.ImageUrl), Server.MapPath("~/Images/" + newProduct.CategoryName + "/" + UploadedImage.AlternateText)); } AddProductLabel.Text = (Confirmation) ? "<span style='color:green'>New product added.</span>" : "<span style='color:red'>Error encountered while adding new product</span>"; } else { AddProductLabel.Text = "<span style='color:red'>Please upload an image</span>"; } }
private void Update_Click(object sender, EventArgs e) { //Response.Write("Clicked details"); Button clicked = sender as Button; LLMS requestDirector = new LLMS(); ProductInfoPanel.Visible = true; Product currentProduct = requestDirector.GetProductDetails(clicked.CommandArgument.ToString()); //Image i = new Image(); //i.ImageUrl = "~/Images/" + currentProduct.CategoryName + "/" + currentProduct.ImageUrl; tbUPC.Text = currentProduct.UPC; tbSize.Text = currentProduct.Size.ToString(); tbPrice.Text = currentProduct.Price.ToString(); tbName.Text = currentProduct.Name; tbDescription.Text = currentProduct.Description; tbCountryOfOrigin.Text = currentProduct.CountryOfOrigin; tbCompany.Text = currentProduct.Company; ddlCategoryName.SelectedIndex = ddlCategoryName.Items.IndexOf(ddlCategoryName.Items.FindByText(currentProduct.CategoryName)); ddlSweetnessIndex.SelectedIndex = ddlSweetnessIndex.Items.IndexOf(ddlSweetnessIndex.Items.FindByText(currentProduct.WineSweetnessIndex)); ItemImage.ImageUrl = "/Images/" + currentProduct.CategoryName + "/" + currentProduct.ImageUrl; ItemImage.AlternateText = currentProduct.ImageUrl; }
protected void btnUpdateProduct_Click(object sender, EventArgs e) { if (ItemImage.AlternateText != "") { LLMS requestDirector = new LLMS(); Product updatedProduct = new Product(); updatedProduct.CategoryID = int.Parse(ddlCategoryName.SelectedValue); updatedProduct.CategoryName = ddlCategoryName.SelectedItem.Text; updatedProduct.Company = tbCompany.Text; updatedProduct.CountryOfOrigin = tbCountryOfOrigin.Text; updatedProduct.Description = tbDescription.Text; updatedProduct.Name = tbName.Text; updatedProduct.Price = decimal.Parse(tbPrice.Text); updatedProduct.Size = int.Parse(tbSize.Text); updatedProduct.UPC = tbUPC.Text; updatedProduct.WineSweetnessIndex = ddlCategoryName.SelectedValue.ToString(); updatedProduct.ImageUrl = ItemImage.AlternateText; //fuImage.SaveAs(Server.MapPath("~/UploadImage/" + fuImage.FileName)); //ItemImage.ImageUrl = "/UploadImage/" + fuImage.FileName; //updatedProduct.ImageUrl = Server.MapPath("~/UploadImage/" + fuImage.FileName); if (requestDirector.UpdateProduct(updatedProduct)) { lblConfirmation.Text = "Successfully update product"; if (!File.Exists(Server.MapPath("~/Images/" + updatedProduct.CategoryName + "/" + ItemImage.AlternateText))) { File.Copy(Server.MapPath(ItemImage.ImageUrl), Server.MapPath("~/Images/" + updatedProduct.CategoryName + "/" + ItemImage.AlternateText)); } } else { lblConfirmation.Text = "Unable to update product"; } } else { lblConfirmation.Text = "<span style='color:red;'>Please upload an image</span>"; } }
protected void Page_Load(object sender, EventArgs e) { LLMS LiquorLakeManager = new LLMS(); List <Category> CategoryList = LiquorLakeManager.FindCategories(); foreach (Category c in CategoryList) { string categoryDiv = "<div class='category_item_container'>"; categoryDiv += "<a href='/ViewCatalog.aspx?category=" + c.CategoryID + "'>"; categoryDiv += "<div class='category_image_container'>"; //categoryDiv += "<img src='/App_Themes/Catalog/Images/liquor_placeholder.png'/>"; categoryDiv += "<img src='/App_Themes/Master/Images/" + c.Name.ToLower() + "categoryimage.jpg'/>"; categoryDiv += "<div class='shade_overlay'></div>"; categoryDiv += "<p class='category_item_name'>" + c.Name + "<p>"; categoryDiv += "</div>"; categoryDiv += "</a>"; categoryDiv += "</div>"; CategoriesContainer.InnerHtml += categoryDiv; } }
private void Delete_Click(object sender, EventArgs e) { Button clicked = sender as Button; string upc = clicked.CommandArgument; LLMS requestDirector = new LLMS(); if (requestDirector.RemoveProduct(upc)) { lblConfirmation.ForeColor = System.Drawing.Color.Green; lblConfirmation.Text = "Successfully removed item: " + upc; } else { lblConfirmation.ForeColor = System.Drawing.Color.Red; lblConfirmation.Text = "Unable to remove item: " + upc; } Response.AddHeader("REFRESH", "3;URL=DeleteProduct.aspx"); }
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); } }
protected void Page_Load(object sender, EventArgs e) { LLMS requestDirector = new LLMS(); List <Product> products = requestDirector.FindProducts(); 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 deleteButton = new Button() { Text = "DELETE", CssClass = "button", CommandArgument = p.UPC //Sending the UPC as the argument, we can later grab this when inside the button }; deleteButton.Click += new EventHandler(Delete_Click); buttonCell.Controls.Add(deleteButton); 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 = 150; i.Height = 150; 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); } }