Click here to Skip to main content
16,018,938 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Can anyone help me!!!!!!!
I want to make a project that get the currency type from user and convert this to another type of currency using WPF application and without any need of internet while running this project.

Here is a part of my code...

C#
void OnClick_Convert(object sender, RoutedEventArgs e)
       {
           try
           {
               double dResult = 0;
               //store the default brush for the convert button before call
               Brush dbrush=this.btnConvert.Background;
               //change the background of convert button before call
               this.btnConvert.Background = Brushes.LightBlue;
               //create the CurrencyConvertor webserivce
               CurrencyConvertorSoapClient wsCurrencyConverter = new CurrencyConvertorSoapClient();
               //call the webmethod
               dResult = wsCurrencyConverter.ConversionRate((Currency)Enum.Parse(typeof(Currency), cmbFromCurrency.SelectionBoxItem.ToString().Substring(0, 3)), (Currency)Enum.Parse(typeof(Currency), cmbToCurrency.SelectionBoxItem.ToString().Substring(0, 3)));
               txtResults.Text = cmbFromCurrency.SelectionBoxItem.ToString() + " To " + cmbToCurrency.SelectionBoxItem.ToString() + " = " + Convert.ToString(dResult);
               //change back the to default brush
               this.btnConvert.Background = dbrush;
           }
           catch (Exception ex)
           {
               MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
           }


this is the webservice that i dont want to use in my project.....
C#
public double ConversionRate(www.webservicex.net.Currency FromCurrency, www.webservicex.net.Currency ToCurrency)
   {
       return base.Channel.ConversionRate(FromCurrency, ToCurrency);
   }
Posted
Updated 23-May-13 9:44am
v4
Comments
Zoltán Zörgő 23-May-13 12:57pm    
And from where do you intend to get the rates?
[no name] 23-May-13 12:57pm    
Okay and the question/problem is what exactly?
Sergey Alexandrovich Kryukov 23-May-13 12:59pm    
"Currency conversion" has nothing to do with WPF. Ever heard of separation of concerns?
—SA
ZurdoDev 23-May-13 13:02pm    
So, what's the question?
nomi g 23-May-13 13:17pm    
I dont want to use webservisex.net because it required internet connection. and i want to make pure desktop app.

1 solution

No, nobody can help you. (I think that answers your question).

The reason being is currency is like stock and the rate exchange changes significantly through out any given day using the Foriegn Exchange Market[^]

So there is no way you can design an application that would correctly convert currencies without calling out to a service that is checking the current exchange rate.

You could potentially cache some rates on the local system and use those while the system is offline, but it would need to get online first to get the rates to cache them and you would want to inform the user how stale the data is (10 min, 10 hours, 10 days etc.)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900