예제 #1
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            //BUILD SCRIPT TO HANDLE CLIENT CLICK EVENT
            StringBuilder clickScript = new StringBuilder();

            clickScript.Append("\n");
            clickScript.Append("<script type=\"text/javascript\">\n");
            clickScript.Append("    function OptionPickerClick(e, name)\n");
            clickScript.Append("    {\n");
            clickScript.Append("        var td = (e.target) ? e.target : e.srcElement; \n");
            clickScript.Append("        var optid = td.style.zIndex;\n");
            clickScript.Append("        document.getElementById(name).value = td.style.zIndex;\n");
            clickScript.Append("        var t = document.getElementById(name + 'Text')\n");
            clickScript.Append("        if (t.innerText != undefined) { t.innerText = td.title }\n");
            clickScript.Append("        else {t.textContent = td.title}\n");
            clickScript.Append("        var images = eval(name + '_Images');\n");
            clickScript.Append("        if ((images != undefined) && (images[optid] != undefined)) {\n");
            clickScript.Append("            var pImage = document.getElementById('ProductImage');\n");
            clickScript.Append("            if (pImage != undefined) pImage.src = images[optid];\n");
            clickScript.Append("        }\n");
            clickScript.Append("    }\n");
            clickScript.Append("</script>\n");

            //CREATE VARIABLES TO STORE IMAGE ARRAY
            StringBuilder imageScript = new StringBuilder();

            imageScript.Append("<script type=\"text/javascript\">\n");
            imageScript.Append("    " + this.ClientID + "_Images = new Array();\n");

            _Option = OptionDataSource.Load(this.OptionId);
            if (_Option != null)
            {
                //CHECK FOR LARGER IMAGES
                foreach (OptionChoice choice in _Option.Choices)
                {
                    if (!string.IsNullOrEmpty(choice.ImageUrl))
                    {
                        imageScript.Append("    " + this.ClientID + "_Images[" + choice.OptionChoiceId.ToString() + "] = '" + this.Page.ResolveUrl(choice.ImageUrl) + "';\n");
                    }
                }
            }
            imageScript.Append("</script>\n");

            //TRY TO GET SCRIPT MANAGER FOR CURRENT PAGE
            ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);

            //ADD SCRIPTS TO PAGE
            if (scriptManager != null)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "OptionPickerClick", clickScript.ToString(), false);
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), this.ClientID, imageScript.ToString(), false);
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OptionPickerClick", clickScript.ToString());
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), this.ClientID, imageScript.ToString());
            }
        }
예제 #2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            int  optionId      = AlwaysConvert.ToInt(Request.QueryString["OptionId"]);
            bool showthumbnail = Convert.ToBoolean(Request.QueryString["ShowThumbnail"]);

            _Option = OptionDataSource.Load(optionId);
            if (_Option == null)
            {
                Response.Redirect("Options.aspx?ProductId=" + AbleCommerce.Code.PageHelper.GetProductId());
            }

            if (!Page.IsPostBack)
            {
                BindChoicesGrid();
            }

            if (showthumbnail)
            {
                AddChoiceThumbnailRequried.Enabled = showthumbnail;
            }

            Caption.Text = string.Format(Caption.Text, _Option.Name);
            AbleCommerce.Code.PageHelper.SetPickImageButton(AddChoiceThumbnail, BrowseThumbnail);
            AbleCommerce.Code.PageHelper.SetPickImageButton(AddChoiceImage, BrowseImage);
        }
예제 #3
0
 protected void OptionsGrid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "MoveUp" || e.CommandName == "MoveDown" || e.CommandName == "DoDelete")
     {
         int optionId = AlwaysConvert.ToInt(e.CommandArgument);
         IList <ProductOption> prodOpts = _Product.ProductOptions;
         Option        option           = OptionDataSource.Load(optionId);
         ProductOption porductOption    = ProductOptionDataSource.Load(_Product, option);
         int           itemIndex        = prodOpts.IndexOf(porductOption);
         ProductOption selectedItem;
         if (e.CommandName == "MoveUp")
         {
             if ((itemIndex < 1) || (itemIndex > (prodOpts.Count - 1)))
             {
                 return;
             }
             selectedItem              = prodOpts[itemIndex];
             prodOpts[itemIndex]       = prodOpts[(itemIndex - 1)];
             prodOpts[(itemIndex - 1)] = selectedItem;
         }
         else if (e.CommandName == "MoveDown")
         {
             if ((itemIndex > (prodOpts.Count - 2)) || (itemIndex < 0))
             {
                 return;
             }
             selectedItem              = prodOpts[itemIndex];
             prodOpts[itemIndex]       = prodOpts[(itemIndex + 1)];
             prodOpts[(itemIndex + 1)] = selectedItem;
         }
         else if (e.CommandName == "DoDelete")
         {
             //DELETE THE PRODUCT - OPTION ASSOCIATION
             if (itemIndex >= 0)
             {
                 prodOpts.DeleteAt(itemIndex);
             }
         }
         //UPDATE THE DISPLAY ORDER
         for (short i = 0; i < prodOpts.Count; i++)
         {
             prodOpts[i].OrderBy = i;
         }
         prodOpts.Save();
         _Options = _Product.GetOptions();
         _Product.Save();
         DoAdjustVariants();
         BindOptionsGrid();
     }
 }
예제 #4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            int optionId = AlwaysConvert.ToInt(Request.QueryString["OptionId"]);

            _Option = OptionDataSource.Load(optionId);
            if (_Option == null)
            {
                Response.Redirect("Options.aspx?ProductId=" + AbleCommerce.Code.PageHelper.GetProductId());
            }
            if (!Page.IsPostBack)
            {
                // initialize the form on first visit
                OptionName.Text        = _Option.Name;
                HeaderText.Text        = _Option.HeaderText;
                ShowThumbnails.Checked = _Option.ShowThumbnails;
                ThumbnailWidth.Text    = _Option.ThumbnailWidth > 0 ? _Option.ThumbnailWidth.ToString() : string.Empty;
                ThumbnailHeight.Text   = _Option.ThumbnailHeight > 0 ? _Option.ThumbnailHeight.ToString() : string.Empty;
                ThumbnailColumns.Text  = _Option.ThumbnailColumns > 0 ? _Option.ThumbnailColumns.ToString() : string.Empty;
            }
        }
예제 #5
0
        /// <summary>
        /// Determines the product context for the current request.
        /// </summary>
        /// <returns>The product context for the current request.</returns>
        public static int GetProductId()
        {
            HttpRequest request = HttpContext.Current.Request;
            //CHECK FOR PRODUCT
            int productId = AlwaysConvert.ToInt(request.QueryString["ProductId"]);

            if (productId != 0)
            {
                return(productId);
            }
            //CHECK FOR PRODUCT ATTRIBUTE
            int optionId = AlwaysConvert.ToInt(request.QueryString["OptionId"]);

            if (optionId != 0)
            {
                //DETERMINE PRODUCT ID FROM ATTRIBUTE
                Option option = OptionDataSource.Load(optionId);
                if ((option != null) && (option.ProductOptions.Count > 0))
                {
                    return(option.ProductOptions[0].ProductId);
                }
            }

            // CHECK FOR SUBSCRIPTION ID
            int subscriptionId = AlwaysConvert.ToInt(request.QueryString["SubscriptionId"]);

            if (subscriptionId != 0)
            {
                Subscription subscription = SubscriptionDataSource.Load(subscriptionId);
                if (subscription != null)
                {
                    return(subscription.ProductId);
                }
            }
            //RETURN 0, PRODUCT COULD NOT BE DETERMINED
            return(0);
        }
예제 #6
0
        private void ProcessRules(BreadCrumbItem breadCrumbItem)
        {
            int id;

            if (breadCrumbItem.Url == "#")
            {
                return;
            }
            switch (breadCrumbItem.Url.ToLowerInvariant())
            {
            case "~/admin/orders/shipments/editshipment.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["OrderShipmentId"]);
                breadCrumbItem.Url  += "?OrderShipmentId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, id);
                break;

            case "~/admin/products/editproduct.aspx":
            case "~/admin/products/variants/variants.aspx":
            case "~/admin/products/variants/options.aspx":
            case "~/admin/products/digitalgoods/digitalgoods.aspx":
            case "~/admin/products/kits/editkit.aspx":
            case "~/admin/products/assets/images.aspx":
            case "~/admin/products/editproducttemplate.aspx":
            case "~/admin/products/specials/default.aspx":
                int categoryId = AbleCommerce.Code.PageHelper.GetCategoryId();
                id = AbleCommerce.Code.PageHelper.GetProductId();
                Product product = ProductDataSource.Load(id);
                if (categoryId > 0)
                {
                    breadCrumbItem.Url += "?CategoryId=" + categoryId + "&ProductId=" + id;
                }
                else
                {
                    breadCrumbItem.Url += "?ProductId=" + id;
                }
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, product.Name);
                break;

            case "~/admin/orders/vieworder.aspx":
            case "~/admin/orders/edit/editorderitems.aspx":
            case "~/admin/orders/viewdigitalgoods.aspx":
            case "~/admin/orders/payments/default.aspx":
            case "~/admin/orders/shipments/default.aspx":
                id = AbleCommerce.Code.PageHelper.GetOrderId();
                Order order = OrderDataSource.Load(id);
                breadCrumbItem.Url  += "?OrderNumber=" + order.OrderNumber;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, order.OrderNumber);
                break;

            case "~/admin/marketing/coupons/editcoupon.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["CouponId"]);
                Coupon coupon = CouponDataSource.Load(id);
                breadCrumbItem.Url  += "?CouponId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, coupon.Name);
                break;

            case "~/admin/products/variants/editoption.aspx":
            case "~/admin/products/variants/editchoices.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["OptionId"]);
                Option option = OptionDataSource.Load(id);
                breadCrumbItem.Url  += "?OptionId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, option.Name);
                break;

            case "~/admin/products/giftwrap/editwrapgroup.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["WrapGroupId"]);
                WrapGroup wrapGroup = WrapGroupDataSource.Load(id);
                breadCrumbItem.Url  += "?WrapGroupId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, wrapGroup.Name);
                break;

            case "~/admin/marketing/email/managelist.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["EmailListId"]);
                EmailList emailList = EmailListDataSource.Load(id);
                if (emailList != null)
                {
                    breadCrumbItem.Url  += "?EmailListId=" + id;
                    breadCrumbItem.Title = string.Format(breadCrumbItem.Title, emailList.Name);
                }
                break;

            case "~/admin/marketing/discounts/editdiscount.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["VolumeDiscountId"]);
                VolumeDiscount discount = VolumeDiscountDataSource.Load(id);
                breadCrumbItem.Url  += "?VolumeDiscountId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, discount.Name);
                break;

            case "~/admin/catalog/editwebpage.aspx":
                id = AbleCommerce.Code.PageHelper.GetWebpageId();
                Webpage webpage = WebpageDataSource.Load(id);
                breadCrumbItem.Url  += "?WebpageId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, webpage.Name);
                break;

            case "~/admin/catalog/editLink.aspx":
                id = AbleCommerce.Code.PageHelper.GetLinkId();
                Link link = LinkDataSource.Load(id);
                breadCrumbItem.Url  += "?LinkId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, link.Name);
                break;

            case "~/admin/people/users/edituser.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["UserId"]);
                User user = UserDataSource.Load(id);
                breadCrumbItem.Url  += "?UserId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, user.UserName);
                break;

            case "~/admin/digitalgoods/editdigitalgood.aspx":
            case "~/admin/digitalgoods/serialkeyproviders/defaultprovider/configure.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["DigitalGoodId"]);
                DigitalGood dg = DigitalGoodDataSource.Load(id);
                if (dg != null)
                {
                    breadCrumbItem.Url  += "?DigitalGoodId=" + id;
                    breadCrumbItem.Title = string.Format(breadCrumbItem.Title, dg.Name);
                }
                break;

            case "~/admin/products/producttemplates/editproducttemplate.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["ProductTemplateId"]);
                ProductTemplate template = ProductTemplateDataSource.Load(id);
                if (template == null)
                {
                    InputField field = InputFieldDataSource.Load(AlwaysConvert.ToInt(Request.QueryString["InputFieldId"]));
                    if (field != null)
                    {
                        template = field.ProductTemplate;
                        id       = template.Id;
                    }
                }
                if (template != null)
                {
                    breadCrumbItem.Url  += "?ProductTemplateId=" + id;
                    breadCrumbItem.Title = string.Format(breadCrumbItem.Title, template.Name);
                }
                else
                {
                }
                break;

            case "~/admin/reports/dailyabandonedbaskets.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["BasketId"]);
                Basket basket = BasketDataSource.Load(id);
                if (basket != null)
                {
                    breadCrumbItem.Url += "?ReportDate=" + basket.User.LastActivityDate.Value.ToShortDateString();
                }
                break;
            }

            // resolve relative urls
            if (breadCrumbItem.Url.StartsWith("~/"))
            {
                breadCrumbItem.Url = Page.ResolveUrl(breadCrumbItem.Url);
            }
        }