Пример #1
0
        // Create new task function
        private Task createTask()
        {
            AddEditTask aet = new AddEditTask();

            bool?result = aet.ShowDialog();

            if (result != result.HasValue)
            {
                return(null);
            }

            Task T = new Task(aet.TaskName,
                              aet.TimeCreated,
                              aet.TimeDue
                              );

            return(T);
        }
Пример #2
0
        private void uppdateTask(int index)
        {
            AddEditTask aet = new AddEditTask();

            aet.EditMode = true;

            Task T = (Task)tasks[index];

            aet.TaskName    = T.Name;
            aet.TimeDue     = T.DateDue;
            aet.TimeCreated = T.DateCreated;
            aet.TaskStatus  = T.Status;
            bool?result = aet.ShowDialog();

            if (result != result.HasValue)
            {
                return;
            }
            Task updatedTask = new Task(aet.TaskName,
                                        aet.TimeCreated,
                                        aet.TimeDue,
                                        aet.TaskStatus
                                        );

            // Update confirmation

            MessageBoxResult result2;

            result2 = MessageBox.Show($"Are you sure you like to update {updatedTask.Name}'s details?",
                                      "Confirmation", MessageBoxButton.YesNo);
            if (result2 == MessageBoxResult.Yes)
            {
                tasks[index]          = updatedTask;
                listBox1.Items[index] = updatedTask.ToString();
            }
            else
            {
                return;
            }
        }