private void Btn_EditConflict_Click(object sender, RoutedEventArgs e) { int selectedIndex; VetConflictDBInfo selectedItem = null; // Get the index from the UI selectedIndex = ListBox_ConflictDetails.SelectedIndex; if (selectedIndex >= 0 && selectedIndex < Veteran.ConflictDetails.Count) { selectedItem = Veteran.ConflictDetails[selectedIndex]; ConflictDetails conflictWin = new ConflictDetails(selectedItem); conflictWin.ShowDialog(); Veteran.ConflictDetails[selectedIndex] = conflictWin.ConflictInfo; ListBox_ConflictDetails.Items.Refresh(); } else { MessageBox.Show(Tools.RecordSelectMessage, Tools.RecordSelectTitle); } }
private void Btn_AddConflict_Click(object sender, RoutedEventArgs e) { ConflictDetails conflictWin = new ConflictDetails(); // If we know the veteran ID, set it if (Veteran.Id != 0) { conflictWin.SetId(Veteran.Id); } conflictWin.ShowDialog(); if (conflictWin.IsOk) { Veteran.ConflictDetails.Add(conflictWin.ConflictInfo); } ListBox_ConflictDetails.Items.Refresh(); }
private void Btn_EditConflict_Click(object sender, RoutedEventArgs e) { int selectedId; VetConflictDBInfo selectedItem = null; bool found = false; // Get the sNum from the UI selectedId = Convert.ToInt32(ListBox_ConflictDetails.SelectedValue); foreach (VetConflictDBInfo conflict in Veteran.ConflictDetails) { if (conflict.CNum == selectedId) { selectedItem = conflict; found = true; } } // Should always be found, but if for some reason the record is not there, do nothing if (found) { ConflictDetails conflictWin = new ConflictDetails(selectedItem); conflictWin.ShowDialog(); if (conflictWin.IsOk) { // Remove the old listing of the item Veteran.ConflictDetails.Remove(selectedItem); // Insert the updated listing Veteran.ConflictDetails.Add(conflictWin.ConflictInfo); } ListBox_ConflictDetails.Items.Refresh(); } }