Пример #1
0
        private void RetourneDemande()
        {
            try
            {
                CaisseServiceClient service2           = new CaisseServiceClient(Utility.Protocole(), Utility.EndPoint("Caisse"));
                List <CsLclient>    _demandeaEncaisser = new List <CsLclient>();
                service2.RetourneDemandeCompleted += (send, es) =>
                {
                    try
                    {
                        if (es != null && es.Cancelled)
                        {
                            Message.ShowError("Erreur survenue lors de l'appel du service.", "Erreur");
                            return;
                        }

                        if (es.Result == null)
                        {
                            Message.ShowError("La récupération des éléments de la demande a retourné une erreur.Réessayer svp!", "Information");
                            return;
                        }
                        if (es.Result != null && es.Result.Count != 0)
                        {
                            _demandeaEncaisser    = es.Result;
                            LstFactureDeLaDemande = new List <CsLclient>();
                            LstFactureDeLaDemande = _demandeaEncaisser.Where(t => t.MONTANT != 0).ToList();

                            if (LstFactureDeLaDemande != null && LstFactureDeLaDemande.Count != 0)
                            {
                                if (LstFactureDeLaDemande.FirstOrDefault().TYPEDEMANDE == SessionObject.Enumere.AchatTimbre)
                                {
                                    LstFactureDeLaDemande.ForEach(o => o.CLIENT = "00000000000");
                                    LstFactureDeLaDemande.ForEach(o => o.ORDRE  = "00");
                                }

                                if (LstFactureDeLaDemande.FirstOrDefault(t => t.NUMEROLOT == "ENCA1") != null) /* AKO 23/08/2017 tester si paiement facture de prestation */
                                {
                                    LstFactureDeLaDemande.Clear();
                                    LstFactureDeLaDemande = _demandeaEncaisser.Where(t => t.MONTANT != 0 && t.ISPRESTATIONSEULEMENT == true).ToList();
                                }
                                // valoriser les champs relatifs à la caissiere en cours
                                foreach (CsLclient _EltsFacture in LstFactureDeLaDemande)
                                {
                                    _EltsFacture.SOLDEFACTURE = _EltsFacture.MONTANT + (_EltsFacture.MONTANTTVA == null ? 0 : _EltsFacture.MONTANTTVA);
                                    _EltsFacture.MATRICULE    = UserConnecte.matricule;
                                    _EltsFacture.CAISSE       = UserConnecte.numcaisse;
                                    _EltsFacture.REFEM        = Galatee.Silverlight.Shared.ClasseMEthodeGenerique.FormatPeriodeMMAAAA(_EltsFacture.REFEM);
                                }
                                this.LsvFacture.ItemsSource = LstFactureDeLaDemande;
                                this.Txt_TotalHt.Text       = LstFactureDeLaDemande.Sum(t => t.MONTANT).Value.ToString(SessionObject.FormatMontant);
                                this.Txt_totalTaxe.Text     = LstFactureDeLaDemande.Sum(t => t.MONTANTTVA).Value.ToString(SessionObject.FormatMontant);
                                this.Txt_TotalTTC.Text      = txt_MontantPayes.Text = LstFactureDeLaDemande.Sum(t => t.SOLDEFACTURE).Value.ToString(SessionObject.FormatMontant);
                                _LeMonantMinimal            = (TotalTTc.Value * _LetauxMinimal) / 100;
                                Txt_NomClient.Text          = string.IsNullOrWhiteSpace(LstFactureDeLaDemande.First().NOM) ? string.Empty : LstFactureDeLaDemande.First().NOM;
                                Txt_Client.Text             = (string.IsNullOrWhiteSpace(LstFactureDeLaDemande.First().CENTRE) ? string.Empty : LstFactureDeLaDemande.First().CENTRE) + (string.IsNullOrWhiteSpace(LstFactureDeLaDemande.First().CLIENT) ? string.Empty : LstFactureDeLaDemande.First().CLIENT) + (string.IsNullOrWhiteSpace(LstFactureDeLaDemande.First().ORDRE) ? string.Empty : LstFactureDeLaDemande.First().ORDRE);
                            }
                            else
                            {
                                Message.ShowInformation("Aucune facture trouvée.", Langue.MsgPasDemande);
                                //Txt_NumeroDemande.Text = string.Empty;
                                this.LsvFacture.ItemsSource = null;
                                this.Txt_TotalHt.Text       = string.Empty;
                                this.Txt_totalTaxe.Text     = string.Empty;
                                this.Txt_TotalTTC.Text      = string.Empty;
                                Txt_NomClient.Text          = string.Empty;
                                Txt_Client.Text             = string.Empty;

                                return;
                            }
                        }
                        else
                        {
                            Message.ShowInformation("Demande non trouvée.", Langue.MsgPasDemande);
                            this.LsvFacture.ItemsSource = null;
                            this.Txt_TotalHt.Text       = string.Empty;
                            this.Txt_totalTaxe.Text     = string.Empty;
                            this.Txt_TotalTTC.Text      = string.Empty;
                            Txt_NomClient.Text          = string.Empty;
                            Txt_Client.Text             = string.Empty;
                        }
                    }
                    catch (Exception ex)
                    {
                        Message.ShowError(ex, "Erreur");
                    }
                };
                service2.RetourneDemandeAsync(this.Txt_NumeroDemande.Text, IsExtension);
            }
            catch (Exception ex)
            {
                Message.ShowInformation("Erreur au chargement des données", Langue.MsgPasDemande);
            }
        }