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 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(); } }
private void ChangeProjectDetails() { using (var form = new ProjectDetailsForm(mContext, Project)) { if (form.ShowDialog() != DialogResult.OK) { return; } Project = form.RetrieveProject(Project); // Update project. Project.Update(mContext); // Flush. mContext.Flush(); UpdateTitlebar(); ShowProjectDetails(); mMainForm.UpdateProject(); } }