public List <CartItem> UpdateCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count]; for (int i = 0; i < CartList.Rows.Count; i++) { IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(CartList.Rows[i]); cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]); CheckBox cbRemove = new CheckBox(); cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove"); cartUpdates[i].RemoveItem = cbRemove.Checked; TextBox quantityTextBox = new TextBox(); quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity"); cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString()); } usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal()); if (usersShoppingCart.GetTotal() <= 0) { UpdateBtn.Visible = false; } return(usersShoppingCart.GetCartItems()); } }
//update cart item with db private List <CartItem> UpdateCartItems() { using (ShoppingCartActions shopaction = new ShoppingCartActions()) { string cartId = shopaction.GetCartId().ToString(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count]; //collect item in cart to update list for (int i = 0; i < CartList.Rows.Count; i++) { IOrderedDictionary rowValues = GetValues(CartList.Rows[i]); cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]); CheckBox cbRm = CartList.Rows[i].FindControl("Remove") as CheckBox; cartUpdates[i].RemoveItem = cbRm.Checked; TextBox qnt = CartList.Rows[i].FindControl("PurchaseQuantity") as TextBox; cartUpdates[i].PurchaseQuantity = Convert.ToInt16(qnt.Text); } shopaction.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); lblTotal.Text = string.Format("{0:c}", shopaction.GetTotal()); return(shopaction.GetCartItems()); } }
private List <CartItem> UpdateCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { ShoppinCartUpdates[] cartUpdates = new ShoppinCartUpdates[CartList.Rows.Count]; for (int i = 0; i < CartList.Rows.Count; i++) { IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(CartList.Rows[i]); cartUpdates[i].produtoId = Convert.ToInt32(rowValues["ProductId"]); CheckBox cbRemove = new CheckBox(); cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove"); cartUpdates[i].isRemovedItem = cbRemove.Checked; TextBox TbQuantity = new TextBox(); TbQuantity = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity"); cartUpdates[i].purchaseQuantity = Convert.ToInt32(TbQuantity.Text); } usersShoppingCart.UpdateShoppingCartDatabase(cartUpdates); CartList.DataBind(); lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal()); return(usersShoppingCart.GetCartItems().ToList()); } }
protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.User.Identity.IsAuthenticated) { CheckoutButton.Enabled = true; } else { CheckoutButton.Enabled = false; } using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { decimal cartTotal = 0; cartTotal = usersShoppingCart.GetTotal(); if (cartTotal > 0) { lblTotal.Text = cartTotal + "kn"; } else { LabelTotalText.Text = ""; lblTotal.Text = ""; KosaricaTitle.InnerText = "Košarica je prazna"; UpdateButton.Visible = false; CheckoutButton.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { Session["Total"] = lblTotal.Text; using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { decimal cartTotal = 0; cartTotal = usersShoppingCart.GetTotal(); if (cartTotal > 0) { // Display Total. lblTotal.Text = cartTotal.ToString(); //Session["Total"] = lblTotal.Text; //lblTotal.Text = String.Format("{0:c}", cartTotal); Session["Total"] = lblTotal.Text; } else { LabelTotalText.Text = ""; lblTotal.Text = ""; server.Text = "Shopping Cart is Empty"; UpdateBtn.Visible = false; CheckoutImageBtn.Visible = false; } } }
protected void CheckoutBtn_Click(object sender, ImageClickEventArgs e) { ShoppingCartActions usersShoppingCart = new ShoppingCartActions(); Session["payment_amt"] = usersShoppingCart.GetTotal(); Response.Redirect("Checkout/CheckoutStart.aspx"); }
public List <CartItem> UpdateCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); List <ShoppingCartActions.ShoppingCartUpdates> cartUpdates = new List <ShoppingCartActions.ShoppingCartUpdates>(); foreach (GridViewRow row in CartList.Rows) { IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(row); var ControlCheckbox = (CheckBox)row.FindControl("Remove"); var TextBox = (TextBox)row.FindControl("PurchaseQuantity"); ShoppingCartActions.ShoppingCartUpdates cartUpdate = new ShoppingCartActions.ShoppingCartUpdates { ProductId = Convert.ToInt32(rowValues["ProductID"]), RemoveItem = ControlCheckbox.Checked, PurchaseQuantity = Convert.ToInt16(TextBox.Text.ToString()) }; cartUpdates.Add(cartUpdate); } usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal()); return(usersShoppingCart.GetCartItems()); } }
protected void Page_Load(object sender, EventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { decimal cartTotal, cartTotalQty = 0; cartTotal = usersShoppingCart.GetTotal(); cartTotalQty = usersShoppingCart.GetTotalQty(); if (cartTotalQty > 0 || cartTotal > 0) { // Display Total. lblTotal.Text = String.Format("{0:c}", cartTotal); CheckoutBtn.Visible = true; UpdateBtn.Visible = true; } else { LabelTotalText.Text = ""; lblTotal.Text = ""; ShoppingCartTitle.InnerText = "Shopping Cart is Empty"; CheckoutBtn.Visible = false; UpdateBtn.Visible = false; } } }
//UpdatecartItems Method public List <CartItem> UpdateCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count]; for (int i = 0; i < CartList.Rows.Count; i++) { //The amount of products in the cart. IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(CartList.Rows[i]); cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]); //This the checkbox to tick to remove a product. CheckBox cbRemove = new CheckBox(); cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove"); cartUpdates[i].RemoveItem = cbRemove.Checked; //This is the textbox to change the quantity. TextBox quantityTextBox = new TextBox(); quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity"); cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString()); } //This updates the total for all prdoucts in the cart using the GetTotal method. usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal()); return(usersShoppingCart.GetCartItems()); } }
public List <CartItem> UpdateCartItems() { using (var shoppingCartActions = new ShoppingCartActions()) { var cartId = shoppingCartActions.GetCartId(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartGridView.Rows.Count]; for (int i = 0; i < CartGridView.Rows.Count; i++) { IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(CartGridView.Rows[i]); cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]); var cbRemove = new CheckBox(); cbRemove = (CheckBox)CartGridView.Rows[i].FindControl("Remove"); cartUpdates[i].RemoveItem = cbRemove.Checked; var quantityTextBox = new TextBox(); quantityTextBox = (TextBox)CartGridView.Rows[i].FindControl("PurchaseQuantity"); cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text); } shoppingCartActions.UpdateShoppingCartDatabase(cartId, cartUpdates); CartGridView.DataBind(); lblTotal.Text = string.Format("{0:c}", shoppingCartActions.GetTotal()); return(shoppingCartActions.GetCartItems()); } }
protected void CheckoutBtn_Click(object sender, EventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { string products = ""; string prices = ""; string quantities = ""; foreach (var product in usersShoppingCart.GetCartItems()) { var name = product.Product.ProductName; var price = product.Product.UnitPrice; var quantity = product.Quantity; quantities = quantities + quantity + ","; prices = prices + price + ","; products = products + name + ","; } Session["product_names"] = products; Session["product_prices"] = prices; Session["product_quantities"] = quantities; Session["payment_amt"] = usersShoppingCart.GetTotal(); } Response.Redirect("Checkout/CheckoutStart.aspx"); }
public List <ShoppingCartItem> UpdateCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count]; for (int i = 0; i < CartList.Rows.Count; i++) { IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(CartList.Rows[i]); cartUpdates[i].PricelistItemId = Convert.ToInt32(rowValues["PricelistItem.PricelistItemId"]); //the ID is not updated, always 0 CheckBox cbRemove = new CheckBox(); cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove"); cartUpdates[i].RemoveItem = cbRemove.Checked; TextBox quantityTextBox = new TextBox(); quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity"); cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString()); } usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); lblTotal.Text = String.Format("€{0:##,#.00}", usersShoppingCart.GetTotal()); return(usersShoppingCart.GetCartItems()); } }
public List <CartItem> RemoveCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CheckoutReviewList.Rows.Count]; for (int i = 0; i < CheckoutReviewList.Rows.Count; i++) { IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(CheckoutReviewList.Rows[i]); cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]); CheckBox cbRemove = new CheckBox(); cartUpdates[i].RemoveItem = true; TextBox quantityTextBox = new TextBox(); quantityTextBox = (TextBox)CheckoutReviewList.Rows[i].FindControl("PurchaseQuantity"); cartUpdates[i].PurchaseQuantity = 0; } usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CheckoutReviewList.DataBind(); lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal()); return(usersShoppingCart.GetCartItems()); } }
protected void CheckoutBtn_Click(object sender, ImageClickEventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { Session["payment_amt"] = usersShoppingCart.GetTotal(); } Response.Redirect("https://www.paypal.com/signin/?returnUrl=%2Fcgi-bin%2Fwebscr%3Fcmd%3D_account&country.x=US&locale.x=en_US"); }
protected void CheckoutBtn_Click(object sender, ImageClickEventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { Session["payment_amt"] = usersShoppingCart.GetTotal().ToString(CultureInfo.InvariantCulture); } Response.Redirect("Checkout/CheckoutStart.aspx"); }
protected void SendCartDetails() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { Session["payment_amt"] = usersShoppingCart.GetTotal(); Session["cart_items"] = usersShoppingCart.GetCartItems(); } }
public void CheckoutBtn_Click(object sender, EventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { Session["payment_amt"] = usersShoppingCart.GetTotal(); Session["Cart"] = usersShoppingCart.GetCartItems(); } Response.Redirect("Checkout/shippingDetails.aspx"); }
protected void CheckoutPayPalBtn_Click(object sender, ImageClickEventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { Session["payment_amt"] = usersShoppingCart.GetTotal(); } Session["payment_method"] = "paypal"; Response.Redirect("Checkout/CheckoutStart.aspx"); }
//When CheckoutBtn is clicked show the shopping cart review. protected void CheckoutBtn_Click(object sender, EventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { Session["Review"] = usersShoppingCart.GetTotal(); } //Redirect to the CheckoutReview page. Response.Redirect("Checkout/CheckoutReview.aspx"); }
public List <CartItem> UpdateCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count]; for (int i = 0; i < CartList.Rows.Count; i++) { IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(CartList.Rows[i]); cartUpdates[i].LivroId = Convert.ToInt32(rowValues["livro_id"]); CheckBox cbRemove = new CheckBox(); cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remover"); cartUpdates[i].RemoverItem = cbRemove.Checked; int quantidadeAnterior = GetShoppingCartItems().Cast <CartItem>().ElementAt(i).quantidade; Estoque estoque = commands["CONSULTAR"].execute(new Estoque() { Livro = new Dominio.Livro.Livro() { ID = cartUpdates[i].LivroId } }).Entidades.Cast <Estoque>().ElementAt(0); TextBox quantityTextBox = new TextBox(); quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity"); if (estoque.Qtde < Convert.ToInt32(quantityTextBox.Text)) { cartUpdates[i].PurchaseQuantity = quantidadeAnterior; lblResultadoCarrinho.Text = "Quantidade em estoque do livro " + estoque.Livro.Titulo + " é de " + estoque.Qtde + " unidade(s)"; lblResultadoCarrinho.Visible = true; } else { cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString()); lblResultadoCarrinho.Text = ""; lblResultadoCarrinho.Visible = false; } } usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); lblSubtotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal()); return(usersShoppingCart.GetCartItems()); } }
// GET: Cart public ActionResult Index() { var cartId = new Helpers.CartHelpers().GetCartId(); var vm = new CartViewModel(); using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions(cartId)) { var shoppingCartItems = usersShoppingCart.GetCartItems(); var cartItemsVM = Mapper.Map <List <CartItemViewModel> >(shoppingCartItems); vm.CartItems = cartItemsVM; vm.ItemsTotal = usersShoppingCart.GetCount(); vm.OrderTotal = usersShoppingCart.GetTotal(); } //var shoppingCartItems = db.ShoppingCartItems.Include(c => c.Product); return(View(vm)); }
public List<cartitem> delteCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); for (int i = 0; i < usersShoppingCart.GetTotal(); i++) { usersShoppingCart.DeleteShoppingCartDatabase(cartId); } // lblTotal.Text = "0"; return usersShoppingCart.GetCartItems(); } }
// GET: Cart public ActionResult Index() { var cartId = new Helpers.CartHelpers().GetCartId(HttpContext); var vm = new CartModel(); var usersShoppingCart = new ShoppingCartActions(_db, cartId); var shoppingCartItems = usersShoppingCart.GetCartItems(); var cartItemsVM = _mapper.Map <List <CartItemModel> >(shoppingCartItems); vm.CartItems = cartItemsVM; vm.ItemsTotal = usersShoppingCart.GetCount(); vm.OrderTotal = usersShoppingCart.GetTotal(); //var shoppingCartItems = db.ShoppingCartItems.Include(c => c.Product); return(View(vm)); }
protected void Page_Load(object sender, EventArgs e) { //set price total using (ShoppingCartActions action = new ShoppingCartActions()) { decimal cartTotal = action.GetTotal(); lblTotal.Text = string.Format("{0:c}", cartTotal); if (cartTotal <= 0) { LabelTotalText.Text = ""; ShoppingCartTitle.InnerText = "shopping cart is empty"; UpdateBtn.Visible = false; CheckoutImageBtn.Visible = false; } } }
// GET: Checkout public ActionResult Index() { var vm = new CheckoutModel(); using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions(cartId, items, categories)) { var shoppingCartItems = usersShoppingCart.GetCartItems(); var cartItemsVM = Mapper.Map <List <CartItemModel> >(shoppingCartItems); vm.CartItems = cartItemsVM; vm.OrderTotal = usersShoppingCart.GetTotal(); vm.ItemsTotal = usersShoppingCart.GetCount(); } var user = (User)Session["User"]; var email = "*****@*****.**"; if (user != null && !string.IsNullOrWhiteSpace(user.Email)) { email = user.Email; } // To make filling out the form faster for demo purposes, pre-fill the values: vm.Order = new OrderModel { // Important! Keep this property here! Total = vm.OrderTotal, // Prefill properties for convenience: FirstName = "Bob", LastName = "Loblaw", Address = "1313 Mockingbird Lane", City = "Virginia Beach", State = "VA", PostalCode = "23456", Country = "United States", Email = email, NameOnCard = "Bob Loblaw", CreditCardType = "Visa", CreditCardNumber = "4111111111111111", ExpirationDate = "12/25", CCV = "987", SMSOptIn = true }; return(View(vm)); }
protected void Page_Load(object sender, EventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { decimal cartTotal = usersShoppingCart.GetTotal(); if (cartTotal > 0) { lblTotal.Text = String.Format("{0:c}", cartTotal); } else { LabelTotalText.Text = ""; lblTotal.Text = ""; ShoppingCartTitle.InnerText = "Shopping Cart is Empty"; //heading.InnerText = "Shopping Cart Empty"; } } }
protected void Page_Load(object sender, EventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { decimal carTotal = 0; carTotal = usersShoppingCart.GetTotal(); if (carTotal > 0) { lblTotal.Text = String.Format("{0:c}", carTotal);//hiển thị thông số } else { LabelTotalText.Text = ""; lblTotal.Text = ""; ShoppingCartTitle.InnerText = "No ooooooo..."; UpdateBtn.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { using (var shoppingCartActions = new ShoppingCartActions()) { decimal cartTotal = 0; cartTotal = shoppingCartActions.GetTotal(); if (cartTotal > 0) { lblTotal.Text = String.Format("{0:c}", cartTotal); } else { LabelTotalText.Text = ""; lblTotal.Text = ""; ShoppingCartTitle.InnerText = "Shopping Cart is Empty"; UpdateBtn.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { decimal cartTotal = 0; cartTotal = usersShoppingCart.GetTotal(); if (cartTotal > 0) { lblTotal.Text = "$" + cartTotal; } else { lblTotal.Text = ""; LabelTotalText.Text = ""; ShoppingCartTitle.InnerText = "Shopping Cart total"; } } // UpdateBtn.Visible = false; }
protected void Page_Load(object sender, EventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { decimal allcoast = 0; allcoast = usersShoppingCart.GetTotal(); if (allcoast > 0) { lblTotal.Text = String.Format("{0:c}", allcoast); } else { LabelTotalText.Text = ""; lblTotal.Text = ""; ShoppingCartTitle.InnerText = "Twój koszyk jest pusty"; UpdateBtn.Visible = false; } } }