/// <summary>
    /// Generates where condition for uniselector.
    /// </summary>
    protected override string GenerateWhereCondition()
    {
        CurrencyInfo main           = CurrencyInfoProvider.GetMainCurrency(SiteID);
        int          mainCurrencyId = (main != null) ? main.CurrencyID : 0;

        // Prepare where condition
        string where = "";
        if (DisplayOnlyWithExchangeRate)
        {
            ExchangeTableInfo tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(SiteID);
            if (tableInfo != null)
            {
                where = "(CurrencyID = " + mainCurrencyId + " OR CurrencyID IN (SELECT ExchangeRateToCurrencyID FROM COM_CurrencyExchangeRate WHERE COM_CurrencyExchangeRate.ExchangeTableID = " + tableInfo.ExchangeTableID + ") AND CurrencyEnabled = 1)";
            }
            else
            {
                where = "(0=1)";
            }
        }

        // Add site main currency when required
        if (AddSiteDefaultCurrency && (main != null))
        {
            where = SqlHelper.AddWhereCondition(where, "CurrencyID = " + mainCurrencyId, "OR");
        }

        // Exclude site main currency when required
        if (ExcludeSiteDefaultCurrency && (main != null))
        {
            where = SqlHelper.AddWhereCondition(where, "(NOT CurrencyID = " + mainCurrencyId + ")");
        }

        // Add base where condition
        return(SqlHelper.AddWhereCondition(where, base.GenerateWhereCondition()));
    }
Example #2
0
    /// <summary>
    /// Exclude main currency and currencies without exchange rate according selector settings.
    /// </summary>
    /// <param name="whereCondition">Where condition.</param>
    protected override string AppendExclusiveWhere(string whereCondition)
    {
        // Prepare where condition
        var where = new WhereCondition(whereCondition);
        if (DisplayOnlyWithExchangeRate)
        {
            var tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(SiteID);
            if (tableInfo != null)
            {
                where.Where(w => w.WhereEquals("CurrencyID", MainCurrencyID)
                            .Or()
                            .WhereIn("CurrencyID", new IDQuery(ExchangeRateInfo.OBJECT_TYPE, "ExchangeRateToCurrencyID")
                                     .WhereEquals("ExchangeTableID", tableInfo.ExchangeTableID)
                                     .WhereTrue("CurrencyEnabled")));
            }
            else
            {
                where.NoResults();
            }
        }
        // Exclude site main currency when required
        if (ExcludeSiteDefaultCurrency && (MainCurrencyID > 0))
        {
            where.WhereNotEquals("CurrencyID", MainCurrencyID);
        }

        // Restrict disabled or site not related currencies
        return(base.AppendExclusiveWhere(where.ToString(true)));
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        if (UseGlobalObjects && ExchangeTableInfoProvider.IsExchangeRateFromGlobalMainCurrencyMissing(CMSContext.CurrentSiteID))
        {
            ShowError(GetString("com.NeedExchangeRateFromGlobal"));
        }
    }
Example #4
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        if (this.UseGlobalObjects && ExchangeTableInfoProvider.IsExchangeRateFromGlobalMainCurrencyMissing(CMSContext.CurrentSiteID))
        {
            lblMissingRate.Visible = true;
        }
    }
Example #5
0
    /// <summary>
    ///  Copies site-specific exchange rates from last valid global exchange table.
    /// </summary>
    protected void CopyFromGlobal()
    {
        CheckConfigurationModification();

        ExchangeTableInfo globalTable = ExchangeTableInfoProvider.GetLastExchangeTableInfo(0);

        if (globalTable != null)
        {
            ExchangeRateInfoProvider.CopyExchangeRates(globalTable.ExchangeTableID, mExchangeTableId);
        }
    }
    private void FindCurrentTableID()
    {
        mCurrentTableId = 0;

        // Get current table (it will be highlighted in the listing)
        ExchangeTableInfo eti = ExchangeTableInfoProvider.GetLastExchangeTableInfo(SiteID);

        if (eti != null)
        {
            mCurrentTableId = eti.ExchangeTableID;
        }
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        // Init Unigrid
        ShippingExtensionGrid.OnAction += new OnActionEventHandler(uniGrid_OnAction);

        ShippingExtensionGrid.ZeroRowsText = GetString("general.nodatafound");
        if (AllowGlobalObjects && ExchangeTableInfoProvider.IsExchangeRateFromGlobalMainCurrencyMissing(CMSContext.CurrentSiteID))
        {
            ShowWarning(GetString("com.NeedExchangeRateFromGlobal"), null, null);
        }
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        // Init Unigrid
        gridElem.OnAction            += gridElem_OnAction;
        gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;
        HandleGridsSiteIDColumn(gridElem);

        if (AllowGlobalObjects && ExchangeTableInfoProvider.IsExchangeRateFromGlobalMainCurrencyMissing(SiteContext.CurrentSiteID))
        {
            ShowWarning(GetString("com.NeedExchangeRateFromGlobal"));
        }
    }
    /// <summary>
    /// Initializes copy from global link.
    /// </summary>
    protected void InitCopyFromGlobalLink()
    {
        // Nothing to be done
        if ((mMainCurrency == null) || string.IsNullOrEmpty(mMainCurrency.CurrencyCode))
        {
            return;
        }

        // Show copy from global link when not configuring global currencies.
        if (ConfiguredSiteID == 0)
        {
            return;
        }

        // Allow copying only if global main currency and site main currency are the same
        if (mMainCurrency.CurrencyCode != CurrencyInfoProvider.GetMainCurrencyCode(0))
        {
            return;
        }

        // Show "Copy from global" link only if there is at least one global exchange rate table
        DataSet ds = ExchangeTableInfoProvider.GetExchangeTables()
                     .TopN(1)
                     .OnSite(0)
                     .Column("ExchangeTableID");

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction
            {
                Text          = GetString("general.copyfromglobal"),
                OnClientClick = "return ConfirmCopyFromGlobal();",
                CommandName   = COPY_FROM_GLBOAL,
                ButtonStyle   = ButtonStyle.Default
            });

            CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;

            // Register javascript to confirm generate
            string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetLocalizedString("com.ConfirmExchangeTableFromGlobal") + ");}";
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script));
        }
    }
Example #10
0
    /// <summary>
    /// Initializes copy from global link.
    /// </summary>
    protected void InitCopyFromGlobalLink()
    {
        // Nothing to be done
        if ((mMainCurrency == null) || string.IsNullOrEmpty(mMainCurrency.CurrencyCode))
        {
            return;
        }

        // Show copy from global link when not configuring global currencies.
        if (ConfiguredSiteID != 0)
        {
            // Allow copying only if global main currency and site main currency are the same
            if (mMainCurrency.CurrencyCode == CurrencyInfoProvider.GetMainCurrencyCode(0))
            {
                string[,] actions = new string[2, 9];

                // Show "Copy from global" link only if there is at least one global exchange rate table
                DataSet ds = ExchangeTableInfoProvider.GetExchangeTables("ExchangeTableSiteID IS NULL", null, 1, "ExchangeTableID");
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    actions[1, 0] = HeaderActions.TYPE_SAVEBUTTON;
                    actions[1, 1] = GetString("general.copyfromglobal");
                    actions[1, 2] = "return ConfirmCopyFromGlobal();";
                    actions[1, 3] = null;
                    actions[1, 4] = null;
                    actions[1, 5] = GetImageUrl("Objects/Ecommerce_ExchangeTable/fromglobal.png");
                    actions[1, 6] = "copyFromGlobal";
                    actions[1, 7] = String.Empty;
                    actions[1, 8] = true.ToString();

                    // Register javascript to confirm generate
                    string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmExchangeTableFromGlobal")) + ");}";
                    ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script));

                    this.CurrentMaster.HeaderActions.Actions          = actions;
                    this.CurrentMaster.HeaderActions.ActionPerformed += new CommandEventHandler(HeaderActions_ActionPerformed);
                }
            }
        }
    }
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            URLHelper.Redirect("ExchangeTable_Edit.aspx?exchangeid=" + Convert.ToString(actionArgument) + "&siteId=" + SiteID);
        }
        else if (actionName == "delete")
        {
            CheckConfigurationModification();

            int tableId = ValidationHelper.GetInteger(actionArgument, 0);
            // Delete ExchangeTableInfo object from database
            ExchangeTableInfoProvider.DeleteExchangeTableInfo(tableId);

            // If current table deleted
            if (mCurrentTableId == tableId)
            {
                // Find new current table
                FindCurrentTableID();
            }
        }
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        // Init Unigrid
        UniGrid.OnAction            += new OnActionEventHandler(uniGrid_OnAction);
        UniGrid.OnExternalDataBound += new OnExternalDataBoundEventHandler(UniGrid_OnExternalDataBound);
        UniGrid.ZeroRowsText         = GetString("general.nodatafound");

        // Init site selector
        SelectSite.Selector.SelectedIndexChanged += new EventHandler(Selector_SelectedIndexChanged);

        if (!RequestHelper.IsPostBack())
        {
            // Init site selector
            SelectSite.SiteID = SiteFilterStartupValue;
        }

        if (this.AllowGlobalObjects && ExchangeTableInfoProvider.IsExchangeRateFromGlobalMainCurrencyMissing(CMSContext.CurrentSiteID))
        {
            lblMissingRate.Visible = true;
        }
    }
Example #13
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        // Init Unigrid
        gridElem.OnAction            += new OnActionEventHandler(gridElem_OnAction);
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);
        gridElem.ZeroRowsText         = GetString("general.nodatafound");

        // Init site selector
        SelectSite.Selector.SelectedIndexChanged += new EventHandler(Selector_SelectedIndexChanged);

        if (AllowGlobalObjects && ExchangeTableInfoProvider.IsExchangeRateFromGlobalMainCurrencyMissing(CMSContext.CurrentSiteID))
        {
            ShowWarning(GetString("com.NeedExchangeRateFromGlobal"), null, null);
        }

        if (!RequestHelper.IsPostBack())
        {
            // Init site selector
            SelectSite.SiteID = SiteFilterStartupValue;
        }
    }
Example #14
0
    /// <summary>
    /// Initializes copy from global link.
    /// </summary>
    protected void InitCopyFromGlobalLink()
    {
        // Nothing to be done
        if ((mMainCurrency == null) || string.IsNullOrEmpty(mMainCurrency.CurrencyCode))
        {
            return;
        }

        // Show copy from global link when not configuring global currencies.
        if (ConfiguredSiteID != 0)
        {
            // Allow copying only if global main currency and site main currency are the same
            if (mMainCurrency.CurrencyCode == CurrencyInfoProvider.GetMainCurrencyCode(0))
            {
                // Show "Copy from global" link only if there is at least one global exchange rate table
                DataSet ds = ExchangeTableInfoProvider.GetExchangeTables("ExchangeTableSiteID IS NULL", null, 1, "ExchangeTableID");
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction
                    {
                        ControlType   = HeaderActionTypeEnum.Hyperlink,
                        Text          = GetString("general.copyfromglobal"),
                        OnClientClick = "return ConfirmCopyFromGlobal();",
                        ImageUrl      = GetImageUrl("Objects/Ecommerce_ExchangeTable/fromglobal.png"),
                        CommandName   = COPY_FROM_GLBOAL
                    });

                    CurrentMaster.HeaderActions.ActionPerformed += new CommandEventHandler(HeaderActions_ActionPerformed);

                    // Register javascript to confirm generate
                    string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmExchangeTableFromGlobal")) + ");}";
                    ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script));
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string newElementName;

        if (IsMultiStoreConfiguration)
        {
            newElementName = "new.configuration.globalshippingoptions";
            CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, "Ecommerce.GlobalShippingOptions");
        }
        else
        {
            newElementName = "new.Configuration.ShippingOptions";
            CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, "Configuration.ShippingOptions");
        }

        // Header actions
        HeaderActions actions = CurrentMaster.HeaderActions;

        actions.ActionsList.Add(new HeaderAction
        {
            Text        = GetString("COM_ShippingOption_List.NewItemCaption"),
            RedirectUrl = GetRedirectURL(newElementName),
        });

        // Init Unigrid
        UniGrid.OnAction            += uniGrid_OnAction;
        UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound;
        HandleGridsSiteIDColumn(UniGrid);

        if (UseGlobalObjects && ExchangeTableInfoProvider.IsExchangeRateFromGlobalMainCurrencyMissing(SiteContext.CurrentSiteID))
        {
            ShowWarning(GetString("com.NeedExchangeRateFromGlobal"));
        }

        InitWhereCondition();
    }
    /// <summary>
    /// Checks exchange rates.
    /// </summary>
    private void CheckExchangeRates()
    {
        if (ExchangeRatesCheck)
        {
            int currentSiteID = 0;

            // Check if the site is using global exchage rates
            if (!ECommerceSettings.UseGlobalExchangeRates(CMSContext.CurrentSiteName))
            {
                currentSiteID = CMSContext.CurrentSiteID;
            }

            // Retrieve last valid exchange table
            ExchangeTableInfo et = ExchangeTableInfoProvider.GetLastValidExchangeTableInfo(CMSContext.CurrentSiteID);
            if (et == null)
            {
                DisplayMessage("com.settingschecker.emptyexchangerate");
            }
            else
            {
                DataSet ds = CurrencyInfoProvider.GetCurrencies(currentSiteID, true);

                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    // Prepare where condition
                    StringBuilder sb = new StringBuilder();
                    foreach (DataRow item in ds.Tables[0].Rows)
                    {
                        sb.Append(item["CurrencyID"] + ",");
                    }
                    sb.Remove(sb.Length - 1, 1);

                    // Get exchange rate from global currency, if some global checkboxes are checked
                    if (mGlobalUsage)
                    {
                        double exchangerateFromGlobalCurrency = ExchangeTableInfoProvider.GetLastExchangeRateFromGlobalMainCurrency(CMSContext.CurrentSiteID);
                        if (exchangerateFromGlobalCurrency <= 0)
                        {
                            DisplayMessage("com.settingschecker.emptyexchangerate");
                            return;
                        }
                    }

                    // Get all exchange rates for selected table
                    DataSet exchangeDs = ExchangeRateInfoProvider.GetExchangeRates("(ExchangeTableID = " + et.ExchangeTableID + ") AND (ExchangeRateToCurrencyID IN  (" + sb.ToString() + "))", null);
                    if (DataHelper.DataSourceIsEmpty(exchangeDs))
                    {
                        // If there is only one currency in dataset, do not show error message
                        if (ds.Tables[0].Rows.Count > 1)
                        {
                            DisplayMessage("com.settingschecker.emptyexchangerate");
                            return;
                        }
                    }
                    // Check if count of currencies is same in exchangetable
                    else if ((ds.Tables[0].Rows.Count != exchangeDs.Tables[0].Rows.Count))
                    {
                        // If we are using global objects, there will be one more currency
                        if (mGlobalUsage)
                        {
                            if (ds.Tables[0].Rows.Count != exchangeDs.Tables[0].Rows.Count + 1)
                            {
                                DisplayMessage("com.settingschecker.emptyexchangerate");
                                return;
                            }
                        }
                        else
                        {
                            DisplayMessage("com.settingschecker.emptyexchangerate");
                            return;
                        }
                    }
                    else
                    {
                        foreach (DataRow item in exchangeDs.Tables[0].Rows)
                        {
                            if (item["ExchangeRateValue"] == null)
                            {
                                DisplayMessage("com.settingschecker.emptyexchangerate");
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
Example #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        editGrid.RowDataBound += new GridViewRowEventHandler(editGrid_RowDataBound);

        // Get main currency
        mMainCurrency = CurrencyInfoProvider.GetMainCurrency(this.ConfiguredSiteID);

        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");

        // Control initializations
        lblExchangeTableValidFrom.Text   = GetString("ExchangeTable_Edit.ExchangeTableValidFromLabel");
        lblExchangeTableDisplayName.Text = GetString("ExchangeTable_Edit.ExchangeTableDisplayNameLabel");
        lblExchangeTableValidTo.Text     = GetString("ExchangeTable_Edit.ExchangeTableValidToLabel");

        // Help image
        this.imgHelp.ImageUrl           = GetImageUrl("General/HelpSmall.png");
        this.imgHelp.ToolTip            = GetString("ExchangeTable_Edit.ExchangeRateHelp");
        this.imgHelpFromGlobal.ImageUrl = GetImageUrl("General/HelpSmall.png");
        this.imgHelpFromGlobal.ToolTip  = GetString("ExchangeTable_Edit.ExchangeRateHelp");

        lblRates.Text = GetString("ExchangeTable_Edit.ExchangeRates");

        btnOk.Text = GetString("General.OK");
        dtPickerExchangeTableValidFrom.SupportFolder = "~/CMSAdminControls/Calendar";
        dtPickerExchangeTableValidTo.SupportFolder   = "~/CMSAdminControls/Calendar";

        string currentTableTitle = GetString("ExchangeTable_Edit.NewItemCaption");

        // Get exchangeTable id from querystring
        mExchangeTableId = QueryHelper.GetInteger("exchangeid", 0);
        if (mExchangeTableId > 0)
        {
            exchangeTableObj = ExchangeTableInfoProvider.GetExchangeTableInfo(mExchangeTableId);
            EditedObject     = exchangeTableObj;

            if (exchangeTableObj != null)
            {
                // Check tables site id
                CheckEditedObjectSiteID(exchangeTableObj.ExchangeTableSiteID);
                // Set title
                currentTableTitle = exchangeTableObj.ExchangeTableDisplayName;

                LoadData(exchangeTableObj);

                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    // Show that the exchangeTable was created or updated successfully
                    if (QueryHelper.GetString("saved", "") == "1")
                    {
                        lblInfo.Visible = true;
                        lblInfo.Text    = GetString("General.ChangesSaved");
                    }
                }
            }

            this.CurrentMaster.Title.TitleText  = GetString("ExchangeTable_Edit.HeaderCaption");
            this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_ExchangeTable/object.png");

            // Init Copy from global link
            InitCopyFromGlobalLink();
        }
        // Creating a new exchange table
        else
        {
            if (!RequestHelper.IsPostBack())
            {
                // Preset valid from date
                ExchangeTableInfo tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(this.ConfiguredSiteID);
                if (tableInfo != null)
                {
                    dtPickerExchangeTableValidFrom.SelectedDateTime = tableInfo.ExchangeTableValidTo;
                }
            }
            // Grids are visible only in edit mode
            plcGrid.Visible = false;

            this.CurrentMaster.Title.TitleText  = GetString("ExchangeTable_New.HeaderCaption");
            this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_ExchangeTable/new.png");
        }

        // Initializes page title breadcrumbs control
        string[,] breadcrumbs = new string[2, 3];
        breadcrumbs[0, 0]     = GetString("ExchangeTable_Edit.ItemListLink");
        breadcrumbs[0, 1]     = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/ExchangeRates/ExchangeTable_List.aspx?siteId=" + SiteID;
        breadcrumbs[0, 2]     = "";
        breadcrumbs[1, 0]     = currentTableTitle;
        breadcrumbs[1, 1]     = "";
        breadcrumbs[1, 2]     = "";
        this.CurrentMaster.Title.Breadcrumbs = breadcrumbs;

        this.CurrentMaster.Title.HelpTopicName = "new_rateexchange_rate_edit";
        this.CurrentMaster.Title.HelpName      = "helpTopic";

        plcRateFromGlobal.Visible = IsFromGlobalRateNeeded();

        // Check presence of main currency
        string currencyErr = CheckMainCurrency(ConfiguredSiteID);

        if (!string.IsNullOrEmpty(currencyErr))
        {
            // Show message
            lblNoMainCurrency.Text    = currencyErr;
            plcNoMainCurrency.Visible = true;
            plcRates.Visible          = false;
        }
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        showProductsInTree = ECommerceSettings.DisplayProductsInSectionsTree(CurrentSiteName);

        if (NodeID > 0)
        {
            // Init document list
            docList.Node                           = DocumentHelper.GetDocument(NodeID, CultureCode, true, Tree);
            docList.Grid.GridName                  = "~/CMSModules/Ecommerce/Pages/Tools/Products/Product_List_Documents.xml";
            docList.AdditionalColumns              = "SKUID, DocumentSKUName, NodeParentID, NodeID, NodeSKUID, SKUName, SKUNumber, SKUPrice, SKUAvailableItems, SKUEnabled, SKUSiteID, SKUPublicStatusID, SKUInternalStatusID, SKUReorderAt";
            docList.WhereCodition                  = GetDocumentWhereCondition();
            docList.OrderBy                        = ShowSections ? "CASE WHEN NodeSKUID IS NULL THEN 0 ELSE 1 END, DocumentName" : "DocumentName";
            docList.OnExternalAdditionalDataBound += gridData_OnExternalDataBound;
            docList.OnDocumentFlagsCreating       += docList_OnDocumentFlagsCreating;
            docList.Grid.OnAction                 += gridData_OnAction;
            docList.Grid.RememberStateByParam      = "";
            docList.SelectLanguageJSFunction       = "EditProductInCulture";

            docList.DeleteReturnUrl    = "~/CMSModules/Content/CMSDesk/Delete.aspx?multiple=true";
            docList.PublishReturnUrl   = "~/CMSModules/Content/CMSDesk/PublishArchive.aspx?multiple=true";
            docList.ArchiveReturnUrl   = "~/CMSModules/Content/CMSDesk/PublishArchive.aspx?multiple=true";
            docList.TranslateReturnUrl = "~/CMSModules/Translations/Pages/TranslateDocuments.aspx";

            if (!string.IsNullOrEmpty(ProductsStartingPath))
            {
                docList.CopyMoveLinkStartingPath = ProductsStartingPath;
            }

            string languageSelectionScript = "function EditProductInCulture(nodeId, culture, translated, url) {parent.RefreshTree(nodeId, nodeId); window.location.href = 'Product_Edit_Frameset.aspx?nodeid='+nodeId+'&culture='+culture;}";
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "EditProductInCulture", ScriptHelper.GetScript(languageSelectionScript));

            plcSKUListing.Visible = false;

            // Stop processing SKU table
            gridData.StopProcessing = true;

            EditedObject = docList.Node;

            // Set title
            string title = docList.Node.IsRoot() ? GetString("com.sku.productslist") : docList.Node.GetDocumentName();
            SetTitle("Objects/Ecommerce_SKU/object.png", HTMLHelper.HTMLEncode(title), "product_list", "helpTopic");
        }
        else
        {
            // Init Unigrid
            gridData.OnAction            += gridData_OnAction;
            gridData.OnExternalDataBound += gridData_OnExternalDataBound;

            // Stop processing product document listing
            docList.StopProcessing     = true;
            plcDocumentListing.Visible = false;

            // Set title according display tree setting
            if (DisplayTreeInProducts)
            {
                SetTitle("Objects/Ecommerce_SKU/object.png", GetString("com.sku.unassignedlist"), "stand_alone_SKUs_list", "helpTopic");
            }
            else
            {
                SetTitle("Objects/Ecommerce_SKU/object.png", GetString("com.sku.productslist"), "SKUs_list", "helpTopic");
            }
        }

        // Show warning when exchange rate from global main currency is missing
        if (AllowGlobalObjects && ExchangeTableInfoProvider.IsExchangeRateFromGlobalMainCurrencyMissing(CMSContext.CurrentSiteID))
        {
            ShowWarning(GetString("com.NeedExchangeRateFromGlobal"), null, null);
        }
    }
Example #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        editGrid.RowDataBound += editGrid_RowDataBound;
        btnOk.Click           += (s, args) => { Save(); };

        // Get main currency
        mMainCurrency = CurrencyInfoProvider.GetMainCurrency(ConfiguredSiteID);

        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");

        // Help image
        imgHelp.ImageUrl           = GetImageUrl("General/HelpSmall.png");
        imgHelp.ToolTip            = GetString("ExchangeTable_Edit.ExchangeRateHelp");
        imgHelpFromGlobal.ImageUrl = GetImageUrl("General/HelpSmall.png");
        imgHelpFromGlobal.ToolTip  = GetString("ExchangeTable_Edit.ExchangeRateHelp");

        dtPickerExchangeTableValidFrom.SupportFolder = "~/CMSAdminControls/Calendar";
        dtPickerExchangeTableValidTo.SupportFolder   = "~/CMSAdminControls/Calendar";

        string currentTableTitle = GetString("ExchangeTable_Edit.NewItemCaption");

        // Get exchangeTable id from querystring
        mExchangeTableId = QueryHelper.GetInteger("exchangeid", 0);
        if (mExchangeTableId > 0)
        {
            exchangeTableObj = EditedObject as ExchangeTableInfo;

            if (exchangeTableObj != null)
            {
                // Check tables site id
                CheckEditedObjectSiteID(exchangeTableObj.ExchangeTableSiteID);
                // Set title
                currentTableTitle = exchangeTableObj.ExchangeTableDisplayName;

                LoadData(exchangeTableObj);

                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    // Show that the exchangeTable was created or updated successfully
                    if (QueryHelper.GetString("saved", "") == "1")
                    {
                        // Show message
                        ShowChangesSaved();
                    }
                }
            }

            // Init Copy from global link
            InitCopyFromGlobalLink();
        }
        // Creating a new exchange table
        else
        {
            if (!RequestHelper.IsPostBack())
            {
                // Preset valid from date
                ExchangeTableInfo tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(ConfiguredSiteID);
                if (tableInfo != null)
                {
                    dtPickerExchangeTableValidFrom.SelectedDateTime = tableInfo.ExchangeTableValidTo;
                }
            }
            // Grids are visible only in edit mode
            plcGrid.Visible = false;
        }

        // Initializes page title breadcrumbs control
        string[,] breadcrumbs           = new string[2, 3];
        breadcrumbs[0, 0]               = GetString("ExchangeTable_Edit.ItemListLink");
        breadcrumbs[0, 1]               = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/ExchangeRates/ExchangeTable_List.aspx?siteId=" + SiteID;
        breadcrumbs[0, 2]               = "";
        breadcrumbs[1, 0]               = currentTableTitle;
        breadcrumbs[1, 1]               = "";
        breadcrumbs[1, 2]               = "";
        CurrentMaster.Title.Breadcrumbs = breadcrumbs;

        plcRateFromGlobal.Visible = IsFromGlobalRateNeeded();

        // Check presence of main currency
        string currencyWarning = CheckMainCurrency(ConfiguredSiteID);

        if (!string.IsNullOrEmpty(currencyWarning))
        {
            ShowWarning(currencyWarning, null, null);
            plcGrid.Visible = false;
        }
    }
Example #20
0
    /// <summary>
    /// Saves exchange rates.
    /// </summary>
    private void Save()
    {
        // Check permissions
        CheckConfigurationModification();

        string errorMessage = new Validator().NotEmpty(txtExchangeTableDisplayName.Text.Trim(), GetString("general.requiresdisplayname")).Result;

        if ((errorMessage == "") && (plcRateFromGlobal.Visible))
        {
            errorMessage = new Validator().NotEmpty(txtGlobalExchangeRate.Text.Trim(), GetString("ExchangeTable_Edit.DoubleFormatRequired")).Result;
        }

        if ((errorMessage == "") && (plcRateFromGlobal.Visible))
        {
            if (!ValidationHelper.IsPositiveNumber(txtGlobalExchangeRate.Text.Trim()) || (ValidationHelper.GetDouble(txtGlobalExchangeRate.Text.Trim(), 0) == 0))
            {
                errorMessage = GetString("ExchangeTable_Edit.errorRate");
            }
        }

        // From/to date validation
        if (errorMessage == "")
        {
            if ((!dtPickerExchangeTableValidFrom.IsValidRange()) || (!dtPickerExchangeTableValidTo.IsValidRange()))
            {
                errorMessage = GetString("general.errorinvaliddatetimerange");
            }

            if ((dtPickerExchangeTableValidFrom.SelectedDateTime != DateTime.MinValue) &&
                (dtPickerExchangeTableValidTo.SelectedDateTime != DateTime.MinValue) &&
                (dtPickerExchangeTableValidFrom.SelectedDateTime >= dtPickerExchangeTableValidTo.SelectedDateTime))
            {
                errorMessage = GetString("General.DateOverlaps");
            }
        }

        // Exchange rates validation
        if (errorMessage == String.Empty)
        {
            foreach (TextBox txt in mTextBoxes.Values)
            {
                string tmp = txt.Text.Trim();
                if (tmp != String.Empty)
                {
                    // Exchange rate mus be double
                    if (!ValidationHelper.IsDouble(tmp))
                    {
                        errorMessage = GetString("ExchangeTable_Edit.DoubleFormatRequired");
                        break;
                    }

                    // Exchange rate must be positive
                    double rate = ValidationHelper.GetDouble(tmp, 1);
                    if (rate <= 0)
                    {
                        errorMessage = GetString("ExchangeTable_Edit.errorRate");
                    }
                }
            }
        }

        // Save changes if no validation error
        if (errorMessage == "")
        {
            ExchangeTableInfo exchangeTableObj = ExchangeTableInfoProvider.GetExchangeTableInfo(txtExchangeTableDisplayName.Text.Trim(), SiteInfoProvider.GetSiteName(ConfiguredSiteID));

            // If exchangeTableName value is unique
            if ((exchangeTableObj == null) || (exchangeTableObj.ExchangeTableID == mExchangeTableId))
            {
                // Get ExchangeTableInfo object by primary key
                exchangeTableObj = ExchangeTableInfoProvider.GetExchangeTableInfo(mExchangeTableId);
                if (exchangeTableObj == null)
                {
                    // Create new item -> insert
                    exchangeTableObj = new ExchangeTableInfo();
                    exchangeTableObj.ExchangeTableSiteID = ConfiguredSiteID;
                }

                exchangeTableObj.ExchangeTableValidFrom              = dtPickerExchangeTableValidFrom.SelectedDateTime;
                exchangeTableObj.ExchangeTableDisplayName            = txtExchangeTableDisplayName.Text.Trim();
                exchangeTableObj.ExchangeTableValidTo                = dtPickerExchangeTableValidTo.SelectedDateTime;
                exchangeTableObj.ExchangeTableRateFromGlobalCurrency = 0;
                if (plcRateFromGlobal.Visible)
                {
                    exchangeTableObj.ExchangeTableRateFromGlobalCurrency = ValidationHelper.GetDouble(txtGlobalExchangeRate.Text.Trim(), 0);
                }

                // Save general exchange table information
                ExchangeTableInfoProvider.SetExchangeTableInfo(exchangeTableObj);

                // Save rates on edit
                if (mExchangeTableId > 0)
                {
                    foreach (TextBox txt in mTextBoxes.Values)
                    {
                        if (mData[txt.ClientID] != null)
                        {
                            int  rateCurrencyId = ValidationHelper.GetInteger(((DataRowView)mData[txt.ClientID])["CurrencyID"], 0);
                            bool rateExists     = mExchangeRates.ContainsKey(rateCurrencyId);

                            if (rateExists)
                            {
                                ExchangeRateInfo rate = new ExchangeRateInfo(mExchangeRates[rateCurrencyId]);

                                if (txt.Text.Trim() == String.Empty)
                                {
                                    // Remove exchange rate
                                    ExchangeRateInfoProvider.DeleteExchangeRateInfo(rate);
                                }
                                else
                                {
                                    rate.ExchangeRateValue = ValidationHelper.GetDouble(txt.Text.Trim(), 0);
                                    // Update rate
                                    ExchangeRateInfoProvider.SetExchangeRateInfo(rate);
                                }
                            }
                            else
                            {
                                if (txt.Text.Trim() != String.Empty)
                                {
                                    // Insert exchange rate
                                    ExchangeRateInfo rate = new ExchangeRateInfo();
                                    rate.ExchangeRateToCurrencyID = rateCurrencyId;
                                    rate.ExchangeRateValue        = ValidationHelper.GetDouble(txt.Text.Trim(), 0);
                                    rate.ExchangeTableID          = mExchangeTableId;

                                    ExchangeRateInfoProvider.SetExchangeRateInfo(rate);
                                }
                            }
                        }
                    }
                }

                URLHelper.Redirect("ExchangeTable_Edit.aspx?exchangeid=" + exchangeTableObj.ExchangeTableID + "&saved=1&siteId=" + SiteID);
            }
            else
            {
                // Show error message
                ShowError(GetString("ExchangeTable_Edit.CurrencyNameExists"));
            }
        }
        else
        {
            // Show error message
            ShowError(errorMessage);
        }
    }
Example #21
0
    /// <summary>
    /// Checks exchange rates.
    /// </summary>
    private void CheckExchangeRates()
    {
        if (ExchangeRatesCheck)
        {
            int currentSiteID = 0;

            // Check if the site is using global exchange rates
            if (!ECommerceSettings.UseGlobalExchangeRates(SiteContext.CurrentSiteName))
            {
                currentSiteID = SiteContext.CurrentSiteID;
            }

            // Retrieve last valid exchange table
            ExchangeTableInfo et = ExchangeTableInfoProvider.GetLastValidExchangeTableInfo(SiteContext.CurrentSiteID);
            if (et == null)
            {
                DisplayMessage("com.settingschecker.emptyexchangerate");
            }
            else
            {
                DataSet ds = CurrencyInfoProvider.GetCurrencies(currentSiteID, true);

                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    // Get exchange rate from global currency, if some global checkboxes are checked
                    if (mGlobalUsage)
                    {
                        double exchangeRateFromGlobalCurrency = ExchangeTableInfoProvider.GetLastExchangeRateFromGlobalMainCurrency(SiteContext.CurrentSiteID);
                        if (exchangeRateFromGlobalCurrency <= 0)
                        {
                            DisplayMessage("com.settingschecker.emptyexchangerate");
                            return;
                        }
                    }

                    // Prepare where condition
                    var currencyIds = DataHelper.GetIntegerValues(ds.Tables[0], "CurrencyID");

                    // Get all exchange rates for selected table
                    DataSet exchangeDs = ExchangeRateInfoProvider.GetExchangeRates(et.ExchangeTableID)
                                         .WhereIn("ExchangeRateToCurrencyID", currencyIds);

                    if (DataHelper.DataSourceIsEmpty(exchangeDs))
                    {
                        // If there is only one currency in dataset, do not show error message
                        if (ds.Tables[0].Rows.Count > 1)
                        {
                            DisplayMessage("com.settingschecker.emptyexchangerate");
                            return;
                        }
                    }
                    // Check if count of currencies is same in exchange table
                    else if ((ds.Tables[0].Rows.Count != exchangeDs.Tables[0].Rows.Count))
                    {
                        // If we are using global objects, there will be one more currency
                        if (mGlobalUsage)
                        {
                            if (ds.Tables[0].Rows.Count != exchangeDs.Tables[0].Rows.Count + 1)
                            {
                                DisplayMessage("com.settingschecker.emptyexchangerate");
                                return;
                            }
                        }
                        else
                        {
                            DisplayMessage("com.settingschecker.emptyexchangerate");
                            return;
                        }
                    }
                    else
                    {
                        foreach (DataRow item in exchangeDs.Tables[0].Rows)
                        {
                            if (item["ExchangeRateValue"] == null)
                            {
                                DisplayMessage("com.settingschecker.emptyexchangerate");
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        editGrid.RowDataBound += editGrid_RowDataBound;
        btnOk.Click           += (s, args) => Save();

        // Get main currency
        mMainCurrency = CurrencyInfoProvider.GetMainCurrency(ConfiguredSiteID);

        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");

        // Help image
        iconHelpGlobalExchangeRate.ToolTip = GetString("ExchangeTable_Edit.ExchangeRateHelp");
        iconHelpMainExchangeRate.ToolTip   = GetString("ExchangeTable_Edit.ExchangeRateHelp");

        // Use time zones for DateTimePickers
        CMS.Globalization.TimeZoneInfo tzi = TimeZoneHelper.GetTimeZoneInfo(MembershipContext.AuthenticatedUser, SiteContext.CurrentSite);
        dtPickerExchangeTableValidFrom.TimeZone       = TimeZoneTypeEnum.Custom;
        dtPickerExchangeTableValidFrom.CustomTimeZone = tzi;
        dtPickerExchangeTableValidTo.TimeZone         = TimeZoneTypeEnum.Custom;
        dtPickerExchangeTableValidTo.CustomTimeZone   = tzi;

        // Get exchangeTable id from query string
        mExchangeTableId = QueryHelper.GetInteger("exchangeid", 0);
        if (mExchangeTableId > 0)
        {
            exchangeTableObj = EditedObject as ExchangeTableInfo;

            if (exchangeTableObj != null)
            {
                // Check tables site id
                CheckEditedObjectSiteID(exchangeTableObj.ExchangeTableSiteID);

                LoadData(exchangeTableObj);

                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    // Show that the exchangeTable was created or updated successfully
                    if (QueryHelper.GetString("saved", "") == "1")
                    {
                        // Show message
                        ShowChangesSaved();
                    }
                }
            }

            // Init Copy from global link
            InitCopyFromGlobalLink();

            // Check presence of main currency
            plcGrid.Visible = CheckMainCurrency(ConfiguredSiteID);

            plcRateFromGlobal.Visible = IsFromGlobalRateNeeded();
        }
        // Creating a new exchange table
        else
        {
            if (!RequestHelper.IsPostBack())
            {
                // Preset valid from date
                ExchangeTableInfo tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(ConfiguredSiteID);
                if (tableInfo != null)
                {
                    dtPickerExchangeTableValidFrom.SelectedDateTime = tableInfo.ExchangeTableValidTo;
                }
            }
            // Grids are visible only in edit mode
            plcGrid.Visible = false;
        }

        // Register bootstrap tooltip over help icons
        ScriptHelper.RegisterBootstrapTooltip(Page, ".info-icon > i");
    }
    /// <summary>
    /// Inits the selector.
    /// </summary>
    protected void InitSelector()
    {
        if (this.RenderInline)
        {
            this.pnlUpdate.RenderMode = UpdatePanelRenderMode.Inline;
        }
        if (this.ShowAllItems)
        {
            this.uniSelector.MaxDisplayedItems = 1000;
        }

        this.uniSelector.EnabledColumnName = "CurrencyEnabled";
        this.uniSelector.IsLiveSite        = this.IsLiveSite;
        this.uniSelector.AllowEmpty        = this.AddNoneRecord;

        if (DoFullPostback)
        {
            ControlsHelper.RegisterPostbackControl(this.uniSelector.DropDownSingleSelect);
        }

        if (AddSelectRecord)
        {
            string[,] fields = new string[1, 2];
            fields[0, 0]     = GetString("currencyselector.select");
            fields[0, 1]     = "-1";
            this.uniSelector.SpecialFields = fields;
        }

        CurrencyInfo main           = CurrencyInfoProvider.GetMainCurrency(this.SiteID);
        int          mainCurrencyId = (main != null) ? main.CurrencyID : 0;

        string where = "";
        if (DisplayOnlyWithExchangeRate)
        {
            ExchangeTableInfo tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(this.SiteID);
            if (tableInfo != null)
            {
                where = "(CurrencyID = " + mainCurrencyId + " OR CurrencyID IN (SELECT ExchangeRateToCurrencyID FROM COM_CurrencyExchangeRate WHERE COM_CurrencyExchangeRate.ExchangeTableID = " + tableInfo.ExchangeTableID + ") AND CurrencyEnabled = 1)";
            }
            else
            {
                where = "(0=1)";
            }
        }

        if (this.AddSiteDefaultCurrency && (main != null))
        {
            where = SqlHelperClass.AddWhereCondition(where, "CurrencyID = " + mainCurrencyId, "OR");
        }

        if (this.ExcludeSiteDefaultCurrency && (main != null))
        {
            where = SqlHelperClass.AddWhereCondition(where, "(NOT CurrencyID = " + mainCurrencyId + ")");
        }

        // Select only records by speciffied site
        if (SiteID >= 0)
        {
            // Show global records by default
            int filteredSiteId = 0;

            // Check configuration when site specified
            if (SiteID > 0)
            {
                // Show site specific records when not using global statuses
                filteredSiteId = UsingGlobalObjects ? 0 : SiteID;
            }

            where = SqlHelperClass.AddWhereCondition(where, "(ISNULL(CurrencySiteID, 0) = " + filteredSiteId + ")");
        }

        // Filter out only enabled items
        if (this.DisplayOnlyEnabled)
        {
            where = SqlHelperClass.AddWhereCondition(where, "CurrencyEnabled = 1");
        }

        // Add items which have to be on the list (if any)
        string additionalList = SqlHelperClass.GetSafeQueryString(this.AdditionalItems, false);

        if ((!string.IsNullOrEmpty(where)) && (!string.IsNullOrEmpty(additionalList)))
        {
            where = SqlHelperClass.AddWhereCondition(where, "(CurrencyID IN (" + additionalList + "))", "OR");
        }

        // Selected value (if any) must be on the list
        if ((!string.IsNullOrEmpty(where)) && (CurrencyID > 0) && (IncludeSelected))
        {
            where = SqlHelperClass.AddWhereCondition(where, "(CurrencyID = " + CurrencyID + ")", "OR");
        }

        // Set where condition
        this.uniSelector.WhereCondition = where;
    }