private void addBtn_Click(object sender, EventArgs e)
        {
            try
            {
                stkDlg newstkDlg;
                newstkDlg = new stkDlg();
                if (newstkDlg.ShowDialog() == DialogResult.OK)// if user pressed ok, add stock object to list
                {
                    StkPrce newStk = newstkDlg.stckprceobj();
                    stkBox.Items.Add(newStk);
                }
            }

            catch
            {
                MessageBox.Show("Cannot leave fields empty!", "Error");
            }
        }
        private void addBtn_Click(object sender, EventArgs e)
        {
            try
            {
                stkDlg newstkDlg;
                newstkDlg = new stkDlg();
                if (newstkDlg.ShowDialog() == DialogResult.OK)// if user pressed ok, add stock object to list
                {
                    StkPrce newStk = newstkDlg.stckprceobj();
                    stkBox.Items.Add(newStk); //add new stock to the list
                }
            }

            catch (Exception)
            {
                MessageBox.Show("Bad data, cannot add to the list!", "Error");
            }
        }
        private void updteBtn_Click(object sender, EventArgs e)
        {
            int ndx = stkBox.SelectedIndex;

            if (ndx < 0) // if no stock is selected in the list box

            {
                MessageBox.Show("You must select a stock  from the list first!");
                return;
            }


            try{
                StkPrce old = (StkPrce)stkBox.SelectedItem;


                stkDlg newstkDlg;
                newstkDlg = new stkDlg(old);


                if (newstkDlg.ShowDialog() == DialogResult.OK)
                {
                    StkPrce newStk = newstkDlg.stckprceobj();


                    stkBox.Items.RemoveAt(ndx);
                    stkBox.Items.Insert(ndx, newStk);
                }
            }

            catch (InvalidCastException)
            {
                MessageBox.Show("Unable to update", "Error");
                return;
            }
        }
        private void updteBtn_Click(object sender, EventArgs e)
        {
            int ndx = stkBox.SelectedIndex;

            if (ndx < 0) // if no stock is selected in the list box
            {
                MessageBox.Show("You must select a stock  from the list first!", "Attention");
                return;
            }


            try
            {
                StkPrce old = (StkPrce)stkBox.SelectedItem; //get selected item and covert it to StkPrce and store it


                stkDlg newstkDlg;
                newstkDlg = new stkDlg(old);// construct a StkDlg that takes the selected item as parameters


                if (newstkDlg.ShowDialog() == DialogResult.OK)
                {
                    StkPrce newStk = newstkDlg.stckprceobj();


                    stkBox.Items.RemoveAt(ndx);       // remove the selected stock
                    stkBox.Items.Insert(ndx, newStk); // insert updated stock information at same location in the list
                }
            }

            catch (InvalidCastException)
            {
                MessageBox.Show("Unable to update", "Error");
                return;
            }
        }