Exemplo n.º 1
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool IsListe = false;
                if (this.Rdb_Liste.IsChecked == true)
                {
                    IsListe = true;
                }
                else
                {
                    IsListe = false;
                }

                if (this.lvwResultat.SelectedItem != null)
                {
                    prgBar.Visibility = System.Windows.Visibility.Visible;
                    LayoutRoot.Cursor = Cursors.Wait;
                    List <ServiceRecouvrement.CsAvisDeCoupureClient> ligne = new List <ServiceRecouvrement.CsAvisDeCoupureClient>();
                    RecouvrementServiceClient client = new RecouvrementServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Recouvrement"));
                    client.returnAvisReedtionCoupureAsync(CampagneSelect, IsListe);
                    client.returnAvisReedtionCoupureCompleted += (ss, ee) =>
                    {
                        try
                        {
                            if (ee.Cancelled || ee.Error != null)
                            {
                                string error = ee.Error.Message;
                                Message.ShowError("error occurs while invoking remote procedure", "returnAvisReedtionCoupure");
                                prgBar.Visibility = System.Windows.Visibility.Collapsed;
                                LayoutRoot.Cursor = Cursors.Arrow;
                                return;
                            }

                            if (ee.Result == null || ee.Result.Count == 0)
                            {
                                Message.ShowInformation("no data found", Galatee.Silverlight.Resources.Langue.wcf_error);
                                prgBar.Visibility = System.Windows.Visibility.Collapsed;
                                LayoutRoot.Cursor = Cursors.Arrow;
                                return;
                            }

                            List <ServiceRecouvrement.CsAvisDeCoupureClient> dataTable = new List <ServiceRecouvrement.CsAvisDeCoupureClient>();
                            dataTable = ee.Result;
                            ligne.AddRange(dataTable);


                            //impression du recu de la liste of cut-off

                            Dictionary <string, string> param = new Dictionary <string, string>();
                            param.Add("pfirstzone", CampagneSelect.PREMIERE_TOURNEE);
                            param.Add("plastzone", CampagneSelect.DERNIERE_TOURNEE);
                            param.Add("pminiAmount", CampagneSelect.MONTANT_RELANCABLE.ToString());
                            param.Add("pduedate", CampagneSelect.DATE_EXIGIBILITE.ToString());
                            param.Add("pnombreCustomer", CampagneSelect.NOMBRE_CLIENT);
                            param.Add("pcampainNumber", CampagneSelect.IDCOUPURE);
                            param.Add("pperioddue", CampagneSelect.PERIODE_RELANCABLE);
                            param.Add("pnumberbill", CampagneSelect.NOMBRE_CLIENT);
                            param.Add("pfirstroute", string.Empty);
                            param.Add("plastroute", string.Empty);
                            param.Add("pfirstcategorie", CampagneSelect.DEBUT_CATEGORIE);
                            param.Add("plastcategorie", CampagneSelect.FIN_CATEGORIE);
                            param.Add("pnamecontroller", CampagneSelect.AGENTPIA);
                            string key = Utility.getKey();

                            if (IsListe == false)
                            {
                                Utility.ActionCaisse <ServicePrintings.CsAvisDeCoupureClient, ServiceRecouvrement.CsAvisDeCoupureClient>(ligne, key, new Dictionary <string, string>(), "AvisDeCoupureDetail", "Recouvrement");
                            }
                            else
                            {
                                Utility.ActionDirectOrientation <ServicePrintings.CsAvisDeCoupureClient, ServiceRecouvrement.CsAvisDeCoupureClient>(ligne, param, SessionObject.DefaultPrinter, "AvisDeCoupureListe", "Recouvrement", true);
                            }

                            prgBar.Visibility = System.Windows.Visibility.Collapsed;
                            LayoutRoot.Cursor = Cursors.Arrow;

                            //string CheminImpression = "55" + SessionObject.LePosteCourant.NOMPOSTE + "5" + "Impression";
                            //if (IsListe == false)
                            //    Utility.ActionDirectOrientation<ServicePrintings.aDisconnection, ServiceRecouvrement.aDisconnection>(ligne, new Dictionary<string, string>(), CheminImpression, "AvisDeCoupureDetail", "Recouvrement", false);
                            //else
                            //    Utility.ActionDirectOrientation<ServicePrintings.aDisconnection, ServiceRecouvrement.aDisconnection>(ligne, param, CheminImpression, "AvisDeCoupureListe", "Recouvrement", true);
                        }
                        catch (Exception ex)
                        {
                            Message.ShowError(ex, Galatee.Silverlight.Resources.Langue.errorTitle);
                        }
                    };
                }
                else
                {
                    //ClosedEnventHandler();
                    ClosedEnventHandler();
                    this.DialogResult = false;
                }
            }
            catch (Exception ex)
            {
                Message.ShowError(ex, Galatee.Silverlight.Resources.Langue.errorTitle);
                prgBar.Visibility = System.Windows.Visibility.Collapsed;
                LayoutRoot.Cursor = Cursors.Arrow;
            }
            //this.DialogResult = true;
        }