Beispiel #1
0
        private void taskBox1_EditItem(object sender, EventArgs e)
        {
            Task task = null;

            if (sender is long id)
            {
                task = store.Get(id) as Task;
            }

            if (task == null)
            {
                return;
            }

            using (var taskDialog = new FormTask())
            {
                taskDialog.StartDate = task.StartDate;
                taskDialog.Deadline  = task.Deadline;
                taskDialog.TaskName  = task.Name;

                if (taskDialog.ShowDialog() == DialogResult.OK)
                {
                    if (!string.IsNullOrWhiteSpace(taskDialog.TaskName))
                    {
                        task.Name      = taskDialog.TaskName;
                        task.Deadline  = taskDialog.Deadline;
                        task.StartDate = taskDialog.StartDate;

                        store.Update(task);

                        taskBox1.UpdateItem(task);
                    }
                }
            }
        }
Beispiel #2
0
 private void NewTaskDialog()
 {
     using (var taskDialog = new FormTask())
     {
         taskDialog.StartDate = calendar.SelectionStart;
         taskDialog.Deadline  = calendar.SelectionEnd;
         if (taskDialog.ShowDialog() == DialogResult.OK)
         {
             if (!string.IsNullOrWhiteSpace(taskDialog.TaskName))
             {
                 var newTask = new Task()
                 {
                     Name      = taskDialog.TaskName,
                     Deadline  = taskDialog.Deadline,
                     StartDate = taskDialog.StartDate,
                     Status    = TaskStatus.New
                 };
                 store.Create(newTask);
                 AddTask(newTask);
             }
         }
     }
 }