private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(txtreference.Text))
            {
                btnSearch.IsEnabled = false;
                if (_rang == 1)
                {
                    CaisseServiceClient client = new CaisseServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Caisse"));
                    client.RetourneClientsParReferenceCompleted += (send, args) =>
                    {
                        if (args.Cancelled || args.Error != null)
                        {
                            Message.ShowError(Galatee.Silverlight.Resources.Langue.wcf_error, Galatee.Silverlight.Resources.Langue.errorTitle);
                            btnSearch.IsEnabled = true;
                            return;
                        }

                        if (args.Result.Count != 0 && args.Result != null)
                        {
                            List <CsClient> lesClientsAfficher = new List <CsClient>();
                            lesClientsAfficher = args.Result.Where(t => lesIdCentre.Contains(t.FK_IDCENTRE)).ToList();
                            if (lesClientsAfficher.Count == 0)
                            {
                                Message.ShowInformation("Ce client n'est pas de votre périmetre d'action", Galatee.Silverlight.Resources.Langue.errorTitle);
                                return;
                            }

                            dgrdroute.ItemsSource = null;
                            PagedCollectionView view = new PagedCollectionView(lesClientsAfficher);
                            dgrdroute.ItemsSource = view;
                            datapager.Source      = view;
                            btnSearch.IsEnabled   = true;
                        }
                        else
                        {
                            Message.ShowInformation("Aucune donnée trouvé", Galatee.Silverlight.Resources.Langue.errorTitle);
                            btnSearch.IsEnabled = true;
                        }
                    };
                    client.RetourneClientsParReferenceAsync(txtreference.Text, compare.ToString());
                }
                else
                if (_rang == 2)
                {
                    CaisseServiceClient Serviceclient = new CaisseServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Caisse"));
                    Serviceclient.RetourneClientsParAmountCompleted += (s, result) =>
                    {
                        try
                        {
                            if (result.Cancelled || result.Error != null)
                            {
                                Message.ShowError(Galatee.Silverlight.Resources.Langue.wcf_error, Galatee.Silverlight.Resources.Langue.errorTitle);

                                btnSearch.IsEnabled = true;
                                return;
                            }
                            if (result.Result.Count != 0 && result.Result != null)
                            {
                                dgrdamount.ItemsSource = null;
                                List <CsClient> lesClientsAfficher = new List <CsClient>();
                                lesClientsAfficher = result.Result.Where(t => lesIdCentre.Contains(t.FK_IDCENTRE)).ToList();
                                if (lesClientsAfficher.Count == 0)
                                {
                                    Message.ShowInformation("Ce client n'est pas de votre périmetre d'action", Galatee.Silverlight.Resources.Langue.errorTitle);
                                    return;
                                }
                                var groupementdeclient = from x in lesClientsAfficher
                                                         group x by new  { x.CENTRE, x.REFCLIENT, x.ORDRE, x.NOMABON } into g
                                select          g;
                                List <CsClient> ListClient = (from cl in groupementdeclient
                                                              select new CsClient {
                                    CENTRE = cl.Key.CENTRE, REFCLIENT = cl.Key.REFCLIENT, ORDRE = cl.Key.ORDRE, NOMABON = cl.Key.NOMABON
                                }).ToList();

                                PagedCollectionView view = new PagedCollectionView(ListClient);
                                dgrdroute.ItemsSource = view;
                                datapager.Source      = view;
                            }
                            else
                            {
                                Message.ShowInformation("Aucune donnée trouvé", Galatee.Silverlight.Resources.Langue.errorTitle);
                            }

                            btnSearch.IsEnabled = true;
                        }
                        catch (Exception ex)
                        {
                            Message.ShowError(ex, Galatee.Silverlight.Resources.Langue.errorTitle);
                        }
                    };
                    Serviceclient.RetourneClientsParAmountAsync(Convert.ToDecimal(txtreference.Text), compare.ToString(), lstidCentre);
                }
                else
                if (_rang == 3)
                {
                    CaisseServiceClient Service = new CaisseServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Caisse"));
                    Service.RetourneClientsParNomsCompleted += (s, result) =>
                    {
                        try
                        {
                            if (result.Cancelled || result.Error != null)
                            {
                                Message.ShowError(Galatee.Silverlight.Resources.Langue.wcf_error, Galatee.Silverlight.Resources.Langue.errorTitle);
                                btnSearch.IsEnabled = true;
                                return;
                            }
                            if (result.Result.Count != 0 && result.Result != null)
                            {
                                List <CsClient> lesClientsAfficher = new List <CsClient>();
                                lesClientsAfficher = result.Result.Where(t => lesIdCentre.Contains(t.FK_IDCENTRE)).ToList();
                                if (lesClientsAfficher.Count == 0)
                                {
                                    Message.ShowInformation("Ce client n'est pas de votre périmetre d'action", Galatee.Silverlight.Resources.Langue.errorTitle);
                                    return;
                                }
                                dgrdroute.ItemsSource = null;
                                PagedCollectionView view = new PagedCollectionView(lesClientsAfficher);
                                dgrdroute.ItemsSource = view;
                                datapager.Source      = view;
                            }
                            else
                            {
                                Message.ShowInformation("Aucune donnée trouvé", Galatee.Silverlight.Resources.Langue.errorTitle);
                            }

                            btnSearch.IsEnabled = true;
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    };
                    Service.RetourneClientsParNomsAsync(txtreference.Text);
                }
            }
            else
            {
                Message.ShowInformation("there is no criteria for search ", Galatee.Silverlight.Resources.Langue.errorTitle);
            }
        }