开发者

How to maintain order precedence

I have couple of tasks listed in a datagrid, with their task name and duedate. I am showing all tasks based on order precedence. If the user needs to add a task in middle of datagrid, I read the selec开发者_如何学Goted task's precedence number, increment it, and set it as the new task's precedence number. Then I increment the precedence number of all tasks listed after the new task.

I read all tasks from the database and maintain it in an ObservableCollection .Before displaying the tasks, I sort based on order precedence.

       public class Task
          {
              public int TaskId { get; set; }
              public string TaskName { get; set; }
              public DateTime DueDate { get; set; }
              public int OrderPrecedence { get; set; }
          }

Here if one new task added to collection, I need to update all others task precendences. Is there a good way to handle the order precedence without updating other task's precedence numbers?


Instead of maintaining an order, could you have a Task Priority? Similar to Windows Task Priority. ie, all "High" priority tasks would run before "Normal" priority tasks. And if two tasks have the same priority, the one with the sooner DueDate would run first.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜