예제 #1
0
 public MainWindow()
 {
     InitializeComponent();
     CBDeviseEnd.ItemsSource = Currency.GetValues(typeof(Currency)).Cast <Currency>();
     CCSoap = new CurrencyConvertorSoapClient();
     //{System.ServiceModel.ChannelFactoryRefCache<WpfApplicationSysDisAmort.ServiceCurrencyConvertor.CurrencyConvertorSoap>.EndpointTraitComparer}
 }
예제 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            CurrencyConvertorSoapClient client = new CurrencyConvertorSoapClient();
            double result = client.ConversionRate((Currency)cmb1.Items[cmb1.SelectedIndex], (Currency)cmb2.Items[cmb2.SelectedIndex]);

            lbl.Content = int.Parse(tb.Text) * result;
        }
        List <KeyValuePair <string, decimal> > ExchangeRateProvider.GetCurrencyListwithValues()
        {
            Currency curdef = (Currency)Enum.Parse(typeof(Currency), "EUR");

            BasicHttpBinding binding = new BasicHttpBinding();

            //Specify the address to be used for the client.
            EndpointAddress address = new EndpointAddress(getServiceUrl());

            CRMGG.ExchangeRates.CurrencyConvertor.CurrencyConvertorSoapClient ws = new CurrencyConvertorSoapClient(binding, address);


            if (ExchangeRates != null)
            {
                return(ExchangeRates);
            }
            else
            {
                ExchangeRates = new List <KeyValuePair <string, decimal> >();
                foreach (Currency cur in Enum.GetValues(typeof(Currency)))
                {
                    decimal dblRate = Convert.ToDecimal(ws.ConversionRate(curdef, cur));

                    ExchangeRates.Add(new KeyValuePair <string, decimal>(cur.ToString(), dblRate));
                }


                return(ExchangeRates);
            }
        }
예제 #4
0
 public double Currency(string from, string to)
 {
     CurrencyConvertorSoapClient client = new CurrencyConvertorSoapClient();
     var rate = client.ConversionRate((amazon.Currency.Currency)Enum.Parse(typeof(amazon.Currency.Currency), from),
         (amazon.Currency.Currency)Enum.Parse(typeof(amazon.Currency.Currency), to));
     return rate;
 }
        public double ConversionRate(string fromCurrency, string toCurrency)
        {
            CurrencyConvertorSoapClient client = new CurrencyConvertorSoapClient("CurrencyConvertorSoap");
            double rate = client.ConversionRate((Currency)Enum.Parse(typeof(Currency), fromCurrency), (Currency)Enum.Parse(typeof(Currency), toCurrency));

            return rate;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            decimal totalAr = 0;
            CurrencyConvertorSoapClient client = new CurrencyConvertorSoapClient();
            double usdCurrency = client.ConversionRate(Currency.ARS, Currency.USD);
            string state       = (string)Session["state"];

            if (state == "deleteError")
            {
                lblState.CssClass = "deleteError";
                Session["state"]  = "unmodified";
            }
            else if (state == "purchaseCompleted")
            {
                lblState.CssClass = "purchaseCompleted";
                Session["state"]  = "unmodified";
            }
            try
            {
                if (!(Session["myCart"] == null))
                {
                    foreach (LineaVenta lineaVenta in (List <LineaVenta>)Session["myCart"])
                    {
                        Producto producto = ProductLogic.GetProducto(lineaVenta.ProductId);

                        TableRow row = new TableRow();
                        row.ID       = producto.ProductID.ToString();
                        row.CssClass = "lineaVenta";

                        TableCell quantity = new TableCell();
                        quantity.Text = lineaVenta.Quantity.ToString();
                        row.Cells.Add(quantity);

                        TableCell name = new TableCell();
                        name.Text = producto.ProductName;
                        row.Cells.Add(name);

                        TableCell price = new TableCell();
                        price.Text = "$ " + decimal.Round(producto.UnitPrice, 2).ToString();
                        row.Cells.Add(price);

                        TableCell subtotal = new TableCell();
                        subtotal.Text = "$ " + decimal.Round((producto.UnitPrice * lineaVenta.Quantity), 2).ToString();
                        row.Cells.Add(subtotal);

                        asptLineaVenta.Rows.Add(row);
                        totalAr += producto.UnitPrice * lineaVenta.Quantity;
                    }
                }
                lblTotal.Text = "AR$ " + decimal.Round(totalAr, 2).ToString() + " (US$ " + decimal.Round((totalAr * (decimal)usdCurrency), 2).ToString() + ")";
            }
            catch (NullReferenceException)
            {
                lblState.CssClass = "dbConnectionError";
            }
        }
예제 #7
0
        private void Convert_Click(object sender, RoutedEventArgs e)
        {
            CurrencyConvertorSoapClient client = new CurrencyConvertorSoapClient("CurrencyConvertorSoap");

            double convertionRate = client.ConversionRate(Currency.USD, Currency.NOK);

            double USD = double.Parse(USDAmount.Text);

            NOKAmount.Text = (USD * convertionRate).ToString();
        }
        public double GetRate(Entities.Currency source, Entities.Currency target)
        {
            if (myClient == null)
            {
                myClient = new CurrencyConvertorSoapClient(new BasicHttpBinding(), new EndpointAddress("http://www.webservicex.net/CurrencyConvertor.asmx"));
            }

            var sourceCurrency = (CurrencyConverter.Currency)Enum.Parse(typeof(CurrencyConverter.Currency), source.Symbol);
            var targetCurrency = (CurrencyConverter.Currency)Enum.Parse(typeof(CurrencyConverter.Currency), target.Symbol);

            var rate = myClient.ConversionRate(sourceCurrency, targetCurrency);

            return(rate);
        }
예제 #9
0
        protected void Calculate_Click(object sender, EventArgs e)
        {
            CurrencyConvertorSoapClient client = new CurrencyConvertorSoapClient("CurrencyConvertorSoap");

            double convertionRate = client.ConversionRate(Currency.USD, Currency.NOK);

            double dUSD = 0.0d;

            if (double.TryParse(USD.Text, out dUSD))
            {
                NOK.Text = (dUSD * convertionRate).ToString();
            }
            else
            {
                NOK.Text = "That's not a number!";
            }
        }
예제 #10
0
        private void ConvertCurrency_Click(object sender, RoutedEventArgs e)
        {
            double parsed;
            var    wasParsed = double.TryParse(SourceCurrencyValue.Text, out parsed);

            if (!wasParsed)
            {
                Result.Text = "Enter a valid value";
                return;
            }
            var currencySource = (Currency)Enum.Parse(typeof(Currency), lpkSourceCurrency.SelectedItem.ToString());
            var currencyTarget = (Currency)Enum.Parse(typeof(Currency), lpkTargetCurrency.SelectedItem.ToString());
            var service        = new CurrencyConvertorSoapClient();

            service.ConversionRateCompleted += service_ConversionRateCompleted;
            service.ConversionRateAsync(currencySource, currencyTarget);
        }
예제 #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["user_name"] == null || Session["user_name"] == "")
        {
            Response.Redirect("Login.aspx");
        }
        else
        {
            s           = Session["user_name"].ToString();
            id          = Session["user_id"].ToString();
            Label1.Text = s;

            if (!this.IsPostBack)
            {
                con = new SqlConnection(str);
                con.Open();
                cmd = new SqlCommand("select * from registration where username=@1", con);
                cmd.Parameters.AddWithValue("@1", s);
                sdr = cmd.ExecuteReader();
                if (sdr.Read())
                {
                    String imgname = sdr.GetString(5);
                    Image1.ImageUrl = imgname;
                }
            }
        }


        try
        {
            CurrencyConvertorSoapClient c = new CurrencyConvertorSoapClient();
            double rate = c.ConversionRate(Currency.USD, Currency.INR);
            Label6.Text = rate.ToString();
        }
        catch (InvalidOperationException ex)
        {
            Response.Write(ex.Message);
        }


        TextBox1.Enabled = false;
        TextBox2.Enabled = false;
        TextBox3.Enabled = false;
        TextBox4.Enabled = false;
        TextBox5.Enabled = false;
    }
예제 #12
0
    /// <summary>
    /// handles page load event
    /// </summary>
    /// <param name="sender">sender of event</param>
    /// <param name="e">event arguments</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        // only run if page is not requested from a postback
        if (!IsPostBack)
        {
            try
            {
                // select the client id from user's client number
                int clientNumber = int.Parse(Page.User.Identity.Name);
                int clientId = dataContext.Clients.Where(
                    client => client.ClientNumber == clientNumber)
                    .Select(client => client.ClientId).First();

                // store clientId in session variable
                Session["ClientId"] = clientId;

                //set the client number label text
                lblClientNumber.Text = clientNumber.ToString();

                // select bank accounts where client id matches the current user
                IQueryable<BankAccount> accounts =
                    from account in dataContext.BankAccounts
                    where account.ClientId == clientId
                    select account;

                //set up databinding for the table
                gvAccounts.DataSource = accounts.ToList();
                gvAccounts.DataBind();

                // set currency conversion
                CurrencyConvertorSoapClient convertor =
                    new CurrencyConvertorSoapClient("CurrencyConvertorSoap");
                lblExchangeRate.Text =
                    String.Format("$1 USD = {0:c} CAD",
                        convertor.ConversionRate(Currency.CAD, Currency.USD));

            }
            catch (Exception ex)
            {
                // display error message
                Utility.handleError("Database error occured: " + ex.Message, lblMessage);
            }
        }
    }
예제 #13
0
        public virtual ActionResult ConversionRate(string fromCurrency, string toCurrency)
        {
            var rate = double.NaN;

            try
            {
                if (!string.IsNullOrEmpty(fromCurrency) && !string.IsNullOrEmpty(toCurrency))
                {
                    Currency fromCur = (Currency)(Enum.Parse(typeof(Currency), fromCurrency));
                    Currency toCur   = (Currency)(Enum.Parse(typeof(Currency), toCurrency));

                    CurrencyConvertorSoapClient client = new CurrencyConvertorSoapClient("CurrencyConvertorSoap");
                    rate = client.ConversionRate(fromCur, toCur);
                }
            }
            catch (Exception)
            {
            }
            return(Json(new { Result = rate }));
        }
예제 #14
0
파일: Common.cs 프로젝트: reachKumar/POC
        public static string GetCurrencyUSDollarValue(string strFromCurrency)
        {
            string strReturnValue = string.Empty;

            try
            {
                Currency fromCurrency = new Currency();
                foreach (Currency currency in Enum.GetValues(typeof(Currency)))
                {
                    if (currency.ToString() == strFromCurrency)
                    {
                        fromCurrency = currency;
                    }
                }
                CurrencyConvertorSoapClient soapClient = new CurrencyConvertorSoapClient();
                double rate = soapClient.ConversionRate(fromCurrency, Currency.USD);
                strReturnValue = rate.ToString();
            }
            catch { }
            return(strReturnValue);
        }
예제 #15
0
        public double ConvertEuroTo(string currencyTo, double value)
        {
            if (currencyTo.ToLower() == "eur") return value;

            if (!_conversionRates.ContainsKey(currencyTo))
            {
                CurrencyService.Currency currencyToEnum;

                Enum.TryParse(currencyTo, true, out currencyToEnum);

                if (currencyToEnum == CurrencyService.Currency.EUR)
                    return value;

                CurrencyConvertorSoap convertor = new CurrencyConvertorSoapClient();

                var rate = convertor.ConversionRate(CurrencyService.Currency.EUR, currencyToEnum);

                _conversionRates.AddOrUpdate(currencyTo, ad => rate, (s, d) => rate);
            }

            var finalRate = _conversionRates[currencyTo];

            return value * finalRate;
        }
예제 #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["user_name"] == null || Session["user_name"] == "")
        {
            Response.Redirect("Login.aspx");
        }
        else
        {

            s = Session["user_name"].ToString();
            id = Session["user_id"].ToString();
            Label1.Text = s;

            if (!this.IsPostBack)
            {
                con = new SqlConnection(str);
                con.Open();
                cmd = new SqlCommand("select * from registration where username=@1", con);
                cmd.Parameters.AddWithValue("@1",s);
                sdr = cmd.ExecuteReader();
                if(sdr.Read())
                {
                    String imgname = sdr.GetString(5);
                    Image1.ImageUrl = imgname;
                }
            }
        }

        try
        {
            CurrencyConvertorSoapClient c = new CurrencyConvertorSoapClient();
            double rate = c.ConversionRate(Currency.USD, Currency.INR);
            Label6.Text = rate.ToString();
        }
        catch(InvalidOperationException ex)
        {
            Response.Write(ex.Message);
        }

        TextBox1.Enabled = false;
        TextBox2.Enabled = false;
        TextBox3.Enabled = false;
        TextBox4.Enabled = false;
        TextBox5.Enabled = false;
    }
예제 #17
0
        public Form1()
        {
            var delayedStock = new DelayedStockQuoteSoapClient();
            Controls.Add(new Service("DelayedStockQuoteSoapClient/QuickQuote", "GOOG",
                async s => (await delayedStock.GetQuickQuoteAsync(s, "0")).ToString(CultureInfo.CurrentCulture)));
            Controls.Add(new Service("DelayedStockQuoteSoapClient/Quote", "GOOG",
                async s => (await delayedStock.GetQuoteAsync(s, "0")).ChangePercent));
            var ip2GeoSoap = new P2GeoSoapClient();
            Controls.Add(new Service("IP2GeoSoap/IP", "213.180.141.140",
                async s => (await ip2GeoSoap.ResolveIPAsync(s, "0")).City));
            //-> http://www.webservicex.net/ConvertTemperature.asmx?WSDL
            var temperature = new ConvertTemperatureSoapClient();
            Controls.Add(new Service("ConvTemp", "0",
                async s =>
                    (await
                        temperature.ConvertTempAsync(double.Parse(s), TemperatureUnit.degreeCelsius,
                            TemperatureUnit.kelvin)).ToString(CultureInfo.CurrentCulture)));
            //-> WSDL
            var curControl = new CurrencyConvertorSoapClient();
            Controls.Add(new Service("CurrConv", "5",
                async s => (double.Parse(s) * await curControl.ConversionRateAsync(Currency.USD, Currency.EUR)).ToString(CultureInfo.InvariantCulture)));

            var weather = new GlobalWeatherSoapClient();
            Controls.Add(new Service("Weather", "Szczecin", async s =>
            {
                var xml = await weather.GetWeatherAsync(s, "Poland");
                return CurrentWeather.ConvertXml(xml).Temperature;
            }));

            var runall = new Button { Text = "Run all", Dock = DockStyle.Bottom };
            runall.Click += (s, ev) => { Service.GoAll(); };
            Controls.Add(runall);
        }
 public static void Main(string[] args)
 {
     var client = new CurrencyConvertorSoapClient("CurrencyConvertorSoap");
     var conv = client.ConversionRate(Currency.USD, Currency.EUR);
     Console.WriteLine("Conversion rate from USD to EUR is {0}", conv);
 }
 public void SyncRateData()
 {
     if (!DeviceNetworkInformation.IsNetworkAvailable)
     {
         this.Status = 0;
     }
     else
     {
         this.Status = 1;
         this.syncClient = new CurrencyConvertorSoapClient();
         this.syncClient.ConversionRateCompleted += new System.EventHandler<ConversionRateCompletedEventArgs>(this.syncClient_ConversionRateCompleted);
         this.syncClient.CloseCompleted += new System.EventHandler<AsyncCompletedEventArgs>(this.syncClient_CloseCompleted);
         this.nextCurrencyIndex = 0;
         this.stepIndex = 0;
         this.SyncStep(0, this.nextCurrencyIndex++);
     }
 }
예제 #20
0
        public decimal getRate(string fromCurrencyIsoCode, string toCurrencyIsoCode)
        {
            if (CurrentProvider == null)
            {
                throw new Exception("Please Setup the Provider before try to get the Exchange Rate");
            }
            if (CurrentProvider.GetType() == typeof(ExchangeRateWebserviceX))
            {
                BasicHttpBinding binding = new BasicHttpBinding();

                //Specify the address to be used for the client.
                EndpointAddress address = new EndpointAddress(CurrentProvider.getServiceUrl());

                CurrencyConvertorSoapClient ws = new CurrencyConvertorSoapClient(binding, address);
                Currency curdef  = (Currency)Enum.Parse(typeof(Currency), fromCurrencyIsoCode);
                Currency cur     = (Currency)Enum.Parse(typeof(Currency), toCurrencyIsoCode);
                decimal  dblRate = Convert.ToDecimal(ws.ConversionRate(curdef, cur));
                return(dblRate);
            }

            decimal result = -1;
            string  providerDefaultCurrencyIsoCode = CurrentProvider.getDefaultCurrencyISOCode();
            List <KeyValuePair <string, decimal> > exchangeratelist = CurrentProvider.GetCurrencyListwithValues();

            if (fromCurrencyIsoCode.ToLower() == toCurrencyIsoCode.ToLower())
            {
                //c'est la meme devise donc on retourne 1
                return(1);
            }

            if (providerDefaultCurrencyIsoCode.ToLower() == fromCurrencyIsoCode.ToLower())
            {
                //c'est la devise par defaut du provider donc pas de calcul on retourne le taux de change fourni
                foreach (var excR in exchangeratelist)
                {
                    if (excR.Key.ToLower() == toCurrencyIsoCode.ToLower())
                    {
                        return(excR.Value);
                    }
                }
            }

            if (providerDefaultCurrencyIsoCode.ToLower() == toCurrencyIsoCode.ToLower())
            {
                //le to est la devise par defaut du provider il faut donc retourner 1 par le taux de change
                foreach (var excR in exchangeratelist)
                {
                    if (excR.Key.ToLower() == fromCurrencyIsoCode.ToLower())
                    {
                        return(1 / excR.Value);
                    }
                }
            }

            if (providerDefaultCurrencyIsoCode.ToLower() != toCurrencyIsoCode.ToLower() && providerDefaultCurrencyIsoCode.ToLower() != fromCurrencyIsoCode.ToLower())
            {
                //le calcul n'est pas fait par rapport à la devise par defaut du provider, il faut donc faire un calcul

                decimal fromexcR = -1;
                decimal toexcR   = -1;
                foreach (var excR in exchangeratelist)
                {
                    if (excR.Key.ToLower() == fromCurrencyIsoCode.ToLower())
                    {
                        fromexcR = excR.Value;
                    }

                    if (excR.Key.ToLower() == toCurrencyIsoCode.ToLower())
                    {
                        toexcR = excR.Value;
                    }
                }

                if (fromexcR != -1 && toexcR != -1)
                {
                    return(toexcR / fromexcR);
                }
            }


            return(result);
        }
예제 #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            decimal totalAr = 0;
            CurrencyConvertorSoapClient client = new CurrencyConvertorSoapClient();
            double usdCurrency = client.ConversionRate(Currency.ARS, Currency.USD);
            string state = (string)Session["state"];

            if (state == "deleteError")
            {
                lblState.CssClass = "deleteError";
                Session["state"] = "unmodified";
            }
            else if (state == "purchaseCompleted")
            {
                lblState.CssClass = "purchaseCompleted";
                Session["state"] = "unmodified";
            }
            try
            {
                if (!(Session["myCart"] == null))
                {
                    foreach (LineaVenta lineaVenta in (List<LineaVenta>)Session["myCart"])
                    {

                        Producto producto = ProductLogic.GetProducto(lineaVenta.ProductId);

                        TableRow row = new TableRow();
                        row.ID = producto.ProductID.ToString();
                        row.CssClass = "lineaVenta";

                        TableCell quantity = new TableCell();
                        quantity.Text = lineaVenta.Quantity.ToString();
                        row.Cells.Add(quantity);

                        TableCell name = new TableCell();
                        name.Text = producto.ProductName;
                        row.Cells.Add(name);

                        TableCell price = new TableCell();
                        price.Text = "$ " + decimal.Round(producto.UnitPrice, 2).ToString();
                        row.Cells.Add(price);

                        TableCell subtotal = new TableCell();
                        subtotal.Text = "$ " + decimal.Round((producto.UnitPrice * lineaVenta.Quantity), 2).ToString();
                        row.Cells.Add(subtotal);

                        asptLineaVenta.Rows.Add(row);
                        totalAr += producto.UnitPrice * lineaVenta.Quantity;
                    }
                }
                lblTotal.Text = "AR$ " + decimal.Round(totalAr, 2).ToString() + " (US$ " + decimal.Round((totalAr * (decimal)usdCurrency), 2).ToString() + ")";
            }
            catch (NullReferenceException)
            {
                lblState.CssClass = "dbConnectionError";
            }
        }