Example #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.");
            }
        }
        public async Task HandleAsync(SubtaskAddedToTask @event)
        {
            var task = await taskRepository.GetAsync(@event.TaskId);

            var project = await projectRepository.GetAsync(task.ProjectId);

            var subtask = new Models.Subtask(@event.SubtaskId)
            {
                ProjectId   = @event.ProjectId,
                Title       = @event.Title,
                Description = @event.Description,
                CreatedAt   = @event.CreatedAt,
                Status      = IssueStatus.Todo,
                Labels      = await labelSearcher.GetLabels(@event.LabelsIds.ToList()),
                Reporter    = await userRepository.GetAsync(@event.ReporterId),
                Assignee    = @event.AssigneeId.HasValue ? await userRepository.GetAsync(@event.AssigneeId.Value) : null
            };

            task.Subtasks.Add(subtask);
            project.Subtasks.Add(subtask);

            await taskRepository.Update(task);

            await projectRepository.Update(project);
        }
        /* Put data input into subtask object before added this subtask into database*/
        private void PutSubTask(Models.Subtask _subtask)
        {
            //_subtask.taskID = (int)comboListTask.SelectedValue;
            if (dateForm != null)
            {
                _subtask.taskID = dateForm.getSelectedNodeTaskID();
            }
            else if (childTasksForm != null)
            {
                _subtask.taskID = childTasksForm.getTask().taskID;
            }

            if (completePicker.Enabled == true)
            {
                _subtask.st_CompleteDate = completePicker.Value;
            }
            else
            {
                _subtask.st_CompleteDate = DateTime.MaxValue;
            }

            //_subtask.st_CreatedDate = createDatePicker.Value;
            _subtask.st_CreatedDate = DateTime.Now;

            if (deadlinePicker.Enabled == true)
            {
                _subtask.st_Deadline = deadlinePicker.Value;
            }
            else
            {
                _subtask.st_Deadline = DateTime.MaxValue;
            }

            _subtask.st_Description = txtDescription.Text.Trim();

            if (comboPriority.SelectedItem.ToString() == "")
            {
                _subtask.st_Priority = -1;
            }
            else if (comboPriority.SelectedItem.ToString() == "Low")
            {
                _subtask.st_Priority = 1;
            }
            else if (comboPriority.SelectedItem.ToString() == "Medium")
            {
                _subtask.st_Priority = 2;
            }
            else
            {
                _subtask.st_Priority = 3;
            }
            _subtask.note = notesTextBox.Text.Trim();
        }
Example #4
0
        /*Returns specified subtask based on subtaskID */
        public static Models.Subtask getASubTask(int subtaskID)
        {
            Models.Subtask subtask         = new Models.Subtask();
            SqlConnection  connection      = DBConnection.GetConnection();
            string         selectStatement = "SELECT * FROM subtask WHERE subtaskID = @subtaskID";
            SqlCommand     selectCommand   = new SqlCommand(selectStatement, connection);

            selectCommand.Parameters.AddWithValue("@subtaskID", subtaskID);

            SqlDataReader reader = null;

            try
            {
                connection.Open();
                reader = selectCommand.ExecuteReader();
                if (reader.Read())
                {
                    subtask.taskID    = Convert.ToInt32(reader["taskID"]);
                    subtask.subtaskID = Convert.ToInt32(reader["subtaskID"]);
                    //subtask.st_Priority = Convert.ToInt32(reader["st_Priority"]);
                    subtask.st_Description = reader["st_Description"].ToString();
                    //subtask.st_Deadline = Convert.ToDateTime(reader["st_Deadline"]);
                    subtask.st_CreatedDate = Convert.ToDateTime(reader["st_CreatedDate"]);
                    //subtask.st_CompleteDate = Convert.ToDateTime(reader["st_CompleteDate"]);
                }
                else
                {
                    subtask = null;
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(subtask);
        }
 //handle the btn submit click
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         if (!isUpdate)//add subtask
         {
             if (validData())
             {
                 Models.Subtask subtask = new Models.Subtask();
                 this.PutSubTask(subtask);
                 int subtaskID = 0;
                 //DialogResult result = MessageBox.Show("Do you want to add this subtask to the following task:\n" + taskTitle, "Create new subtask", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                 //if (result.Equals(DialogResult.OK))
                 //{
                 subtaskID = SubtaskController.AddSubTask(subtask);
                 //if (subtaskID == 0)
                 //   MessageBox.Show("Subtask was not ablet o be added.  Please try again.");
                 if (dateForm != null)
                 {
                     this.dateForm.dateForm_Load(sender, e);
                 }
                 if (childTasksForm != null)
                 {
                     this.childTasksForm.refreshChildList();
                 }
                 this.Close();
                 //}
             }
         }
         else //update subtask
         {
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, ex.GetType().ToString());
     }
 }