Exemplo n.º 1
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                getSelectedProject();
                if (IsProjectHasChild())
                {
                    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 Project? ", MessageBoxCustom.MessageType.Confirmation, MessageBoxCustom.MessageButtons.YesNo).ShowDialog();

                if (Result.Value)
                {
                    Project SelectedProject = Globals.simpleJiraDB.Projects.Where(p => p.Name.Equals(tbProjectName.Text)).FirstOrDefault();
                    Globals.simpleJiraDB.Projects.Remove(SelectedProject);
                    Globals.simpleJiraDB.SaveChanges();
                    Globals.AppWindow.LoadDataFromDb(Globals.currentUser);
                }
                else
                {
                    return;
                }
            }
            catch (SqlException ex)
            {
                new MessageBoxCustom("Error Deleting Project from database:\n" + ex.Message, MessageBoxCustom.MessageType.Error, MessageBoxCustom.MessageButtons.Ok).ShowDialog();
            }
        }
Exemplo n.º 2
0
        private void btDeleteUser_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if ((string.IsNullOrEmpty(cmbUserList.Text)) || (string.IsNullOrEmpty(cmbTeamList.Text)))
                {
                    new MessageBoxCustom("Please choose user to delete", MessageBoxCustom.MessageType.Info, MessageBoxCustom.MessageButtons.Ok).ShowDialog();
                    return;
                }
                Team team = Globals.simpleJiraDB.Teams.Where(t => t.Name.Equals(cmbTeamList.SelectedItem.ToString())).FirstOrDefault <Team>();

                if (team != null)
                {
                    User userDelete = Globals.simpleJiraDB.Users.Where(u => u.LoginName.Equals(cmbUserList.SelectedItem.ToString())).Where(ut => ut.TeamId == team.TeamId).FirstOrDefault <User>();

                    int userStoryCount = Globals.simpleJiraDB.UserStories.Include("User").Where(ust => ust.OwnerId == userDelete.UserId).ToList <UserStory>().Count;

                    int issueCount = Globals.simpleJiraDB.Issues.Include("User").Where(iss => iss.OwnerId == userDelete.UserId).ToList <Issue>().Count;

                    if (issueCount == 0 && userStoryCount == 0)
                    {
                        if (userDelete != null)
                        {
                            bool?Result = new MessageBoxCustom("Are you sure to delete this user? ", MessageBoxCustom.MessageType.Confirmation, MessageBoxCustom.MessageButtons.YesNo).ShowDialog();

                            if (Result.Value)
                            {
                                Globals.simpleJiraDB.Users.Remove(userDelete);
                                Globals.simpleJiraDB.SaveChanges();
                                new MessageBoxCustom("User Deleted", MessageBoxCustom.MessageType.Info, MessageBoxCustom.MessageButtons.Ok).ShowDialog();
                                ResetAndLoadDataFromDB();
                                //if (currentUserInDialog != null)
                                //{
                                //   this.DialogResult = true;
                                //  TeamUserUpdateCallback?.Invoke(currentUserInDialog);
                                //}
                            }
                        }
                        else
                        {
                            new MessageBoxCustom("Cannot find User to Delete", MessageBoxCustom.MessageType.Warning, MessageBoxCustom.MessageButtons.Ok).ShowDialog();
                        }
                    }
                    else
                    {
                        new MessageBoxCustom("Please clear related Issue and UserStory before delete User", MessageBoxCustom.MessageType.Info, MessageBoxCustom.MessageButtons.Ok).ShowDialog();
                    }
                }
            }
            catch (SqlException ex)
            {
                new MessageBoxCustom("Error Deleting User from database:\n" + ex.Message, MessageBoxCustom.MessageType.Error, MessageBoxCustom.MessageButtons.Ok).ShowDialog();
            }
        }
Exemplo n.º 3
0
        private void btDeleteTeam_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Team teamDelete = Globals.simpleJiraDB.Teams.Where(t => t.Name.Equals(cmbNewTeamList.Text)).FirstOrDefault <Team>();
                if (teamDelete != null)
                {
                    int userCount = Globals.simpleJiraDB.Users.Include("Team").Where(u => u.TeamId == teamDelete.TeamId).ToList <User>().Count;

                    int projectCount = Globals.simpleJiraDB.Projects.Include("Team").Where(p => p.TeamId == teamDelete.TeamId).ToList <Project>().Count;

                    if (userCount == 0 && projectCount == 0)
                    {
                        bool?Result = new MessageBoxCustom("Are you sure to delete this Team? ", MessageBoxCustom.MessageType.Confirmation, MessageBoxCustom.MessageButtons.YesNo).ShowDialog();

                        if (Result.Value)
                        {
                            Globals.simpleJiraDB.Teams.Remove(teamDelete);
                            Globals.simpleJiraDB.SaveChanges();
                            new MessageBoxCustom("Team deleted", MessageBoxCustom.MessageType.Info, MessageBoxCustom.MessageButtons.Ok).ShowDialog();
                            ResetAndLoadDataFromDB();
                            //if (currentUserInDialog != null)
                            //{
                            //   this.DialogResult = true;
                            //  TeamUserUpdateCallback?.Invoke(currentUserInDialog);
                            //}
                        }
                    }
                    else
                    {
                        new MessageBoxCustom("Please remove the projects and users under this team before delete", MessageBoxCustom.MessageType.Info, MessageBoxCustom.MessageButtons.Ok).ShowDialog();
                        return;
                    }
                }
                else
                {
                    new MessageBoxCustom("Cannot find team to Delete", MessageBoxCustom.MessageType.Info, MessageBoxCustom.MessageButtons.Ok).ShowDialog();
                }
            }
            catch (SqlException ex)
            {
                new MessageBoxCustom("Error Deleting User from database:\n" + ex.Message, MessageBoxCustom.MessageType.Error, MessageBoxCustom.MessageButtons.Ok).ShowDialog();
            }
        }
Exemplo n.º 4
0
        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();
                }
            }
        }