Photography

Selasa, 07 Agustus 2012

Microsoft Dynamics Navigate 2009 Tips Part 5

How To Add Data Result into Header on Report RDLC

1. Prepare fields and data needed for RDLC in Section Report.
2. Go To Layout and Open Report Properties

3. Insert These Code on last line for generating function to be called in header :

Shared offset as Integer
Shared newPage as Object
Shared currentgroup1 as Object
Shared currentgroup2 as Object
Shared currentgroup3 as Object
Public Function GetGroupPageNumber(NewPage as Boolean, pagenumber as Integer) as Object
  If NewPage
    offset = pagenumber - 1
  End If
  Return pagenumber - offset
End Function

Public Function IsNewPage(group1 as Object, group2 as Object, group3 as Object) As Boolean
newPage = FALSE
If Not (group1 = currentgroup1)
    newPage = TRUE
    currentgroup1 = group1
    currentgroup2 = group2
    currentgroup3 = group3
     ELSE
      If Not (group2 = currentgroup2)
        newPage = TRUE
        currentgroup2 = group2
        currentgroup3 = group3
        ELSE
          If Not (group3 = currentgroup3)
          newPage = TRUE
          currentgroup3 = group3
         End If
     End If
  End If
Return newPage
End Function

Shared Data1 as Object
Shared Data2 as Object
Shared Data3 as Object
Shared Data4 as Object

Public Function GetData(Num as Integer, Group as integer) as Object
if Group = 1 then
   Return Cstr(Choose(Num, Split(Cstr(Data1),Chr(177))))
End If

if Group = 2 then
   Return Cstr(Choose(Num, Split(Cstr(Data2),Chr(177))))
End If

if Group = 3 then
   Return Cstr(Choose(Num, Split(Cstr(Data3),Chr(177))))
End If

if Group = 4 then
   Return Cstr(Choose(Num, Split(Cstr(Data4),Chr(177))))
End If

End Function

Public Function SetData(NewData as Object,Group as integer)
  If Group = 1 and NewData <> "" Then
      Data1 = NewData
  End If

  If Group = 2 and NewData <> "" Then
      Data2 = NewData
  End If

  If Group = 3 and NewData <> "" Then
      Data3 = NewData
  End If

  If Group = 4 and NewData <> "" Then
      Data4 = NewData
  End If

End Function

4. Close report properties and create table inside body report, open properties of new table and change DataSetName to DataSet_Result
  
Properties :
  

5. Select first row and column and open properties of the cell, change the Name and expression :
  
 6. Code for expression : (example)

   =Fields!EncodeBarcode128__Search_Description__.Value + Chr(177) + Fields!Item__No__.Value

7. Close the cell property and create 2 text box in header of report, first textbox will declare function group to be called in other text box.
   Open properties for the first text box and change value : (example)
   =code.SetData(ReportItems!databody.Value,1)
   databody is the name of the cell which we has made.
   
8. Open Second textbox and change the value into :
    =Code.GetData(1,1)
  
   Value for GetData depends on how many source table and group we need to display on header

Thats it Finish and save your RDLC