Beispiel #1
0
 public abstract int NewUnit(UnitInfo unit);
Beispiel #2
0
 public abstract void UpdateUnit(UnitInfo unit);
Beispiel #3
0
        private Control RenderItem(SimpleProductInfo product)
        {
            bool showNetPrice = (StoreSettings.Count > 0) && ((string)StoreSettings["ShowNetpriceInCart"] == "0");

            decimal unitCost         = product.UnitCost;
            decimal originalUnitCost = product.OriginalUnitCost;
            decimal taxPercent       = product.TaxPercent;

            decimal price         = 0.00m;
            decimal originalPrice = 0.00m;
            string  tax           = "";

            if (showNetPrice)
            {
                price         = unitCost + (ProductOptionSelect != null ? ProductOptionSelect.PriceAlteration : 0.00m);
                originalPrice = originalUnitCost + (ProductOptionSelect != null ? ProductOptionSelect.PriceAlteration : 0.00m);
                tax           = Localization.GetString("ExcludeTax.Text", this.LocalResourceFile);
            }
            else
            {
                price         = decimal.Round((unitCost + (ProductOptionSelect != null ? ProductOptionSelect.PriceAlteration : 0.00m)) * (100 + taxPercent) / 100, 2);
                originalPrice = decimal.Round((originalUnitCost + (ProductOptionSelect != null ? ProductOptionSelect.PriceAlteration : 0.00m)) * (100 + taxPercent) / 100, 2);
                tax           = Localization.GetString("IncludeTax.Text", this.LocalResourceFile);
            }

            string template;
            int    imageWidth = 200;

            TemplateControl tp = LoadControl("controls/TemplateControl.ascx") as TemplateControl;

            tp.Key   = "ProductList";
            template = tp.GetTemplate((string)Settings["Template"]);

            //Template = ProductTemplate;

            template = template.Replace("[ITEMNO]", product.ItemNo);
            template = template.Replace("[PRODUCTSHORTDESCRIPTION]", product.ShortDescription);
            template = template.Replace("[PRODUCTDESCRIPTION]", product.ProductDescription);
            template = template.Replace("[TITLE]", product.Name);
            template = template.Replace("[IMAGEURL]", product.Image);

            if (product.HideCost)
            {
                template = template.Replace("[PRICE]", Localization.GetString("AskOffer.Text", this.LocalResourceFile));
            }
            else
            {
                template = template.Replace("[PRICE]", String.Format("{0:n2}", price));
            }

            if (originalPrice > price && !product.HideCost)
            {
                template = template.Replace("[ORIGINALPRICE]", String.Format("{0:n2} {1}", originalPrice, Currency));
            }
            else
            {
                template = template.Replace("[ORIGINALPRICE]", "");
            }

            if (!product.HideCost)
            {
                template = template.Replace("[CURRENCY]", Currency);
            }
            else
            {
                template = template.Replace("[CURRENCY]", "");
            }


            if (taxPercent > 0.00m && !product.HideCost)
            {
                template = template.Replace("[TAX]", String.Format(tax, taxPercent));
            }
            else
            {
                template = template.Replace("[TAX]", "");
            }

            if (product.UnitId > -1)
            {
                UnitInfo unit = Controller.GetUnit(product.UnitId, CurrentLanguage);
                template = template.Replace("[UNIT]", unit.Symbol);
            }
            else
            {
                template = template.Replace("[UNIT]", "");
            }


            int linkCnt = 0;

            while (template.Contains("[LINK]"))
            {
                linkCnt++;
                template = template.ReplaceFirst("[LINK]", "<asp:Literal ID=\"ltrLink" + linkCnt.ToString() + "\" runat=\"server\" />");
            }

            if (template.IndexOf("[IMAGE") > -1)
            {
                if (template.IndexOf("[IMAGE:") > -1)
                {
                    string width = template.Substring(template.IndexOf("[IMAGE:") + 7);
                    width = width.Substring(0, width.IndexOf("]"));
                    if (Int32.TryParse(width, out imageWidth) == false)
                    {
                        imageWidth = 200;
                    }
                    template = template.Replace("[IMAGE:" + width + "]", "<asp:PlaceHolder ID=\"phimgProduct\" runat=\"server\" />");
                }
                else
                {
                    template = template.Replace("[IMAGE]", "<asp:PlaceHolder ID=\"phimgProduct\" runat=\"server\" />");
                }
            }
            while (template.IndexOf("[RESOURCE:") > -1)
            {
                string resKey = template.Substring(template.IndexOf("[RESOURCE:") + 10);
                resKey   = resKey.Substring(0, resKey.IndexOf("]"));
                template = template.Replace("[RESOURCE:" + resKey + "]", Localization.GetString(resKey, this.LocalResourceFile));
            }


            while (template.IndexOf("[FEATURE:") > -1)
            {
                string token = template.Substring(template.IndexOf("[FEATURE:") + 9);
                token = token.Substring(0, token.IndexOf("]"));
                string prop = token.Substring(token.IndexOf(".") + 1);
                token = token.Substring(0, token.IndexOf(".")).ToUpper();

                string value             = "";
                FeatureGridValueInfo fgv = Controller.GetFeatureGridValueByProductAndToken(PortalId, product.SimpleProductId, CurrentLanguage, token);
                if (fgv != null)
                {
                    PropertyInfo p = fgv.GetType().GetProperty(prop);
                    if (p != null && p.CanRead)
                    {
                        value = p.GetValue(fgv, null).ToString();
                    }
                }
                template = template.Replace("[FEATURE:" + token + "." + prop + "]", value);
            }

            Control ctrl = ParseControl(template);

            for (int i = 1; i < linkCnt + 1; i++)
            {
                Literal ltrLink = FindControlRecursive(ctrl, "ltrLink" + i.ToString()) as Literal;
                if (ltrLink != null)
                {
                    int productModuleTabId = Convert.ToInt32(Settings["ProductModulePage"] ?? TabId.ToString());
                    ltrLink.Text = Globals.NavigateURL(productModuleTabId, "", "productid=" + product.SimpleProductId.ToString());
                }
            }

            PlaceHolder phimgProduct = FindControlRecursive(ctrl, "phimgProduct") as PlaceHolder;

            if (phimgProduct != null && product.Image != null)
            {
                string fileName =
                    PortalSettings.HomeDirectoryMapPath.Replace(HttpContext.Current.Request.PhysicalApplicationPath, "") +
                    product.Image.Replace('/', '\\');

                imgProduct = new GeneratedImage();
                imgProduct.ImageHandlerUrl = "~/BBImageHandler.ashx";
                if (imageWidth > 0)
                {
                    imgProduct.Parameters.Add(new ImageParameter()
                    {
                        Name = "Width", Value = imageWidth.ToString()
                    });
                }
                imgProduct.Parameters.Add(new ImageParameter()
                {
                    Name = "File", Value = fileName
                });
                // TODO: Watermark
                //if (false)
                //{
                //    imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkText", Value = Localization.GetString("Sold.Text", this.LocalResourceFile) });
                //    imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontFamily", Value = "Verdana" });
                //    imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontColor", Value = "Red" });
                //    imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontSize", Value = "20" });
                //}
                phimgProduct.Controls.Add(imgProduct);
            }

            return(ctrl);
        }