Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 593
  • Last Modified:

Load controls from XMl into the Winform at run time and call cyrstal report from the WIN form. I am trying to catch control events from the form before calling crystal report.

Dear Experts,
I am new to crytal reports. I don't know crystal reports. the C# winform uses the crystal reports. I have several problems in crystal reports , before that i come across issues in loading the controls from xml file to WIN form at run time. After the controls (Say radio button1, check box1, text box1) get loaded, user can check any radio button or check boxes.i need to catch the event before clicking button in the FORM. Because the submit button calls crytsl reports and i need to set the parameters for the crystal reports.

To be more clear,now my issue is to catch the check box's events when the user click submit button. Please help and i eager to discuss or send the requirement again if the information is quiet confussing.

Kind Regards,
Pooja

0
poojasureshkumar
Asked:
poojasureshkumar
  • 6
  • 4
  • 2
1 Solution
 
UnifiedISCommented:
Here's an example in VB.NET
You loop through the parameters of the report and assign values when the name matches
Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
            rpt.Load(ReportPath)
            Dim ParamDiscValue As CrystalDecisions.Shared.ParameterDiscreteValue
            Dim ParamValues As CrystalDecisions.Shared.ParameterValues
            Dim ParamFields As CrystalDecisions.Shared.ParameterFields
            ParamFields = rpt.ParameterFields

            For Each ParamField As CrystalDecisions.Shared.ParameterField In ParamFields
                ParamValues = ParamField.CurrentValues
                ParamDiscValue = New CrystalDecisions.Shared.ParameterDiscreteValue
             SELECT CASE ParamField.Name
CASE @Param1
                    ParamDiscValue.Value = some value from form
                    ParamValues.Add(ParamDiscValue)
CASE @Param2
                    ParamDiscValue.Value = some value from form
                    ParamValues.Add(ParamDiscValue)
end select
                              Next
0
 
poojasureshkumarAuthor Commented:
Hi UnifiedIS,
Sorry , i could n't get it.
After loading the controls from xml in to the form.I will pass the textbox values as the parameter into the crystal report. My problem area is here,
Consider the form has text box 1, text box2, check box1.
If the checkbok1 got checked, i need to pass Textbox1 value, else Text box2 's value as the parameter to crystal .
Thanks for the mail. Please help me.

Kind Regards,
Suresh
0
 
mlmccCommented:
Something along these lines


            For Each ParamField As CrystalDecisions.Shared.ParameterField In ParamFields
                ParamValues = ParamField.CurrentValues
                ParamDiscValue = New CrystalDecisions.Shared.ParameterDiscreteValue
             SELECT CASE ParamField.Name
CASE @Param1
       If CheckBox1 = vbChecked then
                    ParamDiscValue.Value = TExtBox1.Text
                    ParamValues.Add(ParamDiscValue)
       end if
...
end select
         Next

mlmcc
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
UnifiedISCommented:
Maybe it's easier to understand if the logic is separated from the assigning of the parameter
If you only have one paramater, you can exclude the ParamField.Name comparison and if you wanted, change the for/next loop as well
dim sText as string
if checkbox1.checked then
   sText=textbox1.text
else
  sText = textbox2.text
end if
Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
            rpt.Load(ReportPath)
            Dim ParamDiscValue As CrystalDecisions.Shared.ParameterDiscreteValue
            Dim ParamValues As CrystalDecisions.Shared.ParameterValues
            Dim ParamFields As CrystalDecisions.Shared.ParameterFields
            ParamFields = rpt.ParameterFields

            For Each ParamField As CrystalDecisions.Shared.ParameterField In ParamFields
                ParamValues = ParamField.CurrentValues
                ParamDiscValue = New CrystalDecisions.Shared.ParameterDiscreteValue
                ParamDiscValue.Value = sText
                 ParamValues.Add(ParamDiscValue)
             Next
0
 
poojasureshkumarAuthor Commented:
hi UnifiedIS,
Sorry for the trouble. I am completly dumb in crsytal reports.
This is the c# win form code. It's loading the controls from xml file. After loading the controls.
Say listbox 1, checkbox1 are one of the controls. When the check box is checked, get the selected items from the listbox (ALL), if not checked leave the list box items (NULL).Send the result (either "ALL" or "NULL" ) as parameter field to the report. Am i clear. I can send even the code segment.

Thanks for the tip.

Kind regards,
Pooja
0
 
mlmccCommented:
Please post the code.

mlmcc
0
 
poojasureshkumarAuthor Commented:
Hi mlmcc,
There is no code associated with this report. I can send only the screen shot if you prefer.Please provede me your email id and i will send the screen shot and respective (rpt ) file.

Kind Regards,
Pooja
0
 
mlmccCommented:
Post them to

www.ee-stuff.com

You may have to chage the file extensions or put them in a zip file.

mlmcc
0
 
poojasureshkumarAuthor Commented:
Hi mlmcc,
Here is a link. Please bear with me , since i don't know Crstal report and i not clear with the doubt which i asked you previosly. This is my actual problem. Please find the link
View all files for Question ID: 22896461
https://filedb.experts-exchange.com/incoming/ee-stuff/5287-Crystal-report.jpg 

Direct link to your file
https://filedb.experts-exchange.com/incoming/ee-stuff/5287-Crystal-report.jpg 

I need to show the group1 details only when the condition match with the report parameter value.

Kind regards,
Pooja
0
 
poojasureshkumarAuthor Commented:
hi mmlc,
I some what adjusted the logic applied in the sproc to bring up the actual display.I need to conform that. till then i kindly request you to hold it. Pls.....

Thanks,
Pooja
0
 
mlmccCommented:
So no action on my part needed at this time?

mlmcc
0
 
poojasureshkumarAuthor Commented:
hi mlmcc and UnifiedIS:,
I solved the issue. Modified the stored procedure. Thanks for the help and i would like to grant 100 points to both  for your valuable time.Your help in learning crystal reports are higly appreciated.

Kind Regards,
Suresh
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 6
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now