Пример #1
0
        private async void Window_Activated(object sender, EventArgs e)
        {
            if (flag)
            {
                Back.Background = new ImageBrush(new BitmapImage(new Uri(path)));
                Back.Foreground = new ImageBrush(new BitmapImage(new Uri(path)));

                ProjectCommands pc  = new ProjectCommands();
                DataCommands    dc  = new DataCommands();
                List <string>   lst = await dc.GiveOwnersProjects(user);

                List <Project> prlst = await pc.GiveAllProjects();

                try
                {
                    for (int i = 0; i < prlst.Count; i++)
                    {
                        for (int j = 0; j < lst.Count; j++)
                        {
                            if (lst[j] == prlst[i].Name)
                            {
                                listBox.Items.Add(prlst[i]);
                            }
                        }
                    }
                }
                catch (NullReferenceException)
                {
                    MessageBox.Show("You havent projects and risks");
                }
                flag = false;
            }
        }
Пример #2
0
        private async void Window_Activated(object sender, EventArgs e)
        {
            if (flag)
            {
                Widht  = cnv.ActualWidth;
                Height = cnv.ActualHeight;

                DataCommands dc = new DataCommands();
                SelectedRisks = await dc.GiveAllRisks(project);

                if (SelectedRisks == null)
                {
                    SelectedRisks = new List <Risk>();
                }
                Drawing();
                TreeCommands tc = new TreeCommands();
                vert = await tc.GiveALlVertex();

                FirstVerTex = await tc.GiveFristVertex(drisk.Id);

                GiveTitle();
                CreateFirstVertex();
                CostCurrentBranch(FirstVerTex, 0);
                DrawMaxDangerous();
                WriteInListView();
                flag = false;
            }
        }
Пример #3
0
        /// <summary>
        /// метод при открытие окна
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Window_Activated(object sender, EventArgs e)
        {
            if (flag)
            {
                Label l = new Label();
                l.VerticalAlignment   = VerticalAlignment.Top;
                l.HorizontalAlignment = HorizontalAlignment.Center;
                l.FontSize            = 15;
                l.Margin  = new Thickness(0, 25, 0, 0);
                l.Content = $"Матрица рисков для { project.Name}";
                grid.Children.Add(l);
                Back.Background = new ImageBrush(new BitmapImage(new Uri(path)));
                DataCommands dc = new DataCommands();
                SelectedRisks = await dc.GiveAllRisks(project);

                if (SelectedRisks == null)
                {
                    SelectedRisks = new List <Risk>();
                }
                ADDToSelctes();
                Drawing();
                FindDangerougeRisks();
                flag = false;
            }
        }
Пример #4
0
        private async void AddToActive_Click(object sender, RoutedEventArgs e)
        {
            Risk r = (Risk)((Button)sender).DataContext;

            UnSelRisks.Items.Remove(r);
            SelectedRisks.Add(r);
            SelRisks.Items.Add(r);
            r.Status = 1;
            FindCurrentRisk(r);
            DataCommands dc = new DataCommands();
            await dc.UpdateRisks(r);

            Drawing();
        }
Пример #5
0
        /// <summary>
        /// кнопка установления риску вероятности и эффекта и также в бивани его в бд
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SetUp_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (SelRisks.SelectedItems == null)
                {
                    throw new NullReferenceException("Выберете риск поля кторого вы хотите обновить");
                }
                if (Double.Parse(Parsing(TBINf.Text)) == default(Double) || Double.Parse(Parsing(TBProb.Text)) == default(Double))
                {
                    throw new ArgumentException("Значения Probability и Influence лежать в диапозоне (0,1)");
                }
                if (Owner.SelectedItem == null)
                {
                    throw new NullReferenceException("Выберете пользователя которому хотите назначить риск");
                }

                ((Risk)SelRisks.SelectedItem).Influence   = double.Parse(Parsing(TBINf.Text));
                ((Risk)SelRisks.SelectedItem).Probability = double.Parse(Parsing(TBProb.Text));
                DataCommands dc = new DataCommands();
                await dc.UpdateRisks((Risk)SelRisks.SelectedItem, (User)Owner.SelectedItem);

                SelRisks.Items.Clear();
                SelectedRisks = await dc.GiveAllRisks(project);

                for (int i = 0; i < SelectedRisks.Count; i++)
                {
                    if (SelectedRisks[i].Status == 1)
                    {
                        SelRisks.Items.Add(SelectedRisks[i]);
                    }
                }
                Drawing();
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show(ex.Message, "Exception");
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Exception");
            }
            catch (Exception)
            {
                MessageBox.Show("Что-то пошло не так");
            }
        }
Пример #6
0
        private async void SetUpNew_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (NewRisks.SelectedItems != null &&
                    Double.Parse(Parsing(TBINfNew.Text)) != default(Double) &&
                    Double.Parse(Parsing(TBProbNew.Text)) != default(Double) &&
                    OwnerNew.SelectedItem != null)
                {
                    ((Risk)NewRisks.SelectedItem).Influence   = double.Parse(Parsing(TBINfNew.Text));
                    ((Risk)NewRisks.SelectedItem).Probability = double.Parse(Parsing(TBProbNew.Text));
                    ((Risk)NewRisks.SelectedItem).Status      = 1;
                    ((Risk)NewRisks.SelectedItem).OwnerId     = ((User)OwnerNew.SelectedItem).Id;
                    ((Risk)NewRisks.SelectedItem).OwnerLogin  = ((User)OwnerNew.SelectedItem).Login;

                    FindCurrentRisk(((Risk)NewRisks.SelectedItem));

                    DataCommands dc = new DataCommands();
                    await dc.UpdateRisks((Risk)NewRisks.SelectedItem, (User)OwnerNew.SelectedItem);

                    NewRisks.Items.Clear();
                    SelRisks.Items.Clear();
                    //SelectedRisks = await dc.GiveAllRisks(project);
                    for (int i = 0; i < SelectedRisks.Count; i++)
                    {
                        if (SelectedRisks[i].Status == 0)
                        {
                            NewRisks.Items.Add(SelectedRisks[i]);
                        }
                        if (SelectedRisks[i].Status == 1)
                        {
                            SelRisks.Items.Add(SelectedRisks[i]);
                        }
                    }
                    Drawing();
                }
                else
                {
                    MessageBox.Show("Wrong in enpty1");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Wrong in enpty2");
            }
        }
Пример #7
0
        /// <summary>
        /// прописать удаление
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Delite_Click(object sender, RoutedEventArgs e)
        {
            DataCommands dc = new DataCommands();
            Risk         r  = (Risk)((Button)sender).DataContext;

            SelectedRisks.Remove(r);
            if (SelectedRisks == null)
            {
                SelectedRisks = new List <Risk>();
            }
            SelRisks.Items.Remove(r);
            r.Status = 2;
            FindCurrentRisk(r);
            await dc.UpdateRisks(r);

            UnSelRisks.Items.Add(r);
            Drawing();
        }
Пример #8
0
        /// <summary>
        /// когда открывается окно
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Window_Activated(object sender, EventArgs e)
        {
            if (flag)
            {
                Label l = new Label();
                l.VerticalAlignment   = VerticalAlignment.Top;
                l.HorizontalAlignment = HorizontalAlignment.Center;
                l.FontSize            = 15;
                l.Margin  = new Thickness(0, 25, 0, 0);
                l.Content = $"Матрица рисков для { project.Name}";
                grid.Children.Add(l);
                Back.Background = new ImageBrush(new BitmapImage(new Uri(path)));
                DataCommands dc = new DataCommands();
                SelectedRisks = await dc.GiveAllRisks(project);

                if (SelectedRisks == null)
                {
                    SelectedRisks = new List <Risk>();
                }
                RisksCommand rc = new RisksCommand();
                AllRisklst = await rc.GiveAllRisks();

                ComboBox.Items.Add("Общие риски");
                ComboBox.Text = "Общие риски";
                ComboBox.Items.Add(project.Type);
                sourse = await rc.GiveRisksSourse();

                ADDToSelctes();
                for (int i = 0; i < sourse.Count; i++)
                {
                    ComboBox.Items.Add(sourse[i]);
                }
                Drawing();
                FindDangerougeRisks();
                await WriteOwners();

                flag = false;
            }
        }
Пример #9
0
        private async void Add_Click(object sender, RoutedEventArgs e)
        {
            if (CheckIsSelected(((Risk)((Button)sender).DataContext)))
            {
                ProbabilityInfluenceOwner piow = new ProbabilityInfluenceOwner();
                Risk r = (Risk)(((Button)sender).DataContext);

                if (piow.ShowDialog() == true)
                {
                    try
                    {
                        r.Influence   = piow.Influence;
                        r.Probability = piow.Probability;
                        if (piow.Influence == default(double))
                        {
                            ((Risk)((Button)sender).DataContext).Status = 0;
                        }
                        else
                        {
                            ((Risk)((Button)sender).DataContext).Status = 1;
                        }

                        DataCommands dc = new DataCommands();
                        if (piow.Owner == null)
                        {
                            await dc.IsertNewRisks(r, project.Name);
                        }
                        else
                        {
                            r.OwnerLogin = piow.Owner.Login;
                            r.OwnerId    = piow.Owner.Id;
                            await dc.IsertRisks(r, project.Name, piow.Owner);

                            FindCurrentRisk(r);
                        }
                        SelectedRisks.Add(r);
                        SelectedChanged();
                    }
                    catch
                    {
                        MessageBox.Show("Wrong in enpty");
                    }
                }

                SelRisks.Items.Clear();
                NewRisks.Items.Clear();
                for (int i = 0; i < SelectedRisks.Count; i++)
                {
                    if (SelectedRisks[i].Status == 1)
                    {
                        SelRisks.Items.Add(SelectedRisks[i]);
                    }
                    if (SelectedRisks[i].Status == 0)
                    {
                        NewRisks.Items.Add(SelectedRisks[i]);
                    }
                }
                Drawing();
                AllRisklst.Remove(r);
                ComboBox.SelectedItem = ComboBox.SelectedItem;
            }
            else
            {
                MessageBox.Show("Данный элемент уже выбран");
            }
        }