/// <summary> /// записывает новые риски в проект /// </summary> /// <param name="risklst"></param> /// <param name="ProjectName"></param> /// <returns></returns> public async Task IsertRisks(Risk risk, string ProjectName, User Owner) { await sqlConnect.OpenAsync(); SqlCommand command = new SqlCommand("INSERT INTO [RiskData] (RiskName,Probability,Influence,Project,SourseOfRisk,Effects,Descriprion,TypeOfProject,OwnerLogin,OwnerId,Status) " + "VALUES(@riskName,@probability,@influence,@project,@sourseOfRisk,@effects,@descriprion,@typeOfProject,@OwnerLogin,@OwnerId,@Status)", sqlConnect); command.Parameters.AddWithValue("RiskName", risk.RiskName); command.Parameters.AddWithValue("Probability", risk.Probability); command.Parameters.AddWithValue("Influence", risk.Influence); command.Parameters.AddWithValue("Project", ProjectName); command.Parameters.AddWithValue("SourseOfRisk", risk.SoursOfRisk); command.Parameters.AddWithValue("Effects", risk.Effects); command.Parameters.AddWithValue("Descriprion", risk.Description); command.Parameters.AddWithValue("TypeOfProject", risk.TypeOfProject); command.Parameters.AddWithValue("OwnerLogin", Owner.Login); command.Parameters.AddWithValue("OwnerId", Owner.Id); command.Parameters.AddWithValue("Status", risk.Status); await command.ExecuteNonQueryAsync(); sqlConnect.Close(); }
public RiskTree(Risk drisk, Project project, Point center) { this.center = center; this.drisk = drisk; this.project = project; InitializeComponent(); }
public ReportForAdmin(Risk drisk, Project project, Point center) { this.center = center; this.drisk = drisk; this.project = project; InitializeComponent(); }
public RiskTreeForProjectManager(Risk drisk, Project project, User user, Point center) { this.center = center; this.user = user; this.drisk = drisk; this.project = project; InitializeComponent(); }
private void FindCurrentRisk(Risk risk) { for (int i = 0; i < SelectedRisks.Count; i++) { if (risk.Id == SelectedRisks[i].Id) { SelectedRisks[i].Status = risk.Status; SelectedRisks[i].OwnerId = risk.OwnerId; SelectedRisks[i].OwnerLogin = risk.OwnerLogin; } } }
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(); }
/// <summary> /// проверяет нет ли в выбранных уже такого элемента /// </summary> /// <param name="checkrisk"></param> /// <returns></returns> private bool CheckIsSelected(Risk checkrisk) { if (SelRisks.Items.Count != 0) { for (int i = 0; i < SelRisks.Items.Count; i++) { if (checkrisk.Id == ((Risk)SelRisks.Items[i]).Id) { return(false); } } return(true); } return(true); }
public async Task UpdateRisks(Risk risk) { await sqlConnect.OpenAsync(); SqlCommand command = new SqlCommand("UPDATE [RiskData] SET [Probability]= @Probability, [Influence]= @Influence, [OwnerLogin]= @OwnerLogin, [Status]= @Status, [OwnerId]= @OwnerId WHERE id=@id", sqlConnect); command.Parameters.AddWithValue("Id", risk.Id); command.Parameters.AddWithValue("Status", risk.Status); command.Parameters.AddWithValue("Probability", risk.Probability); command.Parameters.AddWithValue("Influence", risk.Influence); command.Parameters.AddWithValue("OwnerLogin", risk.OwnerLogin); command.Parameters.AddWithValue("OwnerId", risk.OwnerId); await command.ExecuteNonQueryAsync(); sqlConnect.Close(); }
/// <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(); }
public async Task DeliteRisk(Risk risk) { try { await sqlConnect.OpenAsync(); SqlCommand command = new SqlCommand("DELETE FROM [RiskData] WHERE [Id]=@Id", sqlConnect); command.Parameters.AddWithValue("Id", risk.Id); await command.ExecuteNonQueryAsync(); } catch (Exception) { } finally { sqlConnect.Close(); } }
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("Данный элемент уже выбран"); } }