protected void btnSave_Click(object sender, EventArgs e)
        {
            Manufacturer manufacturer = ManufacturerManager.GetManufacturerByID(this.ManufacturerID);

            if (manufacturer != null)
            {
                ProductManufacturerCollection existingProductManufacturers = manufacturer.ProductManufacturers;

                foreach (GridViewRow row in gvProducts.Rows)
                {
                    try
                    {
                        CheckBox       cbProductInfo      = row.FindControl("cbProductInfo") as CheckBox;
                        HiddenField    hfProductID        = row.FindControl("hfProductID") as HiddenField;
                        NumericTextBox txtRowDisplayOrder = row.FindControl("txtDisplayOrder") as NumericTextBox;
                        int            productID          = int.Parse(hfProductID.Value);
                        int            displayOrder       = txtRowDisplayOrder.Value;
                        if (cbProductInfo.Checked)
                        {
                            if (existingProductManufacturers.FindProductManufacturer(productID, this.ManufacturerID) == null)
                            {
                                ManufacturerManager.InsertProductManufacturer(productID, this.ManufacturerID, false, displayOrder);
                            }
                        }
                    }
                    catch (Exception exc)
                    {
                        ProcessException(exc);
                    }
                }
            }

            this.Page.ClientScript.RegisterStartupScript(typeof(ManufacturerProductAddControl), "closerefresh", "<script language=javascript>try {window.opener.document.forms[0]." + this.BtnID + ".click();}catch (e){} window.close();</script>");
        }
Beispiel #2
0
        private void BindData()
        {
            Manufacturer manufacturer = ManufacturerManager.GetManufacturerByID(this.ManufacturerID);

            if (manufacturer != null)
            {
                ProductManufacturerCollection existingProductManufacturerCollection      = manufacturer.ProductManufacturers;
                List <ProductManufacturerMappingHelperClass> productManufacturerMappings = GetProductManufacturerMappings(existingProductManufacturerCollection);
                gvProductManufacturerMappings.DataSource = productManufacturerMappings;
                gvProductManufacturerMappings.DataBind();
            }
        }
        private void BindData()
        {
            Product product = ProductManager.GetProductByID(this.ProductID);

            if (product != null)
            {
                ProductManufacturerCollection existingProductManufacturerCollection      = product.ProductManufacturers;
                List <ProductManufacturerMappingHelperClass> productManufacturerMappings = GetProductManufacturerMappings(existingProductManufacturerCollection);
                gvManufacturerMappings.DataSource = productManufacturerMappings;
                gvManufacturerMappings.DataBind();
            }
        }
Beispiel #4
0
        private void BindData()
        {
            Manufacturer manufacturer = ManufacturerManager.GetManufacturerById(this.ManufacturerId);

            if (manufacturer != null)
            {
                ProductManufacturerCollection existingProductManufacturerCollection      = manufacturer.ProductManufacturers;
                List <ProductManufacturerMappingHelperClass> productManufacturerMappings = GetProductManufacturerMappings(existingProductManufacturerCollection);
                gvProductManufacturerMappings.Columns[1].Visible = SettingManager.GetSettingValueBoolean("Display.ShowAdminProductImages");
                gvProductManufacturerMappings.DataSource         = productManufacturerMappings;
                gvProductManufacturerMappings.DataBind();
            }
        }
        private static ProductManufacturerCollection DBMapping(DBProductManufacturerCollection dbCollection)
        {
            if (dbCollection == null)
                return null;

            ProductManufacturerCollection collection = new ProductManufacturerCollection();
            foreach (DBProductManufacturer dbItem in dbCollection)
            {
                ProductManufacturer item = DBMapping(dbItem);
                collection.Add(item);
            }

            return collection;
        }
Beispiel #6
0
        private List <ProductManufacturerMappingHelperClass> GetProductManufacturerMappings(ProductManufacturerCollection ExistingProductManufacturerCollection)
        {
            List <ProductManufacturerMappingHelperClass> result = new List <ProductManufacturerMappingHelperClass>();

            foreach (ProductManufacturer pm in ExistingProductManufacturerCollection)
            {
                Product product = pm.Product;
                if (product != null)
                {
                    ProductManufacturerMappingHelperClass pmmhc = new ProductManufacturerMappingHelperClass();
                    pmmhc.ProductManufacturerID = pm.ProductManufacturerID;
                    pmmhc.ProductID             = pm.ProductID;
                    pmmhc.ProductInfo           = product.Name;
                    pmmhc.IsMapped     = true;
                    pmmhc.IsFeatured   = pm.IsFeaturedProduct;
                    pmmhc.DisplayOrder = pm.DisplayOrder;
                    result.Add(pmmhc);
                }
            }

            return(result);
        }
        private List <ProductManufacturerMappingHelperClass> GetProductManufacturerMappings(ProductManufacturerCollection ExistingProductManufacturerCollection)
        {
            ManufacturerCollection manufacturerCollection       = ManufacturerManager.GetAllManufacturers();
            List <ProductManufacturerMappingHelperClass> result = new List <ProductManufacturerMappingHelperClass>();

            for (int i = 0; i < manufacturerCollection.Count; i++)
            {
                Manufacturer        manufacturer = manufacturerCollection[i];
                ProductManufacturer existingProductManufacturer = null;
                if (ExistingProductManufacturerCollection != null)
                {
                    existingProductManufacturer = ExistingProductManufacturerCollection.FindProductManufacturer(this.ProductId, manufacturer.ManufacturerId);
                }
                ProductManufacturerMappingHelperClass pmm = new ProductManufacturerMappingHelperClass();
                if (existingProductManufacturer != null)
                {
                    pmm.ProductManufacturerId = existingProductManufacturer.ProductManufacturerId;
                    pmm.IsMapped     = true;
                    pmm.IsFeatured   = existingProductManufacturer.IsFeaturedProduct;
                    pmm.DisplayOrder = existingProductManufacturer.DisplayOrder;
                }
                else
                {
                    pmm.DisplayOrder = 1;
                }
                pmm.ManufacturerId   = manufacturer.ManufacturerId;
                pmm.ManufacturerInfo = manufacturer.Name;

                MapState(manufacturer.ManufacturerId, pmm);

                result.Add(pmm);
            }

            return(result);
        }
Beispiel #8
0
        /// <summary>
        /// Replaces a message template tokens
        /// </summary>
        /// <param name="productVariant">Product variant instance</param>
        /// <param name="Template">Template</param>
        /// <param name="LocalFormat">Localization Provider Short name (en-US, de-DE, etc.)</param>
        /// <param name="AdditionalKeys">Additional keys</param>
        /// <param name="AffiliateID">Affiliate identifier</param>
        /// <param name="Price">Price</param>
        /// <returns>New template</returns>
        protected string replaceMessageTemplateTokens(ProductVariant productVariant, string Template, string LocalFormat, NameValueCollection AdditionalKeys,
                                                      int AffiliateID, decimal Price)
        {
            NameValueCollection tokens = new NameValueCollection();

            IFormatProvider locProvider = new System.Globalization.CultureInfo(LocalFormat);

            string strHelper = Template;

            while (strHelper.Contains("%"))
            {
                strHelper = strHelper.Substring(strHelper.IndexOf("%") + 1);
                string strToken  = strHelper.Substring(0, strHelper.IndexOf("%"));
                string strFormat = "";
                strHelper = strHelper.Substring(strHelper.IndexOf("%") + 1);

                if (strToken.Contains(":"))
                {
                    strFormat = strToken.Substring(strToken.IndexOf(":"));
                    strToken  = strToken.Substring(0, strToken.IndexOf(":"));
                }

                if (tokens.Get(strToken + strFormat) == null)
                {
                    switch (strToken.ToLower())
                    {
                    case "store.name":
                    {
                        tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", SettingManager.StoreName));
                    }
                    break;

                    case "product.pictureurl":
                    {
                        ProductPictureCollection pictures = productVariant.Product.ProductPictures;
                        if (pictures.Count > 0)
                        {
                            tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", PictureManager.GetPictureUrl(pictures[0].PictureID)));
                        }
                        else
                        {
                            tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", string.Empty));
                        }
                    }
                    break;

                    case "pv.producturl":
                    {
                        tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", getProductUrlWithPricelistProvider(productVariant.ProductID, AffiliateID)));
                    }
                    break;

                    case "pv.price":
                    {
                        tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", Price));
                    }
                    break;

                    case "pv.name":
                    {
                        tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", productVariant.FullProductName));
                    }
                    break;

                    case "pv.description":
                    {
                        tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", productVariant.Description));
                    }
                    break;

                    case "product.description":
                    {
                        tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", productVariant.Product.FullDescription));
                    }
                    break;

                    case "product.shortdescription":
                    {
                        tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", productVariant.Product.ShortDescription));
                    }
                    break;

                    case "pv.partnumber":
                    {
                        tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", productVariant.ManufacturerPartNumber));
                    }
                    break;

                    case "product.manufacturer":
                    {
                        string mans = string.Empty;
                        ProductManufacturerCollection productManufacturers = productVariant.Product.ProductManufacturers;
                        foreach (ProductManufacturer pm in productManufacturers)
                        {
                            mans += ", " + pm.Manufacturer.Name;
                        }
                        if (mans.Length != 0)
                        {
                            mans = mans.Substring(2);
                        }

                        if (productManufacturers.Count > 0)
                        {
                            tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", mans));
                        }
                    }
                    break;

                    case "product.category":
                    {
                        string cats = string.Empty;
                        ProductCategoryCollection productCategories = productVariant.Product.ProductCategories;
                        foreach (ProductCategory pc in productCategories)
                        {
                            cats += ", " + pc.Category.Name;
                        }
                        if (cats.Length != 0)
                        {
                            cats = cats.Substring(2);
                        }

                        if (productCategories.Count > 0)
                        {
                            tokens.Add(strToken + strFormat, String.Format(locProvider, "{0" + strFormat + "}", cats));
                        }
                    }
                    break;

                    case "product.shippingcosts":
                    {
                    }
                    break;

                    default:
                    {
                        tokens.Add(strToken + strFormat, strToken + strFormat);
                    }
                    break;
                    }
                }
            }

            foreach (string token in tokens.Keys)
            {
                Template = Template.Replace(string.Format(@"%{0}%", token), tokens[token]);
            }

            foreach (string token in AdditionalKeys.Keys)
            {
                Template = Template.Replace(string.Format(@"%{0}%", token), AdditionalKeys[token]);
            }

            return(Template);
        }