private void aftermost()
 {
     try
     {
         ICLRRuntimeInfo rtInfo = (ICLRRuntimeInfo)RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid.Empty, typeof(ICLRRuntimeInfo).GUID);
         rtInfo.BindAsLegacyV2Runtime();
         string         path   = Directory.GetCurrentDirectory();
         var            a      = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
         ReportDocument report = new ReportDocument();
         report.Load(a + @"/CrystalReport4.rpt");
         CustomerLedgerDataSet ds  = new CustomerLedgerDataSet();
         DataTable             dt1 = ds.BillProduct;
         DataTable             dt2 = ds.Customer;
         foreach (var item in customer.CustomerCollection)
         {
             dt2.Rows.Add(item.Customerid, item.CustomerName, item.CustomerLocation, item.Customerbalance, item.CustomerLastTally, item.Customerphone);
         }
         report.SetDataSource(ds);
         crystalReportsViewer2.ViewerCore.ReportSource = report;
     }
     catch (Exception e1)
     {
         Debug.WriteLine(e1.Message);
     }
 }
Example #2
0
        private async void aftermost()
        {
            try
            {
                ICLRRuntimeInfo rtInfo = (ICLRRuntimeInfo)RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid.Empty, typeof(ICLRRuntimeInfo).GUID);
                rtInfo.BindAsLegacyV2Runtime();

                var            a      = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
                ReportDocument report = new ReportDocument();
                report.Load(a + @"/CrystalReport3.rpt");


                CustomerLedgerDataSet ds  = new CustomerLedgerDataSet();
                DataTable             dt1 = ds.BillProduct;
                DataTable             dt2 = ds.Customer;

                // assume columns have been created
                foreach (var c in billProductModel.BillCollection)
                {
                    dt1.Rows.Add(c.DateTime, c.Billid, c.Quantity, c.ProductName, c.Rate, c.TotalAmount, c.Status, c.Balance);
                }

                dt2.Rows.Add(selectedCustomer.Customerid, selectedCustomer.CustomerName, selectedCustomer.CustomerLocation, selectedCustomer.Customerbalance, selectedCustomer.CustomerLastTally, selectedCustomer.Customerphone);

                report.SetDataSource(ds);

                crystalReportsViewer2.ViewerCore.ReportSource = report;
            }
            catch (Exception e1)
            {
                var win  = (MetroWindow)Application.Current.MainWindow;
                var res1 = await win.ShowMessageAsync(" source: " + e1.Source, e1.Message + "  ||   " + e1.StackTrace +
                                                      MessageDialogStyle.Affirmative);

                Debug.WriteLine(e1.Message);
            }
        }