Monday, October 13, 2014

C# currency converter




C# currency converter 

 



namespace CurrencyConverter
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
            loading();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            String one = comboBox1.SelectedItem.ToString();
            String two = comboBox2.SelectedItem.ToString();
            int three = Int32.Parse(textBox3.Text);

            ServiceReference1.Currency cd = (ServiceReference1.Currency)Enum.Parse(typeof(ServiceReference1.Currency), one);
            ServiceReference1.Currency cd1 = (ServiceReference1.Currency)Enum.Parse(typeof(ServiceReference1.Currency), two);
        

            ServiceReference1.CurrencyConvertorSoapClient ws = new ServiceReference1.CurrencyConvertorSoapClient("CurrencyConvertorSoap");
            double ds = ws.ConversionRate(cd, cd1);
            double result = ds * three;

            label5.Text = result.ToString();
        }

        public void loading()
        {
            foreach (var item in Enum.GetValues(typeof(ServiceReference1.Currency)))
            {
                comboBox1.Items.Add(item);
                comboBox2.Items.Add(item);
            }
        }
    }
}
 

1 comment: