Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

How to use Custom multiple Objects on Crystal Report

$
0
0
I didn't use crystal report before. But for a project, I need to use it instead of fastreport because of printing issues.. I have bene trying to solve my problem for many hours but haven't found out any solution yet.. 

Well, I have two classes to use on crystal report. I want to create a bill report.

I organized some data from my database and put them to my these classes.

   
 public class ReportInfo    {        public DateTime Date { get; set; }        public string BillNumber { get; set; }        public string Address { get; set; }        public string BillAddress { get; set; }        public string BillOwner { get; set; }        public string TaxNumberIDNumber { get; set; }        public List<ReportProduct> Products { get; set; }        public string PaymentType { get; set; }        public string MoneyWithText { get; set; }         }    public class ReportProduct    {                                  public string ProductInfo { get; set; }        public double Amount { get; set; }        public string ProductCode { get; set; }        public double Tax { get; set; }        public double Price { get; set; }            }



As you see, there is one bill class (report info) and a list for products (report producs) in reportinfo class..

I want to create a report that would be some value (bill number, date...) on header and some value (products info) on details area.


here i did it for one bill (Also I dont know how to put bills in a report viewert)

   
var serialID = Convert.ToInt32(dgBillSerials.SelectedRows[0].Cells[0].Value);    var bills= BillsFromDatabase.Bills.Where(b => b.BillSerialID == serialID && (b.BillNumber>=txtFirstBillNumber.Value && b.BillNumber<=txtLastBillNumber.Value)).ToList();    var products = BillsFromDatabase.Products.Where(p => p.BillID == bills[0].ID).ToList();    ReportInfo ri = new ReportInfo();    ri.Address = bills[0].Address;    ri.BillAddress = bills[0].BillAddress;    ri.BillNumber =bills[0].SerialNumber + bills[0].BillNumber.ToString();    ri.BillOwner = bills[0].OwnerType == "sirket" ? bills[0].PersonTitle : bills[0].Name;    ri.Date = bills[0].BillDate;    ri.MoneyWithText = "deneme";    ri.PaymentType = bills[0].PaymentType;    ri.TaxNumberIDNumber=bills[0].OwnerType=="sirket"?bills[0].TaxDepartment + " " + bills[0].TaxNumber:bills[0].NationalID;    ri.Products = new List<ReportProduct>();    double sum=0;        foreach (var product in products)    {     sum += product.Price;     ri.Products.Add(new ReportProduct()     {       Price = product.Price,       ProductCode = product.ProductCode,       ProductInfo = product.ProductInfo,       Amount = Math.Round((product.Price/118)*100,2),       Tax =Math.Round( product.Price -((product.Price / 118) * 100),2)     });                            }        ri.MoneyWithText = Utils.MoneyToText(sum);     ReportDocument crystalReport  = new ReportDocument();     crystalReport.Load(@"..my path....\BillCrystalReport.rpt");     crystalReport.SetDataSource(ri);       crystalReportViewer1.ReportSource = crystalReport;




when I run that code an exception throws that is "source object is not valid"  on crystalReport.SetDataSource(ri);


I know that it looks unfair but I dont know how to implement two tables to my crystal report. when I add my both classes to the crystal repot it looks like that



I made  this one for one class and its OK. but this tutoraial doesnt talk about multiple data objects.

http://msdn.microsoft.com/en-us/library/ms227595(v=vs.80).aspx

ps: using vs 2012 and fw 4.0 and installed sap crystal report.




Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>