private void Update_Camp_Info()
        {
            LotNew = Load_Info_Lot();
            camp_select.ListLot.Add(LotNew);

            ObservableCollection <Galatee.Silverlight.ServiceRecouvrement.CsElementsDeCampagneBTA> brt_non_affecte = new ObservableCollection <Galatee.Silverlight.ServiceRecouvrement.CsElementsDeCampagneBTA>();

            foreach (var item in (List <Galatee.Silverlight.ServiceRecouvrement.CsElementsDeCampagneBTA>)dg_pop_non_affecte.ItemsSource)
            {
                brt_non_affecte.Add(item);
            }
            camp_select.ListElementsCamp = brt_non_affecte.ToList();
        }
        private void btn_Editer_Lot_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dg_lot.SelectedItem != null)
                {
                    Galatee.Silverlight.ServiceRecouvrement.CstbLotsDeControleBTA Lot = (Galatee.Silverlight.ServiceRecouvrement.CstbLotsDeControleBTA)dg_lot.SelectedItem;

                    Galatee.Silverlight.ServiceRecouvrement.RecouvrementServiceClient service = new Galatee.Silverlight.ServiceRecouvrement.RecouvrementServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Recouvrement"));
                    int handler = LoadingManager.BeginLoading("Recuperation des factures ...");
                    service.GetClienteBTADuLotControleAsync(Lot);
                    service.GetClienteBTADuLotControleCompleted += (er, res) =>
                    {
                        try
                        {
                            if (res.Error != null || res.Cancelled)
                            {
                                Message.Show("Erreur dans le traitement des méthode de dectection : " + res.Error.InnerException.ToString(), "Erreur");
                            }
                            else
                            if (res.Result != null)
                            {
                                Utility.ActionDirectOrientation <ServicePrintings.CsClient, ServiceRecouvrement.CsClient>(res.Result, null, SessionObject.CheminImpression, "ClientAControler", "Recouvrement", true);
                            }
                            else
                            {
                                Message.Show("Une erreur s'est produite, veuillez consultez le journal des erreurs",
                                             "Erreur");
                            }

                            LoadingManager.EndLoading(handler);
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    };
                }
            }
            catch (Exception ex)
            {
                Message.ShowError(ex, Galatee.Silverlight.Resources.Langue.errorTitle);
            }
        }
        private Galatee.Silverlight.ServiceRecouvrement.CstbLotsDeControleBTA Load_Info_Lot()
        {
            Galatee.Silverlight.ServiceRecouvrement.CstbLotsDeControleBTA Lot_To_Save = new Galatee.Silverlight.ServiceRecouvrement.CstbLotsDeControleBTA();
            Lot_To_Save.Campagne_ID = camp_select.Campagne_ID;
            Lot_To_Save.Critere_GroupeDeFacturation = CodeGroupe != ""? int.Parse(CodeGroupe):int.MinValue;
            if (CodeTournee != "")
            {
                Lot_To_Save.Critere_IdTournee = int.Parse(CodeTournee);
            }

            Lot_To_Save.Critere_TypeClient   = CodeTypeClient != "" ? int.Parse(CodeTypeClient) : int.MinValue;
            Lot_To_Save.Critere_TypeCompteur = CodeTypeCompteur != "" ? int.Parse(CodeTypeCompteur) : int.MinValue;
            Lot_To_Save.Critere_TypeTarif    = CodeTypeTarif;
            Lot_To_Save.DateCreation         = camp_select.DateCreation;
            Lot_To_Save.Libelle_Lot          = tbx_lib_lot.Text;
            Lot_To_Save.Lot_ID = Guid.NewGuid();
            Lot_To_Save.MatriculeAgentControleur = this.txtAgt_Recepteur.Tag != null ? this.txtAgt_Recepteur.Text :string.Empty;
            Lot_To_Save.MatriculeAgentCreation   = tbx_createur.Text;
            Lot_To_Save.NbreElementsDuLot        = dg_population_lot.ItemsSource != null ? ((List <Galatee.Silverlight.ServiceRecouvrement.CsElementsDeCampagneBTA>)dg_population_lot.ItemsSource).Count : 0;
            Lot_To_Save.StatutLot_ID             = !string.IsNullOrWhiteSpace(tbx_statu.Text) ? tbx_statu.Text == "Actif"?1:0 : int.MinValue;

            Lot_To_Save.ListElementLot = new List <Galatee.Silverlight.ServiceRecouvrement.CstbElementsLotDeControleBTA>();
            foreach (var item in (List <Galatee.Silverlight.ServiceRecouvrement.CsElementsDeCampagneBTA>)dg_population_lot.ItemsSource)
            {
                Lot_To_Save.ListElementLot.Add(new Galatee.Silverlight.ServiceRecouvrement.CstbElementsLotDeControleBTA
                {
                    Contrat_ID         = item.Contrat_ID.ToString(),
                    DateAffectationLot = DateTime.Now,
                    DateSelection      = DateTime.Now,
                    Debut_PerAA        = camp_select.DateDebutControles.Year,
                    Debut_PerMM        = camp_select.DateDebutControles.Month,
                    Lot_ID             = Lot_To_Save.Lot_ID
                                         //NOMABON = item.Nom
                });
            }
            this.ListElementLot = Lot_To_Save.ListElementLot;
            return(Lot_To_Save);
        }