示例#1
0
 public ProjectManagerTree(Risk risk, Project project, User user, Point center)
 {
     this.center  = center;
     this.user    = user;
     this.risk    = risk;
     this.project = project;
     InitializeComponent();
 }
示例#2
0
        public AdminTree(Risk risk, Project project, Point center)
        {
            this.center  = center;
            this.risk    = risk;
            this.project = project;

            InitializeComponent();
        }
        public ReportWindow(Risk risk, Project project, System.Windows.Point center)
        {
            this.center = center;
            _risk       = risk;
            _project    = project;

            InitializeComponent();
        }
 /// <summary>
 /// метод ищет риск по его номеру в списке выбранных рисков
 /// </summary>
 /// <param name="risk"></param>
 private void SearchForCurrentRisk(Risk risk)
 {
     for (int i = 0; i < listSelected.Count; i++)
     {
         if (listSelected[i].ID == risk.ID)
         {
             listSelected[i].Status = risk.Status;
             listSelected[i].IdUser = risk.IdUser;
             listSelected[i].OwnerLogin = risk.OwnerLogin;
         }
     }
 }
        /// <summary>
        /// метод для добавления риска в список активных
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void AddToActiveRisks_Click(object sender, RoutedEventArgs e)
        {
            Risk risk = (Risk)((Button)sender).DataContext;

            listRisksNonselected.Items.Remove(risk);
            listSelected.Add(risk);
            listRisksSelected.Items.Add(risk);

            risk.Status = 1;
            SearchForCurrentRisk(risk);

            DatabaseActions databaseActions = new DatabaseActions();

            await databaseActions.ChangeRisk(risk);
            DrawGraphic();
        }
示例#6
0
        /// <summary>
        /// проверяет нет ли в выбранных уже такого элемента
        /// </summary>
        /// <param name="checkrisk"></param>
        /// <returns></returns>
        private bool CheckIfAlreadySelected(Risk risk)
        {
            if (listRisksSelected.Items.Count != 0)
            {
                for (int i = 0; i < listRisksSelected.Items.Count; i++)
                {
                    if (risk.ID == ((Risk)listRisksSelected.Items[i]).ID)
                    {
                        return(false);
                    }
                }

                return(true);
            }

            return(true);
        }
示例#7
0
        /// <summary>
        /// метод, который меняет характеристики риска
        /// </summary>
        /// <param name="risk"></param>
        /// <returns></returns>
        public async Task ChangeRisk(Risk risk)
        {
            await sqlConnection.OpenAsync();

            SqlCommand sqlCommand =
                new SqlCommand("UPDATE [RiskData] SET [Probability]= @Probability, [Influence]= @Influence, [OwnerLogin]= @OwnerLogin, [Status]= @Status, [OwnerId]= @OwnerId WHERE id=@id", sqlConnection);

            sqlCommand.Parameters.AddWithValue("Id", risk.ID);
            sqlCommand.Parameters.AddWithValue("Status", risk.Status);
            sqlCommand.Parameters.AddWithValue("Probability", risk.Probability);
            sqlCommand.Parameters.AddWithValue("Influence", risk.Influence);
            sqlCommand.Parameters.AddWithValue("OwnerLogin", risk.OwnerLogin);
            sqlCommand.Parameters.AddWithValue("OwnerId", risk.IdUser);

            await sqlCommand.ExecuteNonQueryAsync();

            sqlConnection.Close();
        }
        /// <summary>
        /// метод для удаления рискапри нажатии кнопки Delete
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            DatabaseActions databaseActions = new DatabaseActions();
            Risk risk = (Risk)((Button)sender).DataContext;

            listSelected.Remove(risk);

            if (listSelected == null) 
                listSelected = new List<Risk>();

            listRisksSelected.Items.Remove(risk);
            risk.Status = 2;

            SearchForCurrentRisk(risk);

            await databaseActions.ChangeRisk(risk);

            listRisksNonselected.Items.Add(risk);
            DrawGraphic();
        }
示例#9
0
        /// <summary>
        /// метод, который доавляет новый риск в проект
        /// </summary>
        /// <param name="risk"></param>
        /// <param name="project"></param>
        /// <returns></returns>
        public async Task AddRisk(string project, Risk risk)
        {
            await sqlConnection.OpenAsync();

            SqlCommand sqlCommand =
                new SqlCommand("INSERT INTO [RiskData] (RiskName,Probability,Influence,Project,Source,Effects,PossibleSolution,Type,Status) " +
                               "VALUES(@riskName,@probability,@influence,@project,@source,@effects,@possibleSolution,@type,@Status)", sqlConnection);

            sqlCommand.Parameters.AddWithValue("RiskName", risk.RiskName);
            sqlCommand.Parameters.AddWithValue("Probability", risk.Probability);
            sqlCommand.Parameters.AddWithValue("Influence", risk.Influence);
            sqlCommand.Parameters.AddWithValue("Project", project);
            sqlCommand.Parameters.AddWithValue("Source", risk.Source);
            sqlCommand.Parameters.AddWithValue("Effects", risk.Effects);
            sqlCommand.Parameters.AddWithValue("PossibleSolution", risk.Solution);
            sqlCommand.Parameters.AddWithValue("Type", risk.Type);
            sqlCommand.Parameters.AddWithValue("Status", risk.Status);

            await sqlCommand.ExecuteNonQueryAsync();

            sqlConnection.Close();
        }
示例#10
0
        /// <summary>
        /// метод для удаления
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Delete_Click(object sender, RoutedEventArgs e)
        {
            DatabaseActions databaseActions = new DatabaseActions();
            Risk            risk            = (Risk)((Button)sender).DataContext;
            User            user            = new User();

            if (listSelected == null)
            {
                listSelected = new List <Risk>();
            }

            listRisksSelected.Items.Remove(risk);
            risk.Status = 2;
            SearchForCurrentRisk(risk);

            user.ID    = risk.IdUser;
            user.Login = risk.OwnerLogin;

            await databaseActions.ChangeRisk(risk);

            listRisksNonselected.Items.Add(risk);
            Drawing();
        }
示例#11
0
        /// <summary>
        /// метод добавляет риск в проект
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void AddToProject_Click(object sender, RoutedEventArgs e)
        {
            if (CheckIfAlreadySelected(((Risk)((Button)sender).DataContext)))
            {
                RiskSettingsWindow settingsWindow = new RiskSettingsWindow();
                Risk risk = (Risk)(((Button)sender).DataContext);

                if (settingsWindow.ShowDialog() == true)
                {
                    try
                    {
                        risk.Probability = settingsWindow.Probability;
                        risk.Influence   = settingsWindow.Influence;

                        if (settingsWindow.Influence != default)
                        {
                            ((Risk)((Button)sender).DataContext).Status = 1;
                        }
                        else
                        {
                            ((Risk)((Button)sender).DataContext).Status = 0;
                        }

                        DatabaseActions databaseActions = new DatabaseActions();

                        if (settingsWindow.Owner == null)
                        {
                            await databaseActions.AddRisk(_project.Name, risk);
                        }
                        else
                        {
                            risk.OwnerLogin = settingsWindow.Owner.Login;
                            risk.IdUser     = settingsWindow.Owner.ID;
                            await databaseActions.AddRisk(_project.Name, risk, settingsWindow.Owner);
                        }

                        listSelected.Add(risk);

                        SearchForCurrentRisk(risk);
                        ChangeSelected();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Wrong in enpty" + ex.Message);
                    }
                }

                listRisksSelected.Items.Clear();
                listNewRisks.Items.Clear();

                for (int i = 0; i < listSelected.Count; i++)
                {
                    if (listSelected[i].Status == 1)
                    {
                        listRisksSelected.Items.Add(listSelected[i]);
                    }

                    if (listSelected[i].Status == 0)
                    {
                        listNewRisks.Items.Add(listSelected[i]);
                    }
                }

                Drawing();
                listRisks.Remove(risk);
                SeletionCombobox.SelectedItem = SeletionCombobox.SelectedItem;
            }
            else
            {
                MessageBox.Show("This element has already been selected");
            }
        }
        /// <summary>
        /// метод, который добавляет риск в список выбранных
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void AddButton_Click(object sender, RoutedEventArgs e)
        {
            if (CheckIfSelected(((Risk)((Button)sender).DataContext)))
            {
                RiskSettingsWindow window = new RiskSettingsWindow();
                Risk risk = (Risk)(((Button)sender).DataContext);

                if (window.ShowDialog() == true)
                {
                    try
                    {
                        risk.Influence   = window.Influence;
                        risk.Probability = window.Probability;

                        if (window.Influence == default(double))
                        {
                            ((Risk)((Button)sender).DataContext).Status = 0;
                        }
                        else
                        {
                            ((Risk)((Button)sender).DataContext).Status = 1;
                        }

                        DatabaseActions databaseActions = new DatabaseActions();

                        if (window.Owner == null)
                        {
                            await databaseActions.AddRisk(_project.Name, risk);
                        }
                        else
                        {
                            risk.OwnerLogin = window.Owner.Login;
                            risk.IdUser     = window.Owner.ID;

                            await databaseActions.AddRisk(_project.Name, risk, window.Owner);

                            SearchForCurrentRisk(risk);
                        }

                        listRisksSelected.Add(risk);
                        ChangeSelected();
                    }
                    catch
                    {
                        MessageBox.Show("Something went wrong");
                    }
                }

                listSelected.Items.Clear();
                listNewRisks.Items.Clear();
                for (int i = 0; i < listRisksSelected.Count; i++)
                {
                    if (listRisksSelected[i].Status == 1)
                    {
                        listSelected.Items.Add(listRisksSelected[i]);
                    }

                    if (listRisksSelected[i].Status == 0)
                    {
                        listNewRisks.Items.Add(listRisksSelected[i]);
                    }
                }

                DrawHyperbola();
                listAllRisks.Remove(risk);
                ComboBoxTypes.SelectedItem = ComboBoxTypes.SelectedItem;
            }
            else
            {
                MessageBox.Show("This element has already been selected!");
            }
        }