private void DefacturationLot(List <CsLotri> ListLotSelect, bool isDestructionLot)
        {
            prgBar.Visibility = System.Windows.Visibility.Visible;
            try
            {
                CsStatFacturation        _laStat = new CsStatFacturation();
                FacturationServiceClient service = new FacturationServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Facturation"));
                service.DefacturerLotCompleted += (s, args) =>
                {
                    if (args != null && args.Cancelled)
                    {
                        return;
                    }
                    _laStat = args.Result;

                    if (_laStat != null)
                    {
                        if (!isDestructionLot)
                        {
                            Message.Show("Nombre de client :" + _laStat.NombreCalcule + "\r\n  Montant défacturé : " + decimal.Parse(_laStat.Montant.ToString()).ToString("N2"), "Statistique");
                            this.OKButton.IsEnabled = true;
                        }
                        else
                        {
                            Action = SessionObject.Enumere.Normal;
                            //UcTypeFacturation _ctrlDateExige = new UcTypeFacturation();
                            //_ctrlDateExige.Closed += new EventHandler(galatee_OkClickedClient);
                            //_ctrlDateExige.Show();

                            UcDateExigible _ctrlDateExige = new UcDateExigible();
                            _ctrlDateExige.Closed += new EventHandler(galatee_OkClickedClient);
                            _ctrlDateExige.Show();
                        }
                    }
                    prgBar.Visibility = System.Windows.Visibility.Collapsed;
                };
                service.DefacturerLotAsync(ListLotSelect, Action);
                service.CloseAsync();
            }
            catch (Exception ex)
            {
                prgBar.Visibility = System.Windows.Visibility.Collapsed;
                throw ex;
            }
        }
 private void VerifierSaisieTotal(List <CsLotri> ListLotSelect)
 {
     try
     {
         FacturationServiceClient service = new FacturationServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Facturation"));
         service.verifieSaisieTotalAsync(ListLotSelect);
         service.verifieSaisieTotalCompleted += (s, args) =>
         {
             if (args != null && args.Cancelled)
             {
                 return;
             }
             bool IsSaisiPartiel = args.Result;
             if (IsSaisiPartiel)
             {
                 var w = new MessageBoxControl.MessageBoxChildWindow(Langue.LibelleModule, "Des évènements non saisis existent dans ce lot. \n\r Voulez-vous continuer ?", MessageBoxControl.MessageBoxButtons.YesNo, MessageBoxControl.MessageBoxIcon.Information);
                 w.OnMessageBoxClosed += (_, result) =>
                 {
                     if (w.Result == MessageBoxResult.OK)
                     {
                         UcDateExigible _ctrlDateExige = new UcDateExigible();
                         _ctrlDateExige.Closed += new EventHandler(galatee_OkClickedClient);
                         _ctrlDateExige.Show();
                     }
                     else
                     {
                         this.OKButton.IsEnabled = true;
                     }
                 };
                 w.Show();
             }
             else
             {
                 UcDateExigible _ctrlDateExige = new UcDateExigible();
                 _ctrlDateExige.Closed += new EventHandler(galatee_OkClickedClient);
                 _ctrlDateExige.Show();
             }
         };
     }
     catch (Exception ex)
     {
         prgBar.Visibility = System.Windows.Visibility.Collapsed;
         throw ex;
     }
 }
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                this.OKButton.IsEnabled = false;
                ListSelectionnee        = new List <CsLotri>();
                ListSelectionnee        = RetourneLotriSelectionner(_ListeLotriObs, ListeLotri);
                if (ListSelectionnee != null && ListSelectionnee.Count != 0)
                {
                    if (!IsDefacturation && !IsDestructionSimulation)
                    {
                        if (ListSelectionnee.FirstOrDefault(y => (y.FACTURE != null && y.FACTURE.Contains("*"))) != null)
                        {
                            var w = new MessageBoxControl.MessageBoxChildWindow(Langue.LibelleModule, Langue.msgDestructionSimulation, MessageBoxControl.MessageBoxButtons.YesNo, MessageBoxControl.MessageBoxIcon.Information);
                            w.OnMessageBoxClosed += (_, result) =>
                            {
                                if (w.Result == MessageBoxResult.OK)
                                {
                                    Action = SessionObject.Enumere.DestructionSimulation;
                                    DefacturationLot(ListSelectionnee, true);
                                }
                                else
                                {
                                    this.OKButton.IsEnabled = true;
                                }
                            };
                            w.Show();
                        }
                        else
                        {
                            UcDateExigible _ctrlDateExige = new UcDateExigible();
                            _ctrlDateExige.Closed += new EventHandler(galatee_OkClickedClient);
                            _ctrlDateExige.Show();
                        }
                    }
                    else
                    {
                        string leMsg = string.Empty;
                        if (IsDefacturation)
                        {
                            leMsg = Langue.msgDefacturation;
                        }
                        else
                        {
                            leMsg = Langue.msgSuppressionSimulation;
                        }

                        var w = new MessageBoxControl.MessageBoxChildWindow(Langue.LibelleModule, leMsg, MessageBoxControl.MessageBoxButtons.YesNo, MessageBoxControl.MessageBoxIcon.Information);
                        w.OnMessageBoxClosed += (_, result) =>
                        {
                            if (w.Result == MessageBoxResult.OK)
                            {
                                DefacturationLot(ListSelectionnee, false);
                            }
                        };
                        w.Show();
                    }
                }
                else
                {
                    this.OKButton.IsEnabled = true;
                }
            }
            catch (Exception ex)
            {
                Message.ShowError(ex.Message, Langue.LibelleModule);
            }
        }