void Move_Click(object sender, RoutedEventArgs e) { var sel = SelectedCat; if (sel == null) { return; } var kindOfMove = MessageBox.Show("Make this a sub-item of another category? (If No, it will be moved to the root level.)", "Move Category", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); long?newParentId = null; if (kindOfMove == MessageBoxResult.Yes) { var item = CatSelectDialog.SelectCat("The category will become a sub-item of the item you select here"); if (item == null) { return; } newParentId = item.RowId; } else if (kindOfMove != MessageBoxResult.No) { return; //canceled } Globals.UI.ModifyCat(sel.RowId, cat => { cat.ParentId = newParentId; }); DataContext = new VM(); }
void ImportPeopleCSV_Click(object sender, RoutedEventArgs e) { //category to auto-apply long?autocCatId = CatSelectDialog.SelectCat("Choose category to apply to each imported person, or cancel to skip")?.RowId; string filename = AskForImportFileName(false); if (filename == null) { return; } var cvt = new CsvConverter(); try { using var rdr = new StreamReader(filename); var persons = cvt.PersonFromCsv(rdr).ToArray(); foreach (var person in persons) { var eperson = new ExtPerson(person, null, null); if (autocCatId != null) { eperson.SelectedCatIds = new long[] { autocCatId.Value } } ; Globals.UI.SavePerson(eperson); } VisualUtils.ShowMessageDialog($"Imported {persons.Length} record(s)"); } catch (Exception ex) { VisualUtils.ShowMessageDialog("Importing failed: " + ex.Message); } }
void SelectCat_Click(object sender, RoutedEventArgs e) { CatId = CatSelectDialog.SelectCat("Category to export")?.RowId; }