static long threshold = 2621440; // 2.5MB public AddEditIssueDialog(IssueListItem issue) { InitializeComponent(); try { cmbCategory.ItemsSource = Enum.GetValues(typeof(IssueCategoryEnum)).Cast <IssueCategoryEnum>(); cmbPriority.ItemsSource = Enum.GetValues(typeof(IssuePriorityEnum)).Cast <IssuePriorityEnum>(); cmbStatus.ItemsSource = Enum.GetValues(typeof(IssueStatusEnum)).Cast <IssueStatusEnum>(); List <string> userList = Globals.currentTeamUserList.AsEnumerable().Select(u => u.LoginName).ToList <string>(); List <string> userStoryList = Globals.currentUserStoryList.AsEnumerable().Select(us => us.Name).ToList <string>(); cmbUserList.ItemsSource = userList; cmbUserStoryList.ItemsSource = userStoryList; if (issue != null) { if (issue.Category.Equals(IssueCategoryEnum.Defect.ToString())) { tbTitle.Text = "Update Defect"; } else if (issue.Category.Equals(IssueCategoryEnum.Task.ToString())) { tbTitle.Text = "Update Task"; } this.DataContext = issue; currentIssue = Globals.simpleJiraDB.Issues.Where(iss => iss.IssueId == issue.IssueId).FirstOrDefault(); btAddUpdate.Content = "Update"; cmbUserList.SelectedItem = Globals.currentTeamUserList.Where(ut => ut.UserId == issue.OwnerId).SingleOrDefault().LoginName; cmbUserStoryList.SelectedItem = Globals.currentUserStoryList.Where(us => us.UserStoryId == issue.UserStoryId).SingleOrDefault().Name; if (currentIssue.Photo != null) { image.Source = (ImageSource)((new ImageSourceConverter()).ConvertFrom(currentIssue.Photo)); } } } catch (SqlException ex) { new MessageBoxCustom("ERROR Loading data from database: \n" + ex.Message, MessageBoxCustom.MessageType.Error, MessageBoxCustom.MessageButtons.Ok).ShowDialog(); } }
private void btDelete_Click(object sender, RoutedEventArgs e) { if (SprintView.IsVisible) { try { if (SprintListView.SelectedIndex == -1) { new MessageBoxCustom("Select Sprint to delete", MessageBoxCustom.MessageType.Warning, MessageBoxCustom.MessageButtons.Ok).ShowDialog(); return; } else { Globals.SelectedSprint = Globals.currentSprintList[SprintListView.SelectedIndex]; if (IsSprintHasChild()) { new MessageBoxCustom("Selected Sprint has User Stories attached, you need to clear these User Stories to delete", MessageBoxCustom.MessageType.Warning, MessageBoxCustom.MessageButtons.Ok).ShowDialog(); return; } } bool?Result = new MessageBoxCustom("Are you sure to delete Selected Sprint? ", MessageBoxCustom.MessageType.Confirmation, MessageBoxCustom.MessageButtons.YesNo).ShowDialog(); if (Result.Value) { Globals.simpleJiraDB.Sprints.Remove(Globals.SelectedSprint); Globals.simpleJiraDB.SaveChanges(); LoadDataFromDb(Globals.currentUser); } else { return; } } catch (SqlException ex) { new MessageBoxCustom("Error Deleting Sprint from database:\n" + ex.Message, MessageBoxCustom.MessageType.Error, MessageBoxCustom.MessageButtons.Ok).ShowDialog(); } } if (UserStoryView.IsVisible) { try { if (UserStoryListView.SelectedIndex == -1) { new MessageBoxCustom("Select User Story to delete", MessageBoxCustom.MessageType.Warning, MessageBoxCustom.MessageButtons.Ok).ShowDialog(); return; } else { Globals.SelectedUserStory = Globals.currentUserStoryList[UserStoryListView.SelectedIndex]; if (IsUserStoryHasChild()) { new MessageBoxCustom("Selected User Story has Issues attached you need to clear these issues to delete", MessageBoxCustom.MessageType.Warning, MessageBoxCustom.MessageButtons.Ok).ShowDialog(); return; } } bool?Result = new MessageBoxCustom("Are you sure to delete Selected User Story? ", MessageBoxCustom.MessageType.Confirmation, MessageBoxCustom.MessageButtons.YesNo).ShowDialog(); if (Result.Value) { Globals.simpleJiraDB.UserStories.Remove(Globals.SelectedUserStory); Globals.simpleJiraDB.SaveChanges(); LoadDataFromDb(Globals.currentUser); } else { return; } } catch (SqlException ex) { new MessageBoxCustom("Error Deleting User Story from database:\n" + ex.Message, MessageBoxCustom.MessageType.Error, MessageBoxCustom.MessageButtons.Ok).ShowDialog(); } } if (IssueView.IsVisible) { try { if (IssueListView.SelectedIndex < 0) { new MessageBoxCustom("Select Issue to delete", MessageBoxCustom.MessageType.Warning, MessageBoxCustom.MessageButtons.Ok).ShowDialog(); return; } IssueListItem currentIssue = (IssueListItem)IssueListView.SelectedItem; Issue issueDelete = Globals.simpleJiraDB.Issues.Where(iss => iss.IssueId == currentIssue.IssueId).FirstOrDefault <Issue>(); if (issueDelete != null) { bool?Result = new MessageBoxCustom("Are you sure to delete this Team? ", MessageBoxCustom.MessageType.Confirmation, MessageBoxCustom.MessageButtons.YesNo).ShowDialog(); if (Result.Value) { Globals.simpleJiraDB.Issues.Remove(issueDelete); Globals.simpleJiraDB.SaveChanges(); LoadDataFromDb(Globals.currentUser); } } else { new MessageBoxCustom("Cannot find Issue to delete", MessageBoxCustom.MessageType.Warning, MessageBoxCustom.MessageButtons.Ok).ShowDialog(); } } catch (SqlException ex) { new MessageBoxCustom("Error Deleting Issue from database:\n" + ex.Message, MessageBoxCustom.MessageType.Error, MessageBoxCustom.MessageButtons.Ok).ShowDialog(); } } }