private void EditContact() { if (this.dgvContacts.SelectedRows.Count <= 0) { return; } FormAddContact formAddContact = new FormAddContact(this.dgvContacts.SelectedRows[0].DataBoundItem as Contact); if (formAddContact.ShowDialog() != DialogResult.OK) { return; } this.contacts.Save(); if (formAddContact.Recalc) { this.dateEvents.Remove(formAddContact.EditedContact); this.dateEvents.Add(formAddContact.EditedContact, this.timeMeasures, this.settings); this.dateEvents.Save(); } this.RefreshTables(); }
private void AddContact() { FormAddContact formAddContact = new FormAddContact(); if (formAddContact.ShowDialog() != DialogResult.OK) { return; } Contact editedContact = formAddContact.EditedContact; this.contacts.Add(editedContact, this.settings.ContactSort); this.contacts.Save(); this.dateEvents.Add(editedContact, this.timeMeasures, this.settings); this.dateEvents.Save(); this.RefreshTables(); foreach (DataGridViewRow row in (IEnumerable)this.dgvContacts.Rows) { if ((row.DataBoundItem as Contact).Id == editedContact.Id) { row.Selected = true; break; } } }