Пример #1
0
        /// <summary>
        /// Implements the execution of <see cref="GetPurchaseReportCommand" />
        /// </summary>
        private async void GetPurchaseReportCommand_Execute(object obj)
        {
            try
            {
                IsReportLoaded    = false;
                IsReportNotLoaded = true;
                PurchaseReportVms = new List <PurchaseReportVm>();
                CrystalReportsViewer ReportViewer = (CrystalReportsViewer)obj;

                data = await Task.Run(async() => await GetPurchaseReport());

                await Task.FromResult(0).ContinueWith(b =>
                {
                    PurchaseReportVms = data.Select(

                        a => new PurchaseReportVm
                    {
                        Beverage       = a.Beverage.Name,
                        PurchaseDate   = a.PurchaseDate,
                        Metric         = a.Metric.ToString(),
                        Quantity       = a.Quantity,
                        UnitPrice      = a.UnitPrice,
                        FromDate       = FromDate.ToLongDateString(),
                        ToDate         = ToDate.ToLongDateString(),
                        Rate           = a.Rate,
                        MetricQuantity = a.MetricQuantity,
                        LineTotalAmout = a.Quantity * a.UnitPrice,
                        //Supplier=a.Supplier.SupplierName
                    }).ToList();
                });

                await System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                                                                (ThreadStart) delegate

                {
                    IsReportLoaded    = true;
                    IsReportNotLoaded = false;
                    if (PurchaseReportVms.Count < 1)
                    {
                        MessageBox.Show("No Report");
                        return;
                    }
                    report.SetDataSource(PurchaseReportVms);
                    ReportViewer.ViewerCore.ReportSource = report;
                });
            }catch (Exception ex)
            {
                throw ex;
            }
        }