public AttachmentsForm(Ticket ticket) { if (ticket == null) { throw new ArgumentNullException("ticket"); } Ticket = ticket; InitializeComponent(); attachmentsListUserControl.AttachmentsListView.SelectedIndexChanged += AttachmentsListView_SelectedIndexChanged; ShowAttachments(); }
public TicketHistoryForm(Ticket ticket) { if (ticket == null) { throw new ArgumentNullException("ticket"); } Ticket = ticket; InitializeComponent(); if (Settings.Default.FormatDateTime) { try { DateTimeFormatter dateTimeFormatter = new DateTimeFormatter ( Settings.Default.DateTimePattern, Settings.Default.Calendar ); ticketHistoryListUserControl.DateTimeFormatter = dateTimeFormatter; ticketHistoryDetailsUserControl.DateTimeFormatter = dateTimeFormatter; } catch (Exception) { // Nothing. } } ticketHistoryListUserControl.TicketHistoryListView.SelectedIndexChanged += TicketHistoryListView_SelectedIndexChanged; ShowTicketHistory(); // Select last history. if (ticketHistoryListUserControl.TicketHistoryListView.Items.Count > 0) { ticketHistoryListUserControl.TicketHistoryListView.SelectedIndices.Clear(); ticketHistoryListUserControl.TicketHistoryListView.SelectedIndices.Add(0); } }
public void ShowTicket(Ticket ticket) { if (ticket == null) { throw new ArgumentNullException("ticket"); } milestoneComboBox.SelectedIndex = -1; for (int i = 0; i < milestoneComboBox.Items.Count; i++) { Milestone milestone = (Milestone)milestoneComboBox.Items[i]; if (milestone.ID == ticket.MilestoneID) { milestoneComboBox.SelectedIndex = i; break; } } ticketNumberTextBox.Text = string.Format("{0}", ticket.TicketNumber); summaryTextBox.Text = ticket.Summary; reportedByComboBox.Text = ticket.ReportedBy; typeComboBox.SelectedIndex = (int)ticket.Type; severityComboBox.SelectedIndex = (int)ticket.Severity; stateComboBox.SelectedIndex = (int)ticket.State; assignedToComboBox.Text = ticket.AssignedTo; priorityComboBox.SelectedIndex = (int)ticket.Priority; descriptionTextBox.Text = ticket.Description; return; }
public void RetrieveTicket(Ticket ticket) { if (ticket == null) { throw new ArgumentNullException("ticket"); } Milestone milestone = (Milestone)milestoneComboBox.SelectedItem; ticket.MilestoneID = milestone.ID; ticket.Summary = summaryTextBox.Text; ticket.ReportedBy = reportedByComboBox.Text.Substring(0, Math.Min(255, reportedByComboBox.Text.Length)); // Max 255 characters. ticket.Type = (TicketType)typeComboBox.SelectedIndex; ticket.Severity = (TicketSeverity)severityComboBox.SelectedIndex; ticket.State = (TicketState)stateComboBox.SelectedIndex; ticket.AssignedTo = assignedToComboBox.Text.Substring(0, Math.Min(255, assignedToComboBox.Text.Length)); // Max 255 characters. ticket.Priority = (TicketPriority)priorityComboBox.SelectedIndex; ticket.Description = descriptionTextBox.Text; return; }
public static Ticket[] GetTickets(int milestoneID) { TicketsTableAdapter tableAdapter = Database.TicketsTableAdapter; PeygirDatabaseDataSet.TicketsDataTable rows = tableAdapter.GetDataByMilestoneID(milestoneID); // Create list. List<Ticket> tickets = new List<Ticket>(); foreach (var row in rows) { // Add. Ticket ticket = new Ticket(row); tickets.Add(ticket); } return tickets.ToArray(); }
public static Ticket GetTicket(int id) { TicketsTableAdapter tableAdapter = Database.TicketsTableAdapter; PeygirDatabaseDataSet.TicketsDataTable rows = tableAdapter.GetDataByID(id); if (rows.Count == 1) { // Found. Ticket ticket = new Ticket(rows[0]); return ticket; } // Not found. return null; }
public void ShowTickets(Ticket[] tickets) { if (tickets == null) { throw new ArgumentNullException("tickets"); } // Cache milestones. Dictionary<int, string> milestoneNames = new Dictionary<int, string>(); Milestone[] milestones = Milestone.GetMilestones(); foreach (Milestone milestone in milestones) { milestoneNames[milestone.ID] = milestone.Name; } ticketsListView.BeginUpdate(); ticketsListView.Items.Clear(); foreach (var ticket in tickets) { string ticketPriority; switch (ticket.Priority) { case TicketPriority.Lowest: ticketPriority = Resources.String_Lowest; break; case TicketPriority.Low: ticketPriority = Resources.String_Low; break; case TicketPriority.Normal: ticketPriority = Resources.String_Normal; break; case TicketPriority.High: ticketPriority = Resources.String_High; break; case TicketPriority.Highest: ticketPriority = Resources.String_Highest; break; default: ticketPriority = string.Empty; break; } string ticketType; switch (ticket.Type) { case TicketType.Defect: ticketType = Resources.String_Defect; break; case TicketType.FeatureRequest: ticketType = Resources.String_FeatureRequest; break; case TicketType.Task: ticketType = Resources.String_Task; break; default: ticketType = string.Empty; break; } string ticketSeverity; switch (ticket.Severity) { case TicketSeverity.Blocker: ticketSeverity = Resources.String_Blocker; break; case TicketSeverity.Critical: ticketSeverity = Resources.String_Critical; break; case TicketSeverity.Major: ticketSeverity = Resources.String_Major; break; case TicketSeverity.Normal: ticketSeverity = Resources.String_Normal; break; case TicketSeverity.Minor: ticketSeverity = Resources.String_Minor; break; case TicketSeverity.Trivial: ticketSeverity = Resources.String_Trivial; break; default: ticketSeverity = string.Empty; break; } string ticketState; switch (ticket.State) { case TicketState.New: ticketState = Resources.String_New; break; case TicketState.Accepted: ticketState = Resources.String_Accepted; break; case TicketState.Closed: ticketState = Resources.String_Closed; break; case TicketState.Completed: ticketState = Resources.String_Completed; break; default: ticketState = string.Empty; break; } ListViewItem lvi = new ListViewItem(); lvi.Text = string.Format("{0}", ticket.TicketNumber); lvi.SubItems.Add(ticket.Summary); lvi.SubItems.Add(milestoneNames[ticket.MilestoneID]); lvi.SubItems.Add(ticketPriority); lvi.SubItems.Add(ticketType); lvi.SubItems.Add(ticketSeverity); lvi.SubItems.Add(ticketState); lvi.Tag = ticket; ticketsListView.Items.Add(lvi); } ticketsListView.EndUpdate(); ticketsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); return; }
public Ticket[] GetTickets() { if (ID == InvalidID) { string message = Resources.String_CurrentObjectDoesNotExistInTheDatabase; throw new InvalidOperationException(message); } TicketsTableAdapter tableAdapter = new TicketsTableAdapter(); PeygirDatabaseDataSet.TicketsDataTable rows = tableAdapter.GetDataByProjectID(ID); // Create list. List<Ticket> tickets = new List<Ticket>(); foreach (var row in rows) { // Add. Ticket ticket = new Ticket(row); tickets.Add(ticket); } return tickets.ToArray(); }