private void EditInfoItem(object sender, EventArgs e) { AdditionalInfo info = (AdditionalInfo)lbAdditionalInfo.SelectedItem; if (info != null) { AdditionalInfoDialog dialog = new AdditionalInfoDialog(new AdditionalInfo(info)); dialog.ShowDialog(); if (dialog.DialogResult == DialogResult.OK) { if (org.AdditionalInfosToAdd.Contains(info)) { org.AdditionalInfosToAdd.Remove(info); org.AdditionalInfosToAdd.Add(dialog.AdditionalInfo); } else { org.AdditionalInfosToEdit.RemoveAll(p => p.Id == dialog.AdditionalInfo.Id); org.AdditionalInfosToEdit.Add(dialog.AdditionalInfo); } lbAdditionalInfo.Items[lbAdditionalInfo.SelectedIndex] = dialog.AdditionalInfo; } } }
private void btnAddInfo_Click(object sender, EventArgs e) { AdditionalInfoDialog dlg = new AdditionalInfoDialog(); dlg.ShowDialog(); if (dlg.DialogResult == DialogResult.OK) { lbAdditionalInfo.Items.Add(dlg.AdditionalInfo); org.AdditionalInfosToAdd.Add(dlg.AdditionalInfo); } }