/* * Truncates the table and clears the form */ private void ClearTasks_Click(object sender, EventArgs e) { _task.EmptyTable(); this.Hide(); TaskHistoryForm f2 = new TaskHistoryForm(); f2.ShowDialog(); }
/* * Used to delete a selected task and reload the form */ private void dltSelectedBtn_Click(object sender, EventArgs e) { try { DataGridViewRow row = dataGridView1.SelectedRows[0]; using (SqlCommand sql = new SqlCommand("delete from tasks where id=@id", sqlConnection)) { sql.Parameters.AddWithValue("@id", row.Cells[0].Value.ToString()); sql.ExecuteNonQuery(); } if (int.Parse(row.Index.ToString()) != 0) dataGridView1.Rows.Remove(row); sqlConnection.Close(); this.Hide(); TaskHistoryForm f2 = new TaskHistoryForm(); f2.ShowDialog(); } catch (Exception) { } }
/* * This method will open a new form that contains data retrieved from the database */ private void ViewTasks_Click(object sender, EventArgs e) { TaskHistoryForm f2 = new TaskHistoryForm(); f2.ShowDialog(); }