示例#1
0
    public string RenderSelectedOptions(string xml)
    {
        if (string.IsNullOrEmpty(xml))
        {
            return(string.Empty);
        }

        var res = new StringBuilder("<div class=\"customoptions\" >");

        IList <EvaluatedCustomOptions> evlist = CustomOptionsService.DeserializeFromXml(xml);

        foreach (EvaluatedCustomOptions evco in evlist)
        {
            res.Append(evco.CustomOptionTitle);
            res.Append(": ");
            res.Append(evco.OptionTitle);
            res.Append(" ");
            if (evco.OptionPriceBc > 0)
            {
                res.Append("+");
                res.Append(CatalogService.GetStringPrice(evco.OptionPriceBc));
            }
            res.Append("<br />");
        }

        res.Append("</div>");

        return(res.ToString());
    }
示例#2
0
    protected void Page_Init(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(Request["productid"]))
        {
            return;
        }
        _controls     = new List <Control>();
        CustomOptions = CustomOptionsService.GetCustomOptionsByProductId(ProductId);
        if (CustomOptions == null || CustomOptions.Count == 0)
        {
            return;
        }


        if (Request["edititem"] != null)
        {
            var shpCart = ShoppingCartService.CurrentShoppingCart;

            int editItem = -1;
            IList <EvaluatedCustomOptions> evlist = null;

            if (int.TryParse(Request["edititem"], out editItem))
            {
                if (shpCart.Count > editItem && editItem >= 0)
                {
                    evlist = shpCart[editItem].EvaluatedCustomOptions;
                }
            }
            GetControls(CustomOptions, evlist);
        }
        else
        {
            GetControls(CustomOptions, null);
        }
    }
示例#3
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     Redirect(string.Format("shoppingcart.aspx?productid={0}&amount={1}&attributesxml={2}",
                            CurrentProduct.ProductId,
                            txtAmount.Value,
                            HttpUtility.UrlEncode(CustomOptionsService.SerializeToXml(productCustomOptions.CustomOptions, productCustomOptions.SelectedOptions))),
              true);
 }
示例#4
0
    public void SaveCustomOption()
    {
        LoadCustomOptions();
        if (_valid)
        {
            CustomOptionsService.SubmitCustomOptionsWithSameProductId(ProductId, _customOptions);
            _customOptions = CustomOptionsService.GetCustomOptionsByProductId(ProductId);
        }

        UpdateCustomOptions();
    }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (offer == null)
            {
                Error404();
                return;
            }

            if (!offer.CanOrderByRequest)
            {
                lblMessage.Text = Resource.Client_OrderByRequest_CantBeOrdered;
                MultiView1.SetActiveView(ViewResult);
                return;
            }

            SetMeta(new MetaInfo(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Client_OrderByRequest)),
                    string.Empty);

            if (!IsPostBack)
            {
                MultiView1.SetActiveView(ViewForm);
                float amount = Request["amount"] != null ? Request["amount"].TryParseFloat(1) : 1;
                txtAmount.Text = amount.ToString();
                if (CustomerContext.CurrentCustomer.RegistredUser)
                {
                    txtName.Text = string.Format("{0} {1}", CustomerContext.CurrentCustomer.FirstName,
                                                 CustomerContext.CurrentCustomer.LastName);
                    txtEmail.Text = CustomerContext.CurrentCustomer.EMail;
                    txtPhone.Text = CustomerContext.CurrentCustomer.Phone;
                }
            }

            IList <EvaluatedCustomOptions> listOptions = null;

            Options = Request["options"].IsNotEmpty() && Request["options"] != "null"
                                                ? HttpUtility.UrlDecode(Request["options"])
                                                : null;
            if (Options.IsNotEmpty())
            {
                try
                {
                    listOptions = CustomOptionsService.DeserializeFromXml(Options);
                }
                catch (Exception)
                {
                    listOptions = null;
                }
            }

            lOptions.Text = OrderService.RenderSelectedOptions(listOptions);

            liCaptcha.Visible = SettingsMain.EnableCaptcha;
        }
示例#6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (ProductId == 0)
     {
         return;
     }
     if (!IsPostBack)
     {
         _customOptions = CustomOptionsService.GetCustomOptionsByProductId(ProductId);
     }
     else
     {
         _customOptions = (List <CustomOption>)(ViewState["CustomOptions"]);
     }
 }
示例#7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        customerGroup        = CustomerSession.CurrentCustomer.CustomerGroup;
        lDemoWarning.Visible = Demo.IsDemoEnabled || Trial.IsTrialEnabled;

        if (!IsPostBack)
        {
            if (Request["productid"].IsNotEmpty())
            {
                int productId = Request["productid"].TryParseInt();
                int amount    = Request["amount"].TryParseInt(1);
                if (productId != 0 && ProductService.IsProductEnabled(productId))
                {
                    IList <EvaluatedCustomOptions> listOptions = null;
                    string selectedOptions = HttpUtility.UrlDecode(Request["AttributesXml"]);
                    try
                    {
                        listOptions = CustomOptionsService.DeserializeFromXml(selectedOptions);
                    }
                    catch (Exception)
                    {
                        listOptions = null;
                    }

                    if (CustomOptionsService.DoesProductHaveRequiredCustomOptions(productId) && listOptions == null)
                    {
                        Response.Redirect(SettingsMain.SiteUrl + UrlService.GetLinkDB(ParamType.Product, productId));
                        return;
                    }

                    ShoppingCartService.AddShoppingCartItem(new ShoppingCartItem
                    {
                        EntityId         = productId,
                        Amount           = amount,
                        ShoppingCartType = ShoppingCartType.ShoppingCart,
                        AttributesXml    = listOptions != null ? selectedOptions : string.Empty,
                        ItemType         = EnumItemType.Product
                    });

                    Response.Redirect("shoppingcart.aspx");
                }
            }

            UpdateBasket();
            SetMeta(new MetaInfo(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Client_ShoppingCart_ShoppingCart)), string.Empty);
        }
        //relatedProducts.ProductIds = ShoppingCartService.CurrentShoppingCart.Where(p => p.ItemType == ShoppingCartItem.EnumItemType.Product).Select(p => p.EntityId).ToList();
    }
示例#8
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (ShoppingCartService.CurrentWishlist.Any(item => item.EntityId == ProductId &&
                                                    item.AttributesXml == CustomOptionsService.SerializeToXml(productCustomOptions.CustomOptions, productCustomOptions.SelectedOptions)))
        {
            lbtnWishlist.Visible    = false;
            alreadyWishList.Visible = true;
        }
        else
        {
            lbtnWishlist.Visible    = true;
            alreadyWishList.Visible = false;
        }

        // Meta info ------------------------------------------------------------------------------------------
        //  tabReviews.HeaderText = Reviews.ReviewsCount;
    }
示例#9
0
    protected void btnAddToBasket_Click(object sender, EventArgs e)
    {
        if (!productCustomOptions.IsValid)
        {
            productCustomOptions.ShowValidation = true;
            return;
        }

        if (IsEditItem)
        {
            var returnUrl = "";
            var item      = ShoppingCartService.GetShoppingCart(ItemType)[ItemIndex];
            item.AttributesXml = CustomOptionsService.SerializeToXml(productCustomOptions.CustomOptions, productCustomOptions.SelectedOptions);

            switch (ItemType)
            {
            case ShoppingCartType.ShoppingCart:
                //item.Amount = Int32.Parse(txtAmount.Text);
                returnUrl = "/shoppingcart.aspx";
                break;

            case ShoppingCartType.Wishlist:
                item.Amount = 1;
                returnUrl   = "/wishlist.aspx";
                break;
            }

            ShoppingCartService.UpdateShoppingCartItem(item);
            Redirect(returnUrl);
        }
        else
        {
            ShoppingCartService.AddShoppingCartItem(new ShoppingCartItem
            {
                EntityId = ProductId,
                //Amount = Convert.ToInt32(txtAmount.Text),
                ShoppingCartType = ShoppingCartType.ShoppingCart,
                AttributesXml    = CustomOptionsService.SerializeToXml(productCustomOptions.CustomOptions, productCustomOptions.SelectedOptions),
                ItemType         = EnumItemType.Product
            });

            Redirect("/shoppingcart.aspx");
        }
    }
示例#10
0
        private static void OtherFields(IDictionary <ProductFields, object> fields, int productId, string columSeparator, string propertySeparator)
        {
            //Category
            if (fields.ContainsKey(ProductFields.Category))
            {
                string sorting = string.Empty;
                if (fields.ContainsKey(ProductFields.Sorting))
                {
                    sorting = fields[ProductFields.Sorting].AsString();
                }
                var parentCategory = fields[ProductFields.Category].AsString();
                CategoryService.SubParseAndCreateCategory(parentCategory, productId, columSeparator, sorting);
            }

            //photo
            if (fields.ContainsKey(ProductFields.Photos))
            {
                string photos = fields[ProductFields.Photos].AsString();
                if (!string.IsNullOrEmpty(photos))
                {
                    PhotoService.PhotoFromString(productId, photos, columSeparator, propertySeparator, _skipOriginalPhoto);
                }
            }

            //video
            if (fields.ContainsKey(ProductFields.Videos))
            {
                string videos = fields[ProductFields.Videos].AsString();
                ProductVideoService.VideoFromString(productId, videos, columSeparator);
            }

            //Properties
            if (fields.ContainsKey(ProductFields.Properties))
            {
                string properties = fields[ProductFields.Properties].AsString();
                PropertyService.PropertiesFromString(productId, properties, columSeparator, propertySeparator);
            }

            if (fields.ContainsKey(ProductFields.CustomOption))
            {
                string customOption = fields[ProductFields.CustomOption].AsString();
                CustomOptionsService.CustomOptionsFromString(productId, customOption);
            }
        }
示例#11
0
        public static void SendConfirmationMessage(int orderByRequestId)
        {
            var orderByRequest = GetOrderByRequest(orderByRequestId);
            var code           = CreateCode(orderByRequestId);

            var offer = OfferService.GetOffer(orderByRequest.OfferId);

            IList <EvaluatedCustomOptions> listOptions = null;
            var selectedOptions = orderByRequest.Options.IsNotEmpty() && orderByRequest.Options != "null"
                                                    ? HttpUtility.UrlDecode(orderByRequest.Options)
                                                    : null;

            if (selectedOptions.IsNotEmpty())
            {
                try
                {
                    listOptions = CustomOptionsService.DeserializeFromXml(selectedOptions);
                }
                catch (Exception)
                {
                    listOptions = null;
                }
            }

            string optionsRender = OrderService.RenderSelectedOptions(listOptions);


            var linkByRequestMailTemplate = new LinkByRequestMailTemplate(orderByRequest.OrderByRequestId.ToString(),
                                                                          orderByRequest.ArtNo,
                                                                          orderByRequest.ProductName + " " + optionsRender,
                                                                          orderByRequest.Quantity.ToString(), code,
                                                                          orderByRequest.UserName,
                                                                          orderByRequest.LetterComment,
                                                                          offer != null && offer.Color != null
                                                                              ? offer.Color.ColorName
                                                                              : "",
                                                                          offer != null && offer.Size != null
                                                                              ? offer.Size.SizeName
                                                                              : "");

            linkByRequestMailTemplate.BuildMail();
            SendMail.SendMailNow(orderByRequest.Email, linkByRequestMailTemplate.Subject, linkByRequestMailTemplate.Body, true);
        }
示例#12
0
    protected void AddToWishList_Click(object sender, EventArgs e)
    {
        if (!productCustomOptions.IsValid)
        {
            productCustomOptions.ShowValidation = true;
            return;
        }

        ShoppingCartService.AddShoppingCartItem(new ShoppingCartItem
        {
            EntityId = ProductId,
            //Amount = Convert.ToInt32(txtAmount.Text),
            ShoppingCartType = ShoppingCartType.Wishlist,
            AttributesXml    = CustomOptionsService.SerializeToXml(productCustomOptions.CustomOptions, productCustomOptions.SelectedOptions)
        });
        lbtnWishlist.Visible    = false;
        alreadyWishList.Visible = true;

        Redirect("wishlist.aspx");
    }
        private void LoadOrder()
        {
            var orderByRequest = OrderByRequestService.GetOrderByRequest(OrderByRequestId);

            IList <EvaluatedCustomOptions> listOptions = null;
            var selectedOptions = orderByRequest.Options.IsNotEmpty() && orderByRequest.Options != "null"
                                                    ? HttpUtility.UrlDecode(orderByRequest.Options)
                                                    : null;

            if (selectedOptions.IsNotEmpty())
            {
                try
                {
                    listOptions = CustomOptionsService.DeserializeFromXml(selectedOptions);
                }
                catch (Exception)
                {
                    listOptions = null;
                }
            }

            string optionsRender = OrderService.RenderSelectedOptions(listOptions);


            lArtNo.Text       = orderByRequest.ArtNo;
            lProductName.Text = orderByRequest.ProductName + optionsRender;

            txtQuantity.Text      = orderByRequest.Quantity.ToString();
            txtUserName.Text      = orderByRequest.UserName;
            txtEmail.Text         = orderByRequest.Email;
            txtPhone.Text         = orderByRequest.Phone;
            txtComment.Text       = orderByRequest.Comment;
            txtLetterComment.Text = orderByRequest.LetterComment;

            chkIsComplete.Checked = orderByRequest.IsComplete;
            lOrderDate.Text       = orderByRequest.RequestDate.ToString();
        }
示例#14
0
    protected void btnBuyProduct_Click(object sender, EventArgs e)
    {
        try
        {
            int productId = 0;
            Int32.TryParse(hiddenProductID.Value, out productId);

            if (CustomOptionsService.DoesProductHaveRequiredCustomOptions(productId))
            {
                Response.Redirect(GetProductLink(ProductItems.First(p => p.ProductId == productId)));
            }


            List <CustomOption> customOptions = CustomOptionsService.GetCustomOptionsByProductId(Convert.ToInt32(productId));
            if ((customOptions != null) && (customOptions.Count != 0))
            {
                Page.Response.Redirect(UrlService.GetLinkDB(ParamType.Product, productId));
            }

            ShoppingCartService.AddShoppingCartItem(new ShoppingCartItem
            {
                EntityId         = productId,
                Amount           = 1,
                ShoppingCartType = ShoppingCartType.ShoppingCart,
                AttributesXml    = string.Empty,
                ItemType         = EnumItemType.Product
            });
        }
        catch (ThreadAbortException) { }
        catch (Exception ex)
        {
            Debug.LogError(ex);
        }

        Page.Response.Redirect(GetAbsoluteLink("/shoppingcart.aspx"), true);
    }
示例#15
0
        private void ShowCreditButtons(bool isMultiOffers)
        {
            var creditPayment = PaymentService.GetCreditPaymentMethods().FirstOrDefault();

            if (creditPayment != null && CurrentOffer != null)
            {
                btnAddCredit.Attributes["data-cart-add-productid"] = ProductId.ToString();
                btnAddCredit.Attributes["data-cart-add-offerid"]   = CurrentOffer.OfferId.ToString();
                btnAddCredit.Attributes["data-cart-payment"]       = creditPayment.PaymentMethodId.ToString();
                btnAddCredit.Attributes["data-cart-minprice"]      = creditPayment.MinimumPrice.ToString();

                var productPrice = CatalogService.CalculateProductPrice(CurrentOffer.Price,
                                                                        CurrentProduct.CalculableDiscount,
                                                                        CustomerContext.CurrentCustomer.CustomerGroup,
                                                                        CustomOptionsService.DeserializeFromXml(
                                                                            CustomOptionsService.SerializeToXml(productCustomOptions.CustomOptions, productCustomOptions.SelectedOptions)));

                var isVisible = productPrice > creditPayment.MinimumPrice && CurrentOffer.Amount > 0;

                ButtonSetVisible(btnAddCredit, isVisible, isMultiOffers);
                ButtonSetVisible(lblFirstPaymentNote, isVisible && creditPayment.MinimumPrice > 0, isMultiOffers);
                ButtonSetVisible(lblFirstPayment, isVisible && creditPayment.MinimumPrice > 0, isMultiOffers);

                hfFirstPaymentPercent.Value = creditPayment.FirstPayment.ToString();

                lblFirstPayment.Text = creditPayment.FirstPayment > 0
                    ? CatalogService.GetStringPrice(productPrice * creditPayment.FirstPayment / 100) + @"*"
                    : string.Format("<div class=\"price\">{0}*</div>", Resource.Client_Details_WithoutFirstPayment);
            }
            else
            {
                ButtonSetVisible(btnAddCredit, false, false);
                ButtonSetVisible(lblFirstPaymentNote, false, false);
                ButtonSetVisible(lblFirstPayment, false, false);
            }
        }
示例#16
0
        private void LoadFirstProduct()
        {
            var columSeparator    = txtColumSeparator.Text;
            var propertySeparator = txtPropertySeparator.Text;

            var product = ProductService.GetFirstProduct();

            if (product == null)
            {
                return;
            }
            foreach (var item in Enum.GetValues(typeof(ProductFields)))
            {
                if ((ProductFields)item == ProductFields.None)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = @"-", Value = ProductFields.None.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Sku)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.ArtNo, Value = ProductFields.Sku.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Name)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Name.HtmlEncode(), Value = ProductFields.Name.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.ParamSynonym)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.UrlPath, Value = ProductFields.ParamSynonym.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Category)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = CategoryService.GetCategoryStringByProductId(product.ProductId, columSeparator), Value = ProductFields.Category.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Sorting)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = CategoryService.GetCategoryStringByProductId(product.ProductId, columSeparator, true), Value = ProductFields.Sorting.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Enabled)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Enabled ? "+" : "-", Value = ProductFields.Enabled.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Price)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Offers.Select(x => x.Price).FirstOrDefault().ToString("F2"), Value = ProductFields.Price.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.PurchasePrice)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Offers.Select(x => x.SupplyPrice).FirstOrDefault().ToString("F2"), Value = ProductFields.PurchasePrice.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Amount)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Offers.Select(x => x.Amount).FirstOrDefault().ToString("F2"), Value = ProductFields.Amount.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.MultiOffer)
                {
                    ddlProduct.Items.Add(new ListItem
                    {
                        Text  = OfferService.OffersToString(product.Offers, columSeparator, propertySeparator),
                        Value = ProductFields.MultiOffer.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Unit)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Unit, Value = ProductFields.Unit.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Discount)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Discount.ToString("F2"), Value = ProductFields.Discount.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.ShippingPrice)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.ShippingPrice.ToString("F2"), Value = ProductFields.ShippingPrice.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Weight)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Weight.ToString("F2"), Value = ProductFields.Weight.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Size)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Size.Replace("|", " x "), Value = ProductFields.Size.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.BriefDescription)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.BriefDescription.Reduce(20).HtmlEncode(), Value = ProductFields.BriefDescription.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Description)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Description.Reduce(20).HtmlEncode(), Value = ProductFields.Description.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Title)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Meta.Title.Reduce(20), Value = ProductFields.Title.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.H1)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Meta.H1.Reduce(20), Value = ProductFields.H1.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.MetaKeywords)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Meta.MetaKeywords.Reduce(20), Value = ProductFields.MetaKeywords.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.MetaDescription)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Meta.MetaDescription.Reduce(20), Value = ProductFields.MetaDescription.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Photos)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = PhotoService.PhotoToString(product.ProductPhotos, columSeparator, propertySeparator), Value = ProductFields.Photos.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Videos)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = ProductVideoService.VideoToString(product.ProductVideos, columSeparator).Reduce(20).HtmlEncode(), Value = ProductFields.Videos.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Markers)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = ProductService.MarkersToString(product, columSeparator), Value = ProductFields.Markers.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Properties)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = PropertyService.PropertiesToString(product.ProductPropertyValues, columSeparator, propertySeparator).HtmlEncode(), Value = ProductFields.Properties.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Producer)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = BrandService.BrandToString(product.BrandId), Value = ProductFields.Producer.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.OrderByRequest)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.AllowPreOrder ? "+" : "-", Value = ProductFields.OrderByRequest.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.SalesNotes)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.SalesNote, Value = ProductFields.SalesNotes.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.Related)
                {
                    ddlProduct.Items.Add(new ListItem(ProductService.LinkedProductToString(product.ProductId, RelatedType.Related, columSeparator), ProductFields.Related.ConvertIntString()));
                }

                if ((ProductFields)item == ProductFields.Alternative)
                {
                    ddlProduct.Items.Add(new ListItem(ProductService.LinkedProductToString(product.ProductId, RelatedType.Alternative, columSeparator), ProductFields.Alternative.ConvertIntString()));
                }

                if ((ProductFields)item == ProductFields.CustomOption)
                {
                    ddlProduct.Items.Add(new ListItem(CustomOptionsService.CustomOptionsToString(CustomOptionsService.GetCustomOptionsByProductId(product.ProductId)), ProductFields.CustomOption.ConvertIntString()));
                }

                if ((ProductFields)item == ProductFields.Gtin)
                {
                    ddlProduct.Items.Add(new ListItem(product.Gtin, ProductFields.Gtin.ConvertIntString()));
                }

                if ((ProductFields)item == ProductFields.GoogleProductCategory)
                {
                    ddlProduct.Items.Add(new ListItem(product.GoogleProductCategory, ProductFields.GoogleProductCategory.ConvertIntString()));
                }

                if ((ProductFields)item == ProductFields.Adult)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.Adult ? "+" : "-", Value = ProductFields.Adult.ConvertIntString()
                    });
                }

                if ((ProductFields)item == ProductFields.ManufacturerWarranty)
                {
                    ddlProduct.Items.Add(new ListItem {
                        Text = product.ManufacturerWarranty ? "+" : "-", Value = ProductFields.ManufacturerWarranty.ConvertIntString()
                    });
                }
            }
        }
示例#17
0
        private void WriteItem(ICsvWriter writer, Product product)
        {
            var meta = MetaInfoService.GetMetaInfo(product.ID, MetaType.Product) ??
                       new MetaInfo(0, 0, MetaType.Product, string.Empty, string.Empty, string.Empty, string.Empty);

            foreach (var item in _fieldMapping)
            {
                if (item == ProductFields.Sku)
                {
                    writer.WriteField(product.ArtNo);
                }
                if (item == ProductFields.Name)
                {
                    writer.WriteField(product.Name);
                }

                if (item == ProductFields.ParamSynonym)
                {
                    writer.WriteField(product.UrlPath);
                }

                if (item == ProductFields.Category)
                {
                    writer.WriteField((CategoryService.GetCategoryStringByProductId(product.ProductId, _columSeparator)));
                }

                if (item == ProductFields.Sorting)
                {
                    writer.WriteField((CategoryService.GetCategoryStringByProductId(product.ProductId, _columSeparator, true)));
                }

                if (item == ProductFields.Enabled)
                {
                    writer.WriteField(product.Enabled ? "+" : "-");
                }

                if (!product.HasMultiOffer)
                {
                    var offer = product.Offers.FirstOrDefault() ?? new Offer();
                    if (item == ProductFields.Price)
                    {
                        writer.WriteField(offer.Price.ToString("F2"));
                    }
                    if (item == ProductFields.PurchasePrice)
                    {
                        writer.WriteField(offer.SupplyPrice.ToString("F2"));
                    }
                    if (item == ProductFields.Amount)
                    {
                        writer.WriteField(offer.Amount.ToString(CultureInfo.InvariantCulture));
                    }

                    if (item == ProductFields.MultiOffer)
                    {
                        writer.WriteField(string.Empty);
                    }
                }
                else
                {
                    if (item == ProductFields.Price)
                    {
                        writer.WriteField(string.Empty);
                    }
                    if (item == ProductFields.PurchasePrice)
                    {
                        writer.WriteField(string.Empty);
                    }
                    if (item == ProductFields.Amount)
                    {
                        writer.WriteField(string.Empty);
                    }
                    if (item == ProductFields.MultiOffer)
                    {
                        writer.WriteField(OfferService.OffersToString(product.Offers, _columSeparator, _propertySeparator));
                    }
                }

                if (item == ProductFields.Unit)
                {
                    writer.WriteField(product.Unit);
                }
                if (item == ProductFields.ShippingPrice)
                {
                    writer.WriteField(product.ShippingPrice.ToString("F2"));
                }
                if (item == ProductFields.Discount)
                {
                    writer.WriteField(product.Discount.ToString("F2"));
                }
                if (item == ProductFields.Weight)
                {
                    writer.WriteField(product.Weight.ToString("F2"));
                }
                if (item == ProductFields.Size)
                {
                    writer.WriteField(product.Size.Replace("|", " x "));
                }

                if (item == ProductFields.BriefDescription)
                {
                    writer.WriteField(product.BriefDescription);
                }
                if (item == ProductFields.Description)
                {
                    writer.WriteField(product.Description);
                }

                if (item == ProductFields.Title)
                {
                    writer.WriteField(meta.Title);
                }
                if (item == ProductFields.H1)
                {
                    writer.WriteField(meta.H1);
                }
                if (item == ProductFields.MetaKeywords)
                {
                    writer.WriteField(meta.MetaKeywords);
                }
                if (item == ProductFields.MetaDescription)
                {
                    writer.WriteField(meta.MetaDescription);
                }
                if (item == ProductFields.Markers)
                {
                    writer.WriteField(ProductService.MarkersToString(product, _columSeparator));
                }
                if (item == ProductFields.Photos)
                {
                    writer.WriteField(PhotoService.PhotoToString(product.ProductPhotos, _columSeparator, _propertySeparator));
                }
                if (item == ProductFields.Videos)
                {
                    writer.WriteField(ProductVideoService.VideoToString(product.ProductVideos, _columSeparator));
                }
                if (item == ProductFields.Properties)
                {
                    writer.WriteField(PropertyService.PropertiesToString(product.ProductPropertyValues, _columSeparator, _propertySeparator));
                }

                if (item == ProductFields.Producer)
                {
                    writer.WriteField(BrandService.BrandToString(product.BrandId));
                }

                if (item == ProductFields.OrderByRequest)
                {
                    writer.WriteField(product.AllowPreOrder ? "+" : "-");
                }

                if (item == ProductFields.SalesNotes)
                {
                    writer.WriteField(product.SalesNote);
                }

                if (item == ProductFields.Related)
                {
                    writer.WriteField(ProductService.LinkedProductToString(product.ProductId, RelatedType.Related, _columSeparator));
                }

                if (item == ProductFields.Alternative)
                {
                    writer.WriteField(ProductService.LinkedProductToString(product.ProductId, RelatedType.Alternative, _columSeparator));
                }

                if (item == ProductFields.CustomOption)
                {
                    writer.WriteField(CustomOptionsService.CustomOptionsToString(CustomOptionsService.GetCustomOptionsByProductId(product.ProductId)));
                }

                if (item == ProductFields.Gtin)
                {
                    writer.WriteField(product.Gtin);
                }

                if (item == ProductFields.GoogleProductCategory)
                {
                    writer.WriteField(product.GoogleProductCategory);
                }

                if (item == ProductFields.Adult)
                {
                    writer.WriteField(product.Adult ? "+" : "-");
                }

                if (item == ProductFields.ManufacturerWarranty)
                {
                    writer.WriteField(product.ManufacturerWarranty ? "+" : "-");
                }
            }
            writer.NextRecord();
        }
示例#18
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            bool boolIsValidPast = true;

            boolIsValidPast &= IsValidText(txtName.Text);
            boolIsValidPast &= IsValidText(txtEmail.Text);
            boolIsValidPast &= IsValidText(txtPhone.Text);

            float quantity = 0;

            if (!float.TryParse(txtAmount.Text, out quantity) || (quantity < 0))
            {
                boolIsValidPast = false;
            }

            if (!ValidationHelper.IsValidEmail(txtEmail.Text.Trim()))
            {
                boolIsValidPast = false;
            }

            if (!CaptchaControl1.IsValid())
            {
                CaptchaControl1.TryNew();
                boolIsValidPast = false;
            }

            if (boolIsValidPast == false)
            {
                CaptchaControl1.TryNew();
                ShowMessage(Notify.NotifyType.Error, Resource.Client_Feedback_WrongData);
                return;
            }

            try
            {
                var orderByRequest = new OrderByRequest
                {
                    OfferId     = offer.OfferId,
                    ProductId   = offer.Product.ID,
                    ProductName = offer.Product.Name,
                    ArtNo       = offer.ArtNo,
                    Quantity    = quantity,
                    UserName    = txtName.Text,
                    Email       = txtEmail.Text,
                    Phone       = txtPhone.Text,
                    Comment     = txtComment.Text,
                    IsComplete  = false,
                    RequestDate = DateTime.Now,
                    Options     = Options
                };

                OrderByRequestService.AddOrderByRequest(orderByRequest);


                IList <EvaluatedCustomOptions> listOptions = null;
                if (Options.IsNotEmpty())
                {
                    try
                    {
                        listOptions = CustomOptionsService.DeserializeFromXml(Options);
                    }
                    catch (Exception)
                    {
                        listOptions = null;
                    }
                }

                var mailTemplate =
                    new OrderByRequestMailTemplate(
                        orderByRequest.OrderByRequestId.ToString(CultureInfo.InvariantCulture), offer.ArtNo,
                        offer.Product.Name + " " + OrderService.RenderSelectedOptions(listOptions),
                        quantity.ToString(CultureInfo.InvariantCulture), txtName.Text, txtEmail.Text, txtPhone.Text,
                        txtComment.Text, offer.Color != null ? offer.Color.ColorName : string.Empty,
                        offer.Size != null ? offer.Size.SizeName : string.Empty);

                mailTemplate.BuildMail();

                SendMail.SendMailNow(txtEmail.Text, mailTemplate.Subject, mailTemplate.Body, true);
                SendMail.SendMailNow(SettingsMail.EmailForOrders, mailTemplate.Subject, mailTemplate.Body, true);

                lblMessage.Text = Resource.Client_Feedback_MessageSent;
                MultiView1.SetActiveView(ViewResult);
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
                ShowMessage(Notify.NotifyType.Error, Resource.Client_Feedback_MessageError);
                MultiView1.SetActiveView(ViewResult);
            }
        }
示例#19
0
    private void ProcessExcel()
    {
        try
        {
            // How much ? ------------------

            int intRootCategories      = 7;
            int intSubCategoriesLevel1 = 7;
            int intSubCategoriesLevel2 = 7;

            int intProductCountForCategory = 150;

            // Internal Variables ------------------

            int intCurrentProductIndex = SQLDataHelper.GetInt(SQLDataAccess.ExecuteScalar("Select MAX(ProductId) + 1 FROM Catalog.Product", CommandType.Text, null));
            // 50000

            int intProductAltId1 = 0;
            int intProductAltId2 = 0;
            int intProductAltId3 = 0;

            int intProductAltId4 = 0;
            int intProductAltId5 = 0;
            int intProductAltId6 = 0;

            string strCategoryName1 = "";
            string strCategoryName2 = "";
            string strCategoryName3 = "";

            string strPropName1 = "";
            string strPropName2 = "";
            string strPropName3 = "";
            string strPropName4 = "";
            string strPropName5 = "";
            string strPropName6 = "";
            string strPropName7 = "";

            int intTempProductId = 0;

            //int i, j, k;

            var rnd = new Random();

            // ---------------

            ImportStatistic.TotalRow = (intRootCategories * intSubCategoriesLevel1 * intSubCategoriesLevel2 * intProductCountForCategory);

            // Step by rows

            for (int i = 0; i <= intRootCategories - 1; i++) // 15
            {
                strCategoryName1 = Strings.GetRandomString(rnd, 25, 6);

                if (!chbSimpleMode.Checked) // Simple Mode
                {
                    strPropName1 = Strings.GetRandomString(rnd, 4);
                    strPropName2 = Strings.GetRandomString(rnd, 7);
                    strPropName3 = Strings.GetRandomString(rnd, 7);
                    strPropName4 = Strings.GetRandomString(rnd, 8);
                    strPropName5 = Strings.GetRandomString(rnd, 8);
                    strPropName6 = Strings.GetRandomString(rnd, 9);
                    strPropName7 = Strings.GetRandomString(rnd, 9);
                }

                for (int j = 0; j <= intSubCategoriesLevel1 - 1; j++) // 15 x 10
                {
                    strCategoryName2 = Strings.GetRandomString(rnd, 25, 5);

                    for (int k = 0; k <= intSubCategoriesLevel2 - 1; k++) // 15 x 10 x 10
                    {
                        strCategoryName3 = Strings.GetRandomString(rnd, 25, 4);

                        for (int p = 0; p <= intProductCountForCategory - 1; p++) // 15 x 10 x 10 x 10
                        {
                            intCurrentProductIndex++;

                            intTempProductId = ProcessProduct(rnd, intCurrentProductIndex);

                            // Category ----------------------------------------------------------------------------------------------

                            string parentCategory = string.Format("[{0} >> {1} >> {2}]", strCategoryName1.Trim(), strCategoryName2.Trim(), strCategoryName3.Trim());
                            CategoryService.SubParseAndCreateCategory(parentCategory, intTempProductId);

                            if (!chbSimpleMode.Checked) // Simple Mode
                            {
                                // Property -----------------------------------------------------------------------------------------------

                                BuildProperties(rnd, intTempProductId, strPropName1, strPropName2, strPropName3, strPropName4, strPropName5, strPropName6, strPropName7);

                                // Images -------------------------------------------------------------------------------------------------

                                var tempId = PhotoService.AddPhoto(new Photo(0, intTempProductId, PhotoType.Product)
                                {
                                    Description = Strings.GetRandomString(rnd, 25, 4)
                                });
                                if (!string.IsNullOrWhiteSpace(tempId))
                                {
                                    CopyProductPic(rnd, tempId);
                                }

                                tempId = PhotoService.AddPhoto(new Photo(0, intTempProductId, PhotoType.Product)
                                {
                                    Description = Strings.GetRandomString(rnd, 25, 4)
                                });
                                if (!string.IsNullOrWhiteSpace(tempId))
                                {
                                    CopyProductPic(rnd, tempId);
                                }

                                tempId = PhotoService.AddPhoto(new Photo(0, intTempProductId, PhotoType.Product)
                                {
                                    Description = Strings.GetRandomString(rnd, 25, 4)
                                });
                                if (!string.IsNullOrWhiteSpace(tempId))
                                {
                                    CopyProductPic(rnd, tempId);
                                }


                                // Alt Products --------------------------------------------------------------------------------------------

                                if (intProductAltId1 != 0)
                                {
                                    ProductService.AddRelatedProduct(intTempProductId, intProductAltId1, RelatedType.Alternative);
                                }

                                if (intProductAltId2 != 0)
                                {
                                    ProductService.AddRelatedProduct(intTempProductId, intProductAltId2, RelatedType.Alternative);
                                }

                                if (intProductAltId3 != 0)
                                {
                                    ProductService.AddRelatedProduct(intTempProductId, intProductAltId3, RelatedType.Alternative);
                                }

                                if (intProductAltId4 != 0)
                                {
                                    ProductService.AddRelatedProduct(intTempProductId, intProductAltId4, RelatedType.Alternative);
                                }

                                if (intProductAltId5 != 0)
                                {
                                    ProductService.AddRelatedProduct(intTempProductId, intProductAltId5, RelatedType.Alternative);
                                }

                                if (intProductAltId6 != 0)
                                {
                                    ProductService.AddRelatedProduct(intTempProductId, intProductAltId6, RelatedType.Alternative);
                                }

                                // And RelatedProduct ---------------------------------------------

                                if (intProductAltId1 != 0)
                                {
                                    ProductService.AddRelatedProduct(intTempProductId, intProductAltId1, RelatedType.Related);
                                }

                                if (intProductAltId2 != 0)
                                {
                                    ProductService.AddRelatedProduct(intTempProductId, intProductAltId2, RelatedType.Related);
                                }

                                if (intProductAltId3 != 0)
                                {
                                    ProductService.AddRelatedProduct(intTempProductId, intProductAltId3, RelatedType.Related);
                                }

                                // And RelatedProduct

                                if (intProductAltId4 != 0)
                                {
                                    ProductService.AddRelatedProduct(intTempProductId, intProductAltId4, RelatedType.Related);
                                }

                                if (intProductAltId5 != 0)
                                {
                                    ProductService.AddRelatedProduct(intTempProductId, intProductAltId5, RelatedType.Related);
                                }

                                if (intProductAltId6 != 0)
                                {
                                    ProductService.AddRelatedProduct(intTempProductId, intProductAltId6, RelatedType.Related);
                                }

                                //intProductAltId1 = intProductAltId2;
                                //intProductAltId2 = intProductAltId3;
                                //intProductAltId3 = intTempProductId;

                                intProductAltId1 = intProductAltId2;
                                intProductAltId2 = intProductAltId3;
                                intProductAltId3 = intProductAltId4;

                                intProductAltId4 = intProductAltId5;
                                intProductAltId5 = intProductAltId6;
                                intProductAltId6 = intTempProductId;

                                // Custom Options --------------------------------------------------------------------------------------------

                                var copt = new CustomOption(true)
                                {
                                    CustomOptionsId = -1, ProductId = intTempProductId
                                };

                                // copt.InputType = CustomOptionInputType.RadioButton;
                                copt.Title = Demo.GetRandomCity();

                                var opt = new OptionItem {
                                    OptionId = -1, PriceBc = 0, SortOrder = 10
                                };
                                opt.Title = Demo.GetRandomName();

                                var opt2 = new OptionItem {
                                    OptionId = -1, PriceBc = DevTool.GetRandomInt(rnd, 0, 100), SortOrder = 20
                                };
                                opt2.Title = Demo.GetRandomLastName();

                                var opt3 = new OptionItem {
                                    OptionId = -1, PriceBc = DevTool.GetRandomInt(rnd, 0, 10), SortOrder = 30
                                };
                                opt3.Title = Demo.GetRandomName();

                                copt.Options = new List <OptionItem> {
                                    opt, opt2, opt3
                                };

                                CustomOptionsService.AddCustomOption(copt);
                            }
                        }
                    }
                }
            }

            CategoryService.RecalculateProductsCountManual();

            //TODO find where is this function!
            //ProductService.SumImportLog(Resource.Admin_ImportXLS_UpdoadingSuccessfullyCompleted,Resource.Admin_ImportXLS_UpdoadingCompletedWithErrors);
        }
        catch (Exception ex)
        {
            MsgErr(ex.Message + " at xls");
            Debug.LogError(ex);
        }

        ImportStatistic.IsRun = false;
        ImportStatistic.ThreadImport.Abort();
    }
示例#20
0
        private void LoadBonusCard()
        {
            if (!BonusSystem.IsActive || CurrentOffer.Price <= 0)
            {
                return;
            }

            var bonusCard = BonusSystemService.GetCard(CustomerContext.CurrentCustomer.BonusCardNumber);

            if (bonusCard != null)
            {
                lblProductBonus.Text =
                    CatalogService.RenderBonusPrice(bonusCard.BonusPercent, CurrentOffer.Price,
                                                    CurrentProduct.CalculableDiscount, CustomerContext.CurrentCustomer.CustomerGroup, CustomOptionsService.SerializeToXml(productCustomOptions.CustomOptions, productCustomOptions.SelectedOptions));
            }
            else if (BonusSystem.BonusFirstPercent != 0)
            {
                lblProductBonus.Text =
                    CatalogService.RenderBonusPrice(BonusSystem.BonusFirstPercent, CurrentOffer.Price,
                                                    CurrentProduct.CalculableDiscount, CustomerContext.CurrentCustomer.CustomerGroup, CustomOptionsService.SerializeToXml(productCustomOptions.CustomOptions, productCustomOptions.SelectedOptions));
            }
        }
        private string RenderBasketHtml(Customer customer, ShoppingCart shoppingCart)
        {
            if (!shoppingCart.HasItems)
            {
                return(string.Empty);
            }

            var sb = new StringBuilder();

            sb.Append("<table style=\'width:100%;\' cellspacing=\'0\' cellpadding=\'2\'>");
            sb.Append("<tr>");
            sb.AppendFormat("<td style=\'width:100px; text-align: center;\'>&nbsp;</td>");
            sb.AppendFormat("<td>{0}</td>", Resource.Client_OrderConfirmation_Name);
            sb.AppendFormat("<td style=\'width:90px; text-align:center;\'>{0}</td>", Resource.Client_OrderConfirmation_Price);
            sb.AppendFormat("<td style=\'width:80px; text-align: center;\' >{0}</td>", Resource.Client_OrderConfirmation_Count);
            sb.AppendFormat("<td style=\'width:90px; text-align:center;\'>{0}</td>", Resource.Client_OrderConfirmation_Cost);
            sb.Append("</tr>");

            var      allCurrencies = CurrencyService.GetAllCurrencies(true);
            Currency currency;

            try
            {
                currency = allCurrencies.FirstOrDefault(x => x.Iso3 == SettingsCatalog.DefaultCurrencyIso3) ?? allCurrencies.FirstOrDefault();
            }
            catch (Exception)
            {
                currency = allCurrencies.FirstOrDefault();
            }

            foreach (var item in shoppingCart)
            {
                if (item.Offer != null && item.Offer.Product != null)
                {
                    var photo = item.Offer.Photo;
                    var price = CatalogService.CalculateProductPrice(item.Offer.Price, item.Offer.Product.CalculableDiscount,
                                                                     customer.CustomerGroup, CustomOptionsService.DeserializeFromXml(item.AttributesXml));

                    sb.Append("<tr>");
                    if (photo != null)
                    {
                        sb.AppendFormat("<td style=\'text-align: center;\'><img src='{0}' /></td>",
                                        SettingsMain.SiteUrl.Trim('/') + '/' + FoldersHelper.GetImageProductPath(ProductImageType.XSmall, photo.PhotoName, false));
                    }
                    else
                    {
                        sb.AppendFormat("<td>&nbsp;</td>");
                    }
                    sb.AppendFormat("<td style=\' \'>{0}{1}{2}</td>", item.Offer.Product.Name,
                                    item.Offer.Color != null ? "<div>" + SettingsCatalog.ColorsHeader + ": " + item.Offer.Color.ColorName + "</div>" : "",
                                    item.Offer.Size != null  ? "<div>" + SettingsCatalog.SizesHeader + ": " + item.Offer.Size.SizeName + "</div>" : "");

                    sb.AppendFormat("<td style=\'text-align: center;\'>{0}</td>", CatalogService.GetStringPrice(price, currency));
                    sb.AppendFormat("<td style=\'text-align: center;\'>{0}</td>", item.Amount);
                    sb.AppendFormat("<td style=\'text-align: center;\'>{0}</td>", CatalogService.GetStringPrice(price * item.Amount, currency));
                    sb.Append("</tr>");
                }
            }
            sb.Append("</table>");

            return(sb.ToString());
        }