Exemplo n.º 1
0
        private void EditTicket()
        {
            if (ticketsListView.SelectedItems.Count != 1)
            {
                return;
            }

            var tag = (Ticket)ticketsListView.SelectedItems[0].Tag;

            using (var form = new TicketDetailsForm(mContext, FormUtil.GetFontContext(), FormUtil.GetFormatter(), Project, tag)) {
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                tag.UpdateAndGenerateHistoryRecord(mContext, TicketChangeFormatter.Default, t => {
                    return(form.RetrieveTicket(t));
                });

                // Flush.
                mContext.Flush();

                // Show tickets.
                ShowTickets();

                UpdateTicket(true);
            }
        }
Exemplo n.º 2
0
        private void ShowTicket()
        {
            if (ticketsListView.SelectedItems.Count != 1)
            {
                return;
            }

            var tag = (Ticket)ticketsListView.SelectedItems[0].Tag;

            using (var form = new TicketDetailsForm(mContext, FormUtil.GetFontContext(), FormUtil.GetFormatter(), Project, tag)) {
                form.ReadOnly = true;
                form.ShowDialog();
            }
        }
Exemplo n.º 3
0
        private void AddTicket()
        {
            Milestone[] milestones = Project.GetMilestones(mContext);
            if (milestones.Length == 0)
            {
                MessageBox.Show(
                    Resources.String_PleaseAddAMilestoneBeforeAddingATicket,
                    Resources.String_Error,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1,
                    FormUtil.GetMessageBoxOptions(this));
                tabControl.SelectedTab = milestonesTabPage;
                return;
            }

            using (var form = new TicketDetailsForm(mContext, FormUtil.GetFontContext(), FormUtil.GetFormatter(), Project, null)) {
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                Ticket ticket = form.RetrieveTicket();

                // Add.
                ticket.Add(mContext);

                // Flush.
                mContext.Flush();

                // Create ticket history entry.
                TicketHistory ticketHistory = ticket.NewHistory(Resources.String_TicketCreated);
                ticketHistory.Add(mContext);

                // Show tickets.
                ShowTickets();

                FormUtil.SelectNew(ticketsListView, ticket);

                UpdateButtonsEnabledProperty();

                ticketsListView.Focus();

                UpdateTicket(true);
            }
        }
Exemplo n.º 4
0
        private void ShowTicket()
        {
            if (ticketsListUserControl.TicketsListView.SelectedItems.Count != 1)
            {
                return;
            }

            Ticket ticket = (Ticket)ticketsListUserControl.TicketsListView.SelectedItems[0].Tag;

            TicketDetailsForm form = new TicketDetailsForm();

            Milestone[] milestones = Project.GetMilestones();
            form.TicketDetailsUserControl.ShowMilestones(milestones);

            form.TicketDetailsUserControl.ShowTicket(ticket);
            form.TicketDetailsUserControl.ReadOnly = true;

            form.ShowDialog();

            return;
        }
Exemplo n.º 5
0
        private void EditTicket()
        {
            if (ticketsListUserControl.TicketsListView.SelectedItems.Count != 1)
            {
                return;
            }

            Ticket ticket = (Ticket)ticketsListUserControl.TicketsListView.SelectedItems[0].Tag;

            TicketDetailsForm form = new TicketDetailsForm();

            Milestone[] milestones = Project.GetMilestones();
            form.TicketDetailsUserControl.ShowMilestones(milestones);

            form.TicketDetailsUserControl.ShowTicket(ticket);

            Again:
            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // Check milestone.
                if (form.TicketDetailsUserControl.Milestone == null)
                {
                    MessageBox.Show
                    (
                        Resources.String_PleaseSelectAMilestone,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                // Check summary.
                if (string.IsNullOrWhiteSpace(form.TicketDetailsUserControl.Summary))
                {
                    MessageBox.Show
                    (
                        Resources.String_TheTicketSummaryCannotBeBlank,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                // Check type.
                if (form.TicketDetailsUserControl.Type == (TicketType)(-1))
                {
                    MessageBox.Show
                    (
                        Resources.String_PleaseSpecifyTicketType,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                // Check severity.
                if (form.TicketDetailsUserControl.Severity == (TicketSeverity)(-1))
                {
                    MessageBox.Show
                    (
                        Resources.String_PleaseSpecifyTicketSeverity,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                // Check state.
                if (form.TicketDetailsUserControl.State == (TicketState)(-1))
                {
                    MessageBox.Show
                    (
                        Resources.String_PleaseSpecifyTicketState,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                // Check priority.
                if (form.TicketDetailsUserControl.Priority == (TicketPriority)(-1))
                {
                    MessageBox.Show
                    (
                        Resources.String_PleaseSpecifyTicketPriority,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                // Check description.
                if (string.IsNullOrWhiteSpace(form.TicketDetailsUserControl.Description))
                {
                    MessageBox.Show
                    (
                        Resources.String_TheTicketDescriptionCannotBeBlank,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                // Changes.
                StringBuilder changesStringBuilder = new StringBuilder();
                // Milestone.
                if (ticket.MilestoneID != form.TicketDetailsUserControl.Milestone.ID)
                {
                    changesStringBuilder.AppendFormat(Resources.String_MilestoneChangesFromXToY, ticket.GetMilestone().Name, form.TicketDetailsUserControl.Milestone.Name);
                    changesStringBuilder.AppendLine();
                }
                // Summary.
                if (ticket.Summary != form.TicketDetailsUserControl.Summary)
                {
                    changesStringBuilder.AppendFormat(Resources.String_SummaryChangesFromXToY, ticket.Summary, form.TicketDetailsUserControl.Summary);
                    changesStringBuilder.AppendLine();
                }
                // Reported by.
                if (ticket.ReportedBy != form.TicketDetailsUserControl.ReportedBy)
                {
                    changesStringBuilder.AppendFormat(Resources.String_ReportedByChangesFromXToY, ticket.ReportedBy, form.TicketDetailsUserControl.ReportedBy);
                    changesStringBuilder.AppendLine();
                }
                // Type.
                if (ticket.Type != form.TicketDetailsUserControl.Type)
                {
                    changesStringBuilder.AppendFormat
                    (
                        Resources.String_TypeChangesFromXToY,
                        TranslateTicketType(ticket.Type),
                        TranslateTicketType(form.TicketDetailsUserControl.Type)
                    );
                    changesStringBuilder.AppendLine();
                }
                // Severity.
                if (ticket.Severity != form.TicketDetailsUserControl.Severity)
                {
                    changesStringBuilder.AppendFormat
                    (
                        Resources.String_SeverityChangesFromXToY,
                        TranslateTicketSeverity(ticket.Severity),
                        TranslateTicketSeverity(form.TicketDetailsUserControl.Severity)
                    );
                    changesStringBuilder.AppendLine();
                }
                // State.
                if (ticket.State != form.TicketDetailsUserControl.State)
                {
                    changesStringBuilder.AppendFormat
                    (
                        Resources.String_StateChangesFromXToY,
                        TranslateTicketState(ticket.State),
                        TranslateTicketState(form.TicketDetailsUserControl.State)
                    );
                    changesStringBuilder.AppendLine();
                }
                // AssignedTo.
                if (ticket.AssignedTo != form.TicketDetailsUserControl.AssignedTo)
                {
                    changesStringBuilder.AppendFormat(Resources.String_AssignedToChangesFromXToY, ticket.AssignedTo, form.TicketDetailsUserControl.AssignedTo);
                    changesStringBuilder.AppendLine();
                }
                // Priority.
                if (ticket.Priority != form.TicketDetailsUserControl.Priority)
                {
                    changesStringBuilder.AppendFormat
                    (
                        Resources.String_PriorityChangesFromXToY,
                        TranslateTicketPriority(ticket.Priority),
                        TranslateTicketPriority(form.TicketDetailsUserControl.Priority)
                    );
                    changesStringBuilder.AppendLine();
                }
                // Description.
                if (ticket.Description != form.TicketDetailsUserControl.Description)
                {
                    changesStringBuilder.AppendFormat(Resources.String_DescriptionChanges);
                    changesStringBuilder.AppendLine();
                }

                form.TicketDetailsUserControl.RetrieveTicket(ticket);

                // Update tickets.
                ticket.Update();

                // Create ticket history entry.
                string changes = changesStringBuilder.ToString();
                if (!string.IsNullOrEmpty(changes))
                {
                    TicketHistory ticketHistory = ticket.NewHistory();
                    ticketHistory.Timestamp = DateTime.Now;
                    ticketHistory.Changes = changes;
                    ticketHistory.Comment = ticket.Description;
                    ticketHistory.Add();
                }

                // Flush.
                Database.Flush();

                // Show tickets.
                ShowTickets();
            }

            return;
        }
Exemplo n.º 6
0
        private void AddTicket()
        {
            Milestone[] milestones = Project.GetMilestones();
            if (milestones.Length == 0)
            {
                MessageBox.Show
                (
                    Resources.String_PleaseAddAMilestoneBeforeAddingATicket,
                    Resources.String_Error,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1,
                    FormMessageBoxOptions
                );
                tabControl.SelectedTab = milestonesTabPage;
                return;
            }

            TicketDetailsForm form = new TicketDetailsForm();

            form.TicketDetailsUserControl.ShowMilestones(milestones);

            form.TicketDetailsUserControl.Type = (TicketType)(-1);
            form.TicketDetailsUserControl.Severity = TicketSeverity.Normal;
            form.TicketDetailsUserControl.State = TicketState.New;
            form.TicketDetailsUserControl.Priority = TicketPriority.Normal;

            Again:
            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // Check milestone.
                if (form.TicketDetailsUserControl.Milestone == null)
                {
                    MessageBox.Show
                    (
                        Resources.String_PleaseSelectAMilestone,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                // Check summary.
                if (string.IsNullOrWhiteSpace(form.TicketDetailsUserControl.Summary))
                {
                    MessageBox.Show
                    (
                        Resources.String_TheTicketSummaryCannotBeBlank,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                // Check type.
                if (form.TicketDetailsUserControl.Type == (TicketType)(-1))
                {
                    MessageBox.Show
                    (
                        Resources.String_PleaseSpecifyTicketType,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                // Check severity.
                if (form.TicketDetailsUserControl.Severity == (TicketSeverity)(-1))
                {
                    MessageBox.Show
                    (
                        Resources.String_PleaseSpecifyTicketSeverity,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                // Check state.
                if (form.TicketDetailsUserControl.State == (TicketState)(-1))
                {
                    MessageBox.Show
                    (
                        Resources.String_PleaseSpecifyTicketState,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                // Check priority.
                if (form.TicketDetailsUserControl.Priority == (TicketPriority)(-1))
                {
                    MessageBox.Show
                    (
                        Resources.String_PleaseSpecifyTicketPriority,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                // Check description.
                if (string.IsNullOrWhiteSpace(form.TicketDetailsUserControl.Description))
                {
                    MessageBox.Show
                    (
                        Resources.String_TheTicketDescriptionCannotBeBlank,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                Milestone milestone = form.TicketDetailsUserControl.Milestone;
                Ticket ticket = milestone.NewTicket();
                form.TicketDetailsUserControl.RetrieveTicket(ticket);

                // Add.
                ticket.Add();

                // Flush.
                Database.Flush();

                // Create ticket history entry.
                TicketHistory ticketHistory = ticket.NewHistory();
                ticketHistory.Timestamp = DateTime.Now;
                ticketHistory.Changes = Resources.String_TicketCreated;
                ticketHistory.Comment = ticket.Description;
                ticketHistory.Add();

                // Show tickets.
                ShowTickets();

                // Select new ticket.
                ticketsListUserControl.TicketsListView.SelectedItems.Clear();
                foreach (ListViewItem item in ticketsListUserControl.TicketsListView.Items)
                {
                    Ticket t = (Ticket)item.Tag;
                    if (t.ID == ticket.ID)
                    {
                        item.Selected = true;
                        item.EnsureVisible();
                        break;
                    }
                }

                UpdateButtonsEnabledProperty();

                ticketsListUserControl.Focus();
            }

            return;
        }