//submit button on the combobox click event
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int    volume = Convert.ToInt32(textBox1.Text);
                double price  = Convert.ToDouble(textBox2.Text);

                //make sure volume and price are 0 or greater
                if (volume <= 0 || price <= 0)
                {
                    throw new Exception();
                }

                //create new buyOrder, then add buy order to the respective companies buy orderlist
                //using the combobox selected index
                Class_BuyOrder order = new Class_BuyOrder(price, volume);
                realTimeData.CompanyList[comboBox1.SelectedIndex].addBuyOrder(order);

                //notify observes
                realTimeData.Notify();

                //clear textbox's for the next user bid input
                textBox1.Clear();
                textBox2.Clear();
            }
            catch
            {
                //Show an invalid error message if user entered inputs are invalid
                MessageBox.Show("You have entered an invalid value ", "Invalid Input");
            }
        }
        /*  BUY ORDER LIST RELATED METHODS   */

        //add a new buy order to the buy order list
        public void addBuyOrder(Class_BuyOrder order)
        {
            buyOrdersList.Add(order);
            buyOrdersList = buyOrdersList.OrderByDescending(x => x.getPrice()).ToList();

            buyTransactionCheck(order);
        }
        //check for potential buyers that can complete open sell orders when creating a new buy order
        public void buyTransactionCheck(Class_BuyOrder order)
        {
            foreach (Class_Order o in sellOrdersList)
            {
                //if there is a price in sell orders less than or equal to the buying price then a transcation can occur
                if (o.getPrice() <= order.getPrice())
                {
                    //if the sell order has more shares than the current buy order
                    if (o.getOrderSize() > order.getOrderSize())
                    {
                        //add order shares to the current share volume, set new sell order size by minusing the buyer size, and update company variables for the stock state summary
                        this.volume += order.getOrderSize();
                        o.setOrderSize(o.getOrderSize() - order.getOrderSize());
                        UpdateCompanyHelper(order);//o);


                        //add buy order to the transaction list no more shares left on buy order so break
                        transactionsList.Add(order);
                        break;
                    }

                    //if the buy order has more shares than the current sell order
                    else if (o.getOrderSize() < order.getOrderSize())
                    {
                        //add order shares to the current share volume, set new buy order size by minus the seller size, and update company variables for the stock state summary
                        this.volume += o.getOrderSize();
                        order.setOrderSize(order.getOrderSize() - o.getOrderSize());
                        UpdateCompanyHelper(order);

                        //add sell order to the transaction list and keeping searching still shares to buy
                        transactionsList.Add(o);
                    }

                    //if the buy order and sell order have matching share sizes
                    else
                    {
                        //add order shares to the current share volume, and update company variables for the stock state summary
                        this.volume += order.getOrderSize();
                        UpdateCompanyHelper(order);

                        //add both buy order and sell order to the transaction list no more shares left on buy order so break
                        transactionsList.Add(o);
                        transactionsList.Add(order);
                        break; //exit loop
                    }
                }
            }

            //removing the current pending orders since they have now got a match
            foreach (Class_Order temp in transactionsList)
            {
                Class_SellOrder dummy = new Class_SellOrder();
                if (temp.GetType().Equals(dummy.GetType()))
                {
                    sellOrdersList.Remove((Class_SellOrder)temp);
                }
                else
                {
                    buyOrdersList.Remove((Class_BuyOrder)temp);
                }
            }
        }