Example #1
0
        private void updateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RecordsForm R        = this.ActiveMdiChild as RecordsForm;
            List <int>  selected = new List <int>();

            if (R == null)
            {
                MessageBox.Show("You need an active form to update records.", "Error");
            }
            else
            {
                Records  = R.getRecords();
                selected = R.findIndex();
                foreach (int index in selected.OrderByDescending(i => i))
                {
                    if (index > 1)
                    {
                        InsertForm I = new InsertForm(media);
                        I.setText(Records[index - 2]);
                        I.ShowDialog();
                        if (I.canceled == false && I.mismatch == false)
                        {
                            List <Record> temp = I.getRecs();
                            Records[index - 2] = temp[0];
                            MessageBox.Show("Record has successfully been updated.", "Done!");
                        }
                        R.refresh(Records);
                    }
                }
            }
        }
Example #2
0
        /*********************************************************************************
        *  Event Handler for the Edit>Insert menu item
        *      will allow the user to insert(Add) records to the list of records
        *
        *********************************************************************************/
        private void insertToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Checks to make sure a form is available
            RecordsForm R = this.ActiveMdiChild as RecordsForm;

            if (R == null)
            {
                MessageBox.Show("No form available.", "Error");
            }
            //Since ther is an active form, we can now insert to the list
            else
            {
                //Gets the records that are already displayed on the Records Form
                Records = R.getRecords();
                //Creates and displays an insert form, which allows the user to enter record data
                InsertForm I = new InsertForm(media);
                I.ShowDialog();

                //If the user pressed cancel instead of ok on the insert form, we will not add data.
                //In the insert method, mismatch is set to true if the number of titles, ratings, released are not consistent.
                //  so if mismatch is true, nothing will be added to the list
                if (I.canceled == false && I.mismatch == false)
                {
                    //Gets the list of records created from the InsertForm(list is used for several
                    //  entries with common author/director) and adds them to the records we recieved
                    //  from the RecordsForm a few instructions ago.
                    Records.AddRange(I.getRecs());
                    R.refresh(Records);     //Refresh method displays the new list of records to the RecordsForm
                    MessageBox.Show("Record has successfully been added.", "Done!");
                }
            }
        }