Beispiel #1
0
        /*Add function for delete*/
        private void btnDelete_Click(object sender, EventArgs e)
        {
            var selectedNode = taskTreeView.SelectedNode;

            if (selectedNode != null)
            {
                if (selectedNode.Parent == null)
                {
                    // Root-level node, delete task
                    Models.Task  task   = (Models.Task)selectedNode.Tag;
                    DialogResult result = MessageBox.Show("Do you want to delete this task and its subtasks?", "Delete task", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    if (result.Equals(DialogResult.OK))
                    {
                        TaskController.deleteTask(task.taskID);
                        loadData();
                    }
                }
                else
                {
                    // Child node, delete child task only
                    Models.Subtask subtask = (Models.Subtask)selectedNode.Tag;
                    DialogResult   result  = MessageBox.Show("Do you want to delete this subtask?", "Delete subtask", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    if (result.Equals(DialogResult.OK))
                    {
                        SubtaskController.deleteSubTask(subtask.subtaskID);
                        loadData();
                    }
                }
            }
            else
            {
                MessageBox.Show("Please select a task or subtask to delete.");
            }
        }
Beispiel #2
0
 private void btnDeleteSubtask_Click(object sender, EventArgs e)
 {
     if (listSubTaskGridView.SelectedRows.Count != 0)
     {
         DataGridViewRow row    = this.listSubTaskGridView.SelectedRows[0];
         int             id     = Convert.ToInt32(row.Cells["subtaskID"].Value);
         DialogResult    result = MessageBox.Show("Do you want to delete this subtask?", "Delete subtask", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
         if (result.Equals(DialogResult.OK))
         {
             SubtaskController.deleteSubTask(id);
             refreshChildList();
         }
     }
     else
     {
         MessageBox.Show("No subtask selected. Please try again.");
     }
 }