private void RemplirCommune() { try { if (SessionObject.LstCommune != null && SessionObject.LstCommune.Count != 0) { _listeDesCommuneExistant = SessionObject.LstCommune; return; } Galatee.Silverlight.ServiceAccueil.AcceuilServiceClient service = new Galatee.Silverlight.ServiceAccueil.AcceuilServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Accueil")); service.ChargerCommuneAsync(); service.ChargerCommuneCompleted += (s, args) => { if (args.Error != null && args.Cancelled) { return; } SessionObject.LstCommune = args.Result; _listeDesCommuneExistant = SessionObject.LstCommune; }; service.CloseAsync(); } catch (Exception ex) { throw ex; } }
private void RemplirCommune() { try { if (_listeDesCommuneInitiale != null && _listeDesCommuneInitiale.Count != 0) { Cbo_Commune.ItemsSource = _listeDesCommuneInitiale.OrderBy(t => t.LIBELLE).ToList(); Cbo_Commune.IsEnabled = true; Cbo_Commune.SelectedValuePath = "PK_ID"; Cbo_Commune.DisplayMemberPath = "LIBELLE"; return; } Galatee.Silverlight.ServiceAccueil.AcceuilServiceClient service = new Galatee.Silverlight.ServiceAccueil.AcceuilServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Accueil")); service.ChargerCommuneAsync(); service.ChargerCommuneCompleted += (s, args) => { if (args.Error != null && args.Cancelled) { return; } _listeDesCommuneInitiale.Clear(); List <CsCommune> _listeDesCommuneExistant = new List <CsCommune>(); CsCommune st = null; foreach (ServiceAccueil.CsCommune item in args.Result) { st = new CsCommune(); st.PK_ID = item.PK_ID; st.CODE = item.CODE; st.LIBELLE = item.LIBELLE; _listeDesCommuneExistant = _listeDesCommuneInitiale.Where(t => t.LIBELLE == st.LIBELLE).ToList(); if (_listeDesCommuneExistant == null || _listeDesCommuneExistant.Count == 0) { _listeDesCommuneInitiale.Add(st); } } Cbo_Commune.ItemsSource = _listeDesCommuneInitiale.OrderBy(t => t.LIBELLE).ToList(); Cbo_Commune.IsEnabled = true; Cbo_Commune.SelectedValuePath = "PK_ID"; Cbo_Commune.DisplayMemberPath = "LIBELLE"; if (ObjetSelectionnee != null && ObjetSelectionnee.FK_IDCOMMUNE > 0) { Cbo_Commune.SelectedItem = _listeDesCommuneInitiale.FirstOrDefault(t => t.PK_ID == ObjetSelectionnee.FK_IDCOMMUNE); } }; service.CloseAsync(); } catch (Exception ex) { throw ex; } }