示例#1
0
        /// <summary>
        /// метод выполняется при нажатии кнопки Set Up в разделе таблицы New Risks
        /// устанавливает значения характеристик для нового риска
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SetUpNewRisk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (listNewRisks.SelectedItems != null &&
                    Double.Parse(ParseLine(NewInfluenceTextbox.Text)) != default &&
                    Double.Parse(ParseLine(NewProbabilityTextbox.Text)) != default)
                {
                    ((Risk)listNewRisks.SelectedItem).Status     = 1;
                    ((Risk)listNewRisks.SelectedItem).IdUser     = ((User)NewOwnerCombobox.SelectedItem).ID;
                    ((Risk)listNewRisks.SelectedItem).OwnerLogin = ((User)NewOwnerCombobox.SelectedItem).Login;

                    ((Risk)listNewRisks.SelectedItem).Influence   = double.Parse(ParseLine(NewInfluenceTextbox.Text));
                    ((Risk)listNewRisks.SelectedItem).Probability = double.Parse(ParseLine(NewProbabilityTextbox.Text));

                    SearchForCurrentRisk(((Risk)listNewRisks.SelectedItem));

                    DatabaseActions databaseActions = new DatabaseActions();

                    await databaseActions.ChangeRisk((Risk)listNewRisks.SelectedItem, (User)NewOwnerCombobox.SelectedItem);

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

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

                        if (listSelected[i].Status == 1)
                        {
                            listRisksSelected.Items.Add(listSelected[i]);
                        }
                    }

                    Drawing();
                }
                else
                {
                    MessageBox.Show("Wrong in entry");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Wrong in entry");
            }
        }
        /// <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();
        }
示例#3
0
        /// <summary>
        /// метод, который срабатывает при нажатии кнопки и
        /// устанавливает характерстики для риска и добавляет в бд
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SetUpRisk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (Double.Parse(ParseLine(InfluenceTextbox.Text)) == default || Double.Parse(ParseLine(ProbabilityTextbox.Text)) == default)
                {
                    throw new ArgumentException("Values of Probability and Influence fields must stay (0,1)");
                }

                if (Owner.SelectedItem == null)
                {
                    throw new NullReferenceException("You need to choose the user you want to assign risk to!");
                }

                ((Risk)listRisksSelected.SelectedItem).Influence   = double.Parse(ParseLine(InfluenceTextbox.Text));
                ((Risk)listRisksSelected.SelectedItem).Probability = double.Parse(ParseLine(ProbabilityTextbox.Text));

                DatabaseActions databaseActions = new DatabaseActions();

                await databaseActions.ChangeRisk((Risk)listRisksSelected.SelectedItem, (User)Owner.SelectedItem);

                listRisksSelected.Items.Clear();
                listSelected = await databaseActions.ShowRisks(_project);

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

                Drawing();
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show(ex.Message, "Exception");
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Exception");
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong!");
            }
        }
        private async void SetUpNewButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (listNewRisks.SelectedItems != null &&
                    Double.Parse(ParseLine(NewInfluenceTextbox.Text)) != default &&
                    Double.Parse(ParseLine(NewProbabilityTextbox.Text)) != default &&
                    OwnerNewCombobox.SelectedItem != null)
                {
                    ((Risk)listNewRisks.SelectedItem).Influence   = double.Parse(ParseLine(NewInfluenceTextbox.Text));
                    ((Risk)listNewRisks.SelectedItem).Probability = double.Parse(ParseLine(NewProbabilityTextbox.Text));
                    ((Risk)listNewRisks.SelectedItem).Status      = 1;
                    SearchForCurrentRisk(((Risk)listNewRisks.SelectedItem));

                    DatabaseActions databaseActions = new DatabaseActions();

                    await databaseActions.ChangeRisk((Risk)listNewRisks.SelectedItem, (User)OwnerNewCombobox.SelectedItem);

                    listNewRisks.Items.Clear();
                    listSelected.Items.Clear();
                    listRisksSelected = await databaseActions.ShowRisks(_project);

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

                        if (listRisksSelected[i].Status == 1)
                        {
                            listSelected.Items.Add(listRisksSelected[i]);
                        }
                    }

                    DrawHyperbola();
                }
                else
                {
                    MessageBox.Show("Something went wrong!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// метод запускается при открытии окна
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Window_Activated(object sender, EventArgs e)
        {
            if (flag)
            {
                Label label = new Label();
                label.VerticalAlignment   = VerticalAlignment.Top;
                label.HorizontalAlignment = HorizontalAlignment.Center;
                label.FontSize            = 15;
                label.Margin  = new Thickness(0, 25, 0, 0);
                label.Content = $"Project:  { _project.Name}";

                grid.Children.Add(label);
                BackButton.Background = new ImageBrush(new BitmapImage(new Uri(path)));

                DatabaseActions databaseActions = new DatabaseActions();

                listRisksSelected = await databaseActions.ShowRisks(_project);

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

                RiskActions riskActions = new RiskActions();

                listAllRisks = await riskActions.ShowRisks();

                ComboBoxTypes.Items.Add("Общие риски");
                ComboBoxTypes.Text = "Common Risks";
                ComboBoxTypes.Items.Add(_project.Type);
                listSource = await riskActions.ShowSources();

                AddInSelected();

                for (int i = 0; i < listSource.Count; i++)
                {
                    ComboBoxTypes.Items.Add(listSource[i]);
                }

                DrawHyperbola();
                FindDangerousRisks();
                await SetOwners();

                flag = false;
            }
        }
        /// <summary>
        /// метод для установления вероятности и влияния риска при нажатии на кнопку
        /// и внесении данных в бд
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SetUpButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (Double.Parse(ParseLine(InfluenceTextbox.Text)) == default || Double.Parse(ParseLine(ProbabilityTextbox.Text)) == default)
                {
                    throw new ArgumentException("The values of probability and influence must lay in the interval (0,1)!");
                }

                if (OwnerCombobox.SelectedItem == null)
                {
                    throw new NullReferenceException("You have to choose the user you want to assign the risk to!");
                }

                ((Risk)listSelected.SelectedItem).Influence   = double.Parse(ParseLine(InfluenceTextbox.Text));
                ((Risk)listSelected.SelectedItem).Probability = double.Parse(ParseLine(ProbabilityTextbox.Text));

                DatabaseActions databaseActions = new DatabaseActions();
                await databaseActions.ChangeRisk((Risk)listSelected.SelectedItem, (User)OwnerCombobox.SelectedItem);

                listSelected.Items.Clear();
                listRisksSelected = await databaseActions.ShowRisks(_project);

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

                DrawHyperbola();
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show(ex.Message, "Exception");
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Exception");
            }
            catch (Exception)
            {
                MessageBox.Show("Something's not right!");
            }
        }
        private async void SetUpNewButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (listNewRisks.SelectedItems != null &&
                    Double.Parse(ParseLine(TextboxInfluenceNew.Text)) != default &&
                    Double.Parse(ParseLine(TextboxProbabilityNew.Text)) != default 
                    )
                {
                    ((Risk)listNewRisks.SelectedItem).Influence = double.Parse(ParseLine(InfluenceTextbox.Text));
                    ((Risk)listNewRisks.SelectedItem).Probability = double.Parse(ParseLine(ProbabilityTextbox.Text));
                    ((Risk)listNewRisks.SelectedItem).Status = 1;

                    SearchForCurrentRisk(((Risk)listNewRisks.SelectedItem));

                    DatabaseActions databaseActions = new DatabaseActions();

                    await databaseActions.ChangeRisk((Risk)listNewRisks.SelectedItem, (User)UserNewCombobox.SelectedItem);

                    listNewRisks.Items.Clear();
                    listSelected = await databaseActions.ShowRisks(project);

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

                        if (listSelected[i].Status == 1)
                            listRisksSelected.Items.Add(listSelected[i]);
                    }

                    DrawGraphic();
                }
                else
                {
                    MessageBox.Show("Wrong in enpty1");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("It's possible that user has not been set!");

            }
        }
        /// <summary>
        /// метод выполняеся при открытии окна отчёта
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Window_Activated(object sender, EventArgs e)
        {
            if (flag)
            {
                Widht  = canvas.ActualWidth;
                Height = canvas.ActualHeight;

                DatabaseActions databaseActions = new DatabaseActions();
                listSelected = await databaseActions.ShowRisks(_project);

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

                DrawLine();

                Tree tree = new Tree();

                listVertex = await tree.ShowListVertexes();

                firstVertex = await tree.ShowVertex(_risk.ID);

                Label label = new Label();

                label.HorizontalAlignment = HorizontalAlignment.Left;
                label.VerticalAlignment   = VerticalAlignment.Top;
                label.Margin   = new Thickness(Widht / 2 - 100, 0, 0, 0);
                label.FontSize = 17;
                label.Content  = $"Report for {_project.Name}";

                canvas.Children.Add(label);

                DrawVertex();
                CurrentBranchCost(firstVertex, 0);
                DrawDangerousMaximum();
                WriteDangerousItems();

                flag = false;

                //wordApplication.Visible = true;
                CreateDocument();
            }
        }
        /// <summary>
        /// метод для кнопки Set up, который устанавливает новые значения характеристик для выбранного риска
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SetUpRiskButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (listRisksSelected.SelectedItems == null) 
                    throw new NullReferenceException("You need to choose a risk you want to update!");

                if (Double.Parse(ParseLine(InfluenceTextbox.Text)) == default || Double.Parse(ParseLine(ProbabilityTextbox.Text)) == default)
                    throw new ArgumentException("The 'Probability' and 'Infuence' values must lay in the interval [0;1]!");

                ((Risk)listRisksSelected.SelectedItem).Influence = double.Parse(ParseLine(InfluenceTextbox.Text));
                ((Risk)listRisksSelected.SelectedItem).Probability = double.Parse(ParseLine(ProbabilityTextbox.Text));

                DatabaseActions databaseActions = new DatabaseActions();

                await databaseActions.ChangeRisk((Risk)listRisksSelected.SelectedItem);

                listRisksSelected.Items.Clear();
                listSelected = await databaseActions.ShowRisks(project);

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

                DrawGraphic();
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show(ex.Message, "Exception");

            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Exception");

            }
            catch (Exception)
            {
                MessageBox.Show("Что-то пошло не так");

            }
        }
        /// <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();
        }
示例#11
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();
        }
示例#12
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!");
            }
        }