Пример #1
0
        private void addToWatchlist_Click(object sender, EventArgs e)
        {
            stock = null;
            stock = bLogic.GetStockInfo(companyListBox.SelectedValue.ToString());


            bool flag = bLogic.CheckWatchlist(loggedUser.id);

            if (flag.Equals(true))
            {
                bool flag1 = bLogic.AddToWatchlist(loggedUser.id, stock[0].symbol);
                if (flag1.Equals(false))
                {
                    MessageBox.Show("This stock already exists in the watchlist");
                }

                populateWatchListTable();
                // populateGraph();

                if (removeFromWatchlist.Enabled == false)
                {
                    removeFromWatchlist.Enabled = true;
                }
            }
            else
            {
                MessageBox.Show("cannot add more than 5 stocks");
            }
        }
Пример #2
0
        private void companyListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (companyListBox.SelectedIndex == -1)
            {
            }
            else
            {
                this.detailListBox.Items.Clear();
                stock = bLogic.GetStockInfo(companyListBox.SelectedValue.ToString());

                detailListBox.Items.Add("Symbol: " + stock[0].symbol);
                detailListBox.Items.Add("Name: " + stock[0].name);
                if (stock[0].ipoYear == 0)
                {
                    detailListBox.Items.Add("IPOYear: N/A");
                }
                else
                {
                    detailListBox.Items.Add("IPOYear: " + stock[0].ipoYear);
                }

                stockId = stock[0].id;
                // detailListBox.Items.Add("ID: " + stock[0].id);
                detailListBox.Items.Add("Sector: " + stock[0].sector);
                detailListBox.Items.Add("Industry: " + stock[0].industry);


                List <Quote> quote = new List <Quote>();
                quote.Add(new Quote(stock[0].symbol));
                YahooStockEngine.Fetch(quote);
                foreach (var q in quote)
                {
                    if (q.Ask != null)
                    {
                        stock[0].currentPrice = (double)q.Ask;
                        detailListBox.Items.Add("Current Ask Price: " + stock[0].currentPrice);
                        current_price = System.Convert.ToDouble(q.Ask);
                    }
                    else
                    {
                        stock[0].currentPrice = 0.0;
                        current_price         = 0.0;
                        detailListBox.Items.Add("Current Ask Price: Not available");
                    }
                    if (q.Bid != null)
                    {
                        detailListBox.Items.Add("Current bid: " + q.Bid);
                    }
                    else
                    {
                        detailListBox.Items.Add("Current bid: Not available");
                    }
                    detailListBox.Items.Add("Last Trade Price: " + q.LastTradePrice.ToString());
                    detailListBox.Items.Add("Change in percent: " + q.ChangeInPercent.ToString());
                    detailListBox.Items.Add("Last update time: " + q.LastUpdate.ToString());
                    detailListBox.Items.Add("Earnings for share: " + q.EarningsShare);
                }
            }
            // MessageBox.Show(companyListBox.SelectedValue.ToString());
        }