/// <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!"); } }