예제 #1
0
        private void detailsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Person     person     = (Person)peopleListView.FocusedItem.Tag;
            PersonForm personForm = new PersonForm(PersonFormType.View, person);

            personForm.ShowDialog(this);
        }
예제 #2
0
        private void newPersonToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PersonForm personForm = new PersonForm(PersonFormType.Add);

            personForm.ShowDialog(this);

            if (personForm.DialogResult == DialogResult.OK)
            {
                Person newPerson = new Person
                {
                    _firstName = personForm.getNameInput(),
                    _lastName  = personForm.getLastNameInput(),
                    _age       = personForm.getAgeInput(),
                    _city      = personForm.getCityInput()
                };

                DataModel.AddPerson(newPerson);

                // Update list
                ListViewItem listViewItem = new ListViewItem(newPerson._firstName);
                listViewItem.SubItems.Add(newPerson._lastName);
                listViewItem.Tag = newPerson;
                peopleListView.Items.Add(listViewItem);

                personForm.Dispose();
            }
        }
예제 #3
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Person person = (Person)peopleListView.FocusedItem.Tag;

            PersonForm personForm = new PersonForm(PersonFormType.Edit, person);

            personForm.ShowDialog(this);

            if (personForm.DialogResult == DialogResult.OK)
            {
                person._firstName = personForm.getNameInput();
                person._lastName  = personForm.getLastNameInput();
                person._age       = personForm.getAgeInput();
                person._city      = personForm.getCityInput();

                peopleListView.FocusedItem.SubItems.Clear();
                peopleListView.FocusedItem.Text = person._firstName;
                peopleListView.FocusedItem.SubItems.Add(person._lastName);

                personForm.Dispose();
            }
        }