/// <summary> /// Desactive la mesure/parade en db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, EventArgs e) { if (tvRisk.SelectedNode.Parent != null) { string Message; ADR_Criticality_MesureParade Parade; using (MesureAndParadeRepository MPRepository = new MesureAndParadeRepository()) { Parade = MPRepository.Get(tvRisk.SelectedNode.Text, RiskId); } Parade.IsDisabled = true; bool IsDeleted; using (MesureAndParadeRepository MPRepository = new MesureAndParadeRepository()) { IsDeleted = MPRepository.Delete(Parade); } if (!IsDeleted) { Message = "Erreur lors de la suppression de la mesure/parade"; ShowMessage(Message); } else { GenerateHistorique.CreateHistorique(FormUser.UserID, "Suppression mesures/parades", Parade.ItemText); } AddMesureAndParade(); } }
/// <summary> /// Ajoute en db la nouvelle mesure/parade /// Modifier en db la mesure/parade /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { if (RiskId != 0) { ADR_Criticality_MesureParade Parade; string Message; if (IsSave) { Parade = new ADR_Criticality_MesureParade(); Parade.ItemText = txtMesureParade.Text; Parade.CreationDate = DateTime.Now; Parade.CreateBy = FormUser.UserID; Parade.CriticalityRiskId = RiskId; Parade.WorkCenterId = WorkCenterUser.WorkCenterId; bool IsSave; using (MesureAndParadeRepository MPRepository = new MesureAndParadeRepository()) { IsSave = MPRepository.Insert(Parade); } if (!IsSave) { txtMesureParade.Text = string.Empty; Message = "Erreur lors de la création de la mesure/parade"; ShowMessage(Message); } else { GenerateHistorique.CreateHistorique(FormUser.UserID, "Ajout mesures/parades", "", txtMesureParade.Text); } } else { using (MesureAndParadeRepository MPRepository = new MesureAndParadeRepository()) { Parade = MPRepository.Get(tvRisk.SelectedNode.Text, RiskId); } string Origine = Parade.ItemText; string Destination = txtMesureParade.Text; Parade.ItemText = txtMesureParade.Text; Parade.ModifiedDate = DateTime.Now; Parade.ModifiedBy = FormUser.UserID; Parade.CriticalityRiskId = RiskId; Parade.WorkCenterId = WorkCenterUser.WorkCenterId; bool IsUpdated; using (MesureAndParadeRepository MPRepository = new MesureAndParadeRepository()) { IsUpdated = MPRepository.Update(Parade); } if (!IsUpdated) { Message = "Erreur lors de la modification de la mesure/parade"; ShowMessage(Message); } else { GenerateHistorique.CreateHistorique(FormUser.UserID, "Modification mesures/parades", Origine, Destination); } } AddMesureAndParade(); } }