Ejemplo n.º 1
0
        private void addFront_Click(object sender, EventArgs e)
        {
            if (this.description.Text.Trim() != "")
            {
                Task t = new Task();
                t.description = this.description.Text;
                t.notes = this.notes.Text;
                _taskSet._tasksNotDone.AddFirst(t);
                TaskRepository.InsertTask(t);

                Clear();
            }
        }
Ejemplo n.º 2
0
        public static void UpdateTask(Task t)
        {
            try
            {
                using (IDbConnection connection = GetConnection())
                {
                    var sql = "Update Task set description=@description, notes=@notes, Created=@Created, TimeSpentInSeconds=@TimeSpentInSeconds, Completed=@Completed " +
                        "where id=@id";

                    connection.Execute(sql, t);
                }
            }
            catch
            {
                Console.WriteLine("Update Task failed");
                throw;
            }
        }
Ejemplo n.º 3
0
 private void addNext_Click(object sender, EventArgs e)
 {
     if (this.description.Text.Trim() != "")
     {
         if (_taskSet._currentTask == null)
         {
             addBack_Click(sender, e);
         }
         else
         {
             Task t = new Task();
             t.description = this.description.Text;
             t.notes = this.notes.Text;
             _taskSet._tasksNotDone.AddAfter(_taskSet._currentTask, t);
             TaskRepository.InsertTask(t);
             Clear();
         }
     }
 }
Ejemplo n.º 4
0
        public static void InsertTask(Task t)
        {
            try
            {
                using (IDbConnection connection = GetConnection())
                {
                    var sql = @"Insert into Task (description, notes, Created, TimeSpentInSeconds) values (@description, @notes, @Created, @TimeSpentInSeconds);";
                    connection.Execute(sql, t);

                    sql = "SELECT top(1) id from Task order by id desc";
                    var id = connection.Query<int>(sql).Single();

                    t.id = id;
                }
            }
            catch
            {
                Console.WriteLine("Insert Task failed");
                throw;
            }
        }
Ejemplo n.º 5
0
        private void done_Click(object sender, EventArgs e)
        {
            SaveElapsedTime();

            _taskSet._currentTask.Value.Completed = DateTime.Now;
            update_Click(sender, e);

            Task clonedTask = new Task();
            clonedTask.description = _taskSet._currentTask.Value.description;
            clonedTask.notes = _taskSet._currentTask.Value.notes;
            clonedTask.id = _taskSet._currentTask.Value.id;
            clonedTask.TimeSpentInSeconds = _taskSet._currentTask.Value.TimeSpentInSeconds;
            clonedTask.Created = _taskSet._currentTask.Value.Created;
            clonedTask.Completed = _taskSet._currentTask.Value.Completed;

            _taskSet._tasksDone.AddLast(clonedTask);

            LinkedListNode<Task> newCurrentTask = null;

            if (_taskSet._currentTask.Next != null)
            {
                newCurrentTask = _taskSet._currentTask.Next;
                _taskSet._tasksNotDone.Remove(_taskSet._currentTask);
                _taskSet._currentTask = newCurrentTask;
            }
            else if (_taskSet._currentTask.Previous != null)
            {
                newCurrentTask = _taskSet._currentTask.Previous;
                _taskSet._tasksNotDone.Remove(_taskSet._currentTask);
                _taskSet._currentTask = newCurrentTask;
            }
            else
            {
                _taskSet._tasksNotDone.Remove(_taskSet._currentTask);

                ShowFinishedStatus();
            }

            LoadForm();
        }