Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
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);
            }
        }