Example #1
0
    protected void FindStock()
    {
        FindStockMessageLabel.Text = "";
        string symbol = FindStockTB.Text.Trim();
        string errorMessage = "";

        if (!string.IsNullOrEmpty(symbol))
        {
            string companyName = "";
            StockService stockService = new StockService();

            //  If the User entered the Stock Symbol, then extract the Company Name.
            //  if (stockService.XIgniteIsQuoteExists(symbol, out companyName))
            if (stockService.YahooCSVIsQuoteExists(symbol, out companyName))
            {
                symbol = symbol.ToUpper();
                if (companyName == "")
                {
                    companyName = symbol;
                }

                string queryString = "INSERT IGNORE INTO stoocks.company VALUES ('" + companyName + "','" + symbol + "','');";
                int retVal = dbOps.ExecuteNonQuery(queryString);

                if (retVal != -1)
                {
                    if (!StocksCBL.Items.Contains(new ListItem(symbol, symbol)))
                    {
                        StocksCBL.Items.Add(new ListItem(symbol, symbol));
                        string message = gui.GreenFontStart + " Symbol found. Added to the list above." + gui.GreenFontEnd;
                        FindStockMessageLabel.Text = message;
                    }
                }
            }
            else
            {
                errorMessage = gui.RedFontStart + " * Symbol not found." + gui.RedFontEnd;
                FindStockMessageLabel.Text = errorMessage;
            }
        }
        else
        {
            errorMessage = gui.RedFontStart + " Please Enter a Valid Stock Symbol." + gui.RedFontEnd;
            FindStockMessageLabel.Text = errorMessage;
        }
    }