private void SearchArticle() { Model.Local.ArticleRepository ArticleRepository = new Model.Local.ArticleRepository(); List <Model.Local.Article> ListArticleDisplay = new List <Model.Local.Article>(); Model.Local.Catalog Catalog = this.DataGridCatalogue.SelectedItem as Model.Local.Catalog; if (Catalog != null && this.CheckBoxSearchOnlyCatalog.IsChecked == true) { this.ListArticle = ArticleRepository.ListCatalog(Catalog.Cat_Id); Model.Local.ArticleCatalogRepository ArticleCatalogRepository = new Model.Local.ArticleCatalogRepository(); List <Model.Local.ArticleCatalog> ListArticleCatalog = ArticleCatalogRepository.ListCatalog(Catalog.Cat_Id); foreach (Model.Local.ArticleCatalog ArticleCatalog in ListArticleCatalog) { Boolean Add = true; foreach (Model.Local.Article Article in ListArticle) { if (Article.Art_Id == ArticleCatalog.Art_Id) { Add = false; break; } } if (Add == true) { this.ListArticle.Add(ArticleCatalog.Article); } } } else { this.ListArticle = ArticleRepository.List(); } Boolean isArticle; foreach (Model.Local.Article Article in this.ListArticle) { isArticle = true; if (this.TextBoxSearchArticleName.Text != "" && this.TextBoxSearchArticleName.Text.Replace("%", "") != "") { if (this.TextBoxSearchArticleName.Text.Contains("%")) { if (Article.Art_Name.ToUpper().Contains(this.TextBoxSearchArticleName.Text.Replace("%", "").ToUpper()) == false) { isArticle = false; } } else { if (Article.Art_Name.ToUpper().StartsWith(this.TextBoxSearchArticleName.Text.ToUpper()) == false) { isArticle = false; } } } if (this.TextBoxSearchArticleEan13.Text != "" && this.TextBoxSearchArticleEan13.Text.Replace("%", "") != "") { if (Article.Art_Ean13 != null) { if (this.TextBoxSearchArticleEan13.Text.Contains("%")) { if (Article.Art_Ean13.ToUpper().Contains(this.TextBoxSearchArticleEan13.Text.Replace("%", "").ToUpper()) == false) { isArticle = false; } } else { if (Article.Art_Ean13.ToUpper().StartsWith(this.TextBoxSearchArticleEan13.Text.ToUpper()) == false) { isArticle = false; } } } else { isArticle = false; } } if (this.TextBoxSearchArticleRef.Text != "" && this.TextBoxSearchArticleRef.Text.Replace("%", "") != "") { if (this.TextBoxSearchArticleRef.Text.Contains("%")) { if (Article.Art_Ref.ToUpper().Contains(this.TextBoxSearchArticleRef.Text.Replace("%", "").ToUpper()) == false) { isArticle = false; } } else { if (Article.Art_Ref.ToUpper().StartsWith(this.TextBoxSearchArticleRef.Text.ToUpper()) == false) { isArticle = false; } } } if (Article.Art_Sync != this.CheckBoxSearchArticleSync.IsChecked) { isArticle = false; } if (Article.Art_Active != this.CheckBoxSearchArticleActif.IsChecked) { isArticle = false; } if (isArticle == true) { ListArticleDisplay.Add(Article); } } this.DataGridArticle.ItemsSource = ListArticleDisplay; }