Ejemplo n.º 1
0
        public ReportViewer()
        {
            InitializeComponent();

            reportViewer = new CrystalReportsViewer();
            reportViewwerContainer.Children.Add(reportViewer);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Implements the execution of <see cref="GetTrialBalanceReportCommand" />
        /// </summary>
        private async void GetTrialBalanceReportCommand_Execute(object obj)
        {
            IsReportLoaded    = false;
            IsReportNotLoaded = true;


            await Task.Run(() => GetTrialBalance(TrialBalanceDate));

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

            {
                CrystalReportsViewer ReportViewer = (CrystalReportsViewer)obj;
                IsReportLoaded    = true;
                IsReportNotLoaded = false;
                if (Tbms.Count < 1)
                {
                    MessageBox.Show("No Trial Balance For That Date");
                    return;
                }
                else
                {
                    report.SetDataSource(Tbms);
                    ReportViewer.ViewerCore.ReportSource = report;
                }
            });
        }
        public ReportViewer(ReportClass costSaving)
        {
            InitializeComponent();

            var crv = new CrystalReportsViewer();

            crystalReportsViewer.ViewerCore.ReportSource = costSaving;
        }
Ejemplo n.º 4
0
        public void AddControl(CrystalReportsViewer crystalReports)
        {
            CrystalReportsViewer crystalReportViewer = crystalReports;

            crystalReportViewer.Width  = GridReport.Width;
            crystalReportViewer.Height = GridReport.Height;
            GridReport.Children.Add(crystalReportViewer);
            crystalReportViewer.Owner = this;
        }
Ejemplo n.º 5
0
        public ReportViewer()
        {
            InitializeComponent();

            reportContainer.Children.Clear();
            crystalReportsViewer = new CrystalReportsViewer();
            reportContainer.Children.Add(crystalReportsViewer);

            isReport = new ISReport();
        }
Ejemplo n.º 6
0
 public static Result AddControl(CrystalReportsViewer crystalReportViewer)
 {
     try
     {
         var mainWindow = new MainReportWindow();
         mainWindow.AddControl(crystalReportViewer);
         mainWindow.Show();
         return(new Result(true, "Success"));
     }
     catch (Exception e)
     {
         return(new Result(false, e.Message));
     }
 }
Ejemplo n.º 7
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;
            }
        }
Ejemplo n.º 8
0
        private async void GetSalesReport(CrystalReportsViewer ReportViewer)
        {
            IsReportLoaded    = false;
            IsReportNotLoaded = true;
            SalesReportVms    = new List <SalesReportVm>();


            var data = await Task.Run(async() => await Service.FindSalesByDateAsync(FromDate, ToDate));

            // await Task.CompletedTask.ContinueWith(b => this is f*****g for f*****g dot net 4.6.2 only
            await Task.FromResult(0).ContinueWith(b =>
            {
                SalesReportVms = data.Select(

                    a => new SalesReportVm
                {
                    Beverage        = a.Beverage.Name,
                    Quantity        = a.Quantity,
                    Paid            = (a.Paid ?? 0) * a.Quantity,
                    Discount        = a.Discount ?? 0,
                    SaleDate        = a.SaleDate,
                    UnitPrice       = a.UnitPrice,
                    SalesReportVmId = a.SaleId,
                    Customer        = a.Customer == null?"": a.Customer.CustomerName,
                    ToDate          = ToDate.ToLongDateString(),

                    FromDate = FromDate.ToLongDateString()
                               //SalesDetails = new List<SalesDetail>(GetSalesDetails(a.OrderId))
                }).ToList();
            });


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

            {
                IsReportLoaded    = true;
                IsReportNotLoaded = false;
                if (SalesReportVms.Count < 1)
                {
                    MessageBox.Show("No Report");
                    return;
                }

                report.SetDataSource(SalesReportVms);

                ReportViewer.ViewerCore.ReportSource = report;
            });
        }
        /// <summary>
        /// Implements the execution of <see cref="GetBalanceSheetReportCommand" />
        /// </summary>
        private async void GetBalanceSheetReportCommand_Execute(object obj)
        {
            IsReportLoaded    = false;
            IsReportNotLoaded = true;
            Reports           = new ObservableCollection <BalanceSheetExport>();
            await Task.Run(


                () => GetBalanceSheet());

            await System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                                                            (ThreadStart) delegate
            {
                CrystalReportsViewer ReportViewer = (CrystalReportsViewer)obj;
                report.SetDataSource(Reports);
                ReportViewer.ViewerCore.ReportSource = report;
                IsReportLoaded    = true;
                IsReportNotLoaded = false;
            });
        }
Ejemplo n.º 10
0
 internal void GetLedgerReport(CrystalReportsViewer reportViewr)
 {
     try
     {
         CultureInfo info = new CultureInfo("ne-NP");
         info.NumberFormat.CurrencySymbol = "Rs";
         info.DateTimeFormat              = new DateTimeFormatInfo();
         info.DateTimeFormat.Calendar     = new GregorianCalendar(GregorianCalendarTypes.Localized);
         info.DateTimeFormat.AMDesignator = "AM";
         info.DateTimeFormat.PMDesignator = "PM";
         System.Threading.Thread.CurrentThread.CurrentCulture = info;
         Thread.CurrentThread.CurrentUICulture = info;
         IsReportLoaded    = false;
         IsReportNotLoaded = true;
         Report            = new ObservableCollection <LedgerJournalVm>(
             Task.Run(() => GetLedgerReport(SelectedLedgerAccount.LedgerAccountId)).Result);
         // Report =new ObservableCollection<LedgerJournalVm>( GetLedgerReport(SelectedLedgerAccount.LedgerAccountId));
         if (Report.Count() < 1)
         {
             throw new Exception("No Ledger For " + SelectedLedgerAccount.AccountName + " Found");
         }
         else
         {
             Task.Run(() =>
             {
                 LedgerReport = new LiquorShop.Reports.Ledger();
                 LedgerReport.SetDataSource(Report);
             }).ContinueWith(a =>
             {
                 App.Current.Dispatcher.Invoke(() =>
                 {
                     reportViewr.ViewerCore.ReportSource = LedgerReport;
                 });
             }).ContinueWith(a => { IsReportLoaded = true; IsReportNotLoaded = false; });
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 11
0
        public static Result Load(DataTable dataTable, string reportFileName)
        {
            // is report file specified?
            if (string.IsNullOrEmpty(reportFileName))
            {
                return(new Result(false, "No report file specified in the Report Item"));
            }

            // is report file exist?
            var fullPathName = Path.Combine(ReportController.ReportFolder, reportFileName);

            if (!File.Exists(fullPathName))
            {
                return(new Result(false, "Report File not found."));
            }
            try
            {
                var reportDocument = new ReportDocument();
                reportDocument.Load(fullPathName);
                reportDocument.SetDataSource(dataTable);

                /****************************************
                * Load the CrystalReport using WPF Form
                ****************************************/
                var crystalReportsViewer = new CrystalReportsViewer();
                crystalReportsViewer.ViewerCore.ReportSource = reportDocument;

                var reportWindow = new MainReportWindow();
                reportWindow.AddControl(crystalReportsViewer);
                reportWindow.ShowDialog();

                return(new Result(true, "Report loaded successful."));
            }
            catch (Exception exception)
            {
                return(new Result(false, exception.Message));
            }
        }
        /// <summary>
        /// Implements the execution of <see cref="GetIncomeStatementReportCommand" />
        /// </summary>
        private async void GetIncomeStatementReportCommand_Execute(object obj)
        {
            IsReportLoaded    = false;
            IsReportNotLoaded = true;
            Reports           = new ObservableCollection <IncomeStatementExport>();
            await Task.Run(() => GetIncomeStatement());

            await System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                                                            (ThreadStart) delegate
            {
                if (Reports.Count > 0)
                {
                    CrystalReportsViewer ReportViewer = (CrystalReportsViewer)obj;
                    report.SetDataSource(Reports);
                    ReportViewer.ViewerCore.ReportSource = report;
                }
                else
                {
                    MessageBox.Show("No Report");
                }
                IsReportLoaded    = true;
                IsReportNotLoaded = false;
            });
        }
Ejemplo n.º 13
0
 protected override void OnViewAttached(object view, object context)
 {
     base.OnViewAttached(view, context);
     _reportViewer = (view as Views.ReportingView).ReportViewer;
 }
Ejemplo n.º 14
0
        public override Result ShowReport()
        {
            try
            {
                var crystalReportViewer = new CrystalReportsViewer();
                var myReport            = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                myReport.Load(ReportPath);
                var crSections = myReport.ReportDefinition.Sections;

                if (myReport.Subreports.Count > 0)
                {
                    foreach (CrystalDecisions.CrystalReports.Engine.Section crSection in crSections)
                    {
                        //The subreports
                        var crReportObjects = crSection.ReportObjects;
                        foreach (CrystalDecisions.CrystalReports.Engine.ReportObject crReportObject in crReportObjects)
                        {
                            if (crReportObject.Kind == CrystalDecisions.Shared.ReportObjectKind.SubreportObject)
                            {
                                var crSubreportObject   = (CrystalDecisions.CrystalReports.Engine.SubreportObject)crReportObject;
                                var crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
                                var crTables            = crSubreportDocument.Database.Tables;

                                foreach (CrystalDecisions.CrystalReports.Engine.Table aTable in crTables)
                                {
                                    //The report header subreport.
                                    if (aTable.Name == "Report_Header")
                                    {
                                        crSubreportDocument.SetDataSource(Header);
                                    }
                                    else if (aTable.Name == "LoanPaymentDetails")
                                    {
                                        crSubreportDocument.SetDataSource(LoanPaymentDetails);
                                    }
                                }
                            }
                        }
                    }
                }


                foreach (
                    CrystalDecisions.CrystalReports.Engine.FormulaFieldDefinition ff in
                    myReport.DataDefinition.FormulaFields)
                {
                    //The formula fields
                    if (ff.Kind == CrystalDecisions.Shared.FieldKind.FormulaField)
                    {
                        if (ff.Name.Contains("Report_Title"))
                        {
                            ff.Text = "'" + ReportTitle + "'";
                        }
                        else if (ff.Name.Contains("cCriteria1"))
                        {
                            ff.Text = "'" + Criteria1 + "'";
                        }
                        else if (ff.Name.Contains("cCriteria2"))
                        {
                            ff.Text = "'" + Criteria2 + "'";
                        }
                        else if (ff.Name.Contains("cCriteria3"))
                        {
                            ff.Text = "'" + Criteria3 + "'";
                        }
                    }
                }

                myReport.SetDataSource(Details);
                crystalReportViewer.ViewerCore.ReportSource = myReport;
                return(ReportWindowForm.AddControl(crystalReportViewer));
            }
            catch (Exception e)
            {
                return(new Result(false, e.Message));
            }
        }
Ejemplo n.º 15
0
        public Result LoadReport(DateTime asOf, DataTable[] dataTables, string reportFile)
        {
            ReportFile = reportFile;
            // is report file specified?
            if (string.IsNullOrEmpty(ReportFile))
            {
                return(new Result(false, "No report file specified in the Report Item"));
            }

            // is report file exist?
            var fullPathName = Path.Combine(ReportController.ReportFolder, ReportFile);

            if (!File.Exists(fullPathName))
            {
                return(new Result(false, string.Format("Report File '{0}' not found.", reportFile)));
            }

            try
            {
                // query the database / run stored procedure
                if (!string.IsNullOrEmpty(reportFile))
                {
                    DataTable comp = Company.GetData();

                    // initialize report data
                    DataSource = new DataSet();
                    DataSource.Tables.Add(comp);
                    DataSource.Tables[0].TableName = "comp";

                    foreach (DataTable dataTable in dataTables)
                    {
                        DataSource.Tables.Add(dataTable);
                    }
                }

                /*******************************************************
                * define report document and set report file and data
                * *****************************************************/
                var reportDocument = new ReportDocument();
                reportDocument.Load(fullPathName);

                /*************************************************************************
                * Must loop through each DataTable to update the ReportDocument.Database
                *************************************************************************/
                foreach (DataTable table in DataSource.Tables)
                {
                    reportDocument.Database.Tables[table.TableName].SetDataSource(DataSource.Tables[table.TableName]);
                }

                /******************************************************************
                * Use ReportModel.ReportTitle as the report title of the rpt file
                ******************************************************************/
                foreach (FormulaFieldDefinition ff in reportDocument.DataDefinition.FormulaFields)
                {
                    if (ff.Kind == FieldKind.FormulaField)
                    {
                        if (ff.Name.Contains("report_title"))
                        {
                            ff.Text = "'" + Title + "'";
                            continue;
                        }
                        if (ff.Name.Contains("as_of"))
                        {
                            ff.Text = "'" + string.Format("As of {0:MMMM dd, yyyy}", asOf) + "'";
                        }
                    }
                }

                /****************************************
                * Load the CrystalReport using WPF Form
                ****************************************/
                var crystalReportsViewer = new CrystalReportsViewer();
                crystalReportsViewer.ViewerCore.ReportSource = reportDocument;

                var reportWindow = new MainReportWindow();
                reportWindow.AddControl(crystalReportsViewer);
                reportWindow.ShowDialog();

                return(new Result(true, "Report loaded successful."));
            }
            catch (Exception exception)
            {
                Logger.ExceptionLogger(GetType(), exception);
                return(new Result(false, exception.Message));
            }
        }
Ejemplo n.º 16
0
        public Result LoadReport()
        {
            // is report file specified?
            if (string.IsNullOrEmpty(ReportFile))
            {
                return(new Result(false, "No report file specified in the Report Item"));
            }

            // is report file exist?
            var fullPathName = Path.Combine(ReportController.ReportFolder, ReportFile);

            if (!File.Exists(fullPathName))
            {
                return(new Result(false, "Report File not found."));
            }

            try
            {
                // query the database / run stored procedure
                if (!string.IsNullOrEmpty(StoredProcedure))
                {
                    DataTable comp = Company.GetData();
                    comp.TableName = "comp";

                    DataTable detail = HasStoredProcedureParameter
                                           ? DatabaseController.ExecuteStoredProcedure(StoredProcedure, StoredProcedureParameters)
                                           : DatabaseController.ExecuteStoredProcedure(StoredProcedure);

                    detail.TableName = Path.GetFileNameWithoutExtension(ReportFile);

                    // initialize report data
                    var dataSet = new DataSet();
                    dataSet.Tables.Add(comp);
                    dataSet.Tables.Add(detail);

                    DataSource = dataSet;
                }

                /*******************************************************
                * define report document and set report file and data
                * *****************************************************/
                var reportDocument = new ReportDocument();
                reportDocument.Load(fullPathName);

                /*************************************************************************
                * Must loop through each DataTable to update the ReportDocument.Database
                *************************************************************************/
                if (DataSource != null)
                {
                    foreach (DataTable table in DataSource.Tables)
                    {
                        reportDocument.Database.Tables[table.TableName].SetDataSource(DataSource.Tables[table.TableName]);
                    }
                }

                /******************************************************************
                * Use ReportModel.ReportTitle as the report title of the rpt file
                ******************************************************************/
                foreach (FormulaFieldDefinition ff in reportDocument.DataDefinition.FormulaFields)
                {
                    if (ff.Kind == FieldKind.FormulaField)
                    {
                        if (ff.Name.Contains("ReportTitle"))
                        {
                            ff.Text = "'" + Title + "'";
                            break;
                        }
                    }
                }

                /****************************************
                * Load the CrystalReport using WPF Form
                ****************************************/
                var crystalReportsViewer = new CrystalReportsViewer();
                crystalReportsViewer.ViewerCore.ReportSource = reportDocument;

                var reportWindow = new MainReportWindow();
                reportWindow.AddControl(crystalReportsViewer);
                reportWindow.ShowDialog();

                return(new Result(true, "Report loaded successful."));
            }
            catch (Exception exception)
            {
                Logger.ExceptionLogger(GetType(), exception);
                return(new Result(false, exception.Message));
            }
        }