Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Crystal Reports Issue Post Reply Post New Topic
Page  of 2 Next >>
Author Message
larak
Newbie
Newbie


Joined: 12 Apr 2010
Location: Lebanon
Online Status: Offline
Posts: 7
Quote larak Replybullet Topic: Crystal Reports Issue
    Posted: 13 Apr 2010 at 2:16am
Dear All,

I am working on Visual Studio 2008, .NET Framework 3.5 SP1, C#.

I have a form which contains many fields and created a crystal report to display those fields by passing them as parameter fields.

I have updated the form in order to include multiple vendors to it. However the number of vendors is not fixed and vary according to the user. For that reason I should allow the user to edit this at runtime. Based on that I included a stack panel in my form and created a user control called VendorInformation and added to it some fields, let's take as example VendorName, VendorNumber, VendorCostPrice.

At runtime, if the forms supports this implementation, one vendor subform is displayed in the stackpanel. In addition, I have added an add and remove buttons.

Everytime the add button is clicked, an additional vendor is added to the stackpanel and if the remove button is clicked the vendor will be removed.

We could have 3 vendors and remove the one in the middle not necessarily the last one.

How can I include these details in my main report at runtime?

First, I should be able to add a condition based on one field to see whether the vendors should be included or not in the report.

Second, if the user adds one additional vendor, I should be able to directly update the report when he decides to print it. He can always add a vendor at the end of the others however he can remove any vendor in the middle.

The problem also is that the usercontrol created contains the same field names, and for each new vendor, an instance of that usercontrol is created so how to set the fields in the report for the right vendor?

I would appreciate any help and detailed instructions to follow because I am late and don't know how to handle this issue. Thank you in advance!

Regards,
Lara

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 13 Apr 2010 at 3:23am
to keep things simple for crystal, since I am not a fan of dynamic anything in CR in regards to adding parameters/fields to a report (mostly because CR doesn't seem to understand too well) I would make just as many parameters as properties, ie Name, ID, Cost.  Then from your control you can pass delimited strings of the values from each of the objects that exist...doesn't matter if they have added or deleted, just create the string and pass it to CR.  Let CR parse it and you can manipulate it from there. 
 
Or a 'simpler' method would be to take your delimited strings, either pass them to a business tier or to a stored proc and have them return a datatable, and then set the DataSource for the CR to the datatable, and go from there.
 
HTH
IP IP Logged
larak
Newbie
Newbie


Joined: 12 Apr 2010
Location: Lebanon
Online Status: Offline
Posts: 7
Quote larak Replybullet Posted: 13 Apr 2010 at 3:44am
Thank you for the reply.
The problem is that I need to add multiple sections at runtime, each section is related to one vendor and the parameter names are the same.
Can I add a section at runtime and set the locations of the fields in it based on a condition?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 13 Apr 2010 at 6:42am
I guess I don't understand...are the sections data/layout unique to each vendor?
 
I have never tried to add sections at runtime.  CR seems to be picky about a report matching what it believes is the report layout/schema.  All of my reports are fixed as far as layout, but variable based on parameters passed into the stored proc and the formulas that are coded in the report for the report to respond to.
 
As long as the data all looks the same for each vendor, I don't see the report would need a new section...new group sure.  If the vendors fall into one of several layouts, you could code the layouts as separate sections and then suppress/show them as appropriate, which is another route that can be done...keeps the report static but allow flexibility.
 
HTH
IP IP Logged
larak
Newbie
Newbie


Joined: 12 Apr 2010
Location: Lebanon
Online Status: Offline
Posts: 7
Quote larak Replybullet Posted: 15 Apr 2010 at 8:13am
Thank you again for the reply!
I was able to populate the datatable at runtime and added it to the dataset in the crystal report.
The problem is that how shall I display the fields in the section I have?
I have dropped the parameters to the section but it is displaying only the last row in my datatable!
How shall I display all the rows in my datatable in the section in my report?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 15 Apr 2010 at 8:29am
I take it that the you are not displaying in the detail section...if so it will only display the first record in the header and the last record in the footer.
 
If there is somthing that groups the records, you can a section on that and then since there will be multiple 'sub sections' there will be more records.
 
HTH
IP IP Logged
larak
Newbie
Newbie


Joined: 12 Apr 2010
Location: Lebanon
Online Status: Offline
Posts: 7
Quote larak Replybullet Posted: 15 Apr 2010 at 8:33am
I am sorry I didn't get clearly what you said.
I have added the fields in a detailed section however it is just displaying the last row.
The number of rows is specified at runtime so how shall all the data in the rows be displayed?

I added a detail section and have my datatable under Database Fields in the menu and it is filled at runtime.
How to display it in the section I created?

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 15 Apr 2010 at 8:47am

ok, sorry, I misunderstood.

The only thought that comes to mind, since what you have done sounds correct, is... are there more than 1 data table in the report?  If so, is the table that you added linked to the others in any way?
 
I regularly pass in 2 tables that aren't linked, but I only 1 to hold the parameters that generated the other table.  In other reporting systems, you need to move the row counter on the second table, and so I am guessing that you would need to do that as well in CR, but I have never had a need so I don't know how.
 
If there is some way to join the data to another table or to run a subreport that should get the details to show, but maybe too many.  You know your data and your report so should be able to work around this.
 
HTH
IP IP Logged
larak
Newbie
Newbie


Joined: 12 Apr 2010
Location: Lebanon
Online Status: Offline
Posts: 7
Quote larak Replybullet Posted: 15 Apr 2010 at 8:50am
Yes there are 2 datatables and they are linked however they do not need to be but don't know why I wasn't able to remove the link.
They both belong to the same dataset.

How shall I fix this?

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 15 Apr 2010 at 9:33am
Sorry, don't really know.  I haven't ever linked tables in the dataset, but if they are linked correctly, they should read all the way through. 
 
Can you add another link?  I realize that you can't delete, but can you add or modify?
 
Just some ideas, since I don't know how to correct.
 
 
IP IP Logged
Page  of 2 Next >>
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.