Advertisement
Guest User

Untitled

a guest
May 24th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Net;
  8. using System.Net.Mail;
  9.  
  10. public partial class PaymentForm : System.Web.UI.Page
  11. {
  12. protected void Page_Load(object sender, EventArgs e)
  13. {
  14. if (Session["cart"] != null)
  15. {
  16. ShoppingCart cart = (ShoppingCart)Session["cart"];
  17. gvCart.DataSource = cart.Paintings;
  18. gvCart.DataBind();
  19. decimal total = 0;
  20. foreach (Painting p in cart.Paintings)
  21. total += p.Price;
  22. lblTotal.Text = total.ToString("C");
  23. }
  24. else
  25. lblOutput.Text = "No purchase";
  26. }
  27. protected void gvCart_SelectedIndexChanged(object sender, EventArgs e)
  28. {
  29. ShoppingCart cart = (ShoppingCart)Session["cart"];
  30. cart.Paintings.RemoveAt( gvCart.SelectedIndex );
  31. gvCart.DataBind();
  32. decimal total = 0;
  33. foreach (Painting p in cart.Paintings)
  34. total += p.Price;
  35. lblTotal.Text = total.ToString("C");
  36. }
  37. protected void btnPay_Click(object sender, EventArgs e)
  38. {
  39. ShoppingCart cart = (ShoppingCart)Session["cart"];
  40. cart.CreditCart = tbxCreditCard.Text;
  41. cart.Total = decimal.Parse(lblTotal.Text, System.Globalization.NumberStyles.Currency);
  42. int orderId = ShoppingCartDB.addOrder(cart);
  43. lblOutput.Text = "Your order id is " + orderId;
  44. Session["cart"] = null;
  45. btnPay.Enabled = false;
  46. }
  47.  
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement