Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _InputFieldId = AlwaysConvert.ToInt(Request.QueryString["InputFieldId"]);
     _InputField   = InputFieldDataSource.Load(_InputFieldId);
     if (_InputField == null)
     {
         Response.Redirect("Default.aspx");
     }
     trUseShopBy.Visible = _InputField.IsMerchantField;
     if (!Page.IsPostBack)
     {
         UseShopBy.Checked = _InputField.UseShopBy;
         BindInputTypes();
         //set initial values
         Name.Text = _InputField.Name;
         if (!_InputField.IsMerchantField)
         {
             Required.Checked = _InputField.IsRequired;
         }
         UserPrompt.Text = _InputField.UserPrompt;
         if (_InputField.Columns > 0)
         {
             Columns.Text = _InputField.Columns.ToString();
         }
         if (_InputField.Rows > 0)
         {
             Rows.Text = _InputField.Rows.ToString();
         }
         if (_InputField.MaxLength > 0)
         {
             MaxLength.Text = _InputField.MaxLength.ToString();
         }
         //BIND CHOICE GRID
         BindChoicesGrid();
         //update visible _InputFields
         UpdateVisibleElements();
     }
 }
Ejemplo n.º 2
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);
            }
        }
 protected void FieldGrid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "MoveUp")
     {
         IList <InputField> inputFields;
         if (((GridView)sender).ID == "MerchantFieldGrid")
         {
             inputFields = InputFieldDataSource.LoadForProductTemplate(_ProductTemplateId, InputFieldScope.Merchant);
         }
         else
         {
             inputFields = InputFieldDataSource.LoadForProductTemplate(_ProductTemplateId, InputFieldScope.Customer);
         }
         int itemIndex = AlwaysConvert.ToInt(e.CommandArgument);
         if ((itemIndex < 1) || (itemIndex > inputFields.Count - 1))
         {
             return;
         }
         InputField selectedItem = inputFields[itemIndex];
         InputField swapItem     = inputFields[itemIndex - 1];
         inputFields.RemoveAt(itemIndex - 1);
         inputFields.Insert(itemIndex, swapItem);
         for (int i = 0; i < inputFields.Count; i++)
         {
             inputFields[i].OrderBy = (short)i;
         }
         inputFields.Save();
     }
     else if (e.CommandName == "MoveDown")
     {
         IList <InputField> inputFields;
         if (((GridView)sender).ID == "MerchantFieldGrid")
         {
             inputFields = InputFieldDataSource.LoadForProductTemplate(_ProductTemplateId, InputFieldScope.Merchant);
         }
         else
         {
             inputFields = InputFieldDataSource.LoadForProductTemplate(_ProductTemplateId, InputFieldScope.Customer);
         }
         int itemIndex = AlwaysConvert.ToInt(e.CommandArgument);
         if ((itemIndex > inputFields.Count - 2) || (itemIndex < 0))
         {
             return;
         }
         InputField selectedItem = inputFields[itemIndex];
         InputField swapItem     = inputFields[itemIndex + 1];
         inputFields.RemoveAt(itemIndex + 1);
         inputFields.Insert(itemIndex, swapItem);
         for (int i = 0; i < inputFields.Count; i++)
         {
             inputFields[i].OrderBy = (short)i;
         }
         inputFields.Save();
     }
     else if (e.CommandName == "Copy")
     {
         int        inputFieldId = AlwaysConvert.ToInt(e.CommandArgument);
         InputField copy         = InputField.Copy(inputFieldId, true);
         if (copy != null)
         {
             // THE NAME SHOULD NOT EXCEED THE MAX 100 CHARS
             String newName = "Copy of " + copy.Name;
             if (newName.Length > 100)
             {
                 newName = newName.Substring(0, 97) + "...";
             }
             copy.Name = newName;
             copy.ProductTemplateId = _ProductTemplateId;
             _ProductTemplate.InputFields.Add(copy);
             _ProductTemplate.InputFields.Save();
         }
     }
     ((GridView)sender).DataBind();
 }
Ejemplo n.º 4
0
        public static Basket GetAcBasket(AutoGen.ShoppingCart shoppingcart, bool clearShipNTax)
        {
            TraceContext trace    = WebTrace.GetTraceContext();
            string       traceKey = "GoogleCheckout.AC.AcHelper";

            trace.Write(traceKey, "Begin AcHelper.GetAcBasket");

            int basketId = AcHelper.GetAcBasketId(shoppingcart);

            trace.Write(traceKey, "Look for basket ID " + basketId.ToString());
            Basket basket = BasketDataSource.Load(basketId, false);

            if (basket == null)
            {
                trace.Write(traceKey, "Basket not found. Creating New Basket.");
                basket = new Basket();
            }
            else
            {
                //basket found. check if content hash matches
                string contentHash = GetReportedBasketHash(shoppingcart);
                if (contentHash.Equals(GetAcBasketHash(basket)))
                {
                    //hash matched. basket has not changed.
                    if (clearShipNTax)
                    {
                        ClearShippingAndTaxes(basket);
                    }
                    return(basket);
                }
            }

            trace.Write(traceKey, "Clear existing Basket contents and populate with Google Input.");
            basket.Clear();

            if (shoppingcart.items != null)
            {
                trace.Write(traceKey, "Looping " + shoppingcart.items.Length.ToString() + " items in Google cart");
            }
            foreach (Item thisItem in shoppingcart.items)
            {
                trace.Write(traceKey, "itemName: " + thisItem.itemname);
                BasketItem basketItem = new BasketItem();
                basketItem.Name     = thisItem.itemname;
                basketItem.Quantity = (short)thisItem.quantity;
                basketItem.Price    = thisItem.unitprice.Value;

                XmlNode[] privateNodes = thisItem.merchantprivateitemdata.Any;
                foreach (XmlNode privateNode in privateNodes)
                {
                    trace.Write(traceKey, "privateNode.Name: " + privateNode.Name);
                    switch (privateNode.Name)
                    {
                    case "productId":
                        basketItem.ProductId = AlwaysConvert.ToInt(privateNode.InnerText);
                        break;

                    case "orderItemType":
                        basketItem.OrderItemType = (OrderItemType)AlwaysConvert.ToEnum(typeof(OrderItemType), privateNode.InnerText, OrderItemType.Product, true);
                        break;

                    case "shippable":
                        basketItem.Shippable = (Shippable)AlwaysConvert.ToEnum(typeof(Shippable), privateNode.InnerText, Shippable.Yes, true);
                        break;

                    case "taxCodeId":
                        basketItem.TaxCodeId = AlwaysConvert.ToInt(privateNode.InnerText);
                        break;

                    case "weight":
                        basketItem.Weight = AlwaysConvert.ToDecimal(privateNode.InnerText);
                        break;

                    case "wrapStyleId":
                        basketItem.WrapStyleId = AlwaysConvert.ToInt(privateNode.InnerText);
                        break;

                    case "optionList":
                        basketItem.OptionList = privateNode.InnerText;
                        break;

                    case "giftMessage":
                        basketItem.GiftMessage = privateNode.InnerText;
                        break;

                    case "lineMessage":
                        basketItem.LineMessage = privateNode.InnerText;
                        break;

                    case "lastModifiedDate":
                        basketItem.LastModifiedDate = AlwaysConvert.ToDateTime(privateNode.InnerText, LocaleHelper.LocalNow);
                        break;

                    case "orderBy":
                        basketItem.OrderBy = AlwaysConvert.ToInt16(privateNode.InnerText);
                        break;

                    case "parentItemId":
                        basketItem.ParentItemId = AlwaysConvert.ToInt(privateNode.InnerText);
                        break;

                    case "sku":
                        basketItem.Sku = privateNode.InnerText;
                        break;

                    case "wishlistItemId":
                        basketItem.WishlistItemId = AlwaysConvert.ToInt(privateNode.InnerText);
                        break;

                    case "basketItemKitProducts":
                        List <string> kitList = new List <string>();
                        foreach (XmlNode subNode in privateNode.ChildNodes)
                        {
                            if (subNode.Name.Equals("kitProductId"))
                            {
                                int        kitProductId = AlwaysConvert.ToInt(subNode.InnerText);
                                KitProduct kitProd      = KitProductDataSource.Load(kitProductId);
                                if (kitProd != null)
                                {
                                    kitList.Add(kitProductId.ToString());
                                }
                            }
                        }
                        if (kitList.Count > 0)
                        {
                            basketItem.KitList = string.Join(",", kitList.ToArray());
                        }
                        break;

                    case "inputs":
                        foreach (XmlNode subNode in privateNode.ChildNodes)
                        {
                            if (subNode.Name.Equals("itemInput"))
                            {
                                int inputFieldId = 0;
                                foreach (XmlAttribute attr in subNode.Attributes)
                                {
                                    if (attr.Name.Equals("inputFieldId"))
                                    {
                                        inputFieldId = AlwaysConvert.ToInt(attr.InnerText);
                                        break;
                                    }
                                }
                                InputField inputField = InputFieldDataSource.Load(inputFieldId);
                                if (inputField != null)
                                {
                                    BasketItemInput bInput = new BasketItemInput();
                                    bInput.InputFieldId = inputFieldId;
                                    bInput.InputValue   = subNode.InnerText;
                                    basketItem.Inputs.Add(bInput);
                                }
                            }
                        }
                        break;

                    case "couponCode":
                        basketItem.Sku = privateNode.InnerText;
                        break;
                    }
                }
                basket.Items.Add(basketItem);
            }
            trace.Write(traceKey, "Saving basket");
            basket.Save();

            string key = "Basket_" + basket.BasketId.ToString();

            ContextCache.SetObject(key, basket);

            trace.Write(traceKey, "Basket created, returning to caller (End GetAcBasket)");
            return(basket);
        }