Exemplo n.º 1
0
        // Attaches total cost of cart as parameter and redirects to payment form
        protected void btnCheckout_Click(object sender, EventArgs e)
        {
            BLShoppingCart cart = Session["Cart"] as BLShoppingCart;

            // Cannot checkout unless items are in the cart
            if (!cart.isEmpty())
            {
                string cartTotal = Cost.Text;

                Session["Cost"] = cartTotal;

                if (Session["LoginStatus"].ToString().Equals("LoggedOut"))
                {
                    // Unable to checkout without a registered account
                    Response.Redirect("~/UL/ErrorPage/4");
                }
                else
                {
                    Response.Redirect("~/UL/Payment");
                }
            }
            else
            {
                ErrorLabel.Text = "Cannot perform checkout with no items in cart.";
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Check for secure connection
            if (Request.IsSecureConnection)
            {
                // Page only available to logged in user
                if (Session["LoginStatus"].Equals("User"))
                {
                    // Check if items are still in the cart - otherwise; wrong state
                    BLShoppingCart cart = Session["Cart"] as BLShoppingCart;
                    if (!cart.isEmpty())
                    {
                        if (!IsPostBack)
                        {
                            double amount = Convert.ToDouble((Session["Cart"] as BLShoppingCart).Amount);

                            lblAmount.Text = string.Format("{0:C}", amount);

                            ddlShipping.DataSource = BLShipping.getShippingMethods();
                            ddlShipping.DataBind();

                            BLUser user = Session["CurrentUser"] as BLUser;

                            lblFirst.Text      = user.userFirstName;
                            lblLast.Text       = user.userLastName;
                            lblBillStreet.Text = user.billAddress.addStreet;
                            lblBillSuburb.Text = user.billAddress.addSuburb;
                            lblBillState.Text  = user.billAddress.addState;
                            lblBillZip.Text    = user.billAddress.addZip.ToString();
                            lblPostStreet.Text = user.postAddress.addStreet;
                            lblPostSuburb.Text = user.postAddress.addSuburb;
                            lblPostState.Text  = user.postAddress.addState;
                            lblPostZip.Text    = user.postAddress.addZip.ToString();
                        }
                    }
                    else
                    {
                        Response.Redirect("~/UL/ErrorPage/7");
                    }
                }
                else
                {
                    Response.Redirect("~/UL/ErrorPage/0");
                }
            }
            else
            {
                // Make connection secure if it isn't already
                string url = ConfigurationManager.AppSettings["SecurePath"] + "Payment";
                Response.Redirect(url);
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Check for secure connection
            if (Request.IsSecureConnection)
            {
                // Page only accessible to a logged in user
                if (Session["LoginStatus"].Equals("User"))
                {
                    // Check if items are still in the cart - otherwise; wrong state
                    BLShoppingCart cart = Session["Cart"] as BLShoppingCart;
                    if (!cart.isEmpty())
                    {
                        // Send confirmation of order to account email address
                        BLShipping shipping = Session["Shipping"] as BLShipping;

                        string mailbody = BLPurchase.generateOrderSummary(Session["Name"].ToString(), cart, shipping);

                        try
                        {
                            BLEmail.SendEmail(Session["UserName"].ToString(), "Order Receipt - JerseySure", mailbody);
                        }
                        catch (Exception ex)
                        {
                            Response.Redirect("~/UL/ErrorPage/1");
                        }

                        // Remove cart from session
                        Session.Remove("Cart");
                        Session["Cart"] = new BLShoppingCart();
                    }
                    else
                    {
                        Response.Redirect("~/UL/ErrorPage/7");
                    }
                }
                else
                {
                    Response.Redirect("~/UL/ErrorPage/0");
                }
            }
            else
            {
                // Make connection secure if it isn't already
                string url = ConfigurationManager.AppSettings["SecurePath"] + "PaymentConfirmation";
                Response.Redirect(url);
            }
        }