Esempio n. 1
0
        private void btnSaveContact_Click(object sender, EventArgs e)
        {
            string[] contact = txtNewContact.Text.Split(',');
            if (contact.Length < 3) { lblError.Text = "Error! <firstname>,<lastname>,<phonenumber>"; return; }
            string tmpFirstName = contact[0], tmpLastName = contact[1], tmpNumber = contact[2];

            if (chklsSecret.Checked) {
                SecretContact tmpSecretContactToAdd = new SecretContact(tmpFirstName, tmpLastName, tmpNumber);
                myPhoneBook.AddContact(tmpSecretContactToAdd);

            } else {
                Contact tmpContactToAdd = new Contact(tmpFirstName, tmpLastName, tmpNumber);
                myPhoneBook.AddContact(tmpContactToAdd);
            }

            txtNewContact.Text = "";
            lblError.Text = "";
            UpdateContacts();
        }
Esempio n. 2
0
 public void RemoveContact(Contact contactToRemove)
 {
     contacts.Remove(contactToRemove);
 }
Esempio n. 3
0
 public void AddContact(Contact contactToAdd)
 {
     contacts.Add(contactToAdd);
 }