コード例 #1
0
        private void btnSavePaopleMan_Click(object sender, EventArgs e)
        {
            Person p = (Person)listBoxPeopleMan.SelectedItem;

            try
            {
                if (comboBoxPersonRole.SelectedIndex == 0)
                {
                    personlogic.EditPerson(p, new Student(textBoxFName.Text, textBoxLName.Text, textBoxPCN.Text));
                }
                else
                {
                    personlogic.EditPerson(p, new Teacher(textBoxFName.Text, textBoxLName.Text, textBoxPCN.Text));
                }

                MessageBox.Show("Editing was successful.");
                textBoxFName.Text = "";
                textBoxLName.Text = "";
                textBoxPCN.Text   = "";
                UpdatePeopleListbox();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }