using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
   StockTickerSoap proxy = new StockTickerSoap();

   protected void Page_Load(object sender, EventArgs e)
   {

   }

   protected void txtFirmNameStockSymbol_TextChanged(object sender,
      EventArgs e)
   {
      lblFirmName.Text = proxy.GetName(txtFirmNameStockSymbol.Text);
   }

   protected void txtPriceStockSymbol_TextChanged(object sender,
      EventArgs e)
   {
      lblStockPrice.Text = "$ " +
         Convert.ToString(proxy.GetPrice(txtPriceStockSymbol.Text));
   }

   protected void btnStockExchangeSet_Click(object sender, EventArgs e)
   {
      proxy.SetStockExchange(txtStockExchange.Text);
   }

   protected void btnStockExchangeGet_Click(object sender, EventArgs e)
   {
      txtStockExchange.Text = proxy.GetStockExchange();
   }

   protected void btnGetHistory_Click(object sender, EventArgs e)
   {
      Stock theStock = proxy.GetHistory(txtHistoryStockSymbol.Text);
      string StockName = theStock.StockName;
      double StockPrice = theStock.Price;

      DateTime TradeDate1 = theStock.History[0].TradeDate;
      double Price1 = theStock.History[0].Price;

      DateTime TradeDate2 = theStock.History[1].TradeDate;
      double Price2 = theStock.History[1].Price;

      // Wywietlenie wynikw.
      pnlHistory.Visible = true;
      lblHistoryStockName.Text = StockName;
      lblHistoryStockPrice.Text = "$ " + Convert.ToString(StockPrice);
      lblHistoryDate1.Text = TradeDate1.ToString("d");
      lblHistoryPrice1.Text = "$ " + Convert.ToString(Price1);
      lblHistoryDate2.Text = TradeDate2.ToString("d");
      lblHistoryPrice2.Text = "$ " + Convert.ToString(Price2);
   }
}
