Esempio n. 1
0
        // provide capability to add inventory items***********************************************

        private void editMenuInsert_Click(object sender, EventArgs e)
        {
            //identify the active child form
            PracticeForm child = this.ActiveMdiChild as PracticeForm;
            //create a new EntryForm, passing child and bool update = false
            Form EntryForm = new EntryForm(child, false);

            EntryForm.Controls.RemoveAt(0); // the update button won't be visible; insert only
            EntryForm.Text = "Insert new inventory item";
            EntryForm.ShowDialog();         // show dialog requires action
        }
Esempio n. 2
0
        // provide capability to edit existing inventory entries***********************************

        private void editMenuUpdate_Click(object sender, EventArgs e)
        {
            // Identify the active child; it will be passed to the EntryForm
            PracticeForm child = this.ActiveMdiChild as PracticeForm;

            //create a new EntryForm, passing child and bool update = true
            EntryForm Entry = new EntryForm(child, true);

            // This try / catch is necessary in case the user clicks "update" with no record selected.
            try
            {
                Entry.Controls.RemoveAt(2); // the insert button won't be visible; update only
                Entry.Text = "Update inventory item";
                Entry.ShowDialog();
            }
            catch (ArgumentOutOfRangeException)
            {
                // The exception is handled by the EntryForm.
            }
        }