/// <summary> /// Stock one favorite button click handler. Called when stock one /// "favorites" button is selected to pick a stock from user's favorite /// stocks list to appear in the graph. /// </summary> /// <param name="sender">Default parameter</param> /// <param name="e">Default parameter</param> private void btnStockOneFavorite_Click(object sender, EventArgs e) { fAddStock add_sym = new fAddStock(true); if (add_sym.ShowDialog() == DialogResult.OK) //user selected ok, grab stock picked { stock_one = add_sym.sID; stock_one_str = add_sym.sSymbol; labelStockOne.Text = "Stock: " + stock_one_str; } }
/// <summary> /// Stock one all stocks button click handler. Called when stock one /// "all stocks" button is selected to pick a stock from complete list of /// stock symbols to appear in the graph. /// </summary> /// <param name="sender">Default parameter</param> /// <param name="e">Default parameter</param> private void btnStockOneAllStocks_Click(object sender, EventArgs e) { fAddStock add_sym = new fAddStock(); if (add_sym.ShowDialog() == DialogResult.OK) { stock_one = add_sym.sID; stock_one_str = add_sym.sSymbol; labelStockOne.Text = "Stock: " + stock_one_str; } }
/// <summary> /// Stock three favorite button click handler. Called when stock three /// "favorites" button is selected to pick a stock from user's favorite /// stocks list to appear in the graph. /// </summary> /// <param name="sender">Default parameter</param> /// <param name="e">Default parameter</param> private void btnStockThreeFavorites_Click(object sender, EventArgs e) { fAddStock add_sym = new fAddStock(true); if (add_sym.ShowDialog() == DialogResult.OK) { stock_three = add_sym.sID; stock_three_str = add_sym.sSymbol; labelStockThree.Text = "Stock: " + stock_three_str; } }
/// <summary> /// Called when the add stock button is pressed. If the user has /// less than 20 stocks already saved, the add stock window appears /// and the user can select a new stock to add to their favorites list. /// </summary> /// <param name="sender">Default param.</param> /// <param name="e">Default param.</param> private void btn_AddStock_Click(object sender, EventArgs e) { if (gridView_SavedStocks.Rows.Count < 20) //if user has less than 20 stocks saved { fAddStock add = new fAddStock(); if (add.ShowDialog() == DialogResult.OK) //open new stock window, check for close OK (no cancel) { cDatabaseManager db = new cDatabaseManager(); List <int> save_stocks = new List <int>(); save_stocks.Add(add.sID); //get selected stock id from add stock window db.saveStocksForUser(save_stocks, cUser.UserID); //save it to db updateSavedStocksGrid(); // update stock grid to reflect changes } } else { //more than 20 stocks saved MessageBox.Show("Cannot save more than 20 stocks", "Stop"); } }