//metoda odpowiedzialna za zapisywanie zmian w obiekcie (zadaniu) private void SaveChanges(object sender, RoutedEventArgs e) { if (Name.Text.Length >= 3 && Description.Text.Length >= 3) { TaskCreator toChange = TaskOperator.FindTask((int)((Button)sender).Tag); toChange.Name = Name.Text; toChange.Description = Description.Text; toChange.Priority = Priority.Text; toChange.Status = Status.Text; toChange.Date = Date.SelectedDate; DatabaseOperator databaseOperator = new DatabaseOperator(); databaseOperator.UpdateTask(toChange); //TODO sprawdzenie czy dane zostały poprawnie zapisane w bazie Button button = sender as Button; Popup pop = new Popup(); TextBlock popupText = new TextBlock(); popupText.Text = "Zapisano pomyślnie. Możesz zamknąć okno."; popupText.Background = Brushes.Green; popupText.Foreground = Brushes.White; pop.Child = popupText; pop.PlacementTarget = button; pop.IsOpen = true; mainWindow.FillTasksList(TaskOperator.ListOfTasks); } else { if (Name.Text.Length < 3) { Name.Background = Brushes.LightPink; } if (Description.Text.Length < 3) { Description.Background = Brushes.LightPink; } LengthWarning.Visibility = Visibility.Visible; } }
public void ShowTaskDescription(object sender, MouseButtonEventArgs e) { int id = (int)((StackPanel)sender).Tag; TaskDetails.Text = (TaskOperator.FindTask(id).Description); }