コード例 #1
0
        public void SearchArticleComposition()
        {
            if (SelectedF_TAXE == null)
            {
                MessageBox.Show("Veuillez sélectionner une taxe !", "Recherche article", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                List <Model.Sage.F_ARTICLE_Composition> temp = new Model.Sage.F_ARTICLERepository().ListComposition();

                // Filtres sommeil et publié
                bool sommeil   = Core.Global.GetConfig().ArticleEnSommeil;
                bool nonpublie = Core.Global.GetConfig().ArticleNonPublieSurLeWeb;
                // <JG> 19/12/2016 ajout filtre gammes
                temp = temp.Where(ar => (sommeil || ar.AR_Sommeil == 0) && (nonpublie || ar.AR_Publie == 1) && (sommeil || ar.AE_Sommeil != 1)).ToList();

                Model.Local.CompositionArticleRepository CompositionArticleRepository = new Model.Local.CompositionArticleRepository();
                Model.Local.ArticleRepository            ArticleRepository            = new Model.Local.ArticleRepository();

                // FILTRE TAXE OBLIGATOIRE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                #region Taxes
                switch (Core.Global.GetConfig().TaxSageTVA)
                {
                case PRESTACONNECT.Core.Parametres.TaxSage.CodeTaxe1:
                    temp = temp.Where(a => a.TA_Code1 == SelectedF_TAXE.TA_Code || (string.IsNullOrEmpty(a.TA_Code1) && a.TA_CodeFamille1 == SelectedF_TAXE.TA_Code)).ToList();
                    break;

                case PRESTACONNECT.Core.Parametres.TaxSage.CodeTaxe2:
                    temp = temp.Where(a => a.TA_Code2 == SelectedF_TAXE.TA_Code || (string.IsNullOrEmpty(a.TA_Code2) && a.TA_CodeFamille2 == SelectedF_TAXE.TA_Code)).ToList();
                    break;

                case PRESTACONNECT.Core.Parametres.TaxSage.CodeTaxe3:
                    temp = temp.Where(a => a.TA_Code3 == SelectedF_TAXE.TA_Code || (string.IsNullOrEmpty(a.TA_Code3) && a.TA_CodeFamille3 == SelectedF_TAXE.TA_Code)).ToList();
                    break;

                case PRESTACONNECT.Core.Parametres.TaxSage.Empty:
                default:
                    temp = new List <Model.Sage.F_ARTICLE_Composition>();
                    break;
                }
                #endregion

                if (temp.Count == 0)
                {
                    MessageBox.Show("Aucun résultat pour la taxe sélectionnée !", "Recherche article", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    // filtres
                    if (SelectedF_FAMILLE != null)
                    {
                        temp = temp.Where(ar => ar.FA_CodeFamille == SelectedF_FAMILLE.FA_CodeFamille).ToList();
                    }
                    if (SelectedP_GAMME1 != null)
                    {
                        temp = temp.Where(ar => ar.AR_Gamme1 == SelectedP_GAMME1.cbMarq).ToList();
                    }
                    if (SelectedP_GAMME2 != null)
                    {
                        temp = temp.Where(ar => ar.AR_Gamme2 == SelectedP_GAMME1.cbMarq).ToList();
                    }
                    if (SelectedP_CONDITIONNEMENT != null)
                    {
                        temp = temp.Where(ar => ar.AR_Condition == SelectedP_CONDITIONNEMENT.cbMarq).ToList();
                    }
                    if (!string.IsNullOrWhiteSpace(FilterReferenceValue))
                    {
                        if (FilterReferenceContains)
                        {
                            temp = temp.Where(ar => ar.AR_Ref.Contains(FilterReferenceValue)).ToList();
                        }
                        if (FilterReferenceStartWith)
                        {
                            temp = temp.Where(ar => ar.AR_Ref.StartsWith(FilterReferenceValue)).ToList();
                        }
                    }
                    if (!string.IsNullOrWhiteSpace(FilterDesignationValue))
                    {
                        if (FilterDesignationContains)
                        {
                            temp = temp.Where(ar => ar.AR_Design.ToLower().Contains(FilterDesignationValue.ToLower())).ToList();
                        }
                        if (FilterDesignationStartWith)
                        {
                            temp = temp.Where(ar => ar.AR_Design.ToLower().StartsWith(FilterDesignationValue.ToLower())).ToList();
                        }
                    }

                    List <Int32> ListF_ARTICLE_SagId    = null;
                    List <Int32> ListF_ARTENUMREF_SagId = null;
                    List <Int32> ListF_CONDITION_SagId  = null;
                    if (FilterComposition)
                    {
                        ListF_ARTICLE_SagId    = CompositionArticleRepository.ListSageF_ARTICLE();
                        ListF_ARTENUMREF_SagId = CompositionArticleRepository.ListSageF_ARTENUMREF();
                        ListF_CONDITION_SagId  = CompositionArticleRepository.ListSageF_CONDITION();
                    }
                    if (FilterArticle)
                    {
                        if (ListF_ARTICLE_SagId != null)
                        {
                            ListF_ARTICLE_SagId.AddRange(ArticleRepository.ListSageId());
                        }
                        else
                        {
                            ListF_ARTICLE_SagId = ArticleRepository.ListSageId();
                        }
                    }
                    if (ListF_ARTICLE_SagId != null)
                    {
                        temp = temp.Where(ar => !ListF_ARTICLE_SagId.Contains(ar.cbMarq)).ToList();
                    }
                    if (ListF_ARTENUMREF_SagId != null)
                    {
                        temp = temp.Where(ar => ar.F_ARTENUMREF_SagId == null || (ar.F_ARTENUMREF_SagId != null && !ListF_ARTENUMREF_SagId.Contains(ar.F_ARTENUMREF_SagId.Value))).ToList();
                    }
                    if (ListF_CONDITION_SagId != null)
                    {
                        temp = temp.Where(ar => ar.F_CONDITION_SagId == null || (ar.F_CONDITION_SagId != null && !ListF_CONDITION_SagId.Contains(ar.F_CONDITION_SagId.Value))).ToList();
                    }

                    // filtres exclusion
                    int count = temp.Count;
                    List <Model.Sage.F_ARTICLE_Composition> results = Core.Tools.FiltreImportSage.ImportSageFilter(temp);
                    StrCompositionFilteredProducts = (results.Count < count) ? ((count - results.Count) + " résultats dans les filtres d'exclusion") : string.Empty;
                    if (!ShowResultInImportSageFilter)
                    {
                        temp = results;
                    }

                    ListResultSearchCompositionArticle = new ObservableCollection <Model.Sage.F_ARTICLE_Composition>(temp);
                }
            }
        }