瑞士法郎货币无法正确显示

时间:2012-04-17 09:48:26

标签: asp.net xslt currency aspdotnetstorefront currency-formatting

我有一个使用aspdotnetstorefront构建的电子商务网站。 区域设置设置为

  

de_DE这个

货币是瑞士法郎,它显示如下:

139,00 (CHF)

我在收到通知时遇到问题,价格如下: (这是错误的应该是 139,00(瑞士法郎)

  

1.390.000,00

货币的显示规格设置为:

#,###.00

我的XML包(受影响的行)如下所示:

<xsl:value-of select="receipt:FormatCurrencyWithoutCurrencyCode(Price)" disable-output-escaping="yes" />

FormatCurrencyWithoutCurrencyCode:

#region FormatCurrencyWithoutCurrencyCode
    /// <summary>
    /// Format the currency value into it's localized currency pattern
    /// </summary>
    /// <param name="sCurrencyValue">The currency value</param>
    /// <returns>The formatted currency string</returns>
    public virtual string FormatCurrencyWithoutCurrencyCode(string sCurrencyValue)
    {
        return FormatCurrencyWithoutCurrencyCode(sCurrencyValue, ThisCustomer.CurrencySetting);
    }

    /// <summary>
    /// Format the currency value into it's localized currency pattern
    /// </summary>
    /// <param name="sCurrencyValue">The currency value</param>
    /// <param name="sTargetCurrency">The target currency to base on</param>
    /// <returns>The formatted currency string</returns>
    public virtual string FormatCurrencyWithoutCurrencyCode(string sCurrencyValue, string sTargetCurrency)
    {
        InputValidator iv = new InputValidator("FormatCurrencyWithoutCurrencyCode");
        decimal value = iv.ValidateDecimal("CurrencyValue", sCurrencyValue);
        string targetCurrency = iv.ValidateString("TargetCurrency", sTargetCurrency);

        decimal amt = Currency.Convert(value, Localization.GetPrimaryCurrency(), targetCurrency);

        String tmpS = String.Empty;
        // get currency specs for display control:
        String DisplaySpec = Currency.GetDisplaySpec(targetCurrency);
        String DisplayLocaleFormat = Currency.GetDisplayLocaleFormat(targetCurrency);

        if (DisplaySpec.Length != 0 && Currency.NumPublishedCurrencies() > 1)
        {
            tmpS = amt.ToString(DisplaySpec);
        }
        else if (DisplayLocaleFormat.Length != 0)
        {
            CultureInfo formatter = new CultureInfo(DisplayLocaleFormat);

            // for debugging purposes
            if (CommonLogic.QueryStringUSInt("dec") > 0)
            {
                int decimalPlaces = CommonLogic.QueryStringUSInt("dec");
                formatter.NumberFormat.CurrencyDecimalDigits = decimalPlaces;
            }

            tmpS = amt.ToString("C", formatter);
            if (tmpS.StartsWith("("))
            {
                tmpS = "-" + tmpS.Replace("(", "").Replace(")", "");
            }
        }
        else
        {
            tmpS = Localization.CurrencyStringForDisplayWithoutExchangeRate(amt, false); // use some generic default!
        }

        return tmpS;
    }

    #endregion

0 个答案:

没有答案