Ejemplo n.º 1
0
 private void AddButtonClick(object sender, RoutedEventArgs e)
 {
     AddItemsWindow addItemsWindow = new AddItemsWindow();
     addItemsWindow.ShowDialog();
     using (var db = new Model.BudgetModel())
     {
         var source = new Source();
         if (string.IsNullOrWhiteSpace(addItemsWindow.Value)) MessageBox.Show("Введите название");
         else
         {
             source.Name = addItemsWindow.Value;
             db.Sources.Add(source);
             db.SaveChanges();
             UpdateListBox();
         }
     }
 }
Ejemplo n.º 2
0
 private void RenameMenuItemClick(object sender, RoutedEventArgs e)
 {
     using (var db = new Model.BudgetModel())
     {
         var selectedItem = sourceLstBox.SelectedItem as ListBoxItem;
         if (selectedItem == null) return;
         AddItemsWindow addItemsWindow = new AddItemsWindow(selectedItem.Name);
         addItemsWindow.ShowDialog();
         var renameItem = db.Sources.Find(selectedItem.Id);
         if (string.IsNullOrWhiteSpace(addItemsWindow.Value)) MessageBox.Show("Введите название");
         else
         {
             renameItem.Name = addItemsWindow.Value;
             db.SaveChanges();
             UpdateListBox();
         }
     }
 }