Beispiel #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);
                    }
                }
            }
        }
Beispiel #2
0
        private void deleteToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            RecordsForm  R        = this.ActiveMdiChild as RecordsForm;
            List <int>   selected = new List <int>();
            bool         deleted  = false;
            DialogResult prompt;

            if (R == null)
            {
                MessageBox.Show("You need an active form to delete records.", "Error");
            }
            else
            {
                prompt = MessageBox.Show("Are you sure you would like to permanently delete these records?",
                                         "Delete?", MessageBoxButtons.YesNo);
                if (prompt == DialogResult.Yes)
                {
                    Records  = R.getRecords();
                    selected = R.findIndex();
                    foreach (int index in selected.OrderByDescending(i => i))
                    {
                        if (index > 1)
                        {
                            Records.RemoveAt(index - 2);
                            R.refresh(Records);
                            deleted = true;
                        }
                    }
                    if (deleted)
                    {
                        MessageBox.Show("Record has successfully been removed from your library.", "Done!");
                    }
                    else
                    {
                        MessageBox.Show("Please make a proper selection before deleting", "Error");
                    }
                }
                else
                {
                    MessageBox.Show("Records were NOT deleted!", "Done!");
                }
            }
        }