예제 #1
0
        private void dg_tasks_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var row = ((DataGridView)sender).Rows[e.RowIndex];
            var thisActivity = new Activity {
                Id = int.Parse(row.Cells["Id"].Value.ToString()),
                Description = row.Cells["Description"].Value.ToString(),
                EstimatedPomodoros = int.Parse(row.Cells["Estimated"].Value.ToString()),
                ActualPomodoros = int.Parse(row.Cells["Actual"].Value.ToString()),
                Interruptions = int.Parse(row.Cells["Interruptions"].Value.ToString()),
                IsActiveTask = true,
                IsCompleted = false
            };

            switch (e.ColumnIndex) {
                case 3:
                    thisActivity.ActualPomodoros += 1;
                    break;
                case 4:
                    thisActivity.Interruptions += 1;
                    break;
                case 5:
                    thisActivity.IsCompleted = !thisActivity.IsCompleted;
                    break;
            }

            SQLiteCommand updateCmd = new SQLiteCommand(thisActivity.MakeUpdateStatement(), Program.connection);
            Program.connection.Open();
            updateCmd.ExecuteNonQuery();
            Program.connection.Close();

            RefreshTaskList();
        }
예제 #2
0
        private void btn_move_task_to_activities_Click(object sender, EventArgs e)
        {
            var items = list_tasks.SelectedItems;
            StringBuilder query = new StringBuilder();
            foreach (var item in items) {
                var row = (DataRowView)item;
                Activity rowActivity = new Activity {
                    Id = int.Parse(row[0].ToString()),
                    Description = row[1].ToString(),
                    EstimatedPomodoros = int.Parse(row[2].ToString()),
                    IsActiveTask = false
                };
                query.AppendLine(rowActivity.MakeUpdateStatement());
            }

            SQLiteCommand update = new SQLiteCommand(query.ToString(), Program.connection);
            Program.connection.Open();
            update.ExecuteNonQuery();
            Program.connection.Close();
            ReloadListBoxes();
        }