using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using CurrencyClient.localhost;

namespace CurrencyClient
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class frmConvert : System.Windows.Forms.Form
	{
		private System.Windows.Forms.TextBox txtAmount;
		private System.Windows.Forms.Label lblAmount;
		private System.Windows.Forms.Label lblSource;
		private System.Windows.Forms.TextBox txtSource;
		private System.Windows.Forms.TextBox txtDest;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button btnConvert;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmConvert()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.txtAmount = new System.Windows.Forms.TextBox();
			this.lblAmount = new System.Windows.Forms.Label();
			this.lblSource = new System.Windows.Forms.Label();
			this.txtSource = new System.Windows.Forms.TextBox();
			this.txtDest = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.btnConvert = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// txtAmount
			// 
			this.txtAmount.Location = new System.Drawing.Point(64, 16);
			this.txtAmount.Name = "txtAmount";
			this.txtAmount.Size = new System.Drawing.Size(184, 20);
			this.txtAmount.TabIndex = 0;
			this.txtAmount.Text = "";
			// 
			// lblAmount
			// 
			this.lblAmount.Location = new System.Drawing.Point(8, 16);
			this.lblAmount.Name = "lblAmount";
			this.lblAmount.Size = new System.Drawing.Size(48, 23);
			this.lblAmount.TabIndex = 1;
			this.lblAmount.Text = "Kwota:";
			// 
			// lblSource
			// 
			this.lblSource.Location = new System.Drawing.Point(8, 48);
			this.lblSource.Name = "lblSource";
			this.lblSource.Size = new System.Drawing.Size(56, 32);
			this.lblSource.TabIndex = 2;
			this.lblSource.Text = "Kraj ródłowy:";
			// 
			// txtSource
			// 
			this.txtSource.Location = new System.Drawing.Point(64, 56);
			this.txtSource.Name = "txtSource";
			this.txtSource.Size = new System.Drawing.Size(184, 20);
			this.txtSource.TabIndex = 3;
			this.txtSource.Text = "";
			// 
			// txtDest
			// 
			this.txtDest.Location = new System.Drawing.Point(64, 96);
			this.txtDest.Name = "txtDest";
			this.txtDest.Size = new System.Drawing.Size(184, 20);
			this.txtDest.TabIndex = 4;
			this.txtDest.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 88);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(56, 32);
			this.label1.TabIndex = 5;
			this.label1.Text = "Kraj docelowy:";
			// 
			// btnConvert
			// 
			this.btnConvert.Location = new System.Drawing.Point(176, 136);
			this.btnConvert.Name = "btnConvert";
			this.btnConvert.TabIndex = 6;
			this.btnConvert.Text = "Konwertuj";
			this.btnConvert.Click += new System.EventHandler(this.btnConvert_Click);
			// 
			// frmConvert
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(264, 174);
			this.Controls.Add(this.btnConvert);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.txtDest);
			this.Controls.Add(this.txtSource);
			this.Controls.Add(this.lblSource);
			this.Controls.Add(this.lblAmount);
			this.Controls.Add(this.txtAmount);
			this.Name = "frmConvert";
			this.Text = "Klient konwertera walut";
			this.Load += new System.EventHandler(this.frmConvert_Load);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new frmConvert());
		}

		private void btnConvert_Click(object sender, System.EventArgs e)
		{
			CurrencyConverter conv = new
			CurrencyConverter();
			
			conv.Url = System.Configuration.
					   ConfigurationSettings.
					   AppSettings["Url"];
			
			decimal result = 
			conv.Convert(
			System.Convert.ToDecimal(txtAmount.Text),
			txtSource.Text,
			txtDest.Text);

			MessageBox.Show(result.ToString(),"Conversion Results");
		}

		private void frmConvert_Load(object sender, System.EventArgs e)
		{
		
		}
	}
}
