private void buttonAdd_Click(object sender, EventArgs e) { if (this.textBoxPhone.Text == String.Empty) { MessageBox.Show("No phone inserted", "No input", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { Phone phone = new Phone(); PhonesRepository phonesRepository = new PhonesRepository("phones.txt"); DialogResult result = MessageBox.Show("Are you sure you want to add this phone", "Adding confirmation", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { phone.ParentContactId = FormViewAllContacts.parentId; phone.PhoneNumber = this.textBoxPhone.Text; phonesRepository.Save(phone); MessageBox.Show("Phone added successfully"); FormAddPhone.ActiveForm.Close(); FormViewAllContacts formViewAllContacts = new FormViewAllContacts(); formViewAllContacts.Show(); } } }
private void buttonCancel_Click(object sender, EventArgs e) { FormAddPhone.ActiveForm.Close(); FormViewAllContacts formViewAllContacts = new FormViewAllContacts(); formViewAllContacts.Show(); }
private void buttonNewContact_Click(object sender, EventArgs e) { if (this.textBoxFullName.Text == String.Empty) { MessageBox.Show("Name field must not be empty", "Empty name error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { DialogResult result = MessageBox.Show("Are you sure you want to add this contact", "Adding confirmation", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { ContactsRepository contactsRepository = new ContactsRepository("contacts.txt"); Contact contact = new Contact(); contact.ParentUserId = AuthenticationService.LoggedUser.Id; contact.FullName = this.textBoxFullName.Text; contact.Email = this.textBoxEmail.Text; contact.Address = this.textBoxAddress.Text; contact.Company = this.textBoxCompany.Text; contactsRepository.Save(contact); MessageBox.Show("Contact addded successfully!"); FormNewContact.ActiveForm.Close(); FormViewAllContacts formViewAll = new FormViewAllContacts(); formViewAll.Show(); } } }