Example #1
0
    /// <summary>
    /// Delete Button click Event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        ZNode.Libraries.Admin.PromotionAdmin PromotionAdmin = new ZNode.Libraries.Admin.PromotionAdmin();

        bool check = false;

        check = PromotionAdmin.DeletePromotion(ItemID);

        if (check)
        {
            //Replace the Promtion Cache application object with new active promotions
            HttpContext.Current.Application["PromotionCache"] = PromotionAdmin.GetActivePromotions();

            Response.Redirect(RedirectLink);
        }
        else
        {
            lblErrorMsg.Text = "Delete action could not be completed. Please try again.";
            lblErrorMsg.Visible = true;
        }
    }
Example #2
0
    /// <summary>
    /// Submit Button Click event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ProductAdmin prodAdmin = new ProductAdmin();
        PromotionAdmin promotionAdmin = new ZNode.Libraries.Admin.PromotionAdmin();
        ZNode.Libraries.DataAccess.Entities.Promotion promotionEnity = null;

        if (ItemID > 0)
        {
            promotionEnity = promotionAdmin.GetByPromotionId(ItemID);
        }
        else
        {
            promotionEnity = new ZNode.Libraries.DataAccess.Entities.Promotion();
        }

        // set properties
        promotionEnity.ProductID = null;
        promotionEnity.SKUID = null;
        promotionEnity.AddOnValueID = null;
        promotionEnity.AccountID = null;

        // General Info section properties
        promotionEnity.Name = PromotionName.Text.Trim();
        promotionEnity.Description = Description.Text.Trim();
        promotionEnity.StartDate = Convert.ToDateTime(StartDate.Text.Trim());
        promotionEnity.EndDate = Convert.ToDateTime(EndDate.Text.Trim());
        promotionEnity.DisplayOrder = int.Parse(DisplayOrder.Text.Trim());

        // DiscountType
        if (DiscountType.SelectedIndex != -1)
        {
            promotionEnity.DiscountTypeID = promotionAdmin.GetDiscountTypeId(DiscountType.SelectedItem.Text, DiscountType.SelectedValue);
        }

        decimal decDiscountAmt = Convert.ToDecimal(Discount.Text);
        promotionEnity.OrderMinimum = Convert.ToDecimal(OrderMinimum.Text);

        string className = DiscountType.SelectedValue;

        // Product Level Promotions
        if (className.Equals("ZNodePromotionPercentOffProduct", StringComparison.OrdinalIgnoreCase)
                    || className.Equals("ZNodePromotionAmountOffProduct", StringComparison.OrdinalIgnoreCase))
        {
            promotionEnity.QuantityMinimum = int.Parse(ddlMinimumQty.SelectedValue);

            if (txtReqProductId.Text != "0")
                promotionEnity.ProductID = int.Parse(txtReqProductId.Text.Trim());
            else
            {
                promotionEnity.ProductID = prodAdmin.GetProductIdByName(txtRequiredProduct.Text.Trim());
            }
        }
        else if (className.Equals("ZNodePromotionPercentXifYPurchased", StringComparison.OrdinalIgnoreCase)
                    || className.Equals("ZNodePromotionAmountOffXifYPurchased", StringComparison.OrdinalIgnoreCase))
        {
            promotionEnity.QuantityMinimum = int.Parse(ddlMinimumQty.SelectedValue);
            promotionEnity.PromotionProductQty = int.Parse(ddlQuantity.SelectedValue);

            if (txtReqProductId.Text != "0")
                promotionEnity.ProductID = int.Parse(txtReqProductId.Text.Trim());
            else
                promotionEnity.ProductID = prodAdmin.GetProductIdByName(txtRequiredProduct.Text.Trim()); ;

            if (txtPromProductId.Text != "0")
                promotionEnity.PromotionProductID = int.Parse(txtPromProductId.Text.Trim());
            else
                promotionEnity.PromotionProductID = prodAdmin.GetProductIdByName(txtPromoProduct.Text.Trim()); ;
        }

        // Set Discount field
        promotionEnity.Discount = Convert.ToDecimal(Discount.Text);

        if (ddlProfileTypes.SelectedValue == "0")
        {
            promotionEnity.ProfileID = null;
        }
        else
        {
            promotionEnity.ProfileID = int.Parse(ddlProfileTypes.SelectedValue);
        }

        // Coupon Info section
        promotionEnity.CouponInd = chkCouponInd.Checked;
        if (chkCouponInd.Checked)
        {
            promotionEnity.CouponCode = CouponCode.Text;
            promotionEnity.CouponQuantityAvailable = int.Parse(Quantity.Text);
            promotionEnity.PromotionMessage = txtPromotionMessage.Text;
        }
        else
        {
            promotionEnity.CouponCode = "";
            promotionEnity.PromotionMessage = "";
        }

        bool check = false;

        if (ItemID > 0)
        {
            check = promotionAdmin.UpdatePromotion(promotionEnity);
        }
        else
        {
            check = promotionAdmin.AddPromotion(promotionEnity);
        }

        if (check)
        {
            // Replace the Promtion Cache application object with new active promotions
            HttpContext.Current.Application["PromotionCache"] = promotionAdmin.GetActivePromotions();

            Response.Redirect("list.aspx");
        }
        else
        {
            lblError.Text = "An error occurred while updating. Please try again.";
        }
    }