//Purpose: Opens new form to edit/update exiting item and save changes //Requires: none //Returns: changes to the listbox private void UpdateItem() { UpdateControl = false; int index = items_listBox.SelectedIndex; if (index > 0) { string inputRecord = items_listBox.SelectedItem.ToString(); string[] inputFields; //stores each data piece inputFields = inputRecord.Split('\t'); Record = new Record(Convert.ToInt32(inputFields[0]), inputFields[1], Convert.ToInt32(inputFields[5]), Convert.ToInt32(inputFields[6]), practice); editInventory = new EditInventoryForm(this, record); //new form editInventory.ShowDialog(); UpdateForm(); } }
//event when the insert menu item is clicked private void insertToolStripMenuItem_Click(object sender, EventArgs e) { //determine the active child form. CheckActiveChild(); //if there is an active child form, find the active control if (activeChild != null) { try { //open new blank edit item EditInventoryForm newInventory = new EditInventoryForm((InventoryDataForm)activeChild); //display the new form. newInventory.ShowDialog(); } catch (Exception error) { MessageBox.Show(error.Message); } } }