Header Ads Widget

LightBlog

Breaking

LightBlog

Friday, June 28, 2013

how to use the picture stored in the Company Information table to a Nav R2 report

1. we need to have a Variable with is references to the Company Information Table. 
Lets create a new called CompanyInfo

image

2. Exit C/AL Globals and ad the following code to the
"OnPreReport()" trigger: CompanyInfo.CALCFIELDS(Picture);

image

3. Now we should add a Picture Box on the Sections with SourceExpr: CompanyInfo.Picture. 
We need to do this to have the element available for us in Visual Studio.

image

4. It is now time to open Visual Studio. Select "View/Layout" 
 
5. Notice that we now have an new entry in  the DataSet

image

6. Now lets add this to the report. We need to add the Company Picture first as a TextBox to the body of the report. This will enable us to use it in the Page Header. We add this TextBox in top of the Body.

image

7. We give the TextBox the following properties:

Value: “=Convert.ToBase64String(Fields!CompanyInfo_Picture.Value)”
Name: “CompanyPicture”
Visibility Hidden: “True”
Color: “Red”

8. Now add the following code to the Report properties.

Shared PictureData as Object
Public Function GetPicture() as Object
  Return PictureData
End Function
Public Function SetPicture(NewData as Object)
  if NewData>""
    PictureData = NewData
end if
End Function

image


9. Now let us add the Image control just as we did for the embedded scenario.
Open the Toolbox and add a Image control to the Report.

image


10. With the Image Control added we need to the set correct properties for this control.

Value: “=Convert.FromBase64String(Code.GetPicture())”
Source: “Database”
MIMEType: “image/bmp”

11. Add textbox to Page Header.
Note! This textbox has to be placed above the Picture control just added

Value: “=Code.SetPicture(ReportItems!CompanyPicture.Value)”
Visibility Hidden: “True”
Color: “Red

image



12. Save and import RDLC changes, and then compile report in Classic client.
 

No comments:

Post a Comment

Adbox