Exemplo n.º 1
0
        private void button_InputChanges_Click(object sender, EventArgs e)
        {
            bool errorTriggered = false;
            List<string> errorMessage = new List<string>();
            TrendUniverse AddBuffer = new TrendUniverse();
            TrendUniverse DeleteBuffer = new TrendUniverse();
            AddBuffer.CopyContents(StocksToAdd);// Use buffers to store add and delete data
            DeleteBuffer.CopyContents(StocksToDelete);

            foreach (Trends stock in StocksToAdd.TrendsUniverseContents) // Checks to see if added stock is already in list
            {
                if (Universe.Contains(stock.Symbol))
                {
                    errorTriggered = true;
                    errorMessage.Add(stock.Symbol);
                }
            }

            foreach (Trends stock in StocksToDelete.TrendsUniverseContents) //Checks to see if deleted stock is not in list
            {
                if (!(Universe.Contains(stock.Symbol)))
                {
                    errorTriggered = true;
                    errorMessage.Add(stock.Symbol);
                }
            }

            if (errorTriggered)
            {
                string errors = string.Join(", ", errorMessage.ToArray());
                MessageBox.Show("Error: The following stocks you are attempting to add/remove are either already in the universe, or not in it to be removed \n" + errors);
                return;
            }

            foreach (Trends stock in StocksToAdd.TrendsUniverseContents)
            {
                if(!(string.IsNullOrEmpty(stock.Symbol)))
                    Universe.Add(stock);
            }

            foreach (Trends stock in StocksToDelete.TrendsUniverseContents)
            {
                Universe.Remove(stock.Symbol);
            }

            AddSource.Clear();
            DeleteSource.Clear();
        }
Exemplo n.º 2
0
 private void button_Finish_Click(object sender, EventArgs e)
 {
     if (FormType == 1)
     {
         if (DoneProcessing)
         {
             TrendUniverse stockTemp = new TrendUniverse();
             stockTemp.CopyContents(weeksProcessData.Universe);
             weeksProcessData.Universe = stockTemp;
             FormParent.fund.AddProc(weeksProcessData);
             FormParent.RefreshBindings();
             this.Close();
         }
         else
         {
             MessageBox.Show("Complete the processing before finalizing");
         }
     }
     else
     {
         this.Close();
     }
 }