Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends...
I'm doing one project that I need to create bill in crystal report.Like...

To : Customer Name................................Bill No: 100
Customer Address.....................................Date : 10/10/2012
Contact : 9850******
.....................................................................................
Particulars |Qty |Rate |Total |
Pen | 5|5|25
Notebook 5 | 20|100
Mobile Cover | 5|30|150



So How Can I create this Bill Because the problem is that..
1)Table1 Has only One row (Customer name,Address,Contact,Bill No,Date)
2)Table2 has more than two Rows.

Please Do needful......
Posted
Updated 21-Feb-17 20:21pm

Hi
there are many ways to achieve what you would like to do. one of the solution is, you can create one subreport for the detail section and associate different datasource to main report and sub report.

your main report may point to the header information and subreport will take your detail section information.

hope you can do this easily

best luck
 
Share this answer
 
Comments
Kuldeep B 12-Dec-12 3:14am    
Anit :Thanks for Solution

I tried with your Idea but I'm getting only second table values in sub report.
And no any value in Main report....

Below is my code wht I tried:
SqlDataAdapter da = q.fillbill(bill);
da.Fill(ds1, "billtable");

//dt1.Clear();
//da.Fill(dt1);
if (dt.Rows.Count > 0)
{
//Assign data to the primary report
// CrystalReport1 RptDoc = new CrystalReport1();
ReportDocument RptDoc = new ReportDocument();
RptDoc.Load("C:\\Users\\Sunlogic\\Documents\\Visual Studio 2008\\Projects\\My Stock\\My Stock\\CrystalReport1.rpt");
RptDoc.SetDataSource(ds1);


SqlDataAdapter da1 = q.fillcurrentsale();
da1.Fill(ds2, "saletable");
//dt2.Clear();
//da.Fill(dt2);
q.disconnect();
//Get sub report and assign datatable1 to that report
foreach (ReportObject repOp in RptDoc.ReportDefinition.ReportObjects)
{
if (repOp.Kind == ReportObjectKind.SubreportObject)
{
string SubRepName = ((SubreportObject)repOp).SubreportName;
ReportDocument subRepDoc = RptDoc.Subreports[SubRepName];
subRepDoc.SetDataSource(ds2);
}
}
//Assign report to the crystal report viewer
billp.crystalReportViewer1.ReportSource = RptDoc;
// billp.crystalReportViewer1.DataBind();

}
AmitGajjar 12-Dec-12 3:16am    
check if your main report print anything ? add one simple label and check if label is display there?
Kuldeep B 12-Dec-12 3:27am    
Main report print only Column Name ....Not print data....Only columns are display
AmitGajjar 12-Dec-12 3:40am    
is your datasource correct have data ?
Kuldeep B 12-Dec-12 3:46am    
ya... datasource has data....
I'm getting data from ds2 but not from ds1...Now problem is only with Main report...
...My assigning method is correct or any changes required...please go through code if u have free time...Please..
Thanks for giving time for me..
Without more information about your project and what you are having trouble with...all I can suggest is that you probably want to put the Table1 customer data in the page or report header section and use the Table2 product data in your detail section.

It sounds like you might want to research about basic crystal reports first. Maybe do some sample project or tutorials first to get the hang of it.
You could start here:
Google results[^]
 
Share this answer
 
Hi Friends...
I'm doing one project that I need to create bill in crystal report.Like...

To : Customer Name................................Bill No: 100
Date : 10/10/2012
Contact : 9850******
.....................................................................................
Particulars |Qty |Rate |Total |
Pen | 5|5|25
Notebook 5 | 20|100
Mobile Cover | 5|30|150



So How Can I create this Bill Because the problem is that..
1)Table1 column name is(Customer name,Invoice NO,Order NO ,date,)
2)Table2 column name is.(item name,Quantity,amount per item ,total amount)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900