public void DeleteImportSageFilter() { try { Model.Local.ImportSageFilterRepository ImportSageFilterRepository = new Model.Local.ImportSageFilterRepository(); if (SelectedImportSageFilter != null && ImportSageFilterRepository.ExistValue(SelectedImportSageFilter.Imp_Value)) { ImportSageFilterRepository.Delete(ImportSageFilterRepository.ReadValue(SelectedImportSageFilter.Imp_Value)); ListImportSageFilter.Remove(SelectedImportSageFilter); } ImportSageFilterRepository = null; } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
public void AddImportSageFilter() { try { if (String.IsNullOrWhiteSpace(ImportSageFilterValue)) { MessageBox.Show("Vous devez renseigner la valeur filtrante !", "Prestaconnect", MessageBoxButton.OK, MessageBoxImage.Information); } else if (SelectedTypeSearchValue == null) { MessageBox.Show("Vous devez choisir la condition de filtrage !", "Prestaconnect", MessageBoxButton.OK, MessageBoxImage.Information); } else if (SelectedTargetData == null) { MessageBox.Show("Vous devez choisir les données concernées !", "Prestaconnect", MessageBoxButton.OK, MessageBoxImage.Information); } else if (SelectedTargetData._ImportSageFilterTargetData == Core.Parametres.ImportSageFilterTargetData.InformationLibreArticle && SelectedSageInfolibreArticleTextTable == null) { MessageBox.Show("Vous devez choisir l'information libre cible !", "Prestaconnect", MessageBoxButton.OK, MessageBoxImage.Information); } else { Model.Local.ImportSageFilterRepository ImportSageFilterRepository = new Model.Local.ImportSageFilterRepository(); if (!ImportSageFilterRepository.ExistValue(ImportSageFilterValue)) { Model.Local.ImportSageFilter newImportSageFilter = new Model.Local.ImportSageFilter() { Imp_Value = (SelectedTypeSearchValue.ValueUppercaseOnly) ? ImportSageFilterValue.ToUpper() : ImportSageFilterValue, Imp_TypeSearchValue = SelectedTypeSearchValue.Marq, Imp_TargetData = SelectedTargetData.Marq, Imp_Active = true, }; if (SelectedTargetData._ImportSageFilterTargetData == Core.Parametres.ImportSageFilterTargetData.InformationLibreArticle && SelectedSageInfolibreArticleTextTable != null) { newImportSageFilter.Sag_Infolibre = SelectedSageInfolibreArticleTextTable.CB_Name; } ImportSageFilterRepository.Add(newImportSageFilter); ListImportSageFilter.Add(newImportSageFilter); } else if (MessageBox.Show("Cette valeur filtrante est déjà associée à un filtre !\n" + "Valider le remplacement de la condition et des cibles ?", "Prestaconnect", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { Model.Local.ImportSageFilter ImportSageFilter = ImportSageFilterRepository.ReadValue(ImportSageFilterValue); ImportSageFilter.Imp_Value = (SelectedTypeSearchValue.ValueUppercaseOnly) ? ImportSageFilterValue.ToUpper() : ImportSageFilterValue; ImportSageFilter.Imp_TypeSearchValue = SelectedTypeSearchValue.Marq; ImportSageFilter.Imp_TargetData = SelectedTargetData.Marq; if (SelectedTargetData._ImportSageFilterTargetData == Core.Parametres.ImportSageFilterTargetData.InformationLibreArticle && SelectedSageInfolibreArticleTextTable != null) { ImportSageFilter.Sag_Infolibre = SelectedSageInfolibreArticleTextTable.CB_Name; } ImportSageFilterRepository.Save(); ImportSageFilter = ListImportSageFilter.FirstOrDefault(imp => imp.Imp_Value.ToLower() == ImportSageFilterValue.ToLower()); if (ImportSageFilter != null) { ImportSageFilter.Imp_TypeSearchValue = SelectedTypeSearchValue.Marq; ImportSageFilter.Imp_TargetData = SelectedTargetData.Marq; } } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }