private void readInTasks() { tasks = new ArrayList(); try { if (SQL.read.HasRows) { while (SQL.read.Read()) { // Create taskInfo object and add to arrayList Data.TaskInfo task = new Data.TaskInfo(SQL.read[0].ToString(), SQL.read[1].ToString(), SQL.read[2].ToString(), SQL.read[3].ToString(), SQL.read[4].ToString(), SQL.read[5].ToString(), int.Parse(SQL.read[6].ToString())); tasks.Add(task); // add to list box listBoxTasks.Items.Add(String.Format("Name: {0} | Priority: {1}", task.name, task.priority)); } } else { listBoxTasks.Items.Add(String.Format("No tasks found...")); } } catch (Exception ex) { Console.WriteLine(ex); Console.WriteLine(ex.StackTrace); } }
private void buttonMiddle_Click(object sender, EventArgs e) { Form page = null; switch (userInfo.role) { case Data.UserInfo.MANAGER_ROLE: page = new AddTaskPage(projectidPass); page.FormClosed += Page_FormClosed; Hide(); page.ShowDialog(); break; // View progress case Data.UserInfo.PROGRAMMER_ROLE: if (listBoxTasks.SelectedIndex == -1) { MessageBox.Show("Please select a task"); return; } Data.TaskInfo task = (Data.TaskInfo)tasks[listBoxTasks.SelectedIndex]; page = new ProgressPage(int.Parse(task.taskid)); page.FormClosed += Page_FormClosed; Hide(); page.ShowDialog(); break; } }
private void buttonConfirm_Click(object sender, EventArgs e) { if (!isInput()) { return; } // Get user input String name = textBoxName.Text.Trim(); String completeDate; completeDate = dtpCompleteDate.Checked ? dtpCompleteDate.Text : null; if (completeDate != null && DateTime.Today.Date > dtpCompleteDate.Value.Date) { MessageBox.Show("Can't set complete date before today"); return; } String priority = comboBoxPriority.SelectedItem.ToString(); String description = textBoxDescription.Text; // create task object Data.TaskInfo task = new Data.TaskInfo(null, name, description, priority, null, completeDate, projectid); SQL.insertTask(task); this.Close(); }
private void buttonSelect_Click(object sender, EventArgs e) { int taskIndex = listBoxTasks.SelectedIndex; if (tasks.Count == 0 || taskIndex == -1) { MessageBox.Show("Please select a task"); return; } Data.TaskInfo task = (Data.TaskInfo)tasks[taskIndex]; Form page = null; switch (userInfo.role) { case Data.UserInfo.MANAGER_ROLE: page = new TaskDetailPage(task, userInfo); page.FormClosed += Page_FormClosed; Hide(); page.ShowDialog(); break; // View progress case Data.UserInfo.PROGRAMMER_ROLE: page = new ProgrammerTaskDetailPage(task); page.FormClosed += Page_FormClosed; Hide(); page.ShowDialog(); break; } }
public UpdateTaskPage(Data.TaskInfo task) { InitializeComponent(); this.StartPosition = FormStartPosition.CenterParent; this.task = task; comboBoxPriority.SelectedIndex = 0; dtpCompleteDate.Value = DateTime.Now; }
public TaskDetailPage(Data.TaskInfo task, Data.UserInfo user) { InitializeComponent(); this.StartPosition = FormStartPosition.CenterParent; this.task = task; compute(); }
private void reloadTask() { SQL.getTaskOnID(task.taskid); try { if (SQL.read.HasRows) { SQL.read.Read(); task = new Data.TaskInfo(SQL.read[0].ToString(), SQL.read[1].ToString(), SQL.read[2].ToString(), SQL.read[3].ToString(), SQL.read[4].ToString(), SQL.read[5].ToString(), int.Parse(SQL.read[6].ToString())); } } catch (Exception ex) { Console.WriteLine(ex); Console.WriteLine(ex.StackTrace); } }
private void buttonConfirm_Click(object sender, EventArgs e) { // if no project selected if (listBoxContent.SelectedIndex == -1) { if (userInfo.role == Data.UserInfo.PROGRAMMER_ROLE) { MessageBox.Show("Please select a task"); } else { MessageBox.Show("Please select a project"); } return; } Data.IssueInfo issue = null; switch (userInfo.role) { case Data.UserInfo.MANAGER_ROLE: // get selected project and create issue object Data.ProjectInfo project = (Data.ProjectInfo)listContent[listBoxContent.SelectedIndex]; issue = new Data.IssueInfo(null, textBoxDescription.Text, comboBoxUrgency.SelectedItem.ToString(), comboBoxStatus.SelectedItem.ToString(), null, int.Parse(project.projectid)); break; case Data.UserInfo.PROGRAMMER_ROLE: Data.TaskInfo task = (Data.TaskInfo)listContent[listBoxContent.SelectedIndex]; issue = new Data.IssueInfo(null, textBoxDescription.Text, comboBoxUrgency.SelectedItem.ToString(), comboBoxStatus.SelectedItem.ToString(), null, int.Parse(task.projectid.ToString())); break; } // add issue to database try { SQL.insertIssue(issue); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); Console.WriteLine(ex); MessageBox.Show("Error adding issue"); return; } this.Close(); }
// Inserts task data into task database public static void insertTask(Data.TaskInfo task) { con.Close(); String query = "INSERT INTO task VALUES(@name, @description, @priority, CAST( GETDATE() AS Date ), @completeDate, @projectid)"; try { SqlCommand command = new SqlCommand(query, con); command.Parameters.AddWithValue("@name", task.name); command.Parameters.AddWithValue("@description", task.description); command.Parameters.AddWithValue("@priority", task.priority); command.Parameters.AddWithValue("@completeDate", task.completeDate ?? Convert.DBNull); command.Parameters.AddWithValue("@projectid", task.projectid); con.Open(); SqlCommand dateSet = new SqlCommand("SET DATEFORMAT dmy", con); dateSet.ExecuteNonQuery(); command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); Console.WriteLine(ex); } }
private ArrayList getProgrammerTaskAssc() { ArrayList tasks = new ArrayList(); SQL.getProgrammersTasks(userInfo.username); try { if (SQL.read.HasRows) { while (SQL.read.Read()) { // Add task to association list to be passed to a Data.TaskInfo task = new Data.TaskInfo(SQL.read[0].ToString(), SQL.read[1].ToString(), SQL.read[2].ToString(), SQL.read[3].ToString(), SQL.read[4].ToString(), SQL.read[5].ToString(), int.Parse(SQL.read[6].ToString())); tasks.Add(task); } } } catch (Exception ex) { Console.WriteLine(ex); Console.WriteLine(ex.StackTrace); return(null); } return(tasks); }
public ProgrammerTaskDetailPage(Data.TaskInfo task) { InitializeComponent(); this.StartPosition = FormStartPosition.CenterParent; labelTitle.Text = task.name; textBoxPriority.Text = task.priority; textBoxDescription.Text = task.description; labelProject.Text += SQL.getProjectName(task.projectid); labelStartDate.Text += FormHelper.getDateFromDT(task.startDate); labelCompleteDate.Text += FormHelper.getDateFromDT(task.completeDate); FormHelper.centerControlHalf(this, labelTitle); FormHelper.centerControlHalf(this, textBoxPriority); FormHelper.centerControlHalf(this, textBoxDescription); FormHelper.centerControlHalf(this, labelProject); FormHelper.centerControlHalf(this, labelStartDate); FormHelper.centerControlHalf(this, labelCompleteDate); // stop textbox focus textBoxDescription.GotFocus += textBox_GotFocus; textBoxPriority.GotFocus += textBox_GotFocus; }