protected void placeOrderButton_Click(object sender, EventArgs e) { // Store the total amount decimal amount = ShoppingCartAccess.GetTotalAmount(); // Get shipping ID or default to 0 int shippingId = 0; int.TryParse(shippingSelection.SelectedValue, out shippingId); // Get tax ID or default to "No tax" string shippingRegion = (HttpContext.Current.Profile as ProfileCommon).ShippingRegion; int taxId; switch (shippingRegion) { case "2": taxId = 1; break; default: taxId = 2; break; } // Create the order and store the order ID string orderId = ShoppingCartAccess.CreateCommerceLibOrder(shippingId, taxId); // Redirect to the conformation page Response.Redirect("OrderPlaced.aspx"); }
/// <summary> /// Adds an item in the Shopping Cart. /// </summary> /// <param name="strProductSellerDetailID"></param> /// <param name="intProductID"></param> private void AddToCart(string strProductSellerDetailID, int intProductID, int intCategoryID) { string strHtml = string.Empty; try { using (ShoppingCartAccess cart = new ShoppingCartAccess()) { bool isAddedToCart = cart.ShoppingCart_AddItem(strProductSellerDetailID, intProductID, intCategoryID); if (isAddedToCart) { strHtml = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:100%;margin-left:150px; background-color:#FFA500;\">"; strHtml += "<tr>"; strHtml += "<td align=\"center\" style=\"height:45px; color:#FFFFFF; font-size:14px; font-weight:bold;\" valign=\"middle\">"; strHtml += "<span class=\"title\" style=\"font-size:14px;\">\""; strHtml += hfProductTitle.Value + "\"</span> has been added to your cart."; strHtml += "</td>"; strHtml += "</tr>"; strHtml += "</table>"; lblSystemMessage.Text = strHtml; //lblSystemMessage.Text = "<span class=\"title\" style=\"font-size:13px;color:red\">\""; //lblSystemMessage.Text += hfProductTitle.Value + "\"</span> has been added to your cart."; } } } catch (Exception Exp) { lblSystemMessage.Text = Exp.Message.ToString(); } }
// fill shopping cart controls with data private void PopulateControls() { recommendations.LoadCartRecommendations(); // get the items in the shopping cart DataTable dt = ShoppingCartAccess.GetItems(); // if the shopping cart is empty... if (dt.Rows.Count == 0) { titleLabel.Text = "Количката Ви е празна!"; grid.Visible = false; updateButton.Enabled = false; checkoutButton.Enabled = false; totalAmountLabel.Text = String.Format("{0:c}", 0); } else // if the shopping cart is not empty... { // populate the list with the shopping cart contents grid.DataSource = dt; grid.DataBind(); // setup controls titleLabel.Text = "Това са продуктите във Вашата количка:"; grid.Visible = true; updateButton.Enabled = true; checkoutButton.Enabled = true; // display the total amount decimal amount = ShoppingCartAccess.GetTotalAmount(); totalAmountLabel.Text = String.Format("{0:c}", amount); } }
protected void grid_RowDeleting(object sender, GridViewDeleteEventArgs e) { int rowIndex = e.RowIndex; strProductID = grid.DataKeys[rowIndex]["ProductID"].ToString(); strProductSellerDetailID = grid.DataKeys[rowIndex]["ProductSellerDetailID"].ToString(); if (Int32.TryParse(strProductID, out intProductID) && Int32.TryParse(strProductSellerDetailID, out intProductSellerDetailID)) { try { using (ShoppingCartAccess cart = new ShoppingCartAccess()) { bool success = cart.ShoppingCart_RemoveItem(intProductID, intProductSellerDetailID); lblStatus.Text = success ? "<br />Product successfully removed!<br />" : "<br />There was an error removing the product!<br />"; } } catch (Exception ex) { lblSystemMessage.Text = "Error:" + ex.Message; } } PopulateControls(); }
// deletes old shopping carts protected void deleteButton_Click(object sender, EventArgs e) { byte days = byte.Parse(daysList.SelectedItem.Value); ShoppingCartAccess.DeleteOldCarts(days); countLabel.Text = "The old shopping carts were removed from the database"; }
// fill the controls with data private void PopulateControls() { // get the items in the shopping cart System.Data.DataTable dt = ShoppingCartAccess.GetItems(); // if the shopping cart is empty... if (dt.Rows.Count == 0) { cartSummaryLabel.Text = "Кошницата Ви е празна."; totalAmountLabel.Text = String.Format("{0:c}", 0); viewCartLink.Visible = false; list.Visible = false; } else // if the shopping cart is not empty... { // populate the list with the shopping cart contents list.Visible = true; list.DataSource = dt; list.DataBind(); // set up controls cartSummaryLabel.Text = "Сума на кошницата "; viewCartLink.Visible = true; // display the total amount decimal amount = ShoppingCartAccess.GetTotalAmount(); totalAmountLabel.Text = String.Format("{0:c}", amount); } }
protected void btnCheckOut_Click(object sender, EventArgs e) { string strTotalAmount = string.Empty; string strOrderID = string.Empty; bool success = false; try { using (ShoppingCartAccess shoppingCart = new ShoppingCartAccess()) { DataTable dtTotalAmount = shoppingCart.ShoppingCart_GetTotalAmount(); strOrderID = shoppingCart.ShoppingCart_CreateOrder(rbtnPaymentOption.SelectedValue); if (dtTotalAmount.Rows.Count > 0) { strTotalAmount = dtTotalAmount.Rows[0]["TotalAmount"].ToString(); success = true; } } } catch (Exception ex) { lblSystemMessage.Text = "Error: " + ex.Message; } if (success) { this.Session["PAYMENT_OPTION"] = rbtnPaymentOption.SelectedItem.Text; this.Session["ORDER_ID"] = strOrderID; Response.Redirect("Default.aspx"); } else { Response.Redirect("~/Default.aspx"); } }
protected void AddToCartButton_Click(object sender, EventArgs e) { // Retrieve ProductID from the query string string productId = Request.QueryString["ProductID"]; // Retrieve the selected product options string options = ""; foreach (Control cnt in attrPlaceHolder.Controls) { if (cnt is Label) { Label attrLabel = (Label)cnt; options += attrLabel.Text; } if (cnt is DropDownList) { DropDownList attrDropDown = (DropDownList)cnt; options += attrDropDown.Items[attrDropDown.SelectedIndex] + "; "; } } // Add the product to the shopping cart ShoppingCartAccess.AddItem(productId, options); }
// fill shopping cart controls with data private void PopulateControls() { // set the title of the page this.Title = BalloonShopConfiguration.SiteName + " : Shopping Cart"; // get the items in the shopping cart DataTable dt = ShoppingCartAccess.GetItems(); // if the shopping cart is empty... if (dt.Rows.Count == 0) { titleLabel.Text = "Your shopping cart is empty!"; grid.Visible = false; updateButton.Enabled = false; checkoutButton.Enabled = false; totalAmountLabel.Text = String.Format("{0:c}", 0); } else // if the shopping cart is not empty... { // populate the list with the shopping cart contents grid.DataSource = dt; grid.DataBind(); // setup controls titleLabel.Text = "These are the products in your shopping cart:"; grid.Visible = true; updateButton.Enabled = true; checkoutButton.Enabled = true; // display the total amount decimal amount = ShoppingCartAccess.GetTotalAmount(); totalAmountLabel.Text = String.Format("{0:c}", amount); } }
// create a new order and redirect to a payment page protected void checkoutButton_Click(object sender, EventArgs e) { // Store the total amount because the cart // is emptied when creating the order decimal amount = Convert.ToDecimal(totalAmountLabel.Text); // Create the order and store the order ID string orderId = ShoppingCartAccess.CreateOrder(); // Obtain the site name from the configuration settings string siteName = BalloonShopConfiguration.SiteName; // Create the PayPal redirect location string redirect = ""; redirect += "https://www.paypal.com/xclick/[email protected]"; redirect += "&item_name=" + siteName + " Order " + orderId; redirect += "&item_number=" + orderId; redirect += "&amount=" + String.Format("{0:0.00} ", amount); redirect += "¤cy=USD"; redirect += "&return=http://www." + siteName + ".com"; redirect += "&cancel_return=http://www." + siteName + ".com"; // Redirect to the payment page Response.Redirect(redirect); }
protected void deleteButton_Click(object sender, EventArgs e) { byte days = byte.Parse(daysList.SelectedItem.Value); ShoppingCartAccess.DeleteOldCarts(days); countLabel.Text = "Старите колички бяха изтрити"; }
// fill controls with data private void PopulateControls() { // get the items in the shopping cart DataTable dt = ShoppingCartAccess.GetItems(); // populate the list with the shopping cart contents grid.DataSource = dt; grid.DataBind(); grid.Visible = true; // display the total amount decimal amount = ShoppingCartAccess.GetTotalAmount(); totalAmountLabel.Text = String.Format("{0:c}", amount); // check customer details bool addressOK = true; bool cardOK = true; if (Profile.Address1 + Profile.Address2 == "" || Profile.ShippingRegion == "" || Profile.ShippingRegion == "Please Select" || Profile.Country == "") { addressOK = false; } if (Profile.CreditCard == "") { cardOK = false; } // report / hide place order button if (!addressOK) { if (!cardOK) { InfoLabel.Text = "You must provide a valid address and credit card " + "before placing your order."; } else { InfoLabel.Text = "You must provide a valid address before placing your " + "order."; } } else if (!cardOK) { InfoLabel.Text = "You must provide a credit card before " + "placing your order."; } else { InfoLabel.Text = "Please confirm that the above details are " + "correct before proceeding."; } placeOrderButton.Visible = addressOK && cardOK; }
// fires when an Add to Cart button is clicked protected void list_ItemCommand(object source, DataListCommandEventArgs e) { // The CommandArgument of the clicked Button contains the ProductID string productId = e.CommandArgument.ToString(); // Add the product to the shopping cart ShoppingCartAccess.AddItem(productId); }
// Add the product to cart protected void addToCartButton_Click(object sender, EventArgs e) { // Retrieve ProductID from the query string string productId = Request.QueryString["ProductID"]; // Add the product to the shopping cart ShoppingCartAccess.AddItem(productId); }
// create a new order and redirect to a payment page protected void checkoutButton_Click(object sender, EventArgs e) { // Get the total amount decimal amount = ShoppingCartAccess.GetTotalAmount(); // Create the order and store the order ID string orderId = ShoppingCartAccess.CreateOrder(); string ordername = BalloonShopConfiguration.SiteName + " Order " + orderId; // Go to PayPal Checkout string destination = Link.ToPayPalCheckout(ordername, amount); Response.Redirect(destination); }
protected void Checkout_Click(object sender, EventArgs e) { // Get the total amount decimal amount = ShoppingCartAccess.GetTotalAmount(); // Create the order and store the order ID int orderId = ShoppingCartAccess.CreateOrder(); // string ordername = DatabaseConfiguration.PayPal + " Order " + orderId; // Go to PayPal checkout // string destination = Link.ToPayPalCheckout(ordername, amount); Response.Redirect("https://www.paypal.com/"); }
public void LoadCartRecommendations() { // display product recommendations DataTable table = ShoppingCartAccess.GetRecommendations(); if (table.Rows.Count > 0) { list.ShowHeader = true; list.DataSource = table; list.DataBind(); } }
protected void Button1_Click(object sender, EventArgs e) { double amount = (double)ShoppingCartAccess.GetTotalAmount(); bool promoset = false; if (promoset == false) { if (TextBox1.Text == "GET10ONSHOESHOP") { amount = amount - (amount * 0.10); totalAmountLabel.Text = String.Format("{0:f2}", amount); promoset = true; } } }
// remove a product from the cart protected void grid_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Index of the row being deleted int rowIndex = e.RowIndex; // The ID of the product being deleted string productId = grid.DataKeys[rowIndex].Value.ToString(); // Remove the product from the shopping cart bool success = ShoppingCartAccess.RemoveItem(productId); // Display status statusLabel.Text = success ? "<br />Product successfully removed!<br />" : "<br />There was an error removing the product!<br />"; // Repopulate the control PopulateControls(); }
// remove a product from the cart protected void grid_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Index of the row being deleted int rowIndex = e.RowIndex; // The ID of the product being deleted string productId = grid.DataKeys[rowIndex].Value.ToString(); // Remove the product from the shopping cart bool success = ShoppingCartAccess.RemoveItem(productId); // Display status statusLabel.Text = success ? "Продуктът премахнат успешно!" : "Имаше проблем при премахването на продукта! "; // Repopulate the control PopulateControls(); }
protected void Page_PreRender(object sender, EventArgs e) { // Get the currently loaded page string currentLocation = Request.AppRelativeCurrentExecutionFilePath; // If we're in Product.aspx... if (currentLocation == "~/Product.aspx") { // get the product ID string productId = Request.QueryString["ProductID"]; // get product recommendations DataTable table; // display recommendations table = CatalogAccess.GetRecommendations(productId); list.DataSource = table; list.DataBind(); // display header if (table.Rows.Count > 0) { recommendationsHeader.Text = "Customers who bought this product also bought:"; } else { recommendationsHeader.Text = ""; } } // If we're in ShoppingCart.aspx... else if (currentLocation == "~/ShoppingCart.aspx") { // get product recommendations DataTable table; // display recommendations table = ShoppingCartAccess.GetRecommendations(); list.DataSource = table; list.DataBind(); // display header if (table.Rows.Count > 0) { recommendationsHeader.Text = "Customers who bought these products also bought:"; } else { recommendationsHeader.Text = ""; } } }
protected void btnPlaceOrder_Click1(object sender, EventArgs e) { // this.LoadRecord_Buyer_Information(intProfileID, UserType); try { using (ShoppingCartAccess shoppingCart = new ShoppingCartAccess()) { if (Int32.TryParse(hfOrderID.Value, out intOrderID)) { if (!shoppingCart.IsOrder_PlacedOnce(intOrderID)) { if (shoppingCart.Verify_CustomerOrder(intOrderID, hfCustomerName.Value, hfCustomerEmail.Value, hfShippingAddress.Value, hfBillingAddress.Value)) { string strQueryString = "oi=" + hfOrderID.Value; strQueryString += "&pfi=" + hfProfileID.Value; strQueryString += "&ut=" + hfUserType.Value; strQueryString += "&po=" + hfPaymentOption.Value; //strQueryString += "&po=" + Server.UrlEncode(hfPaymentOption.Value); strQueryString += "&total=" + hfTotalAmount.Value; strQueryString += "&curr=" + hfCurrency.Value; string strEncryptedUrl = UTLUtilities.Encrypt(strQueryString); //string strDecryptedUrl = Response.Redirect("OrderConfirmation.aspx?data=" + strEncryptedUrl, false); } else { lblSystemMessage.Text = "There were some errors processing your order. Please contact Boromela."; } } else { string data = UTLUtilities.Encrypt("You may have already placed this order once."); Response.Redirect("../Error.aspx?data=" + data, false); } } } } catch (Exception ex) { lblSystemMessage.Text = "Error: " + ex.Message; } }
private void PopulateControls() { //this.Title = ShopConfiguration.SiteName + " : Shopping Cart"; // get the items in the shopping cart try { using (ShoppingCartAccess cart = new ShoppingCartAccess()) { dtCartItems = new DataTable(); dtCartItems = cart.LoadList_ShoppingCartItems(); DataTable dtAmount = cart.ShoppingCart_GetTotalAmount(); if (dtAmount.Rows.Count > 0) { lblTotalAmount.Text = "<span class=\"price\">" + dtAmount.Rows[0]["TotalAmount"].ToString() + "</span>"; lblCurrency.Text = "<span class=\"price\">" + dtAmount.Rows[0]["Currency"].ToString() + "</span>"; } } } catch (Exception ex) { lblSystemMessage.Text = "Error: " + ex.Message; } // if the shopping cart is empty... if (dtCartItems.Rows.Count == 0) { titleLabel.Text = "<span class=\"pagetitle\">Your shopping cart is empty!</span>"; grid.Visible = false; btnUpdate.Enabled = false; btnCheckOut.Enabled = false; lblTotalAmount.Text = ""; lblCurrency.Text = ""; //lblTotalAmount.Text = String.Format("{0:c}", 0); } else { grid.DataSource = dtCartItems; grid.DataBind(); titleLabel.Text = "<span class=\"pagetitle\">These are the products in your shopping cart:</span>"; grid.Visible = true; btnUpdate.Enabled = true; btnCheckOut.Enabled = true; } }
private void PopulateControls() { try { using (ShoppingCartAccess cart = new ShoppingCartAccess()) { dtOrderedItems = new DataTable(); dtOrderedItems = cart.LoadList_Ordered_Items(intOrderID); if (dtOrderedItems.Rows.Count > 0) { hfTotalAmount.Value = dtOrderedItems.Rows[0]["TotalAmount"].ToString(); hfCurrency.Value = dtOrderedItems.Rows[0]["Currency"].ToString(); lblTotalAmount.Text = string.Empty; lblTotalAmount.Text = "<span class=\"price\">"; lblTotalAmount.Text += dtOrderedItems.Rows[0]["TotalAmount"].ToString(); lblTotalAmount.Text += "</span>"; lblCurrency.Text = string.Empty; lblCurrency.Text = "<span class=\"price\">"; lblCurrency.Text += dtOrderedItems.Rows[0]["Currency"].ToString(); lblCurrency.Text += "</span>"; } } } catch (Exception ex) { lblSystemMessage.Text = "Error:" + ex.Message; } // if the shopping cart is empty... if (dtOrderedItems.Rows.Count == 0) { grvOrderedItems.Visible = false; lblTotalAmount.Text = ""; lblCurrency.Text = ""; } else { grvOrderedItems.DataSource = dtOrderedItems; grvOrderedItems.DataBind(); grvOrderedItems.Visible = true; } }
protected void Update_Click(object sender, EventArgs e) { // update shopping cart product quantities // Number of rows in the GridView int rowsCount = grid.Rows.Count; // Will store a row of the GridView GridViewRow gridRow; // Will reference a quantity TextBox in the GridView TextBox quantityTextBox; // Variables to store product ID and quantity string productId; int quantity; // Was the update successful? bool success = true; // Go through the rows of the GridView for (int i = 0; i < rowsCount; i++) { // Get a row gridRow = grid.Rows[i]; // The ID of the product being deleted productId = grid.DataKeys[i].Value.ToString(); // Get the quantity TextBox in the Row quantityTextBox = (TextBox)gridRow.FindControl("editQuantity"); // Get the quantity, guarding against bogus values if (Int32.TryParse(quantityTextBox.Text, out quantity)) { // Update product quantity success = success && ShoppingCartAccess.UpdateItem(productId, quantity); } else { // if TryParse didn't succeed success = false; } // Display status message statusLabel.Text = success ? "Your shopping cart was successfully updated!" : "Some quantity updates failed! Please verify your cart!"; } // Repopulate the control PopulateControls(); }
// update shopping cart product quantities protected void updateButton_Click(object sender, EventArgs e) { // Number of rows in the GridView int rowsCount = grid.Rows.Count; // Will store a row of the GridView GridViewRow gridRow; // Will reference a quantity TextBox in the GridView TextBox quantityTextBox; // Variables to store product ID and quantity string productId; int quantity; // Was the update successful? bool success = true; // Go through the rows of the GridView for (int i = 0; i < rowsCount; i++) { // Get a row gridRow = grid.Rows[i]; // The ID of the product being deleted productId = grid.DataKeys[i].Value.ToString(); // Get the quantity TextBox in the Row quantityTextBox = (TextBox)gridRow.FindControl("editQuantity"); // Get the quantity, guarding against bogus values if (Int32.TryParse(quantityTextBox.Text, out quantity)) { // Update product quantity success = success && ShoppingCartAccess.UpdateItem(productId, quantity); } else { // if TryParse didn't succeed success = false; } // Display status message statusLabel.Text = success ? "Кошницата Ви беше променена успешно!" : "Някой промени по количеството се провалиха! Моля проверете кошницата си!"; } // Repopulate the control PopulateControls(); }
protected void countButton_Click(object sender, EventArgs e) { byte days = byte.Parse(daysList.SelectedItem.Value); int oldItems = ShoppingCartAccess.CountOldCarts(days); if (oldItems == -1) { countLabel.Text = "Не могат да бъдат преброени!"; } else if (oldItems == 0) { countLabel.Text = "Няма стари колички."; } else { countLabel.Text = "Има " + oldItems.ToString() + " стари колички."; } }
// counts old shopping carts protected void countButton_Click(object sender, EventArgs e) { byte days = byte.Parse(daysList.SelectedItem.Value); int oldItems = ShoppingCartAccess.CountOldCarts(days); if (oldItems == -1) { countLabel.Text = "Could not count the old shopping carts!"; } else if (oldItems == 0) { countLabel.Text = "There are no old shopping carts."; } else { countLabel.Text = "There are " + oldItems.ToString() + " old shopping carts."; } }
protected void btnUpdate_Click(object sender, ImageClickEventArgs e) { int rowsCount = grid.Rows.Count; GridViewRow gridRow; TextBox quantityTextBox; int quantity; bool success = true; for (int i = 0; i < rowsCount; i++) { gridRow = grid.Rows[i]; strProductID = grid.DataKeys[i]["ProductID"].ToString(); strProductSellerDetailID = grid.DataKeys[i]["ProductSellerDetailID"].ToString(); quantityTextBox = (TextBox)gridRow.FindControl("txtQuantity"); if (Int32.TryParse(quantityTextBox.Text, out quantity) && Int32.TryParse(strProductID, out intProductID) && Int32.TryParse(strProductSellerDetailID, out intProductSellerDetailID)) { try { using (ShoppingCartAccess cart = new ShoppingCartAccess()) { success = success && cart.ShoppingCart_UpdateItem(intProductID, intProductSellerDetailID, quantity); } } catch (Exception ex) { success = false; lblSystemMessage.Text = "Error:" + ex.Message; } } else { success = false; } lblStatus.Text = success ? "<br />Your shopping cart was successfully updated!<br />" : "<br />Some quantity updates failed! Please verify your cart!<br />"; } // Repopulate the control PopulateControls(); }
protected void PopulateControls() { DataTable dt = ShoppingCartAccess.GetCartItems(); if (dt.Rows.Count > 0) { grid.DataSource = dt; grid.DataBind(); decimal amount = ShoppingCartAccess.GetCartTotal(); cartTotal.Text = String.Format("{0:c}", amount); } else { // Label1.Text = "These are no items in your cart "; grid.Visible = false; grid.DataBind(); cartTotal.Text = String.Format("{0:c}", 0); } }