Click here to Skip to main content
15,882,376 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a crystal report viewer and crystal.rpt page.

I want to group all item in one page that have similar company name in particular date
i write following code:

private void Frm_Sale_Invoice_Load(object sender, EventArgs e)
{
int companyID =Convert.ToInt32(Global.CompanyID);
string date = Global.SaleDate;
ReportDocument rpt = new ReportDocument();
DS_SaleInvoice ds = new DS_SaleInvoice();
SqlConnection con = new SqlConnection("server=SHASHA-PC; Initial Catalog=globalprint; uid=sa; pwd=shasha22pal;");
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter("Select s.SaleId,Convert(varchar, s.Date, 103) as Date,cm.company_name,s.income_source,s.colour,s.quantity,s.rate,s.total, s.vat_tax, s.Grand_Total from table_Sales s,tbl_companymaster cm where s.companyId=cm.companyId and s.CompanyId="+companyID+" and s.Date=CONVERT(datetime, '"+date+"', 103) order by s.SaleId", con);
da.Fill(dt);
ds.Tables[0].Merge(dt);

rpt.Load("E:\\raj pen\\Live Recent\\PrintAndBack\\PrintAndBack\\Sale_Invoice.rpt");
rpt.SetDataSource(ds);
CRV_Sale.ReportSource = rpt;
}
in datatable has 2 rows:
SQL
saleid  date      companyname incomesource  color      quantity  rate total   vat_tax  grand_Total
102   29/02/2012   abc          xyz        front b/w     10       10   100     10         110
103   29/02/2012   abc          hkf        color back    11       10   110     10         120

and i want to print that item in crystal report like as follows:
SQL
-----------------------------------------------------------------------
-----------------------------------------------------------------------
Buyer Name: Companyname     Date: date

-----------------------------------------------------------------------
incomesource   color    quantity  rate  total   vat_tax   grand_total
-----------------------------------------------------------------------
xyz           front B/w  10        10    100     10          110

hkf           color back  11       10    110     10          120
-----------------------------------------------------------------------
Total                                                        230
-----------------------------------------------------------------------
two hundred thirty rupees.



please help me!!

Thanking you!
Posted
Updated 11-Mar-12 10:57am
v4
Comments
Uday P.Singh 11-Mar-12 3:09am    
whats the problem, your query is not working or what?
rajesh@1989 11-Mar-12 3:44am    
thank you for your comment....

print preview on crystal report display each item in different page of similar company.
i want to group all item in single page and Grand total it of similar company.

if user select same company and sale different items and want to print sale invoice then should be grouped all item in single page.

In Crystal report, there is one option called "Insert".

Click on it and you will see another sub option named "Group"

Use that and group all the records according to items.

And all the items of same group will be displayed on the same page.

This will solve your problem. Try it.
 
Share this answer
 
Comments
rajesh@1989 11-Mar-12 10:16am    
thank you for your solution!!
I improved my question please check it and give me solution !!
as soon as possible!!
 
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