Monday, October 13, 2014

Currency Convertor Web Service Client



Currency Convertor Web Service Client





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);
            }
        }
    }
}


//////////////////////////////////////////////////////////////////////cal client app

private void button1_Click(object sender, EventArgs e)
        {
            int no1 = Int32.Parse(textBox1.Text.ToString());
            int no2 = Int32.Parse(textBox2.Text.ToString());

            Servicecal.CalulatorClient cal = new Servicecal.CalulatorClient();
            int ans=cal.Add(no1, no2);

            label4.Text = ans.ToString();
}

No comments:

Post a Comment