private void DeleteAttachment() { if (attachmentsListView.Items.Count == 0) { return; } DialogResult result = MessageBox.Show( Resources.String_AreYouSureYouWantToDeleteAttachments, Resources.String_DeleteAttachments, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, FormUtil.GetMessageBoxOptions(this)); if (result != DialogResult.Yes) { return; } FormUtil.DeleteSelected <Attachment>(attachmentsListView, mContext); // Flush. mContext.Flush(); // Show attachments. ShowAttachments(); }
private void MilestoneDetailsForm_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult != DialogResult.OK) { return; } var problems = new List <string>(); if (string.IsNullOrWhiteSpace(nameTextBox.Text.Trim())) { problems.Add(Resources.String_TheMilestoneNameCannotBeBlank); } if (stateComboBox.SelectedIndex == -1) { problems.Add(Resources.String_PleaseSpecifyMilestoneState); } if (!problems.Any()) { return; } MessageBox.Show( string.Join(Environment.NewLine, problems), Resources.String_Error, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, FormUtil.GetMessageBoxOptions(this)); e.Cancel = true; }
private void SaveAttachment() { if (attachmentsListView.SelectedItems.Count != 1) { return; } try { var tag = (Attachment)attachmentsListView.SelectedItems[0].Tag; saveFileDialog.FileName = tag.Name; if (saveFileDialog.ShowDialog() != DialogResult.OK) { return; } string fileName = saveFileDialog.FileName; Attachment attachment = Attachment.GetAttachment(mContext, tag.ID); File.WriteAllBytes(fileName, attachment.GetContents()); } catch (Exception exception) { MessageBox.Show( exception.Message, Resources.String_Error, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, FormUtil.GetMessageBoxOptions(this)); } }
private void ProjectDetailsForm_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult != DialogResult.OK) { return; } var problems = new List <string>(); if (string.IsNullOrWhiteSpace(projectDetailsUserControl.ProjectName)) { problems.Add(Resources.String_TheProjectNameCannotBeBlank); } if (!problems.Any()) { return; } MessageBox.Show( string.Join(Environment.NewLine, problems), Resources.String_Error, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, FormUtil.GetMessageBoxOptions(this)); e.Cancel = true; }
private void DeleteMilestone() { if (milestonesListView.SelectedItems.Count == 0) { return; } DialogResult result = MessageBox.Show( Resources.String_AreYouSureYouWantToDeleteSelectedMilestonesAndTheirTickets, Resources.String_DeleteMilestones, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, FormUtil.GetMessageBoxOptions(this)); if (result != DialogResult.Yes) { return; } FormUtil.DeleteSelected <Milestone>(milestonesListView, mContext); // Flush. mContext.Flush(); // Show milestones. ShowMilestones(); PopulateTicketFilters(); // Tickets may change as the result of removing a milestone ShowTickets(); mMainForm.UpdateTicket(); }
private void TicketDetailsForm_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult != DialogResult.OK) { return; } var problems = new List <string>(); if (milestoneComboBox.SelectedItem == null) { problems.Add(Resources.String_PleaseSelectAMilestone); } if (string.IsNullOrWhiteSpace(summaryTextBox.Text)) { problems.Add(Resources.String_TheTicketSummaryCannotBeBlank); } if (typeComboBox.SelectedIndex == -1) { problems.Add(Resources.String_PleaseSpecifyTicketType); } if (severityComboBox.SelectedIndex == -1) { problems.Add(Resources.String_PleaseSpecifyTicketSeverity); } if (stateComboBox.SelectedIndex == -1) { problems.Add(Resources.String_PleaseSpecifyTicketState); } if (priorityComboBox.SelectedIndex == -1) { problems.Add(Resources.String_PleaseSpecifyTicketPriority); } if (string.IsNullOrWhiteSpace(descriptionTextBox.Text)) { problems.Add(Resources.String_TheTicketDescriptionCannotBeBlank); } if (!problems.Any()) { return; } MessageBox.Show( string.Join(Environment.NewLine, problems), Resources.String_Error, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, FormUtil.GetMessageBoxOptions(this)); e.Cancel = true; }
private void projectComboBox_SelectedIndexChanged(object sender, EventArgs e) { int selectedIndex = projectComboBox.SelectedIndex; milestoneComboBox.BeginUpdate(); milestoneComboBox.SelectedItem = null; milestoneComboBox.Items.Clear(); milestoneComboBox.Enabled = false; if (selectedIndex != -1) { var project = (Project)projectComboBox.SelectedItem; var milestones = project.GetMilestones(mContext); if (!milestones.Any()) { DialogResult result = MessageBox.Show( Resources.String_AskUserAboutMilestone, Resources.String_Error, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, FormUtil.GetMessageBoxOptions(this)); if (result == DialogResult.Yes) { using (var form = new MilestoneDetailsForm(mContext, project, null)) { if (form.ShowDialog() != DialogResult.OK) { return; } Milestone milestone = form.RetrieveMilestone(); // Add. milestone.Add(mContext); // Flush. mContext.Flush(); milestones = new[] { milestone }; } } } milestoneComboBox.Items.AddRange(milestones); milestoneComboBox.Enabled = milestones.Any(); if (milestones.Length == 1) { milestoneComboBox.SelectedItem = milestones[0]; } } milestoneComboBox.EndUpdate(); }
private void OpenLink() { try { string address = string.Format("mailto:{0}", Settings.Default.ProgrammerEmail); Process.Start(address); } catch (Exception exception) { MessageBox.Show( exception.Message, Resources.String_Error, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, FormUtil.GetMessageBoxOptions(this)); } }
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); } }
private void AddAttachment() { try { if (openFileDialog.ShowDialog() != DialogResult.OK) { return; } string fileName = openFileDialog.FileName; var fi = new FileInfo(fileName); Attachment attachment = mTicket.NewAttachment(); attachment.Name = fi.Name.Substring(0, Math.Min(255, fi.Name.Length)); // Max 255 characters. attachment.SetContents(File.ReadAllBytes(fileName)); attachment.Add(mContext); // Flush. mContext.Flush(); ShowAttachments(); FormUtil.SelectNew(attachmentsListView, attachment); } catch (Exception exception) { MessageBox.Show( exception.Message, Resources.String_Error, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, FormUtil.GetMessageBoxOptions(this)); ShowAttachments(); } }