Need Code For The Currency Converter

Posted by Raghu16 under C# on 5/4/2012 | Points: 10 | Views : 6603 | Status : [Member] | Replies : 2
Hi Here I need Code For converting one country currency into another country currency
Example
1)if we give input as Usd 1 Dollar it should display as 53.45 Indian rupees.
2)if we give input as Eur 1 pound it should display as 73.45 Indian rupees.

need code in Asp.net with C# Language
it should display values as per as market in present day (I mean that rupee value may change day by day)




Responses

Posted by: Ketvin on: 5/4/2012 [Member] Starter | Points: 25

Up
0
Down
Use this code It may Help u

public class Util{
@Future(callout=true)
public static void updateAmount(ID opportunityId){
Opportunity opp = [SELECT <fields> FROM Opportunity WHERE id = :opportunityId];

//Callout to your external service
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://your.url');
req.setMethod('GET');
HttpResponse res = h.send(req);
//Write a function to parse the results and return the $ amount.
Decimal result = Util.parseResult(res.getBody());

//Update the fields on your record.
opp.currency_field = result;
update opp;
}
}

Raghu16, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.Saravanan on: 5/4/2012 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Try the below links...
http://www.dotnetfunda.com/codes/code2206-currency-convertor-using-webservices.aspx
http://www.dotnetfunda.com/codes/code246-code-to-create-own-currency-convertor.aspx

Note: If refer link 2, you need to be update that XML each and every day (or) maintain the daily currency values in database table.

Thanks,
T.Saravanan

Raghu16, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response