AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 15.05.2012, 18:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
dax-lessons: Display Barcode in SSRS report [Dynamics AX 2012, X++]
Источник: http://dynamicsaxgyan.wordpress.com/...amics-ax-2012/
==============

Friends,
Today let us learn how to quickly display barcode(s)  in SSRS report, AX 2012.
I will be using report data provider as a data source type. First , let us create a query by name SR_InventItemBarCode and drag and drop InventItemBarCode table as data source. Set the dynamic property on fields to “Yes”


Create a new DP class and methods as shown below:
PHP код:
[

    
SRSReportQueryAttribute(queryStr(SR_InventItemBarCode))

]

class 
SR_InventItemBarCodeDP extends SRSReportDataProviderBase

{

    
SR_TmpInventItemBarCode sr_TmpInventItemBarCode;

    
BarcodeSetupId  barcodeSetupId;

    
BarcodeSetup    barcodeSetup;

    
Barcode         barcode;

    
FontName        barcodeFontName;

    
FontSize        barcodeFontSize;

}

/// <summary>

/// Initializes barcode elements.

/// </summary>

protected void initializeBarcode()

{

    
barcodeSetupId  InventParameters::find().BarcodeSetupIdPick;

    
barcodeSetup    BarcodeSetup::find(barcodeSetupId);

    
barcode         barcodeSetup.barcode();

 

    if(
barcodeSetup.BarcodeType != BarcodeType::NoBarcode)

    {

        
barcodeFontName barcodeSetup.FontName;

        
barcodeFontSize barcodeSetup.FontSize;

    }

    else

    {

        
barcodeFontName ;

        
barcodeFontSize 0;

    }

}

 

/// <summary>

/// Validate and format barcode value before it can be displayed

/// </summary>

/// <param name="_barcodeValue">String which should be encoded to a barcode format</param>

/// <returns>Encoded barcode string</returns>

public BarCodeString encodeBarcode(Str _barcodeValue)

{

    if (
barcodeSetup.validateBarcode(_barcodeValue))

    {

        
barcode.string(true_barcodeValue);

        
barcode.encode();

    }

    else

    {

        throw(
error(strfmt("@SYS41409"barcode.barcodeType(), _barcodeValue)));

    }

 

    return 
barcode.barcodeStr();

}

 

/// <summary>

/// Validate and format barcode value before it can be displayed

/// </summary>

/// <param name="_barcodeValue">String which should be encoded to a barcode format</param>

/// <returns>Encoded barcode string</returns>

public BarCodeString encodeBarcode(Str _barcodeValue)

{

    if (
barcodeSetup.validateBarcode(_barcodeValue))

    {

        
barcode.string(true_barcodeValue);

        
barcode.encode();

    }

    else

    {

        throw(
error(strfmt("@SYS41409"barcode.barcodeType(), _barcodeValue)));

    }

 

    return 
barcode.barcodeStr();

}

protected 
void insertIntoTmp(InventItemBarcode _inventItemBarCode)

{

    
// encode barcodes

    
sr_TmpInventItemBarCode.ItemId         _inventItemBarCode.itemId;

    
sr_TmpInventItemBarCode.BarCodeString  this.encodeBarcode(_inventItemBarCode.itemBarCode);

    
//sr_TmpInventItemBarCode.BarCodeString  = this.encodeBarcode("packing12345"); // you can use any value as barcode string

    
sr_TmpInventItemBarCode.insert();

}

/// <summary>

/// Fetches data from SR_TmpInventItemBarCode Table.

/// </summary>

/// <returns>

///  SR_TmpInventItemBarCode Data for the report.

/// </returns>

[SRSReportDataSetAttribute(tableStr(SR_TmpInventItemBarCode))]

public 
SR_TmpInventItemBarCode getTmpInventItemBarCode()

{

    
select sr_TmpInventItemBarCode;

    return 
sr_TmpInventItemBarCode;


Now lets open visual studio 2010 and create a new report as shown below: [I hope you all know by now how to create a report from Visual studio, If not please follow my earlier posts]

In the below screen, I have added new report and a dataset, set the data source type as Report data provider and in the query I have picked the data provider class “SR_InventItemBarCodeDP”


Once you select the DP class in the query and fields from the temporary Table “SR_TmpInventItemBarCode” you should find the fields in the Dataset Node as shown below.


Now drag and drop the dataset on to Designs node. it will create a auto design as show below.


Now , let us set some styles and layout templates on the Design and the data Region as shown below
Right click on the AutoDesign1, select properties and set the Layout template as “ReportLayoutStyleTemplate”


Right click on the DataSet1Table, select properties and set the Style template as “TableStyleTemplate”


Now , we will set up some properties on the data field “BarCodeString” to look like Barcode. Right click on the BarcodeString field >> properties >>
Select Style >> click on the ellipses button as shown below


This will open Cell Style editor and select BC C128 Wide and Size as 20 pt as show below. [Chose based on your requirement]
For more information on the type of barcodes, please visit http://en.wikipedia.org/wiki/Barcode#Types_of_barcodes



Right click on the AutoDesign1 and chose preview: Below is the Barcode rendered on to the report.


Happy Dax6ng,

Источник: http://dynamicsaxgyan.wordpress.com/...amics-ax-2012/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.

Последний раз редактировалось Poleax; 16.05.2012 в 12:26. Причина: оформление
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
dax-lessons: Save SSRS report to pdf that uses Controller classes [Dynamics AX 2012] Blog bot DAX Blogs 0 12.05.2012 01:11
dax-lessons: Get underlying SQL query using getSQLStatement [Dynamics AX 2012] Blog bot DAX Blogs 0 11.05.2012 18:11
rumicrosofterp: Dynamics AX на Convergence 2012 Blog bot Microsoft и системы Microsoft Dynamics 0 13.01.2012 11:11
dax-lessons: Getting Segments from Segmented Entry control/Ledger dimension–Dynamics AX 2012 [X++] Blog bot DAX Blogs 0 01.12.2011 18:11
gatesasbait: Dynamics AX 2009 SSRS and SSAS Integration Tips Blog bot DAX Blogs 3 09.07.2009 13:07
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 23:23.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.