コード例 #1
0
        private void LoadProduit()
        {
            ReportServiceClient service = new ReportServiceClient();
            List <ServiceReport.CsProduitFacture> reportPrint = new List <CsProduitFacture>();

            int loaderHandler = LoadingManager.BeginLoading("Traitement en cours ... ");

            service.RetourneTousProduitAsync();
            service.RetourneTousProduitCompleted += (er, res) =>
            {
                try
                {
                    if (res.Error != null || res.Cancelled)
                    {
                        LoadingManager.EndLoading(loaderHandler);
                        throw new Exception("Cannot display report");
                    }
                    if (res.Result != null)
                    {
                        reportPrint.Add(new CsProduitFacture {
                            PK_ID = 0, CODE = "00", LIBELLEPRODUIT = "TOUS"
                        });
                        reportPrint.AddRange(res.Result);

                        //Charger la combo
                        Cmb_Produit.ItemsSource = reportPrint;
                        //                    foreach (var item in reportPrint)
                        //{
                        //     item.LIBELLEPRODUIT;
                        //         item.PK_ID
                        //}
                        Cmb_Produit.DisplayMemberPath = "LIBELLEPRODUIT";
                        Cmb_Produit.SelectedValuePath = "CODE";
                        Cmb_Produit.SelectedValue     = "00";
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    LoadingManager.EndLoading(loaderHandler);
                }
            };

            this.DefinedRDLC = "ConnexionsElectricite";
            //return reportPrint;
        }