/*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 void loadData() { listSubTaskGridView.DataSource = null; listSubTaskGridView.Rows.Clear(); listSubTaskGridView.Refresh(); try { List <Subtask> listSubTask = SubtaskController.GetSubtasksForTask(user, task.taskID); //begin for grid data listSubTaskGridView.AutoGenerateColumns = true; listSubTaskGridView.AutoResizeColumns();// = true; listSubTaskGridView.DataSource = listSubTask; //hide some columns listSubTaskGridView.Columns[0].Visible = false; listSubTaskGridView.Columns[1].Visible = false; listSubTaskGridView.Columns[8].Visible = false; listSubTaskGridView.Columns[6].Visible = false; } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); this.BeginInvoke(new MethodInvoker(Close)); } }
public void TestAddSubTask() { YouCompleteMe.Models.Subtask subtask = new YouCompleteMe.Models.Subtask(); subtask.taskID = 33; subtask.st_CreatedDate = DateTime.Now; subtask.st_Deadline = DateTime.Now; subtask.st_CompleteDate = DateTime.Now; subtask.st_Priority = 2; subtask.st_Description = "use for test unit test"; subtask.note = "this use only for unit test"; int subtaskID = SubtaskController.AddSubTask(subtask); YouCompleteMe.Models.Subtask result = SubtaskController.getASubTask(subtaskID); Assert.AreEqual(subtaskID, result.subtaskID); }
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."); } }
/* * Updates tasks and subtasks to complete or incomplete in the database * based on the current checked status */ private void taskTreeView_BeforeCheck(object sender, TreeViewCancelEventArgs e) { // Check whether the node is a task or a subtask // in order to decide which update statements to call if (e.Node.Parent == null) { Models.Task tag = (Models.Task)e.Node.Tag; if (e.Node.Checked == false) { TaskController.updateTaskCompleted(tag.taskID); List <Subtask> subtasks = SubtaskController.GetSubtasksForTask(user, tag.taskID); foreach (Subtask st in subtasks) { if (st.st_CompleteDate == DateTime.MaxValue) { SubtaskController.UpdateSubtaskToCompleted(st.subtaskID); } } foreach (TreeNode node in e.Node.Nodes) { node.Checked = true; } } else if (e.Node.Checked == true) { TaskController.updateTaskIncomplete(tag.taskID); } } else { Subtask subTag = (Subtask)e.Node.Tag; if (e.Node.Checked == false) { SubtaskController.UpdateSubtaskToCompleted(subTag.subtaskID); } else if (e.Node.Checked == true) { SubtaskController.UpdateSubtaskToIncomplete(subTag.subtaskID); } } }
public void getSearchData() { listSubTaskGridView.DataSource = null; listSubTaskGridView.Rows.Clear(); listSubTaskGridView.Refresh(); try { if (fromdateTimePicker.Value > todateTimePicker.Value) { MessageBox.Show("Start date must come before the end date"); } else { DateTime fromDate = fromdateTimePicker.Value; DateTime toDate = todateTimePicker.Value; DataSet ds = SubtaskController.GetListSubTaskByCreatedDate(task.taskID, fromDate, toDate); if (ds.Tables.Count > 0) { //begin for grid data listSubTaskGridView.AutoGenerateColumns = true; listSubTaskGridView.AutoResizeColumns();// = true; listSubTaskGridView.DataSource = ds.Tables["subtask"]; //hide some columns listSubTaskGridView.Columns[0].Visible = false; listSubTaskGridView.Columns[1].Visible = false; } else { MessageBox.Show("No subtask to show. Please try your search again."); } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); this.BeginInvoke(new MethodInvoker(Close)); } }
//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()); } }
/* Currently unused */ //private void tasksBindingNavigatorSaveItem_Click(object sender, EventArgs e) //{ // this.Validate(); // this.tasksBindingSource.EndEdit(); // this.tableAdapterManager.UpdateAll(this.project6920DataSet); //} /* * Populate the task tree view with tasks and subtasks */ private void populateTaskTreeView() { //this.tasks = TaskController.getUserTasks(user, parentCalendar.getSelectedDate()); taskTreeView.ShowLines = false; //taskTreeView.AfterCheck -= taskTreeView_AfterCheck; // Add tasks to the list foreach (Models.Task task in this.tasks) { taskTreeView.Nodes.Add(task.title); TreeNode currentNode = taskTreeView.Nodes[this.tasks.FindIndex(a => a.taskID == task.taskID)]; currentNode.Tag = task; // Mark complete tasks with a checked box if (task.completed == true) { currentNode.Checked = true; } // Set font color to indicate priority if (task.task_priority == 1) { currentNode.ForeColor = Color.Red; } else if (task.task_priority == 2) { currentNode.ForeColor = Color.Orange; } if (task.isMeeting == 1) { currentNode.ForeColor = Color.Blue; } // Add details tooltip String priority = ""; if (task.task_priority == -1) { priority = "None"; } else if (task.task_priority == 1) { priority = "High"; } else if (task.task_priority == 2) { priority = "Medium"; } else { priority = "Low"; } string deadline = ""; if (task.deadline == DateTime.MaxValue) { deadline = "None"; } else { deadline = task.deadline.ToString(); } currentNode.ToolTipText = "Deadline: " + deadline + "\n" + "Priority: " + priority + "\n" + "Notes: " + this.getNoteString(task.taskID, -1); taskTreeView.ShowNodeToolTips = true; // Get all subtasks for the current task List <Subtask> subtasks = SubtaskController.GetSubtasksForTask(user, task.taskID); // Add each subtask as a nested node foreach (Subtask st in subtasks) { currentNode.Nodes.Add(st.st_Description); currentNode.Nodes[subtasks.FindIndex(b => b.subtaskID == st.subtaskID)].Tag = st; // Add details tooltip String st_priority = ""; if (st.st_Priority == -1) { st_priority = "None"; } else if (st.st_Priority == 1) { st_priority = "High"; } else if (st.st_Priority == 2) { st_priority = "Medium"; } else { st_priority = "Low"; } string subtaskdeadline = ""; if (st.st_Deadline == DateTime.MaxValue) { subtaskdeadline = "None"; } else { subtaskdeadline = st.st_Deadline.ToString(); } currentNode.Nodes[subtasks.FindIndex(b => b.subtaskID == st.subtaskID)].ToolTipText = "Deadline: " + subtaskdeadline + "\n" + "Priority: " + st_priority + "\n" + "Notes: " + this.getNoteString(task.taskID, st.subtaskID); // Mark completed subtasks with a checked box if (st.st_CompleteDate != DateTime.MaxValue) { currentNode.Nodes[subtasks.FindIndex(b => b.subtaskID == st.subtaskID)].Checked = true; } } } taskTreeView.BeforeCheck += taskTreeView_BeforeCheck; }
public void TestGetSubTaskWithFailData() { Subtask result = SubtaskController.getASubTask(-1); Assert.AreEqual(null, result); }