private void Edit_Executed(object sender, ExecutedRoutedEventArgs e) { if (Event.Exists((long)(Events.SelectedItem as TextBlock).Tag)) { EventWindow eventWindow = new EventWindow(Event.FromDataRow(Event.SelectOne((long)(Events.SelectedItem as TextBlock).Tag))); if ((bool)eventWindow.ShowDialog(this)) { if (Event.Exists((long)(Events.SelectedItem as TextBlock).Tag)) { long selectedEventId = (long)(Events.SelectedItem as TextBlock).Tag; eventWindow.Event.Update(); UpdateEvents(); Events.SelectItem(Events.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == selectedEventId)); } else { ShowErrorWindow(2); } } } else { ShowErrorWindow(2); } }
private void EditEvent_Executed(object sender, ExecutedRoutedEventArgs e) { EventWindow eventWindow = new EventWindow(Dealer.Events.First(x => x.Id == (long)(Events.SelectedItem as TextBlock).Tag).Clone()); if ((bool)eventWindow.ShowDialog(this)) { Dealer.Events[Dealer.Events.FindIndex(x => x.Id == eventWindow.Event.Id)] = eventWindow.Event; UpdateEvents(); Events.SelectItem(Events.Items.FirstOrDefault <FrameworkElement>(x => x.Tag is long && (long)x.Tag == eventWindow.Event.Id)); } }
private void AddEvent_Click(object sender, RoutedEventArgs e) { EventWindow eventWindow = new EventWindow(); if ((bool)eventWindow.ShowDialog(this)) { eventWindow.Event.Id = Dealer.Events.Count != 0 ? Dealer.Events.Max(x => x.Id) + 1 : 1; Dealer.Events.Add(eventWindow.Event); UpdateEvents(); Events.SelectItem(Events.Items.FirstOrDefault <FrameworkElement>(x => x.Tag is long && (long)x.Tag == eventWindow.Event.Id)); } }