Example #1
0
        //*******************************************************
        //
        // The Page_Load event on this page is used to obtain
        // order information from a database and then update
        // UI elements with them.
        //
        //*******************************************************

        private void Page_Load(object sender, System.EventArgs e)
        {
            // Obtain Order ID from QueryString
            int OrderID = Int32.Parse(Request.Params["OrderID"]);

            // Get the customer ID too
            string CustomerId = User.Identity.Name;

            // Obtain Order Details from Database
            IBuySpy.OrdersDB     orderHistory   = new IBuySpy.OrdersDB();
            IBuySpy.OrderDetails myOrderDetails = orderHistory.GetOrderDetails(OrderID, CustomerId);

            // if order was found, display it
            if (myOrderDetails != null)
            {
                // Bind Items to GridControl
                GridControl1.DataSource = myOrderDetails.OrderItems;
                GridControl1.DataBind();

                // Update labels with summary details
                lblTotal.Text       = String.Format("{0:c}", myOrderDetails.OrderTotal);
                lblOrderNumber.Text = OrderID.ToString();
                lblOrderDate.Text   = myOrderDetails.OrderDate.ToShortDateString();
                lblShipDate.Text    = myOrderDetails.ShipDate.ToShortDateString();
            }
            // otherwise display an error message
            else
            {
                MyError.Text         = "Order not found!";
                detailsTable.Visible = false;
            }
        }
Example #2
0
        //*******************************************************
        //
        // The Page_Load event on this page is used to obtain
        // from a database a collection of all orders placed
        // by the current customer.  The collection is then
        // databound to a templated asp:datalist control.
        //
        //*******************************************************

        private void Page_Load(object sender, System.EventArgs e)
        {
            String customerID = User.Identity.Name;

            // Obtain and bind a list of all orders ever placed by visiting customer
            IBuySpy.OrdersDB orderHistory = new IBuySpy.OrdersDB();

            MyList.DataSource = orderHistory.GetCustomerOrders(customerID);
            MyList.DataBind();

            // Hide the list and display a message if no orders have ever been made
            if (MyList.Items.Count == 0)
            {
                MyError.Text   = "You have no orders to display.";
                MyList.Visible = false;
            }
        }
Example #3
0
        //*******************************************************
        //
        // The SubmitBtn_Click event handle is used to order the
        // items within the current shopping cart.  It then
        // displays the orderid and order status to the screen
        // (hiding the "SubmitBtn" button to ensure that the
        // user can't click it twice).
        //
        //*******************************************************

        private void SubmitBtn_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            IBuySpy.ShoppingCartDB cart = new IBuySpy.ShoppingCartDB();

            // Calculate end-user's shopping cart ID
            String cartId = cart.GetShoppingCartId();

            // Calculate end-user's customerID
            String customerId = User.Identity.Name;

            if ((cartId != null) && (customerId != null))
            {
                // Place the order
                IBuySpy.OrdersDB ordersDatabase = new IBuySpy.OrdersDB();
                int orderId = ordersDatabase.PlaceOrder(customerId, cartId);

                //Update labels to reflect the fact that the order has taken place
                Header.Text       = "Check Out Complete!";
                Message.Text      = "<b>Your Order Number Is: </b>" + orderId;
                SubmitBtn.Visible = false;
            }
        }