private void listViewResults_MouseDoubleClick(object sender, MouseEventArgs e) { // TODO: show a dialog to edit selected row. ListViewItem item = listViewResults.GetItemAt(e.X, e.Y); if (item != null) { Door door = (Door)item.Tag; DoorDialog dd = new DoorDialog(objects, (MDI_ParentForm)MdiParent, door); DialogResult result = dd.ShowDialog(); if (result == DialogResult.OK) { // update the door door.Save(); objects.UpdateLockData(door); // now update the ui PopulateResults(""); } else if (result == DialogResult.No) // sign to delete the door { // delete it. foreach(KeyType type in objects.keytypes) { type.doors.Remove(door); } objects.doors.Remove(door); door.Delete(); // now the ui PopulateResults(textBoxSearch.Text); } dd.Dispose(); } }
private void buttonCreate_Click(object sender, EventArgs e) { // TODO: open form to create new door DoorDialog dd = new DoorDialog(objects, (MDI_ParentForm)MdiParent); DialogResult result = dd.ShowDialog(); if (result == DialogResult.OK) { Door door = dd.door; objects.doors.Add(door); door.Save(); objects.UpdateLockData(door); // now update the ui. PopulateResults(""); } dd.Dispose(); }