private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                prgBar.Visibility = System.Windows.Visibility.Visible;
                List <CsLotri> LotPourMaj = new List <CsLotri>();
                this.OKButton.IsEnabled = false;
                var ligneLotriSelect = ((List <CsLotri>)dtgFactures.ItemsSource).Where(t => t.IsSelect == true).ToList();
                if (ligneLotriSelect != null && ligneLotriSelect.Count > 0)
                {
                    foreach (CsLotri item in ligneLotriSelect)
                    {
                        LotPourMaj.AddRange(lstLotInit.Where(t => t.NUMLOTRI == item.NUMLOTRI && t.PERIODE == item.PERIODE && t.JET == item.JET).ToList());
                        LotPourMaj.ForEach(t => t.MATRICULE  = UserConnecte.matricule);
                        LotPourMaj.ForEach(t => t.MOISCOMPTA = Shared.ClasseMEthodeGenerique.FormatPeriodeAAAAMM(item.MOISCOMPTA));
                    }

                    FacturationServiceClient service = new FacturationServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Facturation"));
                    service.MiseAjourLotsAsync(LotPourMaj);
                    service.MiseAjourLotsCompleted += (erreur, resultat) =>
                    {
                        prgBar.Visibility = System.Windows.Visibility.Collapsed;

                        if (resultat.Error != null || resultat.Cancelled)
                        {
                            Message.Show("Une erreur s'est produite", "Erreur");
                        }
                        else
                        {
                            CsStatFacturation _laStat = resultat.Result;
                            if (_laStat != null)
                            {
                                this.DialogResult = false;
                                UcResultatFacturation ctrl = new UcResultatFacturation(_laStat);
                                ctrl.Show();
                                prgBar.Visibility = System.Windows.Visibility.Collapsed;
                            }
                            this.OKButton.IsEnabled = true;
                        }
                    };
                }
                else
                {
                    Message.Show("Vous devez choisir un lot dans la liste", "Erreur");
                    this.OKButton.IsEnabled = true;
                    prgBar.Visibility       = System.Windows.Visibility.Collapsed;
                    return;
                }
            }
            catch (Exception ex)
            {
                Message.Show("Erreur à la mise à jour", "Erreur");
            }
        }
        private void  CalculerFacture(List <CsLotri> ListLotSelect, bool IsSumulation, bool IsFacturationTotal)
        {
            prgBar.Visibility = System.Windows.Visibility.Visible;
            try
            {
                List <CsFactureBrut>     _laStat = new List <CsFactureBrut>();
                FacturationServiceClient service = new FacturationServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Facturation"));
                service.CalculeDuLotGeneralCompleted += (s, args) =>
                {
                    if (args != null && args.Cancelled)
                    {
                        Message.Show(Langue.msgErrorFact, Langue.LibelleModule);
                        prgBar.Visibility = System.Windows.Visibility.Collapsed;

                        return;
                    }
                    if (args == null && args.Cancelled)
                    {
                        Message.Show(Langue.msgErrorFact, Langue.LibelleModule);
                        prgBar.Visibility = System.Windows.Visibility.Collapsed;
                        return;
                    }
                    _laStat = args.Result;
                    if (_laStat != null)
                    {
                        UcResultatFacturation ctrl = new UcResultatFacturation(_laStat, IsSimulation);
                        ctrl.Show();
                    }
                    else
                    {
                        Message.Show(Langue.msgErrorFact, Langue.LibelleModule);
                    }
                    prgBar.Visibility = System.Windows.Visibility.Collapsed;
                };
                service.CalculeDuLotGeneralAsync(ListLotSelect, IsSumulation);
                service.CloseAsync();
            }
            catch (Exception ex)
            {
                prgBar.Visibility = System.Windows.Visibility.Collapsed;
                throw ex;
            }
        }