private void Button_Click(object sender, RoutedEventArgs e) { Button b = sender as Button; if (b.Name == "btnRemove") { //Look for the row in the database, in order to remove it. if ((dg.SelectedItem as ScheduleSlot).idTimeSlot != 0) { int tsId = (dg.SelectedItem as ScheduleSlot).idTimeSlot; ScheduleSlot sl = (from r in bdModel.ScheduleSlots where r.idTimeSlot == tsId select r).SingleOrDefault(); bdModel.ScheduleSlots.Remove(sl); bdModel.SaveChanges(); dg.ItemsSource = bdModel.ScheduleSlots.ToList(); } } else if (b.Name == "btnUpdate") { int tsId = (dg.SelectedItem as ScheduleSlot).idTimeSlot; ScheduleSlot s1 = (from r in bdModel.ScheduleSlots where r.idTimeSlot == tsId select r).SingleOrDefault(); ScheduleSlot tmp = s1; AddPlotWindow apw = new AddPlotWindow(tmp, bdModel); //bd.ScheduleSlots.Remove(s1); apw.ShowDialog(); bdModel.SaveChanges(); dg.ItemsSource = bdModel.ScheduleSlots.ToList(); } }
private void mnAddPlot(object s, RoutedEventArgs e) { AddPlotWindow addPlotWindow = new AddPlotWindow(); addPlotWindow.ShowDialog(); }
private void button_Click(object sender, RoutedEventArgs e) { AddPlotWindow apw = new AddPlotWindow(); apw.Show(); }