ReportViewer grouping header in report header section? - c#

Hi, I'm working on a report which uses reportviewer in VS2010.
It is an invoice report. It has some accounts in the system, for each account, it has some orders. Now, in each month, we need to send the invoice to each account.
In the report, at the top, we need to list "Bill To" (the address for each account) and "Invoice#", for each account, it is different, and it is continouous. Then, at the center, it should list the details of the orders for this account. Obviously, each account should have an invoice.
See the attached screen shot. I used grouping and created the invoice shown in screen shot.
But, it has a problem. The "Account address", "Terms", and "Invoice #", I could not put them in the grouping (those are the same within the group). Thus, for different groups, they are shown as the same values, although in the rdlc file, I put their fields there.
Anyone knows how to solve the problem?
One possibility is: instead of creating the invoice for all accounts in one report (i.e. 20 pages, each page is an invoice for an account), create a report for each invoice for each account (so total 20 files), then print the invoice directly. This will work since we can manipulate all the data, and use reportviewer parameters for Account Address, Terms, ...
However, it means we could not browse the reports before print (withint the software). Any suggestions?
thanks
reader

What you can do is , since for each account there is an address, invoice# and invoice details or orders in your case,
So what you can do is :
EDIT : Let me go in some detailed fashion ! (Please zoom in to see the image details clearly)
1.Create a new report and add a Tablix to it
--Tablix has the property , it can iterate through your data
and create dataset which will get data for Account address, invoice, and Terms. Then :
if you are not able to view the image properly ..here is the same presented for you
This is the way I did my reports with similar requirements...sub-reports would ease the tasks to a much extent ..
p.s:
Edit: No need to go for a Header.. as you say in your subject of question.
jus the main report and a sub-report should do what you need !
I jus saw yours is crystal report.. but the concept is over all the same

Related

Crystal Reports report 02.months - 01.next months

in Crystal Report 13 generated reports , the report is divided into months , with the first on the first number , and grouped automatically. It is necessary that the report formed the second day of the first month and the first day of the next . That is: with 05.02.2016 on 06.01.2016 how to implement it manually , I found a group , but the problem is that I have to create each month itself, and how to implement it in the formula can not understand . Sorry for my english , Google translator , as the Russian forums did not find help.
Now it looks like this:
and should
Дата this DateTime
After hours of hardwork, I was able to find a solution.. try and let me know if it works. Its a tested solution though.
This can be done using the sub report.
Create a formula Required date and write below code:
CDate(DateAdd("d",1,CDate(Year({Дата}),Month({Дата}),01)))
In main report create a group using the created formula Required date and unless you want some sections to display in main report suppress all sections except group footer
Now create a sub report with same tables as main report and place the report in group footer 1, Now link the created formula to the sub report, In sub report there will be a paramter created as Pm-#Required date
Open sub report Record Selection Formula and write below code:
CDate({Дата})>= {?Pm-#Required date}
and
CDate({Дата})< CDate(DateAdd("m",1,{?Pm-#Required date})
Now place the required fields on design of the report and run the report.
Let me know how it works

Crystal Reports and multiple tables

I'm using C# and Entity Framework.
I created the dataset to display data from it:
With only one table(buildings), i created my crystal report very well.
But now, i want to create another one that display:
name_b, Adresse_b,date
the number of appartements of a building
the number of shared_areas of a building
and the name of the user.
I have to write a query in the crystalReportViewer1_Load and set it as datasource or what?
Thank you to help me.
There are a few options -
1. In your current report, group the report by Building, then
create a sub-report containing all of the details (name,
address,etc) and place it into the group footer in the main (outer)
report. Link the report by ID_Building. This will show you all of
the details for each building.
2. In you current report, add all of the tables to the data connection (database expert); then group the report as desired (by building, Apartment, etc).
You can create running totals to get the count of apartments and the number of shared_areas.

Crystal Reports for Visual Studio: display 2 unrelated tables

I ask for advice what would you suggest to display 2 unrelated tables in a single report (if needed with subreport), the first one with groupings and the second one "flat"?
Details:
I am developing a report with C# 4 and Crystal Reports for Visual studio.
Data comes from a Stored procedure in Sql Server 2005, that returns 2 tables.
I pass the data to the report with the .SetDataSource(Dataset) method and I checked that data in the dataset is correct.
I need to display the data from the first table in a quite complex form with different sections. This part works.
At the end of the report I need to print the data from the second table (no grouping, just a "flat" print). To do this I added a subreport.
The tables are not related. I added a Dummy field on them with the same value and used it to mimic a relation in the database expert; I configured the subreport link, based on the dummy field.
I have 2 problems.
The data in the main report is cross joined with the second table (I could expect that since they are related with a constant field)
The subreport is always empty (I checked several times that its table in datasource contains correct data).
I tried different configurations of link and tried to place the subreport in different sections (It should be in the report footer).
I set a border around the subreport: the border is printed but inside it is empty.
I also setup a formula to count the records of both tables and put the count in the report: the count is > 0 for both.
Your approach looks wrong.... At first if both are not releated I don't see any use in creating a dummy field and linking tables which will always provide cross join. Any way as per your descrition table 1 data is saperately displayed and table 2 data is saperately displayed
As per your description in main report you need data from table 1 and in footer you need data from table 2.
Try this approach:
Don't link tables
take table 1 in main report and show the required display.
Take sub report and in that take only table 2 and display in footer and make sure don't link main report and sub report nor link two tables.
Ideally speaking, without linked table not used in crystal report as reporting tools used to display the relevant data based on our criteria and display 2 different set of data without link does not mean as a report as well as tough to integrate in crystal report.
Tough to integrate means at any point you have to link the table either via union in sqlserver or at crystal report side, other wise it display as Cartesian.
As per my thoughts you can do it by some approach.
Approach 1 : You can get the data by union or unionAll with set of columns and filter the data where table's column does not have null value ie.
http://www.maximumimpactsolutions.co.uk/blog/comments.asp?bd=118
Table1col1 Table1col2 Table1col3 Table2Col1 Table2Col2 Table2Col3
value value value null null null --table1data
null null null value value value --table2data
Approach 2 : Second is sub-report, but still need the linked as you already done. But there is proper rule to be set (this is very very tedious job).
Approach 3 : Generate 2 report at c# side and merge into one PDF, then export it.
check this links.
Reporting on multiple tables independently in Crystal Reports 11
http://www.tek-tips.com/viewthread.cfm?qid=241195
http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=4756
http://www.codeproject.com/Questions/348959/Crystal-reports-for-multiple-tables

Report Designer in VS Community 2015

I'm a seasoned MS Access developer trying to learn C# and I'm finding formatting reports to be really difficult compared to how easy MS Access is.
I couldn't get anything useful out of the report wizard, but I've now got my head around creating a report manually. So ok I now have a basic report showing a customer listing, with a title in the page header section.
So now what I want to do is change the title at runtime. For example if I filter the dataset to only show UK customers who have bought goods this year, I want to change the title in order to explain what is being listed: "UK Customers who bought goods this year".
In MS Access I can use the report pageheader OnFormat event to do things like this. Can this be done in C#?
I've managed to sort this out myself. In the DataSet for my Report I added a column to the TableAdapter query. Select #Title as Title, Customers.CustomerCode etc... In the Report I added a TextBox for the Title and bound it to the title field in the dataset. Then when my report opens, I can supply the title as a parameter when the DataSet Table is filled.
Reporting Services uses visual basic for the expression language, so you can set the title to something like ="foo #" & (3+3) to get a value of "foo #6". Additionally, you can use parameters as you mentioned in your answer by setting the title to =Report.Parameters!Title.Value (assuming you have a parameter named "Title").
If you'd like to use C#, then unfortunately you can only do this via a custom assembly, which is not the easiest thing in the world to get set up.
For more information on embedding code in a SSRS report, take a look at this page on MSDN: https://msdn.microsoft.com/en-us/library/ms159238(v=sql.120).aspx

Multiple Subreports with a subreport passing value to other

I'm using Report Viewer at C# in WinForms. I have 3 database tables: Equipament, Sector and History, I also have 3 Report.rdlc, The MAIN is the ReportEquipament and the other two subreport are ReportSector and ReportHistory. I already know how to fill the ReportSector, what I want to do is to pass the idSector from the ReportSector, so I can call a procedure at the SQL Server database and search all the History with this Sector ID, and show the data at the ReportHistory. I have no idea on how to do it. I new with ReportViewer and this is my first time doing Reports.
PS: I know how to do the procedure, just don't know how to use it.
Thanks.
Jonas.
Let me try to explain better:
I search for a specific Equipament, and that Equipament passed for many Sectors,
and while he was at this sector he had problems, and this problems are related to
the Sector.
What I want is something like that:
Equipament: X
Sectors: (Here the ID of the Equipament is passed to find the Sector that he has)
Sector: X (here the ID of this Sector is passed to the Subreport "Problem")
Problems: (with the ID of the Sector I search all the problems at this sector)
Problem: X
Problem: Y
Sector: Y (here the ID of this Sector is passed to the Subreport "Problem")
Problems: (with the ID of the Sector I search all the problems at this sector)
Problem: X
Problem: Y
Okay after rereading you're question and understanding what you're asking here is how I have solved similar problems with SSRS. If you have the id variable at the time you load the main report (not subreports) then all you need to do is to pass that parameter into the main report and access it via the sub report.
Look here: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/92ea8f6b-ad27-42b9-a673-72ee9ce2d1fc/how-to-pass-parameters-to-ssrs-sub-reports?forum=sqlreportingservices
And here: http://technet.microsoft.com/en-us/library/ms160348(v=sql.100).aspx
If instead you need to run the main and first sub report first and then get an ID, you're most pain free way of doing this is to run one report and then have the user enter in more information to run a second report. If you really really want to make it so that can interact with the report
Look here: http://sqlserverbiblog.wordpress.com/2011/02/14/can-i-add-controls-to-a-reporting-services-report-3/
If i am not wrong you getting problem in parameter passing in sub report. Here is the link for that

Categories

Resources