Exemple #1
0
        protected void treeProductGroup_TreeNodePopulate(object sender, TreeNodeEventArgs e)
        {
            // http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/navigation/treeview.aspx
            TreeNode parent = e.Node;
            int      ProductGroupId;

            ProductGroupId = Convert.ToInt32(parent.Value.Substring(1));

            Controller = new BBStoreController();
            DataTable selectedProductGroups  = Controller.GetProductsInGroupByProduct(ProductId);
            List <ProductGroupInfo> products = Controller.GetProductSubGroupsByNode(PortalId, CurrentLanguage, ProductGroupId, false, false, true);

            foreach (ProductGroupInfo p in products)
            {
                TreeNode  newNode = new TreeNode(p.ProductGroupName, "_" + p.ProductGroupId.ToString());
                DataRow[] zosn    = selectedProductGroups.Select("ProductgroupId = " + p.ProductGroupId.ToString());
                if (zosn.Length > 0)
                {
                    newNode.Checked = true;
                }
                newNode.SelectAction     = TreeNodeSelectAction.Expand;
                newNode.PopulateOnDemand = true;
                //newNode.ImageUrl = FileNameToImgSrc(p.Icon);

                parent.ChildNodes.Add(newNode);
            }
        }
        protected override void OnInit(EventArgs e)
        {
            Controller = new BBStoreController();
            if (!IsPostBack)
            {
                cmdDeleteStaticFilter.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteProductTemplate.Text", this.LocalResourceFile) + "');");
                FillStaticFilterCombo();

                String allLinkPos = Localization.GetString("AllLinkPos.Text", this.LocalResourceFile);
                if (!String.IsNullOrEmpty(allLinkPos))
                {
                    string[] allPos = allLinkPos.Split(',');
                    foreach (string pos in allPos)
                    {
                        cboShowAllLink.Items.Add(new ListItem(pos));
                    }
                }
                else
                {
                    cboShowAllLink.Items.Add(new ListItem("None"));
                }
            }

            base.OnInit(e);
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                Controller = new BBStoreController();

                if (Request["adminmode"] != null)
                {
                    pnlBack.Visible = false;
                }


                if (!IsPostBack)
                {
                    List <FeatureListItemInfo> featureListItems = Controller.GetFeatureListItemsByListId(FeatureListId, CurrentLanguage, false);
                    featureListItems.Insert(0, new FeatureListItemInfo()
                    {
                        FeatureListItem = "<Add new>", FeatureListItemId = -1
                    });
                    lstFeatureListItems.DataSource     = featureListItems;
                    lstFeatureListItems.DataTextField  = "FeatureListItem";
                    lstFeatureListItems.DataValueField = "FeatureListItemId";
                    lstFeatureListItems.DataBind();


                    cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteConfirm.Text", this.LocalResourceFile) + "');");
                    lblFLIDetailsCaption.Text = Localization.GetString("lblFLIDetailsCaption.Text", this.LocalResourceFile);
                }
            }
            catch (Exception exc)
            {
                //Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemple #4
0
        public override void DoWork()
        {
            try
            {
                this.Progressing();
                this.ScheduleHistoryItem.AddLogNote("Start purging old carts...<br>");
                BBStoreController ctrl = new BBStoreController();

                PortalController pc = new PortalController();
                var portals         = pc.GetPortals();
                foreach (PortalInfo portal in portals)
                {
                    Hashtable cartsettings = ctrl.GetCartSettings(portal.PortalID);

                    int interval = Convert.ToInt32(cartsettings["PurgeInterval"] ?? "0");
                    if (interval > 0)
                    {
                        ctrl.PurgeCarts(portal.PortalID, interval);
                        this.ScheduleHistoryItem.AddLogNote("Deleting carts in portal '" + portal.PortalName +
                                                            "' older than " + DateTime.Today.AddDays((-1) * interval).ToShortDateString() + "...<br>");
                    }
                }

                this.ScheduleHistoryItem.AddLogNote("Purging carts finished.");
                this.ScheduleHistoryItem.Succeeded = true;
            }
            catch (Exception ex)
            {
                this.ScheduleHistoryItem.Succeeded = false;
                this.ScheduleHistoryItem.AddLogNote("Exception: " + ex.ToString());
                this.Errored(ref ex);
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
            }
        }
Exemple #5
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                Controller = new BBStoreController();

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

                ModuleController objModules = new ModuleController();

                // If this is the first visit to the page
                if (Page.IsPostBack == false)
                {
                    UnitInfo unit = null;

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

                    // if unit exists
                    if (UnitId > 0)
                    {
                        unit = Controller.GetUnit(UnitId);
                    }

                    List <ILanguageEditorInfo> dbLangs = new List <ILanguageEditorInfo>();
                    if (unit == null)
                    {
                        txtDecimals.Text = "0";
                        foreach (KeyValuePair <string, Locale> keyValuePair in loc)
                        {
                            UnitLangInfo unitLang = new UnitLangInfo();
                            unitLang.Language = keyValuePair.Key;
                            dbLangs.Add(unitLang);
                        }
                    }
                    else
                    {
                        txtDecimals.Text = unit.Decimals.ToString();
                        foreach (UnitLangInfo unitLang in Controller.GetUnitLangs(UnitId))
                        {
                            dbLangs.Add(unitLang);
                        }
                    }
                    lngUnits.Langs = dbLangs;
                }
            }

            catch (Exception exc)
            {
                //Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemple #6
0
 protected override void OnInit(EventArgs e)
 {
     Controller = new BBStoreController();
     if (!IsPostBack)
     {
         // We fill the Combo
         FillFeatureListCombo();
     }
     tplTemplate.CreateImageCallback = CreateThumbHtml;
     base.OnLoad(e);
 }
Exemple #7
0
        private void ShowMiniCart()
        {
            _controller = new BBStoreController();

            CartInfo myCart = _controller.GetCart(PortalSettings.PortalId, CartId);

            if (myCart != null)
            {
                List <CartProductInfo> myProducts = _controller.GetCartProducts(CartId);

                ModuleController objModules = new ModuleController();
                ModuleInfo       cartModule = objModules.GetModuleByDefinition(PortalSettings.PortalId, "BBStore Cart");

                Hashtable storeSettings = _controller.GetStoreSettings(PortalSettings.PortalId);

                string template = _itemTemplate;

                if (!String.IsNullOrEmpty((string)storeSettings["MiniCartTemplate"]))
                {
                    template = (string)storeSettings["MiniCartTemplate"];
                }

                bool hideIfEmpty = Convert.ToBoolean(storeSettings["HideMiniCartIfEmpty"] ?? "false");

                bool    showNetPrice = (storeSettings["ShowNetpriceInCart"].ToString() == "0");
                decimal total        = myCart.OrderTotal + myCart.AdditionalTotal;

                if (showNetPrice == false)
                {
                    total += myCart.OrderTax + myCart.AdditionalTax;
                }

                decimal productCount = 0;
                foreach (CartProductInfo cp in myProducts)
                {
                    productCount += cp.Quantity;
                }

                if (hideIfEmpty && total <= 0)
                {
                    template = "";
                }
                else
                {
                    template = template.Replace("[PRODUCTS]", productCount.ToString("f0"));
                    template = template.Replace("[TOTAL]", total.ToString("f2"));
                    template = template.Replace("[CURRENCY]", myCart.Currency);
                    template = template.Replace("[CARTLINK]", (cartModule == null ? "" : Globals.NavigateURL(cartModule.TabID)));
                    template = template.Replace("[CHECKOUTLINK]", (cartModule == null ? "" : Globals.NavigateURL(cartModule.TabID, "", "action=checkout")));
                }
                ltrMiniCart.Text = template;
            }
        }
Exemple #8
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                Controller = new BBStoreController();

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

                if (Request["adminmode"] != null)
                {
                    pnlBack.Visible = false;
                }

                ctlFeatureLists.AddButtonClick       += ctlFeatureLists_AddButtonClick;
                ctlFeatureLists.AddAllButtonClick    += ctlFeatureLists_AddAllButtonClick;
                ctlFeatureLists.RemoveButtonClick    += ctlFeatureLists_RemoveButtonClick;
                ctlFeatureLists.RemoveAllButtonClick += ctlFeatureLists_RemoveAllButtonClick;

                if (!IsPostBack)
                {
                    // styling treeview
                    treeProductGroup.SelectedNodeStyle.BackColor = System.Drawing.Color.Red;
                    treeProductGroup.SelectedNodeStyle.ForeColor = System.Drawing.Color.White;

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

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

                    cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteConfirm.Text", this.LocalResourceFile) + "');");
                }
            }
            catch (Exception exc)
            {
                //Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemple #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //TODO: Beim Aufruf der Seite ohne ProductGroupParameter wird der Breadcrumb nicht angezeigt (Info aus Filter)
            BBStoreController Controller = new BBStoreController();
            int ParentNode;

            if (Request["productgroup"] != null)
            {
                ParentNode = Convert.ToInt32(Request["productgroup"]);

                // We retrieve the treepath of the ParentNode
                string treePath = Controller.GetProductGroupPath(PortalSettings.PortalId, ParentNode);

                Label lbl = new Label();
                lbl.Text = Separator;
                phBreadCrumb.Controls.Add(lbl);

                // Now lets build the breadcrumb
                string[]   bread = treePath.Split('/');
                LinkButton cmdBread;

                for (int i = 0; i < bread.Length; i++)
                {
                    cmdBread = new LinkButton();
                    int productGroupId = Convert.ToInt32(bread[i].Substring(1));
                    cmdBread.Attributes.Add("productgroup", productGroupId.ToString());
                    ProductGroupInfo pgi = Controller.GetProductGroup(PortalSettings.PortalId, System.Threading.Thread.CurrentThread.CurrentCulture.Name, productGroupId);
                    cmdBread.Text     = pgi.ProductGroupName;
                    cmdBread.Click   += new EventHandler(cmdBread_Click);
                    cmdBread.CssClass = "SkinObject";
                    phBreadCrumb.Controls.Add(cmdBread);

                    if (i + 1 < bread.Length)
                    {
                        lbl      = new Label();
                        lbl.Text = Separator;
                        phBreadCrumb.Controls.Add(lbl);
                    }
                }
            }
        }
Exemple #10
0
        protected override void OnInit(EventArgs e)
        {
            try
            {
                _controller = new BBStoreController();
                Localization.LocalizeGridView(ref GridView1, this.LocalResourceFile);

                if (!IsPostBack)
                {
                    int prodid = 0;
                    if (Request["productid"] != null && Int32.TryParse(Request["ProductId"], out prodid))
                    {
                        ProductId = prodid;
                    }
                    else if (Settings["ProductId"] != null)
                    {
                        ProductId = Convert.ToInt32(Settings["ProductId"]);
                    }
                    else
                    {
                        ProductId = -1;
                    }

                    // Fill the net / gross / see cart Optiongroup
                    rblShowNetPrice.Items.Add(new ListItem(Localization.GetString("ShowNetPrice.Cart.Text", this.LocalResourceFile), "-1"));
                    rblShowNetPrice.Items.Add(new ListItem(Localization.GetString("ShowNetPrice.Net.Text", this.LocalResourceFile), "0"));
                    rblShowNetPrice.Items.Add(new ListItem(Localization.GetString("ShowNetPrice.Gross.Text", this.LocalResourceFile), "1"));

                    _pageIndex          = 0;
                    Sort                = "SimpleProductId";
                    GridView1.PageIndex = _pageIndex;
                }
                tplTemplate.CreateImageCallback = CreateThumbHtml;
            }
            catch (Exception exc)
            {
                //Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
            base.OnLoad(e);
        }
Exemple #11
0
        protected void treeProductGroup_TreeNodePopulate(object sender, TreeNodeEventArgs e)
        {
            // http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/navigation/treeview.aspx
            TreeNode parent = e.Node;
            int      productGroupId;

            productGroupId = Convert.ToInt32(parent.Value.Substring(1));

            Controller = new BBStoreController();

            List <ProductGroupInfo> products = Controller.GetProductSubGroupsByNode(PortalId, CurrentLanguage, productGroupId, false, false, true);

            foreach (ProductGroupInfo p in products)
            {
                TreeNode newNode = new TreeNode(p.ProductGroupName, "_" + p.ProductGroupId.ToString());
                newNode.SelectAction     = TreeNodeSelectAction.Select;
                newNode.PopulateOnDemand = true;
                newNode.ImageUrl         = BBStoreHelper.FileNameToImgSrc(p.Icon, PortalSettings);
                parent.ChildNodes.Add(newNode);
            }
        }
        protected override void OnInit(EventArgs e)
        {
            Controller = new BBStoreController();
            if (!IsPostBack)
            {
                // TODO: Sort Combobox
                List <ProductGroupInfo> pgl = Controller.GetProductGroups(PortalId, CurrentLanguage, true);
                cboRootLevel.Items.Add(new ListItem(Localization.GetString("SelectOption.Text", this.LocalResourceFile), "-1"));
                cboRootLevel.AppendDataBoundItems = true;
                cboRootLevel.DataSource           = pgl;
                cboRootLevel.DataTextField        = "ProductGroupName";
                cboRootLevel.DataValueField       = "ProductGroupId";
                cboRootLevel.DataBind();

                cboDefaultProductGroup.Items.Add(new ListItem(Localization.GetString("SelectOption.Text", this.LocalResourceFile), "-1"));
                cboDefaultProductGroup.AppendDataBoundItems = true;
                cboDefaultProductGroup.DataSource           = pgl;
                cboDefaultProductGroup.DataTextField        = "ProductGroupName";
                cboDefaultProductGroup.DataValueField       = "ProductGroupId";
                cboDefaultProductGroup.DataBind();
            }
            tplTemplate.CreateImageCallback = CreateThumbHtml;
            base.OnLoad(e);
        }
Exemple #13
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);
            }
        }
Exemple #14
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                Controller = new BBStoreController();

                // If this is the first visit to the page
                if (Page.IsPostBack == false)
                {
                    CouponInfo coupon = null;

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

                    // if coupon exists
                    if (CouponId > 0)
                    {
                        coupon = Controller.GetCouponById(CouponId);
                    }

                    //TODO: Weitere Felder
                    taxDiscountValue.Mode = "gross";
                    if (coupon == null)
                    {
                        txtCaption.Text         = "";
                        txtCode.Text            = "";
                        txtTaxPercent.Text      = 0.0m.ToString();
                        txtDiscountPercent.Text = "";
                        taxDiscountValue.Value  = 0.0m;
                        txtMaxUsages.Text       = "1";
                        txtUsagesLeft.Text      = "1";
                        txtValidUntil.Text      = DateTime.Now.ToString("yyyy-MM-dd");
                    }
                    else
                    {
                        txtCaption.Text         = coupon.Caption;
                        txtCode.Text            = coupon.Code;
                        txtTaxPercent.Text      = coupon.TaxPercent.ToString();
                        txtDiscountPercent.Text = coupon.DiscountPercent.ToString();
                        taxDiscountValue.Value  = (coupon.DiscountValue == null ? 0 : (decimal)coupon.DiscountValue);
                        txtMaxUsages.Text       = coupon.MaxUsages.ToString();
                        txtUsagesLeft.Text      = coupon.UsagesLeft.ToString();
                        if (coupon.ValidUntil != null)
                        {
                            txtValidUntil.Text = ((DateTime)coupon.ValidUntil).ToString("yyyy-MM-dd");
                        }
                        else
                        {
                            txtValidUntil.Text = "";
                        }
                    }
                }
            }

            catch (Exception exc)
            {
                //Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        public void ConvertTemplates(int portalId)
        {
            BBStoreController          controller       = new BBStoreController();
            ModuleController           moduleController = new ModuleController();
            List <ModuleProductInfo>   moPros           = controller.GetModuleProducts(portalId);
            List <ProductTemplateInfo> templates        = controller.GetProductTemplates(portalId);

            TemplateControl templateControl = LoadControl("Controls/TemplateControl.ascx") as TemplateControl;

            if (templateControl != null)
            {
                // ModuleProducts
                templateControl.Key = "SimpleProduct";
                foreach (ModuleProductInfo moPro in moPros)
                {
                    ModuleInfo module = moduleController.GetModule(moPro.ModuleId);
                    if (moPro.Template != String.Empty)
                    {
                        string name = "Module_" + moPro.ModuleId.ToString();
                        templateControl.SaveTemplate(moPro.Template, name, BBStore.TemplateControl.TemplateEnum.Neutral);
                        moduleController.UpdateModuleSetting(moPro.ModuleId, "Template", name);
                    }
                    else
                    {
                        ProductTemplateInfo templateInfo = (from t in templates where t.ProductTemplateId == moPro.ProductTemplateId select t).FirstOrDefault();
                        if (templateInfo != null)
                        {
                            string name = templateInfo.TemplateName;
                            templateControl.SaveTemplate(templateInfo.Template, name, BBStore.TemplateControl.TemplateEnum.Neutral);
                            moduleController.UpdateModuleSetting(moPro.ModuleId, "Template", name);
                            moduleController.UpdateModuleSetting(moPro.ModuleId, "ProductId", moPro.ProductId.ToString());
                            moduleController.UpdateModuleSetting(moPro.ModuleId, "ShowNetPrice", moPro.IsTaxIncluded.ToString());
                        }
                    }
                    controller.DeleteModuleProduct(PortalId, moPro.ModuleId);
                }

                // ProductTemplates
                ArrayList allModules = moduleController.GetAllModules();
                foreach (ProductTemplateInfo template in templates)
                {
                    templateControl.Key = template.TemplateSource;
                    templateControl.SaveTemplate(template.Template, template.TemplateName, BBStore.TemplateControl.TemplateEnum.Neutral);

                    // We need to update the settings for all modules which have this ProductTemplateId as setting
                    int id = template.ProductTemplateId;

                    foreach (ModuleInfo module in allModules)
                    {
                        Hashtable settings = moduleController.GetModuleSettings(module.ModuleID);
                        if (settings["ProductTemplateId"] != null && Convert.ToInt32(settings["ProductTemplateId"]) == id)
                        {
                            moduleController.UpdateModuleSetting(module.ModuleID, "Template", template.TemplateName);
                            moduleController.DeleteModuleSetting(module.ModuleID, "ProductTemplateId");
                        }
                        if (settings["ProductGroupTemplateId"] != null && Convert.ToInt32(settings["ProductGroupTemplateId"]) == id)
                        {
                            moduleController.UpdateModuleSetting(module.ModuleID, "Template", template.TemplateName);
                            moduleController.DeleteModuleSetting(module.ModuleID, "ProductGroupTemplateId");
                        }
                    }
                    controller.DeleteProductTemplate(template.ProductTemplateId);
                }
                // DynamicPage -> ProductModulePage for Product List Modules
                foreach (ModuleInfo module in allModules)
                {
                    Hashtable settings = moduleController.GetModuleSettings(module.ModuleID);
                    if (settings["DynamicPage"] != null && settings["CssHover"] == null)
                    {
                        moduleController.UpdateModuleSetting(module.ModuleID, "ProductModulePage", (string)settings["DynamicPage"]);
                        moduleController.DeleteModuleSetting(module.ModuleID, "DynamicPage");
                    }
                }

                // Mailtemplates
                string templateContent = "";
                string templateFile    = this.PortalSettings.HomeDirectoryMapPath + @"Templates\order.html";
                if (File.Exists(templateFile))
                {
                    templateContent     = File.ReadAllText(templateFile);
                    templateControl.Key = "Order";
                    templateControl.SaveTemplate(templateContent, "Order", BBStore.TemplateControl.TemplateEnum.Portal);
                    File.Delete(templateFile);
                }
                templateFile = MapPath(ControlPath + @"\Templates\order.html");
                if (File.Exists(templateFile))
                {
                    templateContent     = File.ReadAllText(templateFile);
                    templateControl.Key = "Order";
                    templateControl.SaveTemplate(templateContent, "Order", BBStore.TemplateControl.TemplateEnum.Neutral);
                    File.Delete(templateFile);
                }
                templateFile = this.PortalSettings.HomeDirectoryMapPath + @"Templates\request.html";
                if (File.Exists(templateFile))
                {
                    templateContent     = File.ReadAllText(templateFile);
                    templateControl.Key = "Request";
                    templateControl.SaveTemplate(templateContent, "Request", BBStore.TemplateControl.TemplateEnum.Portal);
                    File.Delete(templateFile);
                }
                templateFile = MapPath(ControlPath + @"\Templates\request.html");
                if (File.Exists(templateFile))
                {
                    templateContent     = File.ReadAllText(templateFile);
                    templateControl.Key = "Request";
                    templateControl.SaveTemplate(templateContent, "Request", BBStore.TemplateControl.TemplateEnum.Neutral);
                    File.Delete(templateFile);
                }
            }
        }
        protected void FillCountry()
        {
            ddlCountry.Items.Add(new ListItem("Andorra", "AD"));
            ddlCountry.Items.Add(new ListItem("Albania", "AL"));
            ddlCountry.Items.Add(new ListItem("Austria", "AT"));
            ddlCountry.Items.Add(new ListItem("Bosnia and Herzegovina", "BA"));
            ddlCountry.Items.Add(new ListItem("Belgium", "BE"));
            ddlCountry.Items.Add(new ListItem("Bulgaria", "BG"));
            ddlCountry.Items.Add(new ListItem("Switzerland", "CH"));
            ddlCountry.Items.Add(new ListItem("Cyprus", "CY"));
            ddlCountry.Items.Add(new ListItem("Czech Republic", "CZ"));
            ddlCountry.Items.Add(new ListItem("Germany", "DE"));
            ddlCountry.Items.Add(new ListItem("Denmark", "DK"));
            ddlCountry.Items.Add(new ListItem("Estonia", "EE"));
            ddlCountry.Items.Add(new ListItem("Spain", "ES"));
            ddlCountry.Items.Add(new ListItem("Finland", "FI"));
            ddlCountry.Items.Add(new ListItem("Faroe Islands", "FO"));
            ddlCountry.Items.Add(new ListItem("France", "FR"));
            ddlCountry.Items.Add(new ListItem("United Kingdom", "GB"));
            ddlCountry.Items.Add(new ListItem("Georgia", "GE"));
            ddlCountry.Items.Add(new ListItem("Gibraltar", "GI"));
            ddlCountry.Items.Add(new ListItem("Greenland", "GL"));
            ddlCountry.Items.Add(new ListItem("Greece", "GR"));
            ddlCountry.Items.Add(new ListItem("Croatia", "HR"));
            ddlCountry.Items.Add(new ListItem("Hungary", "HU"));
            ddlCountry.Items.Add(new ListItem("Ireland", "IE"));
            ddlCountry.Items.Add(new ListItem("Israel", "IL"));
            ddlCountry.Items.Add(new ListItem("Iceland", "IS"));
            ddlCountry.Items.Add(new ListItem("Italy", "IT"));
            ddlCountry.Items.Add(new ListItem("Kuwait", "KW"));
            ddlCountry.Items.Add(new ListItem("Kazakhstan", "KZ"));
            ddlCountry.Items.Add(new ListItem("Lebanon", "LB"));
            ddlCountry.Items.Add(new ListItem("Liechtenstein", "LI"));
            ddlCountry.Items.Add(new ListItem("Lithuania", "LT"));
            ddlCountry.Items.Add(new ListItem("Luxembourg", "LU"));
            ddlCountry.Items.Add(new ListItem("Latvia", "LV"));
            ddlCountry.Items.Add(new ListItem("Monaco", "MC"));
            ddlCountry.Items.Add(new ListItem("Montenegro", "ME"));
            ddlCountry.Items.Add(new ListItem("Macedonia, Former Yugoslav Republic of", "MK"));
            ddlCountry.Items.Add(new ListItem("Mauritania", "MR"));
            ddlCountry.Items.Add(new ListItem("Malta", "MT"));
            ddlCountry.Items.Add(new ListItem("Mauritius", "MU"));
            ddlCountry.Items.Add(new ListItem("Netherlands", "NL"));
            ddlCountry.Items.Add(new ListItem("Norway", "NO"));
            ddlCountry.Items.Add(new ListItem("Poland", "PL"));
            ddlCountry.Items.Add(new ListItem("Portugal", "PT"));
            ddlCountry.Items.Add(new ListItem("Romania", "RO"));
            ddlCountry.Items.Add(new ListItem("Serbia", "RS"));
            ddlCountry.Items.Add(new ListItem("Saudi Arabia", "SA"));
            ddlCountry.Items.Add(new ListItem("Sweden", "SE"));
            ddlCountry.Items.Add(new ListItem("Slovenia", "SI"));
            ddlCountry.Items.Add(new ListItem("Slovak Republic", "SK"));
            ddlCountry.Items.Add(new ListItem("San Marino", "SM"));
            ddlCountry.Items.Add(new ListItem("Tunisia", "TN"));
            ddlCountry.Items.Add(new ListItem("Turkey", "TR"));

            BBStoreController controller = new BBStoreController();

            Hashtable storeSettings = controller.GetStoreSettings(PortalId);
            string    countryCode   = (string)storeSettings["VendorCountry"];

            try
            {
                ddlCountry.SelectedValue = countryCode;
            }
            catch (Exception)
            {
            }
        }
        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);
        }
        private void RefreshLicense(bool forceUpdate)
        {
            LicenseDataInfo license = new BBStoreController().GetLicense(PortalId, forceUpdate);

            if (license != null)
            {
                string         modules = "<ul style=\"line-height:16px;padding:0;margin-left:0;font-weight:normal;\">";
                ModuleKindEnum licenseModuleKindEnum = (ModuleKindEnum)license.Modules;
                if ((licenseModuleKindEnum & ModuleKindEnum.Admin) == ModuleKindEnum.Admin)
                {
                    modules += "<li style=\"list-style-type:none;\">Admin</li>";
                }
                if ((licenseModuleKindEnum & ModuleKindEnum.Cart) == ModuleKindEnum.Cart)
                {
                    modules += "<li style=\"list-style-type:none;\">Cart</li>";
                }
                if ((licenseModuleKindEnum & ModuleKindEnum.Contact) == ModuleKindEnum.Contact)
                {
                    modules += "<li style=\"list-style-type:none;\">Contact</li>";
                }
                if ((licenseModuleKindEnum & ModuleKindEnum.FeatureList) == ModuleKindEnum.FeatureList)
                {
                    modules += "<li style=\"list-style-type:none;\">FeatureList</li>";
                }
                if ((licenseModuleKindEnum & ModuleKindEnum.MiniCart) == ModuleKindEnum.MiniCart)
                {
                    modules += "<li style=\"list-style-type:none;\">MiniCart</li>";
                }
                if ((licenseModuleKindEnum & ModuleKindEnum.Product) == ModuleKindEnum.Product)
                {
                    modules += "<li style=\"list-style-type:none;\">Product</li>";
                }
                if ((licenseModuleKindEnum & ModuleKindEnum.ProductGroup) == ModuleKindEnum.ProductGroup)
                {
                    modules += "<li style=\"list-style-type:none;\">ProductGroup</li>";
                }
                if ((licenseModuleKindEnum & ModuleKindEnum.ProductList) == ModuleKindEnum.ProductList)
                {
                    modules += "<li style=\"list-style-type:none;\">ProductList</li>";
                }
                if ((licenseModuleKindEnum & ModuleKindEnum.Search) == ModuleKindEnum.Search)
                {
                    modules += "<li style=\"list-style-type:none;\">Search</li>";
                }
                modules += "</ul>";

                ltrLicense.Text = String.Format("<table class=\"dnnGrid\" cellpadding=\"2\" cellspacing=\"0\" border=\"0\">" +
                                                "<tr class=\"dnnGridItem\"><td style=\"vertical-align:top;font-weight:bold\">" + LocalizeString("lblTag.Header") + "</td><td>{0}</td></tr>" +
                                                "<tr class=\"dnnGridAltItem\"><td style=\"vertical-align:top;font-weight:bold\">" + LocalizeString("lblVersion.Header") + "</td><td>{1}</td></tr>" +
                                                "<tr class=\"dnnGridItem\"><td style=\"vertical-align:top;font-weight:bold\">" + LocalizeString("lblModules.Header") + "</td><td>{2}</td></tr>" +
                                                "<tr class=\"dnnGridAltItem\"><td style=\"vertical-align:top;font-weight:bold\">" + LocalizeString("lblValid.Header") + "</td><td>{3}</td></tr>" +
                                                "<tr class=\"dnnGridItem\"><td style=\"vertical-align:top;font-weight:bold\">" + LocalizeString("lblLastCheck.Header") + "</td><td>{4}</td></tr>" +
                                                "</table>", license.Tag, license.Version.ToString() + ".x", modules,
                                                (license.ValidUntil == null ? "-" : ((DateTime)license.ValidUntil).ToShortDateString()),
                                                (ModuleSettings["LastLicenseRead"] ?? "-") + " (" + (ModuleSettings["LicenseReadRetries"] ?? "0") + ")");
            }
            else
            {
                ltrLicense.Text = "";
            }
        }