private void fillPartDetails() { if (!string.IsNullOrWhiteSpace(Request.QueryString["id"])) { int id = Convert.ToInt32(Request.QueryString["id"]); OnlinePurchase choosePart = new OnlinePurchase(); productdb product = choosePart.chooseProduct(id); LegacyPartsDB l = new LegacyPartsDB(); part pt = l.chooseParts(id); lblPrice.Text = "Price per Unit : $ " + pt.price; lblTitle.Text = pt.description; if (product == null) { imgProduct.ImageUrl = "~/Images/Products/NoImageFound.jpg"; //int q = Convert.ToInt32(product.qty); //if (q == null) Quantity.Visible = false; //int[] qty = Enumerable.Range(0, 0).ToArray(); //Quantity.DataSource = qty; //Quantity.AppendDataBoundItems = true; //Quantity.DataBind(); Availability.Text = "Not available"; btnAddCart.Visible = false; } else { imgProduct.ImageUrl = "~/Images/Products/" + product.image; int q = Convert.ToInt32(product.qty); if (q == 0) { Quantity.Visible = false; Availability.Text = "Not available"; btnAddCart.Visible = false; } else { int[] qty = Enumerable.Range(1, q).ToArray(); Quantity.DataSource = qty; Quantity.AppendDataBoundItems = true; Quantity.DataBind(); Availability.Text = "Available"; } } } }
protected void Page_Load(object sender, EventArgs e) { PurchaseCtrl pc = new PurchaseCtrl(); List <productdb> product = pc.viewProducts(); LegacyPartsDB l = new LegacyPartsDB(); ReceivingDeskController r = new ReceivingDeskController(); foreach (productdb prod in product) { string name = l.partName(prod.id); r.updateName(prod.id, name); } }
protected void btnAddCart_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(Request.QueryString["id"])) { string usname = Session["UserName"].ToString(); Customer c = new Customer(); int clID = c.returnClientID(usname); string clientId; if (usname.Equals("Guest")) { clientId = "-1"; } else { clientId = clID.ToString(); } LegacyPartsDB legacy = new LegacyPartsDB(); int id = Convert.ToInt32(Request.QueryString["id"]); int qty = Convert.ToInt32(Quantity.SelectedValue); string ptname = legacy.partName(id); cart cart = new cart { ClientId = clientId, Amount = qty, ProductId = id, DatePurchased = DateTime.Now, isInCart = true, partName = ptname }; CartModel ct = new CartModel(); lblResult.Text = ct.insertCart(cart); } else { lblResult.Text = "No product added.."; } }
private void fillPage() { OnlinePurchase fillproduct = new OnlinePurchase(); List <productdb> product = fillproduct.viewProducts(); // productdb desc = fillproduct.chooseProduct(); LegacyPartsDB l = new LegacyPartsDB(); List <part> pt = l.viewAllParts(); /* * if(product != null) * { * foreach(productdb prod in product) * { * Panel productPanel = new Panel(); * ImageButton imageButton = new ImageButton(); * Label lblName = new Label(); * * imageButton.ImageUrl = "~/Images/Products/" + prod.image; * imageButton.CssClass = "productImage"; * imageButton.PostBackUrl = "~/Pages/ChooseProduct.aspx?id=" + prod.id; * * lblName.Text = prod.name; * lblName.CssClass = "productName"; * * productPanel.Controls.Add(imageButton); * productPanel.Controls.Add(new Literal { Text ="<br/>"}); * productPanel.Controls.Add(lblName); * * PartsDisplay.Controls.Add(productPanel); * * } * }*/ if (pt != null) { foreach (part prod in pt) { Panel productPanel = new Panel(); ImageButton imageButton = new ImageButton(); Label lblName = new Label(); productdb img = fillproduct.chooseProduct(prod.number); if (img == null) { imageButton.ImageUrl = "~/Images/Products/NoImageFound.jpg"; imageButton.CssClass = "productImage"; imageButton.PostBackUrl = "~/Pages/ChooseProduct.aspx?id=" + prod.number; } else { imageButton.ImageUrl = "~/Images/Products/" + img.image; imageButton.CssClass = "productImage"; imageButton.PostBackUrl = "~/Pages/ChooseProduct.aspx?id=" + prod.number; } lblName.Text = prod.description; lblName.CssClass = "productName"; productPanel.Controls.Add(imageButton); productPanel.Controls.Add(new Literal { Text = "<br/>" }); productPanel.Controls.Add(lblName); PartsDisplay.Controls.Add(productPanel); } } else { PartsDisplay.Controls.Add(new Literal { Text = "No Product found ...!!!" }); } }
private void CreateShopTable(IEnumerable <cart> carts, out double subTotal) { subTotal = new double(); ReceivingDeskScreen model = new ReceivingDeskScreen(); // ProductModel model = new ProductModel(); foreach (cart cart in carts) { int pid = Convert.ToInt32(cart.ProductId); //Create HTML elements and fill values with database data productdb product = model.GetProduct(pid); LegacyPartsDB l = new LegacyPartsDB(); part pt = l.chooseParts(pid); ImageButton btnImage = new ImageButton { ImageUrl = string.Format("~/Images/Products/{0}", product.image), PostBackUrl = string.Format("~/Pages/ChooseProduct.aspx?id={0}", product.id) }; LinkButton lnkDelete = new LinkButton { PostBackUrl = string.Format("~/Pages/ShoppingCart.aspx?productId={0}", cart.id), Text = "Delete Item", ID = "del" + cart.id, }; lnkDelete.Click += Delete_Item; //Fill amount list with numbers int q = Convert.ToInt32(product.qty); int[] amount = Enumerable.Range(1, q).ToArray(); DropDownList ddlAmount = new DropDownList { DataSource = amount, AppendDataBoundItems = true, AutoPostBack = true, ID = cart.id.ToString() }; ddlAmount.DataBind(); ddlAmount.SelectedValue = cart.Amount.ToString(); ddlAmount.SelectedIndexChanged += ddlAmount_SelectedIndexChanged; //Create table to hold shopping cart details Table table = new Table { CssClass = "CartTable" }; TableRow row1 = new TableRow(); TableRow row2 = new TableRow(); TableCell cell1_1 = new TableCell { RowSpan = 2, Width = 50 }; TableCell cell1_2 = new TableCell { Text = string.Format("<h4>{0}</h4><br />{1}<br/>In Stock", pt.description, "Item No:" + product.id), HorizontalAlign = HorizontalAlign.Left, Width = 350, }; TableCell cell1_3 = new TableCell { Text = "Unit Price<hr/>" }; TableCell cell1_4 = new TableCell { Text = "Quantity<hr/>" }; TableCell cell1_5 = new TableCell { Text = "Item Total<hr/>" }; TableCell cell1_6 = new TableCell(); double pri = Convert.ToDouble(pt.price); TableCell cell2_1 = new TableCell(); TableCell cell2_2 = new TableCell { Text = "$ " + pt.price }; TableCell cell2_3 = new TableCell(); TableCell cell2_4 = new TableCell { Text = "$ " + Math.Round((cart.Amount * pri), 2) }; TableCell cell2_5 = new TableCell(); //Set custom controls cell1_1.Controls.Add(btnImage); cell1_6.Controls.Add(lnkDelete); cell2_3.Controls.Add(ddlAmount); //Add rows & cells to table row1.Cells.Add(cell1_1); row1.Cells.Add(cell1_2); row1.Cells.Add(cell1_3); row1.Cells.Add(cell1_4); row1.Cells.Add(cell1_5); row1.Cells.Add(cell1_6); row2.Cells.Add(cell2_1); row2.Cells.Add(cell2_2); row2.Cells.Add(cell2_3); row2.Cells.Add(cell2_4); row2.Cells.Add(cell2_5); table.Rows.Add(row1); table.Rows.Add(row2); ShoppingCart.Controls.Add(table); //Add total of current purchased item to subtotal //Math.Round((subTotal += (cart.Amount * pri)), 2); subTotal += (cart.Amount * pri); } //Add selected objects to Session //Session[User.Identity.GetUserId()] = carts; }