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(); }
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(); }
private void btn_add_activity_Click(object sender, EventArgs e) { if (this.ValidateChildren()) { var activity = new Activity { Description = txt_activity_description.Text, EstimatedPomodoros = int.Parse(txt_activity_estimate.Text), ActualPomodoros = 0, Interruptions = 0, IsActiveTask = false, IsCompleted = false }; SQLiteCommand cmd = new SQLiteCommand(activity.MakeInsertStatement(), Program.connection); Program.connection.Open(); cmd.ExecuteNonQuery(); Program.connection.Close(); txt_activity_description.Clear(); txt_activity_description.Focus(); txt_activity_estimate.Clear(); ReloadListBoxes(); } }