private void processProgrammerIssues() { SQL.getProgrammersIssues(userInfo.username); try { if (SQL.read.HasRows) { while (SQL.read.Read()) { // Create projectInfo object and add to arrayList Data.IssueInfo issue = new Data.IssueInfo(SQL.read[0].ToString(), SQL.read[3].ToString(), SQL.read[5].ToString(), SQL.read[6].ToString(), SQL.read[4].ToString(), int.Parse(SQL.read[1].ToString())); issues.Add(issue); projectName = SQL.read[2].ToString(); // add to list box listBoxIssues.Items.Add(String.Format("Project: {0} | Description: {1} | Status: {2}", projectName, issue.description, issue.status)); } } else { listBoxIssues.Items.Add(String.Format("No issues found for {0}", userInfo.username)); } } catch (Exception ex) { Console.WriteLine(ex); Console.WriteLine(ex.StackTrace); } }
public IssueDetailsPage(Data.IssueInfo issueInfo, String projectName, Data.UserInfo userInfo) { InitializeComponent(); issue = issueInfo; this.StartPosition = FormStartPosition.CenterParent; labelTitle.Text += issue.issueid; labelReportDate.Text += FormHelper.getDateFromDT(issue.reportDate); labelProject.Text += projectName; fillMaluableData(); // stop focus of textbox textBoxDescription.GotFocus += textBox_GotFocus; textBoxStatus.GotFocus += textBox_GotFocus; textBoxUrgency.GotFocus += textBox_GotFocus; FormHelper.centerControlHalf(this, labelTitle); FormHelper.centerControlHalf(this, textBoxUrgency); FormHelper.centerControlHalf(this, textBoxStatus); FormHelper.centerControlHalf(this, textBoxDescription); FormHelper.centerControlHalf(this, labelReportDate); FormHelper.centerControlHalf(this, labelProject); if (userInfo.role == Data.UserInfo.PROGRAMMER_ROLE) { buttonUpdate.Hide(); buttonUpdate.Enabled = false; FormHelper.centerControlHalf(this, buttonBack); } }
public IssueUpdatePage(Data.IssueInfo issue) { InitializeComponent(); this.StartPosition = FormStartPosition.CenterParent; comboBoxUrgency.SelectedIndex = 0; comboBoxStatus.SelectedIndex = 0; this.issue = issue; }
private void reloadIssue() { SQL.getIssueOnID(issue.issueid); try { if (SQL.read.HasRows) { SQL.read.Read(); issue = new Data.IssueInfo(SQL.read[0].ToString(), SQL.read[1].ToString(), SQL.read[3].ToString(), SQL.read[4].ToString(), SQL.read[2].ToString(), int.Parse(SQL.read[5].ToString())); } } catch (Exception ex) { Console.WriteLine(ex); Console.WriteLine(ex.StackTrace); } fillMaluableData(); }
private void buttonDetails_Click(object sender, EventArgs e) { int issueIndex = listBoxIssues.SelectedIndex; if (issueIndex == -1) { MessageBox.Show("Please select an issue"); return; } Data.IssueInfo issue = (Data.IssueInfo)issues[issueIndex]; IssueDetailsPage page = new IssueDetailsPage(issue, getProjectName(issue), userInfo); page.FormClosed += Page_FormClosed; Hide(); page.ShowDialog(); }
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 given issue info in database public static void insertIssue(Data.IssueInfo issue) { con.Close(); String query = "INSERT INTO issue VALUES(@description, CAST(GETDATE() AS Date), @urgency, @status, @projectid)"; try { SqlCommand command = new SqlCommand(query, con); command.Parameters.AddWithValue("@description", issue.description); command.Parameters.AddWithValue("@urgency", issue.urgency); command.Parameters.AddWithValue("@status", issue.status); command.Parameters.AddWithValue("@projectid", issue.projectid.ToString()); 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 String getProjectName(Data.IssueInfo issue) { SQL.getProjectFromIssueID(issue.issueid); String projectName = null; try { if (SQL.read.HasRows) { SQL.read.Read(); projectName = SQL.read[1].ToString(); } else { throw new Exception("No issue id"); } } catch (Exception ex) { Console.WriteLine(ex); Console.WriteLine(ex.StackTrace); return(null); } return(projectName); }