async private void PrintData()
        {
            busyIndicator.IsBusy      = true;
            busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");

            try
            {
                //Get Company related details
                var companyClient = new CompanyClient();
                StreamingManager.Copy(api.CompanyEntity, companyClient);
                byte[] getLogoBytes = await UtilDisplay.GetLogo(api);

#if SILVERLIGHT
                if (dgDebtorTrans.SelectedItem != null)
                {
                    var selectedItem = dgDebtorTrans.SelectedItem as DebtorStatementList;
                    if (selectedItem.ChildRecords.Count == 0)
                    {
                        return;
                    }

                    var debt = new DebtorClient();
                    StreamingManager.Copy(selectedItem.deb, debt);
                    if (debt != null)
                    {
                        debt.Transactions = selectedItem.ChildRecords;

                        //Setting the Localization for the debtor
                        var debtLocalize = Uniconta.ClientTools.Localization.GetLocalization(UtilDisplay.GetLanguage(debt, api.CompanyEntity));
                        foreach (var rec in debt.Transactions)
                        {
                            rec.LocOb = debtLocalize;
                        }

                        var debtorMessageClient = await Utility.GetDebtorMessageClient(api, debt._Language, DebtorEmailType.AccountStatement);

                        string messageText = debtorMessageClient?._Text;

                        DebtorStatementCustomPrint dbStatementCustomPrint = new DebtorStatementCustomPrint(api, selectedItem, companyClient, debt,
                                                                                                           txtDateFrm.DateTime, txtDateTo.DateTime, getLogoBytes, messageText);

                        object[] obj = new object[1];
                        obj[0] = dbStatementCustomPrint as Controls.CustomPrintTemplateData;
                        if (chkShowCurrency.IsChecked == true)
                        {
                            AddDockItem(TabControls.DebtorStatementCurrencyCustomPrintPage, obj, true, string.Format("{0}: {1}, {2}", Uniconta.ClientTools.Localization.lookup("PrintPreview"), selectedItem.AccountNumber, selectedItem.Name));
                        }
                        else
                        {
                            AddDockItem(TabControls.DebtorStatementCustomPrintPage, obj, true, string.Format("{0}: {1}, {2}", Uniconta.ClientTools.Localization.lookup("PrintPreview"), selectedItem.AccountNumber, selectedItem.Name));
                        }
                    }
                }
#else
                IEnumerable <DebtorStatementList> debtorStatementList = (IEnumerable <DebtorStatementList>)dgDebtorTrans.ItemsSource;
                var layoutSelectedDebtorStatementList = new Dictionary <string, List <DebtorStatementList> >();

                var Comp           = api.CompanyEntity;
                var layoutgrpCache = Comp.GetCache(typeof(Uniconta.DataModel.DebtorLayoutGroup));
                if (layoutgrpCache == null)
                {
                    layoutgrpCache = await Comp.LoadCache(typeof(Uniconta.DataModel.DebtorLayoutGroup), api);
                }

                var xtraReports = new List <DevExpress.XtraReports.UI.XtraReport>();
                var iReports    = new List <IPrintReport>();
                var marked      = debtorStatementList.Any(m => m.Mark == true);

                foreach (var db in debtorStatementList)
                {
                    if (db.ChildRecords.Count == 0 || (marked && !db.Mark))
                    {
                        continue;
                    }

                    var statementPrint = await GenerateStandardStatementReport(companyClient, txtDateFrm.DateTime, txtDateTo.DateTime, db, getLogoBytes);

                    if (statementPrint == null)
                    {
                        continue;
                    }

                    var standardReports = new IDebtorStandardReport[1] {
                        statementPrint
                    };

                    IPrintReport standardPrint;
                    if (chkShowCurrency.IsChecked == true)
                    {
                        standardPrint = new StandardPrintReport(api, standardReports, (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.StatementCurrency);
                    }
                    else
                    {
                        standardPrint = new StandardPrintReport(api, standardReports, (byte)Uniconta.ClientTools.Controls.Reporting.StandardReports.Statement);
                    }
                    await standardPrint.InitializePrint();

                    if (standardPrint.Report != null)
                    {
                        iReports.Add(standardPrint);
                    }
                }

                if (iReports.Count > 0)
                {
                    var dockJName = string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("Preview"), Uniconta.ClientTools.Localization.lookup("Statement"));
                    AddDockItem(UnicontaTabs.StandardPrintReportPage, new object[] { iReports, Uniconta.ClientTools.Localization.lookup("Statement") }, dockJName);
                }
#endif
            }
            catch (Exception ex)
            {
                busyIndicator.IsBusy = false;
                api.ReportException(ex, string.Format("DebtorStatement.PrintData(), CompanyId={0}", api.CompanyId));
                UnicontaMessageBox.Show(ex.Message, Uniconta.ClientTools.Localization.lookup("Exception"), MessageBoxButton.OK);
            }
            finally { busyIndicator.IsBusy = false; }
        }
        async private void PrintData()
        {
            busyIndicator.IsBusy      = true;
            busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("GeneratingPage");

            try
            {
#if SILVERLIGHT
                //Get Company related details
                var companyClient = new CompanyClient();
                StreamingManager.Copy(api.CompanyEntity, companyClient);
                byte[] getLogoBytes = await UtilDisplay.GetLogo(api);

                if (dgDebtorTrans.SelectedItem != null)
                {
                    var selectedItem = dgDebtorTrans.SelectedItem as DebtorStatementList;
                    if (selectedItem.ChildRecords.Length == 0)
                    {
                        return;
                    }

                    var debt = new DebtorClient();
                    StreamingManager.Copy(selectedItem.deb, debt);
                    debt.Transactions = selectedItem.ChildRecords;

                    //Setting the Localization for the debtor
                    var lan          = UtilDisplay.GetLanguage(debt, companyClient);
                    var debtLocalize = Uniconta.ClientTools.Localization.GetLocalization(lan);
                    foreach (var rec in debt.Transactions)
                    {
                        rec.LocOb = debtLocalize;
                        if (rec._Primo)
                        {
                            rec._Text = debtLocalize.Lookup("Primo");
                        }
                    }

                    if (lastMessage == null || messageLanguage != lan)
                    {
                        messageLanguage = lan;
                        var msg = await Utility.GetDebtorMessageClient(api, lan, DebtorEmailType.AccountStatement);

                        if (msg != null)
                        {
                            lastMessage = msg._Text;
                        }
                        else
                        {
                            lastMessage = string.Empty;
                        }
                    }

                    DebtorStatementCustomPrint dbStatementCustomPrint = new DebtorStatementCustomPrint(api, selectedItem, companyClient, debt,
                                                                                                       txtDateFrm.DateTime, txtDateTo.DateTime, getLogoBytes, lastMessage);

                    object[] obj = new object[1];
                    obj[0] = dbStatementCustomPrint as Controls.CustomPrintTemplateData;
                    if (chkShowCurrency.IsChecked == true)
                    {
                        AddDockItem(TabControls.DebtorStatementCurrencyCustomPrintPage, obj, true, string.Format("{0}: {1}, {2}", Uniconta.ClientTools.Localization.lookup("PrintPreview"), selectedItem.AccountNumber, selectedItem.Name));
                    }
                    else
                    {
                        AddDockItem(TabControls.DebtorStatementCustomPrintPage, obj, true, string.Format("{0}: {1}, {2}", Uniconta.ClientTools.Localization.lookup("PrintPreview"), selectedItem.AccountNumber, selectedItem.Name));
                    }
                }
#else
                var debtorStatementList = dgDebtorTrans.VisibleItems.Cast <DebtorStatementList>();
                var marked = debtorStatementList.Any(m => m.Mark == true);

                var iReports = await GeneratePrintReport(debtorStatementList.ToList(), marked, chkShowCurrency.IsChecked == true, true);

                if (iReports.Count() > 0)
                {
                    var dockJName = string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("Preview"), Uniconta.ClientTools.Localization.lookup("Statement"));
                    AddDockItem(UnicontaTabs.StandardPrintReportPage, new object[] { iReports, Uniconta.ClientTools.Localization.lookup("Statement") }, dockJName);
                }
#endif
            }
            catch (Exception ex)
            {
                busyIndicator.IsBusy = false;
                api.ReportException(ex, string.Format("DebtorStatement.PrintData(), CompanyId={0}", api.CompanyId));
                UnicontaMessageBox.Show(ex);
            }
            finally { busyIndicator.IsBusy = false; }
        }