private void sort_Title_Z_Click(object sender, RoutedEventArgs e) { Controller.Engine engine = new Controller.Engine(); var s = engine.list_viewer.OrderByDescending(x => x.Title); lb_services.ItemsSource = s; }
public Services() { InitializeComponent(); Controller.Engine engine = new Controller.Engine(); lb_services.ItemsSource = engine.list_viewer; }
/// <summary> /// кнопка удаления /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_delete_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Вы уверены что хотите удалить данный элемент", "Уведомление", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (result == MessageBoxResult.Yes) { try { var bt = e.OriginalSource as Button; var tp = bt.DataContext as Controller.Viewer; DB.Entities ef = new DB.Entities(); var item = ef.Services.SingleOrDefault(x => x.idService == tp.idService); ef.Services.Remove(item); ef.SaveChanges(); lb_services.ItemsSource = ""; Controller.Engine engine = new Controller.Engine(); lb_services.ItemsSource = engine.list_viewer; MessageBox.Show("Объект успешно удален", "ОК", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception) { throw; } } else { MessageBox.Show("Удаление отменено"); } }
private void sort_Cost_Click(object sender, RoutedEventArgs e) { Controller.Engine engine = new Controller.Engine(); var s = engine.list_viewer.OrderBy(x => x.CostSort); lb_services.ItemsSource = s; }