Exemplo n.º 1
0
        private void GeneratePage(ISecurity security)
        {
            IQuote latestQuote = security.GetLatestQuote();

            BuyHyperlink.NavigateUrl = "~/User/CreateOrder.aspx?isin=" + security.Isin;

            //General
            Name.InnerText = security.Name;

            double quoteChange = 0;

            if (latestQuote != null)
            {
                Value.InnerText = String.Format("{0:0.00€}", latestQuote.Price);
                quoteChange = security.GetLatestQuote().Change;
            }

            Change.InnerText = (quoteChange>=0 ? "+" : "") + Convert.ToString(quoteChange) + "%";
            if (quoteChange > 0)
                Change.Attributes.Add("class", "pos");
            else if (quoteChange < 0)
                Change.Attributes.Add("class", "neg");

            Exchange.InnerText = security.Exchange.Name;
            ISIN.InnerText = security.Isin;
            ISINcode = security.Isin;
            Symbol.InnerText = security.Symbol;

            //Data
            if (latestQuote != null)
            {
                Open.InnerText = String.Format("{0:0.00€}", latestQuote.Open);
                High.InnerText = String.Format("{0:0.00€}", latestQuote.High);
                Low.InnerText = String.Format("{0:0.00€}", latestQuote.Low);
            }

            //History
            DataTable historyTable = new DataTable();

            historyTable.Columns.Add("Date");
            historyTable.Columns["Date"].DataType = typeof(DateTime);
            historyTable.Columns.Add("Change");
            historyTable.Columns["Change"].DataType = typeof(Double);
            historyTable.Columns.Add("Open");
            historyTable.Columns["Open"].DataType = typeof(Double);
            historyTable.Columns.Add("High");
            historyTable.Columns["High"].DataType = typeof(Double);
            historyTable.Columns.Add("Low");
            historyTable.Columns["Low"].DataType = typeof(Double);

            List<IQuote> quotes = security.GetDailyQuotes(DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0)), DateTime.Now);

            foreach(IQuote quote in quotes)
            {
                DataRow row = historyTable.NewRow();
                row[0] = quote.Time;
                row[1] = quote.Change;
                row[2] = quote.Open;
                row[3] = quote.High;
                row[4] = quote.Low;
                historyTable.Rows.Add(row);
            }

            HistoryGridView.DataSource = historyTable;
            HistoryGridView.DataBind();
        }