Пример #1
0
    protected void applyCoupon_Click(object sender, EventArgs e)
    {
        //Get the coupon.
        try {
            Commerce.Promotions.Coupon selectedCoupon = Commerce.Promotions.Coupon.GetCoupon(couponCode.Text);
            //we have the coupon .. validate the order.
            Commerce.Promotions.CouponValidationResponse valid =
                selectedCoupon.ValidateCouponForOrder(currentOrder);
            if (valid.IsValid)
            {
                //apply the coupon to the order
                selectedCoupon.ApplyCouponToOrder(currentOrder);
                couponMessage.Text       = "Coupon code " + selectedCoupon.CouponCode + " was applied to your order!";
                currentOrder.CouponCodes = selectedCoupon.CouponCode;

                //add a note to the order that the coupon was applied
                OrderController.AddNote("Applied coupon " + selectedCoupon.CouponCode + " to order during checkout", currentOrder);

                //re-display the order
                lblOrderItems.Text = currentOrder.ItemsToString(true);
            }
            else
            {
                couponMessage.Text = "The selected coupon could not be applied to your order.  " + valid.ValidationMessage;
            }
        }
        catch (ArgumentException ex) {
            couponMessage.Text = "The code you entered could not be found or verified.";
        }
        couponMessage.Visible = true;
        EnsurePanelsHidden();
    }
Пример #2
0
    /****************************************************************
     *
     * AddToCart()
     *
     * *************************************************************/
    void AddToCart(string sGUID, int nQty)
    {
        //string sFemaleProductGUID = "f6d3b994-d5ca-491f-b55a-f22fa8974b25";
        productGUID = new Guid(sGUID);
        try
        {
            product = ProductController.GetProductDeepByGUID(productGUID);
            //make sure we have a product
            TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");

            //set the page variables
            productID        = product.ProductID;
            productSku       = product.Sku;
            product.Quantity = nQty;
            OrderController.AddCallCenterItem(product);

            //**********************************************************************************
            // Add keycode for OrderMotion
            // but only add one note, so check to see if the keycode note has already been added.
            //**********************************************************************************
            bool bIsCallCtrOrder = false;
            currentOrder = OrderController.GetCurrentOrder();
            OrderNoteCollection noteCollection = currentOrder.Notes;
            int nCount = noteCollection.Count;
            for (int nIndex = 0; nCount > nIndex; nIndex++)
            {
                OrderNote note = noteCollection[nIndex];
                //if (note.Equals("CALLCENTER"))
                if (true == note.Note.Equals("CALLCENTER"))
                {
                    bIsCallCtrOrder = true;
                    break;
                }
            }
            if (false == bIsCallCtrOrder)
            {
                OrderController.AddNote("CALLCENTER", currentOrder);
            }
        }
        catch (Exception ex)
        {
            LovRubLogger.LogException(ex);
            throw ex;
        }
    }
Пример #3
0
    /*
     * protected void btnWomen1_Click(object sender, EventArgs e)
     * {
     *  string sProductGUID = "f6d3b994-d5ca-491f-b55a-f22fa8974b25";
     *
     *  productGUID = new Guid(sProductGUID);
     *  try
     *  {
     *      product = ProductController.GetProductDeepByGUID(productGUID);
     *      //make sure we have a product
     *      TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");
     *
     *      //set the page variables
     *      productID = product.ProductID;
     *      productSku = product.Sku;
     *      product.Quantity = 1;
     *      OrderController.AddItem(product);
     *      AddKeyForOrderMotion();
     *      //This behavior is by design
     *      //See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpresponseclassendtopic.asp
     *      Response.Redirect("additemresult.aspx", false);
     *      //Response.Redirect("order.aspx", false); KPL
     *
     *  }
     *  catch (Exception ex)
     *  {
     *      LovRubLogger.LogException(ex); // 04/10/08 KPL added
     *      throw ex;
     *      //ExceptionPolicy.HandleException(ex, "Application Exception");
     *      //Response.Redirect(Page.ResolveUrl("~/ExceptionPage.aspx"), false);
     *  }
     * }
     *
     * protected void btnWomen2_Click(object sender, EventArgs e)
     * {
     *  string sProductGUID = "f6d3b994-d5ca-491f-b55a-f22fa8974b25";
     *
     *  productGUID = new Guid(sProductGUID);
     *  try
     *  {
     *      product = ProductController.GetProductDeepByGUID(productGUID);
     *      //make sure we have a product
     *      TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");
     *
     *      //set the page variables
     *      productID = product.ProductID;
     *      productSku = product.Sku;
     *      product.Quantity = 2;
     *      OrderController.AddItem(product);
     *      AddKeyForOrderMotion();
     *      //This behavior is by design
     *      //See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpresponseclassendtopic.asp
     *      Response.Redirect("additemresult.aspx", false);
     *      //Response.Redirect("order.aspx", false); KPL
     *
     *  }
     *  catch (Exception ex)
     *  {
     *      LovRubLogger.LogException(ex); // 04/10/08 KPL added
     *      throw ex;
     *      //ExceptionPolicy.HandleException(ex, "Application Exception");
     *      //Response.Redirect(Page.ResolveUrl("~/ExceptionPage.aspx"), false);
     *  }
     * }
     * protected void btnWomen3_Click(object sender, EventArgs e)
     * {
     *  string sProductGUID = "f6d3b994-d5ca-491f-b55a-f22fa8974b25";
     *
     *  productGUID = new Guid(sProductGUID);
     *  try
     *  {
     *      product = ProductController.GetProductDeepByGUID(productGUID);
     *      //make sure we have a product
     *      TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");
     *
     *      //set the page variables
     *      productID = product.ProductID;
     *      productSku = product.Sku;
     *      product.Quantity = 3;
     *      OrderController.AddItem(product);
     *      AddKeyForOrderMotion();
     *      //This behavior is by design
     *      //See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpresponseclassendtopic.asp
     *      Response.Redirect("Additemresult.aspx", false);
     *      //Response.Redirect("order.aspx", false); KPL
     *
     *  }
     *  catch (Exception ex)
     *  {
     *      LovRubLogger.LogException(ex); // 04/10/08 KPL added
     *      throw ex;
     *      //ExceptionPolicy.HandleException(ex, "Application Exception");
     *      //Response.Redirect(Page.ResolveUrl("~/ExceptionPage.aspx"), false);
     *  }
     * }
     */


    /**************************************************************
     *  //protected void btnMen2_Click(object sender, ImageClickEventArgs e)
     *  protected void btnMen2_Click(object sender, EventArgs e)
     *  {
     *      string sProductGUID = "a3ba18d1-b7d0-488c-9687-706873e0ee53";
     *      productGUID = new Guid(sProductGUID);
     *      try
     *      {
     *          product = ProductController.GetProductDeepByGUID(productGUID);
     *          //make sure we have a product
     *          TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");
     *
     *          //set the page variables
     *          productID = product.ProductID;
     *          productSku = product.Sku;
     *          product.Quantity = 2;
     *          OrderController.AddItem(product);
     *          AddKeyForOrderMotion();
     *
     *          //This behavior is by design
     *          //See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpresponseclassendtopic.asp
     *          Response.Redirect("additemresult.aspx", false);
     *          //Response.Redirect("order.aspx", false); KPL
     *
     *      }
     *      catch (Exception ex)
     *      {
     *          LovRubLogger.LogException(ex); // 04/10/08 KPL added
     *          throw ex;
     *      }
     *  }
     *
     *  protected void btnMen1_Click(object sender, EventArgs e)
     *  //protected void btnMen1_Click(object sender, ImageClickEventArgs e)
     *  {
     *      string sProductGUID = "a3ba18d1-b7d0-488c-9687-706873e0ee53";
     *      productGUID = new Guid(sProductGUID);
     *      try
     *      {
     *          product = ProductController.GetProductDeepByGUID(productGUID);
     *          //make sure we have a product
     *          TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");
     *
     *          //set the page variables
     *          productID = product.ProductID;
     *          productSku = product.Sku;
     *          product.Quantity = 1;
     *          OrderController.AddItem(product);
     *          AddKeyForOrderMotion();
     *          //This behavior is by design
     *          //See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpresponseclassendtopic.asp
     *          Response.Redirect("additemresult.aspx", false);
     *          //Response.Redirect("order.aspx", false); KPL
     *
     *      }
     *      catch (Exception ex)
     *      {
     *          LovRubLogger.LogException(ex); // 04/10/08 KPL added
     *          throw ex;
     *          //ExceptionPolicy.HandleException(ex, "Application Exception");
     *          //Response.Redirect(Page.ResolveUrl("~/ExceptionPage.aspx"), false);
     *      }
     *  }
     *
     *
     * protected void btnMen3_Click(object sender, EventArgs e)
     * {
     *  string sProductGUID = "a3ba18d1-b7d0-488c-9687-706873e0ee53";
     *  productGUID = new Guid(sProductGUID);
     *  try
     *  {
     *      product = ProductController.GetProductDeepByGUID(productGUID);
     *      //make sure we have a product
     *      TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");
     *
     *      //set the page variables
     *      productID = product.ProductID;
     *      productSku = product.Sku;
     *      product.Quantity = 3;
     *      OrderController.AddItem(product);
     *      AddKeyForOrderMotion();
     *      //This behavior is by design
     *      //See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpresponseclassendtopic.asp
     *      Response.Redirect("additemresult.aspx", false);
     *      //Response.Redirect("order.aspx", false); KPL
     *
     *  }
     *  catch (Exception ex)
     *  {
     *      LovRubLogger.LogException(ex); // 04/10/08 KPL added
     *      throw ex;
     *  }
     * }
     *
     * //protected void btnWomen1_Click(object sender, ImageClickEventArgs e)
     * protected void btnWomen1_Click(object sender, EventArgs e)
     * {
     *  string sProductGUID = "f6d3b994-d5ca-491f-b55a-f22fa8974b25";
     *
     *  productGUID = new Guid(sProductGUID);
     *  try
     *  {
     *      product = ProductController.GetProductDeepByGUID(productGUID);
     *      //make sure we have a product
     *      TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");
     *
     *      //set the page variables
     *      productID = product.ProductID;
     *      productSku = product.Sku;
     *      product.Quantity = 1;
     *      OrderController.AddItem(product);
     *      AddKeyForOrderMotion();
     *      //This behavior is by design
     *      //See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpresponseclassendtopic.asp
     *      Response.Redirect("additemresult.aspx", false);
     *      //Response.Redirect("order.aspx", false); KPL
     *
     *  }
     *  catch (Exception ex)
     *  {
     *      LovRubLogger.LogException(ex); // 04/10/08 KPL added
     *      throw ex;
     *      //ExceptionPolicy.HandleException(ex, "Application Exception");
     *      //Response.Redirect(Page.ResolveUrl("~/ExceptionPage.aspx"), false);
     *  }
     * }
     *
     * protected void btnWomen2_Click(object sender, EventArgs e)
     * //protected void btnWomen2_Click(object sender, ImageClickEventArgs e)
     * {
     *  string sProductGUID = "f6d3b994-d5ca-491f-b55a-f22fa8974b25";
     *
     *  productGUID = new Guid(sProductGUID);
     *  try
     *  {
     *      product = ProductController.GetProductDeepByGUID(productGUID);
     *      //make sure we have a product
     *      TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");
     *
     *      //set the page variables
     *      productID = product.ProductID;
     *      productSku = product.Sku;
     *      product.Quantity = 2;
     *      OrderController.AddItem(product);
     *      AddKeyForOrderMotion();
     *      //This behavior is by design
     *      //See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpresponseclassendtopic.asp
     *      Response.Redirect("additemresult.aspx", false);
     *      //Response.Redirect("order.aspx", false); KPL
     *
     *  }
     *  catch (Exception ex)
     *  {
     *      LovRubLogger.LogException(ex); // 04/10/08 KPL added
     *      throw ex;
     *      //ExceptionPolicy.HandleException(ex, "Application Exception");
     *      //Response.Redirect(Page.ResolveUrl("~/ExceptionPage.aspx"), false);
     *  }
     * }
     * protected void btnWomen3_Click(object sender, EventArgs e)
     * {
     *  string sProductGUID = "f6d3b994-d5ca-491f-b55a-f22fa8974b25";
     *
     *  productGUID = new Guid(sProductGUID);
     *  try
     *  {
     *      product = ProductController.GetProductDeepByGUID(productGUID);
     *      //make sure we have a product
     *      TestCondition.IsTrue(product.IsLoaded, "Invalid url/product id");
     *
     *      //set the page variables
     *      productID = product.ProductID;
     *      productSku = product.Sku;
     *      product.Quantity = 3;
     *      OrderController.AddItem(product);
     *      AddKeyForOrderMotion();
     *      //This behavior is by design
     *      //See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpresponseclassendtopic.asp
     *      Response.Redirect("Additemresult.aspx", false);
     *      //Response.Redirect("order.aspx", false); KPL
     *
     *  }
     *  catch (Exception ex)
     *  {
     *      LovRubLogger.LogException(ex); // 04/10/08 KPL added
     *      throw ex;
     *      //ExceptionPolicy.HandleException(ex, "Application Exception");
     *      //Response.Redirect(Page.ResolveUrl("~/ExceptionPage.aspx"), false);
     *  }
     * }
     *
     *********************************************************************/

    public void AddKeyForOrderMotion()
    {
        // should only add one note. so check for existing note before adding new one.

        // Add keycode for OrderMotion
        Order currentOrder = OrderController.GetCurrentOrder();

        OrderController.AddNote("WEB", currentOrder);

        // get keycode
        OrderNoteCollection noteCollection = currentOrder.Notes;
        int nCount = noteCollection.Count;

        if (nCount > 0)
        {
            OrderNote note = noteCollection[0];
            String    sk   = note.Note;
        }
    }
Пример #4
0
    protected void Submit_Click(object sender, EventArgs e)
    {
        string sMaleProductGUID   = "a3ba18d1-b7d0-488c-9687-706873e0ee53";
        string sFemaleProductGUID = "f6d3b994-d5ca-491f-b55a-f22fa8974b25";
        // Local GUIDs
        //string sMaleDiscountGUID = "63365e35-8bfa-47ec-b83b-b799fc5e7cf5";
        //string sFemaleDiscountGUID = "5977c427-2f44-40e8-bf5f-14e68d6d3e03";
        //string sMassageGelGUID = "698b62ca-0672-49ba-a760-db0729bec0ea";

        // Production GUIDs
        string sMaleDiscountGUID   = "38dbc864-dea2-4b78-a745-2bef70336368";
        string sFemaleDiscountGUID = "5424233a-4d2b-45a3-a9c0-6cf2fab56a22";
        string sMassageGelGUID     = "f7ada596-0385-4314-8b13-bd949d3856f0";

        int  nCounter = 0;
        bool bAlreadyChargedFullPrice = false;

        // Validate input amounts.
        // make sure # of free bottles entered matches calculated value
        if (!ValidateInputQty())
        {
            return;
        }

        if (true == CheckBox1.Checked)
        {
            nFreeBottles = 1;
        }

        //******************************************************
        // Add the ordered items to the cart.
        //******************************************************
        nTotalQty = nMaleQty + nFemaleQty;
        if (1 == nTotalQty)
        {
            // determine if male or female
            // add the 1 Female item to the cart.
            if (nFemaleQty > 0)
            {
                AddToCart(sFemaleProductGUID, nFemaleQty);
            }
            // add the 1 Male item to the cart.
            if (nMaleQty > 0)
            {
                AddToCart(sMaleProductGUID, nMaleQty);
            }
        } //if (1 == nTotalQty)

        /*****************************************
         * if 2 or more items
         *      if nMaleQty > 0
         *          put first Male in using current ID (LRM1)
         *          bAlreadyChargedFullPrice = true;*
         *          nMaleQty--;
         *
         *          while(0 != nMaleQty)
         *              add next item to cart as a new ID (LRMCC1, LRWCC1)
         *              nMaleQty--;
         *
         *      if nFemaleQty > 0
         *          if (!bAlreadyChargeFullPrice)
         *                  put first female in using current ID (LRW1)
         *                  bAlreadyChargedFullPrice = true;*
         *                  nFemaleQty--;
         *
         *          while(0 != nFemaleQty)
         *              add next item to cart as a new ID (LRMCC1, LRWCC1)
         *              nFemaleQty--;
         *      if nFreeBottle
         *          add RubLov Massage Gel into cart (DFDF).
         *
         ****************************************/
        if (nTotalQty >= 2)
        {
            if (nMaleQty > 0)
            {
                nCounter = nMaleQty;
                //put first Male in using current ID (LRM1)
                AddToCart(sMaleProductGUID, 1);
                bAlreadyChargedFullPrice = true;
                nCounter--;
                if (0 != nCounter)
                {
                    //add next Male items to cart at Discounted Price (LRMCC1, LRWCC1)
                    AddToCart(sMaleDiscountGUID, nCounter);
                }
            }
            if (nFemaleQty > 0)
            {
                nCounter = nFemaleQty;
                if (false == bAlreadyChargedFullPrice)
                {
                    //put first Female in using current ID (LRW1)
                    AddToCart(sFemaleProductGUID, 1);
                    bAlreadyChargedFullPrice = true;
                    nCounter--;
                }
                if (0 != nCounter)
                {
                    //add rest of female items at Discounted Price (LRMCC1, LRWCC1)
                    AddToCart(sFemaleDiscountGUID, nCounter);
                }
            }

            if (1 == nFreeBottles)
            {
                AddToCart(sMassageGelGUID, 1);
            }
        }

        // Add keycode for OrderMotion
        // but only add one note, so check to see if the keycode note has already been added.
        bool bIsCallCtrOrder = false;

        currentOrder = OrderController.GetCurrentOrder();
        OrderNoteCollection noteCollection = currentOrder.Notes;
        int nCount = noteCollection.Count;

        for (int nIndex = 0; nCount > nIndex; nIndex++)
        {
            OrderNote note = noteCollection[nIndex];
            if (!note.Equals("CALLCENTER"))
            {
                bIsCallCtrOrder = true;
                break;
            }
        }
        if (false == bIsCallCtrOrder)
        {
            OrderController.AddNote("CALLCENTER", currentOrder);
        }

        // redirect to 'CCBasket.aspx'
        if ((nMaleQty > 0) || (nFemaleQty > 0))
        {
            Response.Redirect("CCBasket.aspx", false);
        }
    }