Esempio n. 1
0
    /// <summary>
    /// Bind Edit mode fields
    /// </summary>
    public void BindEditData()
    {
        ZNode.Libraries.Admin.PromotionAdmin couponAdmin = new ZNode.Libraries.Admin.PromotionAdmin();
        ZNode.Libraries.DataAccess.Entities.Promotion promotion = couponAdmin.DeepLoadByPromotionId(ItemID);

        if (promotion != null)
        {
            // General Section
            PromotionName.Text = promotion.Name;
            Description.Text = promotion.Description;
            StartDate.Text = promotion.StartDate.ToShortDateString();
            EndDate.Text = promotion.EndDate.ToShortDateString();
            DisplayOrder.Text = promotion.DisplayOrder.ToString();

            // Discount
            Discount.Text = promotion.Discount.ToString();
            DiscountType.SelectedValue = promotion.DiscountTypeIDSource.ClassName.ToString();
            ToggleDiscountValidator();

            if (!string.IsNullOrEmpty(promotion.DiscountTypeIDSource.ClassName))
            {
                if (promotion.ProfileID.HasValue)
                {
                    ddlProfileTypes.SelectedValue = promotion.ProfileID.Value.ToString();
                }

                if (promotion.ProductID.HasValue)
                {
                    txtReqProductId.Text = promotion.ProductID.Value.ToString();
                    txtRequiredProduct.Text = promotion.ProductIDSource.Name;
                }

                if (promotion.PromotionProductID.HasValue)
                {
                    txtPromProductId.Text = promotion.PromotionProductID.Value.ToString();

                    ProductAdmin prodAdmin = new ProductAdmin();
                    txtPromoProduct.Text = prodAdmin.GetProductName(promotion.PromotionProductID.Value);

                    ddlQuantity.SelectedValue = promotion.PromotionProductQty.GetValueOrDefault(1).ToString();

                }

                txtPromProductId.Text = promotion.PromotionProductID.GetValueOrDefault(0).ToString();
                ddlQuantity.SelectedValue = promotion.PromotionProductQty.GetValueOrDefault(0).ToString();
                ddlMinimumQty.SelectedValue = promotion.QuantityMinimum.GetValueOrDefault(1).ToString();

                // Coupon Info
                chkCouponInd.Checked = promotion.CouponInd;
                if (chkCouponInd.Checked)
                    pnlCouponInfo.Visible = true;

                CouponCode.Text = promotion.CouponCode;
                txtPromotionMessage.Text = promotion.PromotionMessage;

                if (promotion.CouponQuantityAvailable.HasValue)
                    Quantity.Text = promotion.CouponQuantityAvailable.Value.ToString();
                if (promotion.OrderMinimum.HasValue)
                    OrderMinimum.Text = promotion.OrderMinimum.Value.ToString("N2");

                // Set page Title
                lblTitle.Text += promotion.Name;
            }
            else
            {

            }
        }
    }