Beispiel #1
0
        protected void btnSubmitOrder_Click(object sender, EventArgs e)
        {
            List <CartItem> cartItems = (List <CartItem>)Session["items"];

            if (currentCustomer != null)
            {
                currentOrder.CustomerFirst = currentCustomer.CustomerFirst;
                currentOrder.CustomerLast  = currentCustomer.CustomerLast;
                currentOrder.OrderDate     = DateTime.Now;
                currentOrder.OrderTotal    = total;
                OrderDA.SaveOrder(currentOrder);
                currentOrder = OrderDA.GetCustomersLatestOrder(currentCustomer.CustomerFirst, currentCustomer.CustomerLast);
                foreach (CartItem item in cartItems)
                {
                    int    productID     = item.ProductID;
                    int    orderID       = currentOrder.OrderID;
                    string productDetail = item.Description;

                    OrderDA.SaveOrderLineItems(orderID, productID, productDetail);
                }
                Session["Receipt"] = currentOrder;
            }
            else
            {
                currentOrder.CustomerFirst = txtFirstName.Text;
                currentOrder.CustomerLast  = txtLastName.Text;
                currentOrder.OrderDate     = DateTime.Now;
                currentOrder.OrderTotal    = total;
                OrderDA.SaveOrder(currentOrder);
                currentOrder = OrderDA.GetCustomersLatestOrder(currentOrder.CustomerFirst, currentOrder.CustomerLast);
                foreach (CartItem item in cartItems)
                {
                    int    productID     = item.ProductID;
                    int    orderID       = currentOrder.OrderID;
                    string productDetail = item.ProductDetail;

                    OrderDA.SaveOrderLineItems(orderID, productID, productDetail);
                }
                Session["Receipt"] = currentOrder;
            }
            Response.Redirect("OrderReciept.aspx");
        }