VisionCore How To
Home Search Support Forum Knowledge Base Print

How to create Custom Report and Sub Report

A. Creating Custom Report

 

1. Choose the Report Name that you like to customize. Click on the Designer button

Sample:

sub1

 

2. Save the Report Layout and Report Settings to your desired Layout Name

Sample:

sub2

sub3

 

3. Choose the DataSource ID for your Custom Report.

sub4

 

4. Set the desired setting of your Custom Report. Click the Save button and Close the Report Setting form.

sub5

 

5. Close the designer and your Custom Report in the Report Manager under the Custom Reports Group

sub6

 

B. Creating Sub Report

 

1. Open the Designer of your Custom Report. Then click on New button or click on New from the File Menu.

2. Create your desired layout.

sub7

Don’t forget to type in the field name in the textbox.

sub8

sub9

 

3. When you’re finished with your Sub Report, Click on Save and Save the Report Layout to your desired file name.

sub10

 

4. Save your Desired Report Settings.

sub11

C. Adding SubReport to the Customized Report

1.        Go back to the Designer of your Customized Report.

2.        Click SubReport from the ToolBox

sub12

 

3.        Drag the SubReport to the Report Layout. Make sure that the size of the SubReport tool is large enough to fill in the size of your Sub Report.

4.        In the Properties Window change the ReportName field to the Report Name of your Sub Report.

sub13

 

5.        Click on the Script tab of the Report Layout.

sub14

 

6.        Create a script that will fill in the data you needed for your Sub Report.

Sample:

sub15

sub16

 

 

Editing Sub Report

1.        Click on Open from the File menu of the Designer.

sub17

 

2.        Select the file name of your Sub Report.

sub18

 

Creating Script for the Customized Report

1.        In the Object dropdown, select PageHeader  and Format in the Event Dropdown.

sub19

2.        The Script will look like this:

sub20

       This is the event that will fire the script.

3.        After the opening bracket. Place this line of code. This code is used for exception handling.

      try

      {

       }

      catch

      {

      }

       The script will then look like this:

sub21

 

4.        Add this line of code in the 5th line of your code. This will represents a report data source

sub22

The script will now look like this.

 

      sub23

5.        On the 6th line is this code. This line will be used to execute and render the report.

DataDynamics.ActiveReports.ActiveReport3 rptSub  = new DataDynamics.ActiveReports.ActiveReport3();

 

6.        On the next line is this code:

       rptSub=rptCustom;

       This is used for assigning a Subreport to the datasource

      rptCustom >   Is the name of the SubReport control in the Report Layout

sub24

7.        Add your SQL Query in the next line.

Sample:

       string strSQL = "select dblTransferQty, dblOrgStock,strTransferID  from tblICTransferDetail where                strProductID='"

                      + ((TextBox)rpt.Sections["GroupHeader1"].Controls["txtDstrProductID0"]).Text + " ' " ;

 

Info Note:

      string strSQL >   is the variable where you will pass the SQL Query of your Sub Report.

 

Sample SQL Query:

       "select dblTransferQty, dblOrgStock,strTransferID  from tblICTransferDetail where strProductID='"

              + ((TextBox)rpt.Sections["GroupHeader1"].Controls["txtDstrProductID0"]).Text + " ' " ;

      dblTransferQty, dblOrgStock,strTransferID >   Fieldnames from the table in a database.

      tblICTransferDetail >   Tablename

      ((TextBox)rpt.Sections["GroupHeader1"].Controls["txtDstrProductID0"]).Text >   This control holds the data for filtering

sub25

GroupHeader1 = Report Section that holds the data of Product ID

txtDstrProductID0 = Control Name that holds the Product ID.

sub26

8.        Next are the following line of codes:

       dsPolicy.ConnectionString=ConnectionString;

      dsPolicy.SQL = strSQL;

      rptSub.DataSource = dsPolicy;

      dsPolicy – the datasource that we declared in Step 4.

      rptSub – the Report that we declared in Step 5.

      dsPolicy.ConnectionString=ConnectionString; >   This will set the connection to the database.

      dsPolicy.SQL = strSQL; >   This will execute the SQL command.

      rptSub.DataSource = dsPolicy; >   This will assign the Datasaource of the Sub Report

sub27

 

sub28

 

9.        Next is the line of code below:

sub31

 

10.        Click the Save button. The code should look like this.

sub30