void galatee_OkClicked(object sender, EventArgs e)
        {
            Galatee.Silverlight.MainView.UcListeGenerique ctrs = sender as Galatee.Silverlight.MainView.UcListeGenerique;
            if (ctrs.isOkClick)
            {
                lstRegrSelect.Clear();
                foreach (var p in ctrs.MyObjectList)
                {
                    ServiceRecouvrement.CsRegCli leRegroupement = (ServiceRecouvrement.CsRegCli)p;
                    leRegroupement.CODPOS = "(" + leRegroupement.CODE + ")  " + leRegroupement.NOM;
                    lstRegrSelect.Add(leRegroupement);
                }

                this.Cbo_Regcli.ItemsSource       = null;
                this.Cbo_Regcli.DisplayMemberPath = "CODPOS";
                this.Cbo_Regcli.ItemsSource       = lstRegrSelect;
                if (lstRegrSelect.Count != 0)
                {
                    this.Cbo_Regcli.SelectedItem = lstRegrSelect.First();
                }

                this.Cbo_Regcli.Tag = lstRegrSelect;
            }
            else
            {
                this.Cbo_Regcli.IsEnabled = true;
            }
        }
 private void txt_Regroupement_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (this.txt_Regroupement.Text.Length == SessionObject.Enumere.TailleCodeRegroupement)
     {
         ServiceRecouvrement.CsRegCli leRegcli = LstCodeRegroupement.FirstOrDefault(y => y.CODE == this.txt_Regroupement.Text);
         if (leRegcli != null && !string.IsNullOrEmpty(leRegcli.CODE))
         {
             this.cbo_regroupement.SelectedItem = leRegcli;
         }
         else
         {
             Message.ShowInformation("Le regroupement saisi est inexistant", "Recouvrement");
         }
     }
 }
        private void RetournCampagneByRegcli(ServiceRecouvrement.CsRegCli Regroupement, string periode)
        {
            Galatee.Silverlight.ServiceRecouvrement.RecouvrementServiceClient service = new Galatee.Silverlight.ServiceRecouvrement.RecouvrementServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Recouvrement"));
            service.RetournCampagneByRegcliCompleted += (s, args) =>
            {
                if (args != null && args.Cancelled)
                {
                    return;
                }
                if (args.Result == null)
                {
                    return;
                }
                LstCampagneGc = args.Result;

                dg_campagne.ItemsSource = LstCampagneGc;
                return;
            };
            service.RetournCampagneByRegcliAsync(Regroupement, periode);
        }
        private void dgMyDataGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            DataGrid dg = (sender as DataGrid);
            var      lesFactureSelect = ((List <ServiceRecouvrement.CsRegCli>)dg.ItemsSource).ToList();

            if (dg.SelectedItem != null)
            {
                ServiceRecouvrement.CsRegCli SelectedObject = (ServiceRecouvrement.CsRegCli)dg.SelectedItem;
                if (SelectedObject.IsSelect == false)
                {
                    SelectedObject.IsSelect = true;
                    ListRegCliAffecter_Selectionner.Add((ServiceRecouvrement.CsRegCli)dgListeFraixParicipation.SelectedItem);
                }
                else
                {
                    SelectedObject.IsSelect = false;
                    ListRegCliAffecter_Selectionner.Remove((ServiceRecouvrement.CsRegCli)dgListeFraixParicipation.SelectedItem);
                }
            }
        }
        private void   OKButton_Click(object sender, RoutedEventArgs e)
        {
            string IdCoupure = string.Empty;

            try
            {
                CsAvisCoupureEdition avisCoupure = new CsAvisCoupureEdition();
                bntPrinting.IsEnabled = false;
                aCampagne      Campagne = new aCampagne();
                aDisconnection dis      = new aDisconnection();

                avisCoupure.ClientResilie = this.Chk_ExclusResil.IsChecked;
                avisCoupure.Matricule     = UserConnecte.matricule;
                avisCoupure.AgentPia      = UserConnecte.matricule;
                string DueDate = (string.IsNullOrEmpty(this.dtpDate.Text)) ? null : dtpDate.Text;
                if (this.Cbo_Regcli.Tag != null)
                {
                    avisCoupure.ListeRegroupement = (List <ServiceRecouvrement.CsRegCli>) this.Cbo_Regcli.Tag;
                }

                avisCoupure.Exigible = this.dtpDate.SelectedDate;

                if (this.Rdb_facturePeriode.IsChecked == true)
                {
                    if (string.IsNullOrEmpty(this.Txt_MontantPeriode.Text))
                    {
                        Message.ShowWarning("Remplisez le montant èxigible de la période", "Avis de coupure");
                        LayoutRoot.Cursor = Cursors.Arrow;

                        return;
                    }
                    if (string.IsNullOrEmpty(this.Txt_Periode.Text))
                    {
                        Message.ShowWarning("Remplisez la période èxigible", "Avis de coupure");
                        return;
                    }
                    avisCoupure.Periode     = this.Txt_Periode.Text;
                    avisCoupure.SoldeClient = string.IsNullOrEmpty(this.Txt_MontantPeriode.Text) ? 0 : int.Parse(this.Txt_MontantPeriode.Text);
                }
                else if (this.Rdb_MontantGlobal.IsChecked == true)
                {
                    if (string.IsNullOrEmpty(this.Txt_MontantGlobal.Text))
                    {
                        Message.ShowWarning("Remplisez le montant èxigible", "Avis de coupure");
                        return;
                    }
                    avisCoupure.SoldeClient = System.Convert.ToDecimal(string.IsNullOrEmpty(this.Txt_MontantGlobal.Text) ? "0" : this.Txt_MontantGlobal.Text);
                }
                else if (this.Rdb_NombreFactureMontant.IsChecked == true)
                {
                    if (string.IsNullOrEmpty(this.Txt_MontantFacture.Text))
                    {
                        Message.ShowWarning("Remplisez le montant èxigible", "Avis de coupure");
                        return;
                    }
                    if (string.IsNullOrEmpty(this.Txt_NombreFactureMontant.Text))
                    {
                        Message.ShowWarning("Remplisez le nombre de facture èxigible", "Avis de coupure");
                        return;
                    }
                    avisCoupure.MontantPeriode = string.IsNullOrEmpty(this.Txt_MontantFacture.Text) ? 0 : System.Convert.ToDecimal(this.Txt_MontantFacture.Text);
                    avisCoupure.TotalClient    = string.IsNullOrEmpty(this.Txt_NombreFactureMontant.Text) ? 0 : int.Parse(this.Txt_NombreFactureMontant.Text);
                }
                if (string.IsNullOrEmpty(avisCoupure.MatriculeDebut) && !string.IsNullOrEmpty(avisCoupure.MatriculeFin))
                {
                    Message.ShowInformation("Entrez la première référence !", Galatee.Silverlight.Resources.Langue.errorTitle);
                    return;
                }
                if (!string.IsNullOrEmpty(avisCoupure.MatriculeDebut) && string.IsNullOrEmpty(avisCoupure.MatriculeFin))
                {
                    Message.ShowInformation("Entrez la deuxième référence!", Galatee.Silverlight.Resources.Langue.errorTitle);
                    return;
                }

                bool IsListe = false;
                ligne.Clear();
                if (this.rdbtnList.IsChecked == true)
                {
                    IsListe = true;
                }
                else
                {
                    IsListe = false;
                }
                prgBar.Visibility = System.Windows.Visibility.Visible;
                LayoutRoot.Cursor = Cursors.Wait;
                RecouvrementServiceClient proxy = new RecouvrementServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Recouvrement"));
                proxy.TraitementAvisCoupureGCAsync(avisCoupure, dis, IsListe);
                proxy.TraitementAvisCoupureGCCompleted += (ssn, results) =>
                {
                    try
                    {
                        if (results.Cancelled || results.Error != null)
                        {
                            string error = results.Error.Message;
                            Message.ShowError("Erreur d'invocation du service. Réessayer svp !", Galatee.Silverlight.Resources.Langue.errorTitle);
                            bntPrinting.IsEnabled = true;
                            LayoutRoot.Cursor     = Cursors.Arrow;
                            prgBar.Visibility     = System.Windows.Visibility.Collapsed;
                            return;
                        }

                        if (results.Result == null || results.Result.Count == 0)
                        {
                            Message.ShowError("Aucune donnée de campagne retournée!", Galatee.Silverlight.Resources.Langue.errorTitle);
                            bntPrinting.IsEnabled = true;
                            LayoutRoot.Cursor     = Cursors.Arrow;
                            prgBar.Visibility     = System.Windows.Visibility.Collapsed;
                            return;
                        }

                        ligne.Clear();
                        ligne.AddRange(results.Result);
                        ServiceRecouvrement.CsRegCli lereg = ((List <ServiceRecouvrement.CsRegCli>) this.Cbo_Regcli.Tag).First();
                        Dictionary <string, string>  param = new Dictionary <string, string>();
                        string key = Utility.getKey();
                        if (IsListe == false)
                        {
                            Utility.Action <ServicePrintings.aDisconnection, ServiceRecouvrement.aDisconnection>(ligne, key, null, SessionObject.CheminImpression, "AvisDeCoupureDetailSGC", "Recouvrement");
                        }
                        else
                        {
                            Utility.Action <ServicePrintings.aDisconnection, ServiceRecouvrement.aDisconnection>(ligne, key, null, SessionObject.CheminImpression, "AvisDeCoupureListeSGC", "Recouvrement");
                        }

                        LayoutRoot.Cursor     = Cursors.Arrow;
                        prgBar.Visibility     = System.Windows.Visibility.Collapsed;
                        bntPrinting.IsEnabled = true;
                    }
                    catch (Exception ex)
                    {
                        prgBar.Visibility     = System.Windows.Visibility.Collapsed;
                        LayoutRoot.Cursor     = Cursors.Arrow;
                        bntPrinting.IsEnabled = true;
                        Message.ShowError(ex, Galatee.Silverlight.Resources.Langue.errorTitle);
                    }
                };
            }
            catch (Exception ex)
            {
                bntPrinting.IsEnabled = true;
                prgBar.Visibility     = System.Windows.Visibility.Collapsed;
                LayoutRoot.Cursor     = Cursors.Arrow;
                Message.ShowError(ex, Galatee.Silverlight.Resources.Langue.errorTitle);
            }
        }
        private void   OKButton_Click(object sender, RoutedEventArgs e)
        {
            string IdCoupure = string.Empty;

            try
            {
                CsAvisCoupureEdition avisCoupure = new CsAvisCoupureEdition();
                bntPrinting.IsEnabled = false;
                aCampagne      Campagne = new aCampagne();
                aDisconnection dis      = new aDisconnection();

                avisCoupure.Matricule            = UserConnecte.matricule;
                avisCoupure.AgentPia             = UserConnecte.matricule;
                avisCoupure.referenceClientDebut = string.IsNullOrEmpty(this.Txt_Client.Text) ? string.Empty : this.Txt_Client.Text;
                avisCoupure.OrdreTourneDebut     = string.IsNullOrEmpty(this.Txt_Ordre.Text) ? string.Empty : this.Txt_Ordre.Text;
                string DueDate = (string.IsNullOrEmpty(this.dtpDate.Text)) ? null : dtpDate.Text;
                if (this.Cbo_Regcli.Tag != null)
                {
                    avisCoupure.ListeRegroupement = (List <ServiceRecouvrement.CsRegCli>) this.Cbo_Regcli.Tag;
                }

                avisCoupure.MontantRelancable = string.IsNullOrEmpty(this.Txt_MontantExigible.Text) ? 0 : Convert.ToDecimal(this.Txt_MontantExigible.Text);
                avisCoupure.Exigible          = this.dtpDate.SelectedDate;
                if (this.Txt_LibelleCentre.Tag != null)
                {
                    List <CsCentre> lstCentreCampage = new List <CsCentre>();
                    List <string>   lstCodeCentre    = (List <string>) this.Txt_LibelleCentre.Tag;
                    foreach (var item in lstCodeCentre)
                    {
                        lstCentreCampage.Add(new CsCentre {
                            CODE = item
                        });
                    }
                    avisCoupure.Centre_Campagne = lstCentreCampage;
                }
                if (string.IsNullOrEmpty(avisCoupure.MatriculeDebut) && !string.IsNullOrEmpty(avisCoupure.MatriculeFin))
                {
                    Message.ShowInformation("Entrez la première référence !", Galatee.Silverlight.Resources.Langue.errorTitle);
                    return;
                }
                if (!string.IsNullOrEmpty(avisCoupure.MatriculeDebut) && string.IsNullOrEmpty(avisCoupure.MatriculeFin))
                {
                    Message.ShowInformation("Entrez la deuxième référence!", Galatee.Silverlight.Resources.Langue.errorTitle);
                    return;
                }
                if (this.chk_ParAbonnement.IsChecked == true)
                {
                    avisCoupure.IsParAbonnement = true;
                }
                else
                {
                    avisCoupure.IsParAbonnement = false;
                }

                if (chk_ResilierExclus.IsChecked == true)
                {
                    avisCoupure.ClientResilie = true;
                }
                else
                {
                    avisCoupure.ClientResilie = false;
                }

                if (!string.IsNullOrEmpty(this.Txt_DateDebut.Text) && ClasseMEthodeGenerique.IsFormatPeriodeValide(this.Txt_DateDebut.Text))
                {
                    avisCoupure.PeriodeDebut = ClasseMEthodeGenerique.FormatPeriodeAAAAMM(this.Txt_DateDebut.Text);
                }


                if (!string.IsNullOrEmpty(this.Txt_DateFin.Text) && ClasseMEthodeGenerique.IsFormatPeriodeValide(this.Txt_DateFin.Text))
                {
                    avisCoupure.PeriodeFin = ClasseMEthodeGenerique.FormatPeriodeAAAAMM(this.Txt_DateFin.Text);
                }

                ligne.Clear();
                prgBar.Visibility = System.Windows.Visibility.Visible;
                LayoutRoot.Cursor = Cursors.Wait;
                RecouvrementServiceClient proxy = new RecouvrementServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Recouvrement"));
                proxy.TraitementAvisCoupureGCAsync(avisCoupure, dis, IsPreavis);
                proxy.TraitementAvisCoupureGCCompleted += (ssn, results) =>
                {
                    try
                    {
                        if (results.Cancelled || results.Error != null)
                        {
                            string error = results.Error.Message;
                            Message.ShowError("Erreur d'invocation du service. Réessayer svp !", Galatee.Silverlight.Resources.Langue.errorTitle);
                            bntPrinting.IsEnabled = true;
                            LayoutRoot.Cursor     = Cursors.Arrow;
                            prgBar.Visibility     = System.Windows.Visibility.Collapsed;
                            return;
                        }

                        if (results.Result == null || results.Result.Count == 0)
                        {
                            Message.ShowError("Aucune donnée de campagne retournée!", Galatee.Silverlight.Resources.Langue.errorTitle);
                            bntPrinting.IsEnabled = true;
                            LayoutRoot.Cursor     = Cursors.Arrow;
                            prgBar.Visibility     = System.Windows.Visibility.Collapsed;
                            return;
                        }

                        ligne.Clear();
                        ligne.AddRange(results.Result);
                        ServiceRecouvrement.CsRegCli lereg = ((List <ServiceRecouvrement.CsRegCli>) this.Cbo_Regcli.Tag).First();
                        string key = Utility.getKey();
                        Dictionary <string, string> param = new Dictionary <string, string>();
                        if (param.Count != 0)
                        {
                            param.Clear();
                        }
                        if (this.chk_ParAbonnement.IsChecked == true)
                        {
                            if (IsPreavis)
                            {
                                param.Add("PpChefService", leParam != null && !string.IsNullOrEmpty(leParam.NOMCHEFSERVICE) ? leParam.NOMCHEFSERVICE : string.Empty);
                                Utility.ActionExportation <ServicePrintings.CsLclient, ServiceRecouvrement.CsLclient>(ligne, param, string.Empty, SessionObject.CheminImpression, "PreavisDeCoupurParAbon", "Recouvrement", true, "doc");
                            }
                            else
                            {
                                param.Add("PpNomDonneurOrdre", leParam != null && !string.IsNullOrEmpty(leParam.NOMCHEFSERVICE)? leParam.NOMCHEFSERVICE : string.Empty);
                                param.Add("PpTitreDonneurOrdre", leParam != null && !string.IsNullOrEmpty(leParam.TITRE_DONNEURORDRE)? leParam.TITRE_DONNEURORDRE:string.Empty);
                                param.Add("PpContactDonneurOrdre", leParam != null && !string.IsNullOrEmpty(leParam.CONTACT_DONNEURORDRE)? leParam.CONTACT_DONNEURORDRE :string.Empty);
                                param.Add("PpStructureExecution", leParam != null && !string.IsNullOrEmpty(leParam.STRUCTURE_EXECUTION)? leParam.STRUCTURE_EXECUTION :string.Empty);
                                param.Add("PpNomAgentExecution", leParam != null && !string.IsNullOrEmpty(leParam.AGENT_EXECUTION)? leParam.AGENT_EXECUTION :string.Empty);
                                param.Add("PpMatriculeAgent", leParam != null && !string.IsNullOrEmpty(leParam.MATRICULE_EXECUTION) ? leParam.MATRICULE_EXECUTION : string.Empty);

                                Utility.ActionExportation <ServicePrintings.CsLclient, ServiceRecouvrement.CsLclient>(ligne, param, string.Empty, SessionObject.CheminImpression, "OrdreDeCoupurParAbon", "Recouvrement", true, "doc");
                            }
                        }
                        else
                        {
                            if (IsPreavis)
                            {
                                param.Add("PpChefService", leParam != null && !string.IsNullOrEmpty(leParam.NOMCHEFSERVICE) ? leParam.NOMCHEFSERVICE : string.Empty);
                                Utility.ActionExportation <ServicePrintings.CsLclient, ServiceRecouvrement.CsLclient>(ligne, param, string.Empty, SessionObject.CheminImpression, "PreavisDeCoupur", "Recouvrement", true, "doc");
                            }
                            else
                            {
                                param.Add("PpNomDonneurOrdre", leParam != null && !string.IsNullOrEmpty(leParam.NOMCHEFSERVICE) ? leParam.NOMCHEFSERVICE : string.Empty);
                                param.Add("PpTitreDonneurOrdre", leParam != null && !string.IsNullOrEmpty(leParam.TITRE_DONNEURORDRE) ? leParam.TITRE_DONNEURORDRE : string.Empty);
                                param.Add("PpContactDonneurOrdre", leParam != null && !string.IsNullOrEmpty(leParam.CONTACT_DONNEURORDRE) ? leParam.CONTACT_DONNEURORDRE : string.Empty);
                                param.Add("PpStructureExecution", leParam != null && !string.IsNullOrEmpty(leParam.STRUCTURE_EXECUTION) ? leParam.STRUCTURE_EXECUTION : string.Empty);
                                param.Add("PpNomAgentExecution", leParam != null && !string.IsNullOrEmpty(leParam.AGENT_EXECUTION) ? leParam.AGENT_EXECUTION : string.Empty);
                                param.Add("PpMatriculeAgent", leParam != null && !string.IsNullOrEmpty(leParam.MATRICULE_EXECUTION) ? leParam.MATRICULE_EXECUTION : string.Empty);

                                Utility.ActionExportation <ServicePrintings.CsLclient, ServiceRecouvrement.CsLclient>(ligne, param, string.Empty, SessionObject.CheminImpression, "OrdreDeCoupur", "Recouvrement", true, "doc");
                            }
                        }


                        LayoutRoot.Cursor     = Cursors.Arrow;
                        prgBar.Visibility     = System.Windows.Visibility.Collapsed;
                        bntPrinting.IsEnabled = true;
                    }
                    catch (Exception ex)
                    {
                        prgBar.Visibility     = System.Windows.Visibility.Collapsed;
                        LayoutRoot.Cursor     = Cursors.Arrow;
                        bntPrinting.IsEnabled = true;
                        Message.ShowError(ex, Galatee.Silverlight.Resources.Langue.errorTitle);
                    }
                };
            }
            catch (Exception ex)
            {
                bntPrinting.IsEnabled = true;
                prgBar.Visibility     = System.Windows.Visibility.Collapsed;
                LayoutRoot.Cursor     = Cursors.Arrow;
                Message.ShowError(ex, Galatee.Silverlight.Resources.Langue.errorTitle);
            }
        }