Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Net;
- using System.Net.Mail;
- public partial class PaymentForm : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (Session["cart"] != null)
- {
- ShoppingCart cart = (ShoppingCart)Session["cart"];
- gvCart.DataSource = cart.Paintings;
- gvCart.DataBind();
- decimal total = 0;
- foreach (Painting p in cart.Paintings)
- total += p.Price;
- lblTotal.Text = total.ToString("C");
- }
- else
- lblOutput.Text = "No purchase";
- }
- protected void gvCart_SelectedIndexChanged(object sender, EventArgs e)
- {
- ShoppingCart cart = (ShoppingCart)Session["cart"];
- cart.Paintings.RemoveAt( gvCart.SelectedIndex );
- gvCart.DataBind();
- decimal total = 0;
- foreach (Painting p in cart.Paintings)
- total += p.Price;
- lblTotal.Text = total.ToString("C");
- }
- protected void btnPay_Click(object sender, EventArgs e)
- {
- ShoppingCart cart = (ShoppingCart)Session["cart"];
- cart.CreditCart = tbxCreditCard.Text;
- cart.Total = decimal.Parse(lblTotal.Text, System.Globalization.NumberStyles.Currency);
- int orderId = ShoppingCartDB.addOrder(cart);
- lblOutput.Text = "Your order id is " + orderId;
- Session["cart"] = null;
- btnPay.Enabled = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement