Пример #1
0
        protected void lstProducts_ItemCreated(object sender, ListViewItemEventArgs e)
        {
            if (IsConfigured)
            {
                ListView          lv      = sender as ListView;
                ListViewDataItem  item    = e.Item as ListViewDataItem;
                SimpleProductInfo product = item.DataItem as SimpleProductInfo;

                if (product != null)
                {
                    Panel pnl = e.Item.FindControl("pnlItem") as Panel;
                    pnl.Attributes["onmouseover"] = "this.style.cursor='pointer';";

                    PlaceHolder ph = e.Item.FindControl("productPlaceholder") as PlaceHolder;

                    var ctrl = RenderItem(product);
                    ph.Controls.Add(ctrl);
                }
            }
            else
            {
                Pager.Visible             = false;
                lstProducts.Visible       = false;
                lstProductsBS3.Visible    = false;
                lstProductsSimple.Visible = false;
            }
        }
Пример #2
0
        public int SaveProduct(string PortalId, string strStoreGuid, SimpleProductInfo product, string Token)
        {
            int portalId = -1;

            Int32.TryParse(PortalId, out portalId);
            if (portalId < 0)
            {
                throw new Exception("PortalId must be zero or greater");
            }

            if (product == null)
            {
                throw new Exception("Product must not be null");
            }

            Guid storeGuid = new Guid(strStoreGuid);

            if (storeGuid == Guid.Empty)
            {
                throw new Exception("StoreGuid must be valid!");
            }

            return(ImportController.SaveProduct(portalId, product, storeGuid));
        }
Пример #3
0
        public override List <SitemapUrl> GetUrls(int portalId, PortalSettings ps, string version)
        {
            CultureInfo current   = Thread.CurrentThread.CurrentCulture;
            CultureInfo currentUI = Thread.CurrentThread.CurrentUICulture;

            BBStoreController controller = new BBStoreController();
            List <SitemapUrl> retVal     = new List <SitemapUrl>();

            ModuleController moduleController = new ModuleController();
            ArrayList        mods             = moduleController.GetModules(portalId);

            // Lets build the Languages Collection
            LocaleController            lc  = new LocaleController();
            Dictionary <string, Locale> loc = lc.GetLocales(PortalSettings.Current.PortalId);

            // Productgroups
            foreach (var mod in mods)
            {
                ModuleInfo modInfo = (ModuleInfo)mod;
                if (modInfo.ModuleDefinition.FriendlyName == "BBStore Product Groups")
                {
                    bool fixedRoot = (modInfo.ModuleSettings["RootLevelFixed"] != null && Convert.ToBoolean(modInfo.ModuleSettings["RootLevelFixed"]));
                    int  rootLevel = (modInfo.ModuleSettings["RootLevel"] != null ? Convert.ToInt32(modInfo.ModuleSettings["RootLevel"]) : -1);
                    List <ProductGroupInfo> productGroups = new List <ProductGroupInfo>();
                    if (rootLevel > -1 && fixedRoot)
                    {
                        productGroups.Add(controller.GetProductGroup(portalId, rootLevel));
                    }
                    else if (rootLevel > -1 && !fixedRoot)
                    {
                        productGroups = controller.GetProductSubGroupsByNode(portalId, "en-US", rootLevel, false, false, false);
                    }
                    else if (rootLevel == -1 && fixedRoot)
                    {
                        productGroups.Add(new ProductGroupInfo()
                        {
                            ProductGroupId = -1
                        });
                    }
                    else
                    {
                        productGroups = controller.GetProductGroups(portalId);
                    }

                    List <ProductGroupInfo> sortedGroups = productGroups.OrderBy(p => p.ProductGroupId).ToList();
                    foreach (ProductGroupInfo productGroup in sortedGroups)
                    {
                        foreach (KeyValuePair <string, Locale> lang in loc)
                        {
                            // Set language to product Language
                            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(lang.Key);
                            Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang.Key);

                            // Lets check if we already have this
                            string name = "", url = "";
                            ProductGroupLangInfo pgl = controller.GetProductGroupLang(productGroup.ProductGroupId, lang.Key);
                            if (pgl != null)
                            {
                                name = HttpUtility.UrlEncode(pgl.ProductGroupName);
                            }
                            if (name != String.Empty)
                            {
                                url = Globals.NavigateURL(modInfo.TabID, "", "productGroup=" + productGroup.ProductGroupId.ToString(), "name=" + name);
                            }
                            else
                            {
                                url = Globals.NavigateURL(modInfo.TabID, "", "productGroup=" + productGroup.ProductGroupId.ToString());
                            }
                            if (retVal.Find(r => r.Url == url) == null)
                            {
                                var pageUrl = new SitemapUrl
                                {
                                    Url             = url,
                                    Priority        = (float)0.5,
                                    LastModified    = DateTime.Now.AddDays(-1),
                                    ChangeFrequency = SitemapChangeFrequency.Daily
                                };
                                retVal.Add(pageUrl);
                            }
                        }
                    }
                }
            }

            foreach (var mod in mods)
            {
                // First we need to know where our ProductModule sits
                ModuleInfo modInfo = (ModuleInfo)mod;
                if (modInfo.ModuleDefinition.FriendlyName == "BBStore Product" || modInfo.ModuleDefinition.FriendlyName == "BBStore Simple Product")
                {
                    int tabId = modInfo.TabID;

                    int productId = -1;
                    if (modInfo.ModuleSettings["ProductId"] != null)
                    {
                        productId = Convert.ToInt32(modInfo.ModuleSettings["ProductId"]);
                    }

                    if (productId < 0)
                    {
                        // We've got a dynamic module ! Here we show all products that are not disbaled !
                        List <SimpleProductInfo> products = controller.GetSimpleProducts(portalId).FindAll(p => p.Disabled == false);
                        foreach (SimpleProductInfo product in products)
                        {
                            foreach (KeyValuePair <string, Locale> lang in loc)
                            {
                                // Set language to product Language
                                Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(lang.Key);
                                Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang.Key);

                                // Lets check if we already have this
                                string name = "", url = "";
                                SimpleProductLangInfo spl = controller.GetSimpleProductLang(product.SimpleProductId, lang.Key);
                                if (spl != null)
                                {
                                    name = HttpUtility.UrlEncode(spl.Name);
                                }
                                if (name != string.Empty)
                                {
                                    url = Globals.NavigateURL(tabId, "", "productid=" + product.SimpleProductId.ToString(), "name=" + name);
                                }
                                else
                                {
                                    url = Globals.NavigateURL(tabId, "", "productid=" + product.SimpleProductId.ToString());
                                }

                                if (retVal.Find(r => r.Url == url) == null)
                                {
                                    var pageUrl = new SitemapUrl
                                    {
                                        Url             = url,
                                        Priority        = (float)0.3,
                                        LastModified    = product.LastModifiedOnDate,
                                        ChangeFrequency = SitemapChangeFrequency.Daily
                                    };
                                    retVal.Add(pageUrl);
                                }
                            }
                        }
                    }
                    else
                    {
                        // This is a fixed module !
                        SimpleProductInfo product = controller.GetSimpleProductByProductId(portalId, productId);
                        foreach (KeyValuePair <string, Locale> lang in loc)
                        {
                            // Set language to product Language
                            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(lang.Key);
                            Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang.Key);

                            // Lets check if we already have this
                            string name = "", url = "";
                            SimpleProductLangInfo spl = controller.GetSimpleProductLang(productId, lang.Key);
                            if (spl != null)
                            {
                                name = HttpUtility.UrlEncode(spl.Name);
                            }
                            if (name != string.Empty)
                            {
                                url = Globals.NavigateURL(tabId, "", "name=" + name);
                            }
                            else
                            {
                                url = Globals.NavigateURL(tabId);
                            }

                            if (retVal.Find(r => r.Url == url) == null)
                            {
                                var pageUrl = new SitemapUrl
                                {
                                    Url             = url,
                                    Priority        = (float)0.4,
                                    LastModified    = product.LastModifiedOnDate,
                                    ChangeFrequency = SitemapChangeFrequency.Daily
                                };
                                retVal.Add(pageUrl);
                            }
                        }
                    }
                }

                // Reset values
                Thread.CurrentThread.CurrentCulture   = current;
                Thread.CurrentThread.CurrentUICulture = currentUI;
            }
            return(retVal);
        }
Пример #4
0
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                // First lets save the product
                SimpleProductInfo SimpleProduct = null;
                bool isNew = false;

                if (ProductId >= 0)
                {
                    SimpleProduct = Controller.GetSimpleProductByProductId(PortalId, ProductId);
                }
                else
                {
                    isNew = true;
                }

                if (SimpleProduct != null)
                {
                    SimpleProduct.Image                = BBStoreHelper.GetRelativeFilePath(ImageSelector.Url);
                    SimpleProduct.ItemNo               = txtItemNo.Text.Trim();
                    SimpleProduct.UnitCost             = taxUnitCost.NetPrice;
                    SimpleProduct.OriginalUnitCost     = taxOriginalUnitCost.NetPrice;
                    SimpleProduct.TaxPercent           = Convert.ToDecimal(txtTaxPercent.Text.Trim());
                    SimpleProduct.LastModifiedByUserId = UserId;
                    SimpleProduct.LastModifiedOnDate   = DateTime.Now;
                    SimpleProduct.Disabled             = chkDisabled.Checked;
                    SimpleProduct.HideCost             = chkHideCost.Checked;
                    SimpleProduct.NoCart               = chkNoCart.Checked;
                    SimpleProduct.SupplierId           = String.IsNullOrEmpty(cboSupplier.SelectedValue) ? -1 : Convert.ToInt32(cboSupplier.SelectedValue);
                    SimpleProduct.UnitId               = String.IsNullOrEmpty(ddlUnit.SelectedValue) ? -1 : Convert.ToInt32(ddlUnit.SelectedValue);
                    SimpleProduct.Weight               = Convert.ToDecimal(txtWeight.Text.Trim());
                    Controller.UpdateSimpleProduct(SimpleProduct);
                }
                else
                {
                    SimpleProduct                      = new SimpleProductInfo();
                    SimpleProduct.PortalId             = PortalId;
                    SimpleProduct.Image                = BBStoreHelper.GetRelativeFilePath(ImageSelector.Url);
                    SimpleProduct.ItemNo               = txtItemNo.Text.Trim();
                    SimpleProduct.UnitCost             = taxUnitCost.NetPrice;
                    SimpleProduct.OriginalUnitCost     = taxOriginalUnitCost.NetPrice;
                    SimpleProduct.TaxPercent           = Convert.ToDecimal(txtTaxPercent.Text.Trim());
                    SimpleProduct.CreatedOnDate        = DateTime.Now;
                    SimpleProduct.LastModifiedOnDate   = DateTime.Now;
                    SimpleProduct.CreatedByUserId      = UserId;
                    SimpleProduct.LastModifiedByUserId = UserId;
                    SimpleProduct.Disabled             = chkDisabled.Checked;
                    SimpleProduct.HideCost             = chkHideCost.Checked;
                    SimpleProduct.NoCart               = chkNoCart.Checked;
                    SimpleProduct.SupplierId           = String.IsNullOrEmpty(cboSupplier.SelectedValue) ? -1 : Convert.ToInt32(cboSupplier.SelectedValue);
                    SimpleProduct.UnitId               = String.IsNullOrEmpty(ddlUnit.SelectedValue) ? -1 : Convert.ToInt32(ddlUnit.SelectedValue);
                    SimpleProduct.Weight               = Convert.ToDecimal(txtWeight.Text.Trim());
                    ProductId = Controller.NewSimpleProduct(SimpleProduct);
                }

                // Lets update the ShippingModel
                Controller.DeleteProductShippingModelByProduct(ProductId);
                int shippingModelId = -1;
                if (cboShippingModel.SelectedValue != null && Int32.TryParse(cboShippingModel.SelectedValue, out shippingModelId))
                {
                    Controller.InsertProductShippingModel(new ProductShippingModelInfo()
                    {
                        ShippingModelId = shippingModelId, SimpleProductId = ProductId
                    });
                }


                // Now lets update Language information
                lngSimpleProducts.UpdateLangs();
                Controller.DeleteSimpleProductLangs(ProductId);
                foreach (SimpleProductLangInfo si in lngSimpleProducts.Langs)
                {
                    si.SimpleProductId = ProductId;
                    Controller.NewSimpleProductLang(si);
                }

                // Lets handle the Product Groups
                int redirProductGroupId = 0;
                if (HasProductGroupModule)
                {
                    if (Request.QueryString["productgroup"] != null)
                    {
                        redirProductGroupId = Convert.ToInt32(Request.QueryString["productgroup"]);
                    }


                    Controller.DeleteProductInGroups(ProductId);
                    foreach (TreeNode node in treeProductGroup.CheckedNodes)
                    {
                        int ProductGroupId = Convert.ToInt32(node.Value.Substring(1));
                        Controller.NewProductInGroup(ProductId, ProductGroupId);
                        if (redirProductGroupId == 0)
                        {
                            redirProductGroupId = ProductGroupId;
                        }
                    }
                }

                // If we created a new product, we bound this as a fixed product to the module
                if (isNew && this.Parent.NamingContainer.ID != "ViewAdmin")
                {
                    ModuleController module = new ModuleController();
                    module.UpdateModuleSetting(ModuleId, "ProductId", ProductId.ToString());
                }
                FeatureGrid.SaveFeatures();

                List <string> addParams = new List <string>();

                if (Request["adminmode"] != null)
                {
                    addParams.Add("adminmode=productlist");
                }
                if (redirProductGroupId > 0)
                {
                    addParams.Add("productgroup=" + redirProductGroupId.ToString());
                }
                addParams.Add("productId=" + ProductId.ToString());

                Response.Redirect(Globals.NavigateURL(TabId, "", addParams.ToArray()), true);
            }
            catch (Exception exc)
            {
                //Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Пример #5
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                Controller = new BBStoreController();

                taxUnitCost.PercentControl         = txtTaxPercent;
                taxOriginalUnitCost.PercentControl = txtTaxPercent;

                taxPriceUnitCost.PercentControl         = txtPriceTaxPercent;
                taxPriceOriginalUnitCost.PercentControl = txtPriceTaxPercent;

                LocaleController            lc  = new LocaleController();
                Dictionary <string, Locale> loc = lc.GetLocales(PortalId);

                //TODO: Panels ausblenden wenn kein Modul verwendet

                ModuleController objModules = new ModuleController();
                if (objModules.GetModuleByDefinition(PortalId, "BBStore Product Groups") == null)
                {
                    HasProductGroupModule = false;
                }

                if (objModules.GetModuleByDefinition(PortalId, "BBStore Product Features") == null)
                {
                    HasProductFeatureModule = false;
                }

                Hashtable storeSettings = Controller.GetStoreSettings(PortalId);
                if (storeSettings != null)
                {
                    _imageDir = (string)(storeSettings["ProductImageDir"] ?? "");
                }

                // If this is the first visit to the page
                if (Page.IsPostBack == false)
                {
                    // Show Supplier ?
                    if (storeSettings != null && storeSettings["SupplierRole"] != null && (string)storeSettings["SupplierRole"] != "-1")
                    {
                        pnlSupplier.Visible = true;
                        RoleController roleController = new RoleController();
                        //RoleInfo role = roleController.GetRole(Convert.ToInt32(storeSettings["SupplierRole"]), PortalId);
                        ArrayList          aUsers = roleController.GetUsersByRoleName(PortalId, (string)storeSettings["SupplierRole"]);
                        ListItemCollection users  = new ListItemCollection();
                        foreach (UserInfo user in aUsers)
                        {
                            users.Add(new ListItem(user.DisplayName, user.UserID.ToString()));
                        }
                        string selText = Localization.GetString("SelectSupplier.Text", this.LocalResourceFile);
                        users.Insert(0, new ListItem(selText, "-1"));
                        cboSupplier.DataSource     = users;
                        cboSupplier.DataValueField = "Value";
                        cboSupplier.DataTextField  = "Text";
                        cboSupplier.DataBind();
                    }

                    // Shipping Models
                    List <ShippingModelInfo> shippingModels = Controller.GetShippingModels(PortalId);

                    cboShippingModel.DataSource     = shippingModels;
                    cboShippingModel.DataValueField = "ShippingModelId";
                    cboShippingModel.DataTextField  = "Name";
                    cboShippingModel.DataBind();

                    string selUnitText = Localization.GetString("SelectUnit.Text", this.LocalResourceFile);
                    ddlUnit.Items.Add(new ListItem(selUnitText, "-1"));
                    foreach (UnitInfo unit in Controller.GetUnits(PortalId, CurrentLanguage, "Unit"))
                    {
                        ddlUnit.Items.Add(new ListItem(unit.Unit, unit.UnitId.ToString()));
                    }
                    ddlUnit.DataValueField = "Value";
                    ddlUnit.DataTextField  = "Text";
                    ddlUnit.DataBind();


                    // Set ProductGroups Visible / not Visible
                    //pnlProductGroup.Visible = HasProductGroupModule;

                    SimpleProductInfo SimpleProduct = null;

                    if (Request["productid"] != null)
                    {
                        ProductId = Convert.ToInt32(Request["productid"]);
                    }

                    // if product exists
                    if (ProductId > 0)
                    {
                        SimpleProduct = Controller.GetSimpleProductByProductId(PortalId, ProductId);
                    }

                    List <ILanguageEditorInfo> dbLangs = new List <ILanguageEditorInfo>();

                    if (SimpleProduct == null)
                    {
                        taxUnitCost.Value         = 0.00m;
                        taxUnitCost.Mode          = "gross";
                        txtTaxPercent.Text        = 0.0m.ToString();
                        taxOriginalUnitCost.Value = 0.00m;
                        taxOriginalUnitCost.Mode  = "gross";
                        ImageSelector.Url         = _imageDir + "This_fileName-Should_not_3xist";
                        cboSupplier.SelectedValue = "-1";
                        dbLangs.Add(new SimpleProductLangInfo()
                        {
                            Language = CurrentLanguage
                        });
                        lngSimpleProducts.Langs = dbLangs;
                        txtWeight.Text          = 0.000m.ToString();
                    }
                    else
                    {
                        // Fill in the Language information
                        foreach (SimpleProductLangInfo simpleProductLang in Controller.GetSimpleProductLangs(SimpleProduct.SimpleProductId))
                        {
                            dbLangs.Add(simpleProductLang);
                        }
                        lngSimpleProducts.Langs = dbLangs;


                        // Set Image Info
                        int fileId = -1;
                        if (!String.IsNullOrEmpty(SimpleProduct.Image))
                        {
                            try
                            {
                                IFileInfo file = FileManager.Instance.GetFile(PortalId, SimpleProduct.Image);
                                if (file != null)
                                {
                                    fileId = file.FileId;
                                }
                            }
                            catch (Exception)
                            {
                                fileId = -1;
                            }
                        }
                        string imageUrl = "";
                        if (fileId > -1)
                        {
                            imageUrl = "FileID=" + fileId.ToString();
                        }
                        else
                        {
                            imageUrl = _imageDir + "This_fileName-Should_not_3xist";
                        }

                        // Set other fields
                        txtItemNo.Text            = SimpleProduct.ItemNo;
                        txtTaxPercent.Text        = SimpleProduct.TaxPercent.ToString();
                        taxUnitCost.Mode          = "gross";
                        taxUnitCost.Value         = SimpleProduct.UnitCost;
                        taxOriginalUnitCost.Mode  = "gross";
                        taxOriginalUnitCost.Value = SimpleProduct.OriginalUnitCost;
                        chkDisabled.Checked       = SimpleProduct.Disabled;
                        chkHideCost.Checked       = SimpleProduct.HideCost;
                        chkNoCart.Checked         = SimpleProduct.NoCart;
                        cboSupplier.SelectedValue = SimpleProduct.SupplierId.ToString();
                        ddlUnit.SelectedValue     = SimpleProduct.UnitId.ToString();
                        ImageSelector.Url         = imageUrl;
                        imgImage.ImageUrl         = BBStoreHelper.FileNameToImgSrc(imageUrl, PortalSettings);
                        txtWeight.Text            = SimpleProduct.Weight.ToString();

                        // Set ShippingModel
                        List <ProductShippingModelInfo> productshippingModels = Controller.GetProductShippingModelsByProduct(SimpleProduct.SimpleProductId);
                        if (productshippingModels.Count > 0)
                        {
                            cboShippingModel.SelectedValue = productshippingModels[0].ShippingModelId.ToString();
                        }
                    }

                    // Treeview Basenode
                    TreeNode newNode = new TreeNode(Localization.GetString("treeProductGroups.Text", this.LocalResourceFile), "_-1");
                    newNode.SelectAction     = TreeNodeSelectAction.Expand;
                    newNode.PopulateOnDemand = true;
                    newNode.ImageUrl         = @"~\images\category.gif";
                    newNode.ShowCheckBox     = false;
                    treeProductGroup.Nodes.Add(newNode);
                    //newNode.Expanded = false;


                    // Product Price
                    Localization.LocalizeGridView(ref grdPriceList, LocalResourceFile);
                    grdPriceList.DataSource = ProductPrices;
                    grdPriceList.DataBind();

                    RoleController roleController1 = new RoleController();
                    //RoleInfo role = roleController.GetRole(Convert.ToInt32(storeSettings["SupplierRole"]), PortalId);
                    ArrayList          aRoles = roleController1.GetPortalRoles(PortalId);
                    ListItemCollection roles  = new ListItemCollection();
                    foreach (RoleInfo role in aRoles)
                    {
                        roles.Add(new ListItem(role.RoleName, role.RoleID.ToString()));
                    }
                    string selText1 = Localization.GetString("SelectRole.Text", this.LocalResourceFile);
                    roles.Insert(0, new ListItem(selText1, "-1"));
                    ddlPriceRoleId.DataSource     = roles;
                    ddlPriceRoleId.DataValueField = "Value";
                    ddlPriceRoleId.DataTextField  = "Text";
                    ddlPriceRoleId.DataBind();
                }
                if (HasProductFeatureModule)
                {
                    FeatureGrid.ProductId = ProductId;
                }
            }

            catch (Exception exc)
            {
                //Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Пример #6
0
        protected void lstProducts_ItemCreated(object sender, ListViewItemEventArgs e)
        {
            if (IsConfigured)
            {
                int imageWidth = 145;

                ListView          lv            = sender as ListView;
                ListViewDataItem  item          = e.Item as ListViewDataItem;
                SimpleProductInfo simpleProduct = item.DataItem as SimpleProductInfo;
                if (simpleProduct != null)
                {
                    string template = _template;

                    if (template.IndexOf("[IMAGE") > -1)
                    {
                        if (template.IndexOf("[IMAGE:") > -1)
                        {
                            string width;
                            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\" />");
                        }
                    }
                    template = template.Replace("[ITEMNO]", simpleProduct.ItemNo);
                    template = template.Replace("[TITLE]", simpleProduct.Name);
                    template = template.Replace("[PRODUCTDESCRIPTION]", simpleProduct.ProductDescription);
                    template = template.Replace("[PRODUCTSHORTDESCRIPTION]", simpleProduct.ShortDescription);
                    template = template.Replace("[DELETE]", "<asp:ImageButton runat=\"server\" id=\"cmdDelete\" CommandName=\"Delete\" CausesValidation=\"False\" IconKey=\"Delete\"></asp:ImageButton>");

                    Control ctrl = ParseControl(template);

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

                        GeneratedImage 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
                        phimgProduct.Controls.Add(imgProduct);
                    }

                    PlaceHolder ph = e.Item.FindControl("productPlaceholder") as PlaceHolder;
                    ph.Controls.Add(ctrl);
                }
            }
        }
Пример #7
0
 public abstract void UpdateSimpleProduct(SimpleProductInfo SimpleProduct);
Пример #8
0
 public abstract int NewSimpleProduct(SimpleProductInfo SimpleProduct);
Пример #9
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);
        }
Пример #10
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            List <SimpleProductInfo> products = _controller.GetSimpleProductsStandardPrice(PortalId, Thread.CurrentThread.CurrentCulture.Name, Sort, Where);

            GridView1.DataSource = products;
            GridView1.DataBind();

            if (products != null && products.Count > 0)
            {
                try
                {
                    if (ProductId == -1)
                    {
                        lblSelected.Text            = Localization.GetString("DynamicSelected.Message", this.LocalResourceFile);
                        rblSelectType.SelectedValue = "0";
                        pnlStatic.Visible           = false;
                        divMessage.Attributes.Add("class", "dnnFormMessage dnnFormInfo");
                    }
                    else if (ProductId == -2)
                    {
                        lblSelected.Text  = Localization.GetString("NoSelected.Message", this.LocalResourceFile);
                        pnlStatic.Visible = false;
                        divMessage.Attributes.Add("class", "dnnFormMessage dnnFormWarning");
                    }
                    else if (ProductId == -3)
                    {
                        lblSelected.Text            = Localization.GetString("NoSelected.Message", this.LocalResourceFile);
                        pnlStatic.Visible           = true;
                        rblSelectType.SelectedValue = "1";
                        divMessage.Attributes.Add("class", "dnnFormMessage dnnFormWarning");
                    }
                    else
                    {
                        SimpleProductInfo pi = _controller.GetSimpleProductByProductId(PortalId, ProductId, CurrentLanguage, UserId, false);
                        if (pi != null)
                        {
                            lblSelected.Text = "(" + ProductId.ToString() + ") " + pi.ItemNo + " " + pi.Name;
                        }
                        else
                        {
                            lblSelected.Text = "(" + ProductId.ToString() + ")";
                        }

                        rblSelectType.SelectedValue = "1";
                        pnlStatic.Visible           = true;
                        divMessage.Attributes.Add("class", "dnnFormMessage dnnFormInfo");
                    }
                }
                catch (Exception exc)
                {
                    //Module failed to load
                    Exceptions.ProcessModuleLoadException(this, exc);
                }
            }
            else
            {
                // pnlSelectProduct.Visible = false;
                lblSelected.Text = Localization.GetString("DynamicSelected.Message", this.LocalResourceFile);
            }
        }