private void btnOk_Click(object sender, RoutedEventArgs e) { if (Closed != null) { client = this.RecupererLesElementsSelectionnes().FirstOrDefault(); Closed(this, new EventArgs()); this.DialogResult = true; } }
List <aClient> RecupererLesElementsSelectionnes() { List <aClient> cls = new List <aClient>(); foreach (aClient lvi in this.lvwResultat.SelectedItems) { aClient cl = lvi; cls.Add(cl); } return(cls); }
void Recherche() { try { btnsearch.IsEnabled = false; aClient critere = new aClient(); critere.Centre = (string.IsNullOrEmpty(this.txtCentre.Text)) ? string.Empty : this.txtCentre.Text; critere.Client = (string.IsNullOrEmpty(this.txtClient.Text)) ? string.Empty : this.txtClient.Text; critere.Ordre = (string.IsNullOrEmpty(this.txtOrdre.Text)) ? string.Empty : this.txtOrdre.Text; RecouvrementServiceClient client = new RecouvrementServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Recouvrement")); client.RechercherListeClientsCompleted += (ss, args) => { if (args.Cancelled || args.Error != null) { string error = args.Error.Message; MessageBox.Show(args.Error.Message, "RechercherListeClients", MessageBoxButton.OK); btnsearch.IsEnabled = true; return; } if (args.Result == null || args.Result.Count == 0) { MessageBox.Show("Aucune donnée trouvée", "RechercherListeClients", MessageBoxButton.OK); btnsearch.IsEnabled = true; return; } List <aClient> clients = new List <aClient>(); clients.AddRange(args.Result); this.lvwResultat.ItemsSource = null; this.lvwResultat.ItemsSource = clients; btnsearch.IsEnabled = true; }; client.RechercherListeClientsAsync(critere); } catch (Exception ex) { btnsearch.IsEnabled = true; string error = ex.Message; //MessageBox.Show(ex.Message, Program.rm.GetString("msgSuiviRecouvrements"), MessageBoxButtons.OK, MessageBoxIcon.Information); } }