Exemple #1
0
        //GET: Currency
        //public ActionResult Index()
        //{
        //    return View();
        //}
        //DataTable
        public ActionResult Currency()
        {
            List <Currency> currencies = currencyManager.GetAllCurrencies();

            ViewBag.Currency = currencies;
            return(View());
        }
        protected void gvLiveRates_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "ApplyLiveRate")
            {
                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = gvLiveRates.Rows[index];

                Label          lblCurrencyCode = row.FindControl("lblCurrencyCode") as Label;
                DecimalTextBox txtRate         = row.FindControl("txtRate") as DecimalTextBox;

                Currency           currency   = null;
                CurrencyCollection currencies = CurrencyManager.GetAllCurrencies();
                foreach (Currency currency2 in currencies)
                {
                    if (currency2.CurrencyCode.ToLower() == lblCurrencyCode.Text.ToLower())
                    {
                        currency = currency2;
                    }
                }
                if (currency != null)
                {
                    CurrencyManager.UpdateCurrency(currency.CurrencyId, currency.Name, currency.CurrencyCode,
                                                   txtRate.Value, currency.DisplayLocale, currency.CustomFormatting, currency.Published, currency.DisplayOrder,
                                                   currency.CreatedOn, DateTime.Now);
                    BindCurrencyGrid();
                }
            }
        }
        protected void BindCurrencyGrid()
        {
            CurrencyCollection currencyCollection = CurrencyManager.GetAllCurrencies();

            gvCurrencies.DataSource = currencyCollection;
            gvCurrencies.DataBind();
        }
Exemple #4
0
        /// <summary>
        /// Gets currency string
        /// </summary>
        /// <param name="amount">Amount</param>
        /// <param name="showCurrency">A value indicating whether to show a currency</param>
        /// <param name="targetCurrency">Target currency</param>
        /// <returns>Currency string without exchange rate</returns>
        public static string GetCurrencyString(decimal amount,
                                               bool showCurrency, Currency targetCurrency)
        {
            string result = string.Empty;

            if (!String.IsNullOrEmpty(targetCurrency.CustomFormatting))
            {
                result = amount.ToString(targetCurrency.CustomFormatting);
            }
            else
            {
                if (!String.IsNullOrEmpty(targetCurrency.DisplayLocale))
                {
                    result = amount.ToString("C", new CultureInfo(targetCurrency.DisplayLocale));
                }
                else
                {
                    result = String.Format("{0} ({1})", amount.ToString("N"), targetCurrency.CurrencyCode);
                    return(result);
                }
            }

            if (showCurrency && CurrencyManager.GetAllCurrencies().Count > 1)
            {
                result = String.Format("{0} ({1})", result, targetCurrency.CurrencyCode);
            }
            return(result);
        }
Exemple #5
0
        private void BindCurrencies()
        {
            CurrencyCollection currencies = CurrencyManager.GetAllCurrencies();

            if (currencies.Count > 1)
            {
                this.Visible = true;
                this.ddlCurrencies.Items.Clear();
                Currency customerCurrency = NopContext.Current.WorkingCurrency;
                foreach (Currency currency in currencies)
                {
                    ListItem item = new ListItem(currency.Name, currency.CurrencyID.ToString());
                    this.ddlCurrencies.Items.Add(item);
                }
                if (customerCurrency != null)
                {
                    CommonHelper.SelectListItem(this.ddlCurrencies, customerCurrency.CurrencyID);
                }
            }
            else
            {
                this.Visible = false;
            }
        }