예제 #1
0
        /// <summary>
        /// Print or reprint the posting report for this batch.
        /// </summary>
        public static void PrintPostingRegister(Int32 ALedgerNumber, Int32 ABatchNumber, Boolean AEditTemplate = false)
        {
            FastReportsWrapper ReportingEngine = new FastReportsWrapper("Batch Posting Register");

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            GLBatchTDS BatchTDS = TRemote.MFinance.GL.WebConnectors.LoadABatchAndContent(ALedgerNumber, ABatchNumber);
            TRptCalculator Calc = new TRptCalculator();
            ALedgerRow LedgerRow = BatchTDS.ALedger[0];

            //Call RegisterData to give the data to the template
            ReportingEngine.RegisterData(BatchTDS.ABatch, "ABatch");
            ReportingEngine.RegisterData(BatchTDS.AJournal, "AJournal");
            ReportingEngine.RegisterData(BatchTDS.ATransaction, "ATransaction");

            Calc.AddParameter("param_batch_number_i", ABatchNumber);
            Calc.AddParameter("param_ledger_number_i", ALedgerNumber);
            String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(ALedgerNumber);
            Calc.AddStringParameter("param_ledger_name", LedgerName);

            if (AEditTemplate)
            {
                ReportingEngine.DesignReport(Calc);
            }
            else
            {
                ReportingEngine.GenerateReport(Calc);
            }
        }
예제 #2
0
        /// <summary>Helper for the report printing ClientTask</summary>
        /// <param name="ReportName"></param>
        /// <param name="paramStr"></param>
        public static void PrintReportNoUi(String ReportName, String paramStr)
        {
            String[] Params = paramStr.Split(',');
            Int32 LedgerNumber = -1;
            Int32 BatchNumber = -1;

/*
 *          String Msg = ReportName + "\n";
 *          foreach (String param in Params)
 *          {
 *              Msg += (param + "\n");
 *          }
 *          MessageBox.Show(Msg, "FastReportWrapper.PrintReportNoUi");
 */
            FastReportsWrapper ReportingEngine = new FastReportsWrapper(ReportName);

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            Dictionary <String, TVariant>paramsDictionary = new Dictionary <string, TVariant>();
            TRptCalculator Calc = new TRptCalculator();

            //
            // Copy paramters to report:
            foreach (String param in Params)
            {
                String[] term = param.Split('=');

                if (term.Length > 1)
                {
                    if (term[1][0] == '"') // This is a string
                    {
                        String val = term[1].Substring(1, term[1].Length - 2);
                        Calc.AddStringParameter(term[0], val);
                        paramsDictionary.Add(term[0], new TVariant(val));
                    }
                    else // This is a number - Int32 assumed.
                    {
                        Int32 IntTerm;

                        if (Int32.TryParse(term[1], out IntTerm))
                        {
                            Calc.AddParameter(term[0], IntTerm);
                            paramsDictionary.Add(term[0], new TVariant(IntTerm));

                            //
                            // As I'm adding these values, I'll keep a note of any that may be useful later..
                            switch (term[0])
                            {
                                case "param_ledger_number_i":
                                {
                                    LedgerNumber = IntTerm;
                                    break;
                                }

                                case "param_batch_number_i":
                                {
                                    BatchNumber = IntTerm;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("Error: Parameter not recognised: " + param, "FastReportWrapper.PrintReportNoUi");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Error: malformed Parameter: " + param, "FastReportWrapper.PrintReportNoUi");
                }
            } // foreach param

            //
            // Get Data for report:
            switch (ReportName)
            {
                case "Batch Posting Register":
                {
                    if ((LedgerNumber != -1) && (BatchNumber != -1))
                    {
                        ReportingEngine.RegisterBatchPostingData(Calc, LedgerNumber, BatchNumber);
                    }
                    else
                    {
                        MessageBox.Show("Error: Can't get data for Batch Posting Register", "FastReportWrapper.PrintReportNoUi");
                    }

                    break;
                }

                case "Gift Batch Detail":
                {
                    DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("GiftBatchDetail", paramsDictionary);
                    ReportingEngine.RegisterData(ReportTable, "GiftBatchDetail");
                    break;
                }
            } // switch

            // I'm not in the User Interface thread, so I can use an invoke here:

            Application.OpenForms[0].Invoke((ThreadStart) delegate { ReportingEngine.GenerateReport(Calc); });
        } // PrintReportNoUi
예제 #3
0
        } // AutoEmailReports

        /// <summary>
        ///
        /// </summary>
        /// <param name="ReportName"></param>
        /// <param name="paramStr"></param>
        public static void PrintReportNoUi(String ReportName, String paramStr)
        {
            String[] Params = paramStr.Split(',');
            Int32 LedgerNumber = -1;
            Int32 BatchNumber = -1;

/*
 *          String Msg = ReportName + "\n";
 *          foreach (String param in Params)
 *          {
 *              Msg += (param + "\n");
 *          }
 *          MessageBox.Show(Msg, "FastReportWrapper.PrintReportNoUi");
 */
            FastReportsWrapper ReportingEngine = new FastReportsWrapper(ReportName);

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            TRptCalculator Calc = new TRptCalculator();

            //
            // Copy paramters to report:
            foreach (String param in Params)
            {
                String[] term = param.Split('=');

                if (term.Length > 1)
                {
                    if (term[1][0] == '"') // This is a string
                    {
                        Calc.AddStringParameter(term[0], term[1].Substring(1, term[1].Length - 2));
                    }
                    else // This is a number - Int32 assumed.
                    {
                        Int32 IntTerm;

                        if (Int32.TryParse(term[1], out IntTerm))
                        {
                            Calc.AddParameter(term[0], IntTerm);

                            //
                            // As I'm adding these values, I'll keep a note of any that may be useful later..
                            switch (term[0])
                            {
                                case "param_ledger_number_i":
                                {
                                    LedgerNumber = IntTerm;
                                    break;
                                }

                                case "param_batch_number_i":
                                {
                                    BatchNumber = IntTerm;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("Error: Parameter not recognised: " + param, "FastReportWrapper.PrintReportNoUi");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Error: malformed Parameter: " + param, "FastReportWrapper.PrintReportNoUi");
                }
            } // foreach

            //
            // Get Data for report:
            switch (ReportName)
            {
                case "Batch Posting Register":
                {
                    if ((LedgerNumber != -1) && (BatchNumber != -1))
                    {
                        GLBatchTDS BatchTDS = TRemote.MFinance.GL.WebConnectors.LoadABatchAndContent(LedgerNumber, BatchNumber);
                        ReportingEngine.RegisterData(BatchTDS.ABatch, "ABatch");
                        ReportingEngine.RegisterData(BatchTDS.AJournal, "AJournal");
                        ReportingEngine.RegisterData(BatchTDS.ATransaction, "ATransaction");
                    }
                    else
                    {
                        MessageBox.Show("Error: Can't get data for Batch Posting Register", "FastReportWrapper.PrintReportNoUi");
                    }

                    break;
                }
            } // switch

            ReportingEngine.GenerateReport(Calc);
        } // PrintReportNoUi
        /// <summary>
        /// Print out the Hierarchy using FastReports template.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilePrint(object sender, EventArgs e)
        {
            FastReportsWrapper ReportingEngine = new FastReportsWrapper("Account Hierarchy");

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            if (!FMainDS.AAccount.Columns.Contains("AccountPath"))
            {
                FMainDS.AAccount.Columns.Add("AccountPath", typeof(String));
                FMainDS.AAccount.Columns.Add("AccountLevel", typeof(Int32));
            }

            DataView PathView = new DataView(FMainDS.AAccountHierarchyDetail);
            PathView.Sort = "a_reporting_account_code_c";

            DataView AccountView = new DataView(FMainDS.AAccount);
            AccountView.Sort = "a_account_code_c";

            // I need to make the "AccountPath" field that will be used to sort the table for printout:
            foreach (DataRowView rv in PathView)
            {
                DataRow Row = rv.Row;
                String AccountCode = Row["a_reporting_account_code_c"].ToString();
                String Path = Row["a_report_order_i"] + "-" + AccountCode + '~';
                Int32 Level = 0;
                String ReportsTo = Row["a_account_code_to_report_to_c"].ToString();

                while (ReportsTo != "")
                {
                    Int32 ParentIdx = PathView.Find(ReportsTo);

                    if (ParentIdx >= 0)
                    {
                        DataRow ParentRow = PathView[ParentIdx].Row;
                        ReportsTo = ParentRow["a_account_code_to_report_to_c"].ToString();
                        Path = ParentRow["a_report_order_i"] + "-" + ParentRow["a_reporting_account_code_c"].ToString() + "~" + Path;
                        Level++;

                        if (Level > 100) // Surely this is a fault. If I just break here,
                        {
                            break;  // the report will print and I should be able to see what the fault is.
                        }
                    }
                    else
                    {
                        ReportsTo = "";
                    }
                }

                Int32 AccountIdx = AccountView.Find(AccountCode);
                DataRow AccountRow = AccountView[AccountIdx].Row;
                AccountRow["AccountPath"] = Path;
                AccountRow["AccountLevel"] = Level;
            }

            AccountView.Sort = "AccountPath";
            DataTable SortedByPath = AccountView.ToTable();

            ReportingEngine.RegisterData(SortedByPath, "AccountHierarchy");
            ReportingEngine.RegisterData(FMainDS.AAnalysisAttribute, "AnalysisAttribute");
            TRptCalculator Calc = new TRptCalculator();
            ALedgerRow LedgerRow = FMainDS.ALedger[0];
            Calc.AddParameter("param_ledger_number_i", LedgerRow.LedgerNumber);
            Calc.AddStringParameter("param_ledger_name", LedgerRow.LedgerName);

            if (ModifierKeys.HasFlag(Keys.Control))
            {
                ReportingEngine.DesignReport(Calc);
            }
            else
            {
                ReportingEngine.GenerateReport(Calc);
            }
        }
예제 #5
0
        } // AutoEmailReports

        /// <summary>
        ///
        /// </summary>
        /// <param name="ReportName"></param>
        /// <param name="paramStr"></param>
        public static void PrintReportNoUi(String ReportName, String paramStr)
        {
            String[] Params       = paramStr.Split(',');
            Int32    LedgerNumber = -1;
            Int32    BatchNumber  = -1;

/*
 *          String Msg = ReportName + "\n";
 *          foreach (String param in Params)
 *          {
 *              Msg += (param + "\n");
 *          }
 *          MessageBox.Show(Msg, "FastReportWrapper.PrintReportNoUi");
 */
            FastReportsWrapper ReportingEngine = new FastReportsWrapper(ReportName);

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            TRptCalculator Calc = new TRptCalculator();

            //
            // Copy paramters to report:
            foreach (String param in Params)
            {
                String[] term = param.Split('=');

                if (term.Length > 1)
                {
                    if (term[1][0] == '"') // This is a string
                    {
                        Calc.AddStringParameter(term[0], term[1].Substring(1, term[1].Length - 2));
                    }
                    else // This is a number - Int32 assumed.
                    {
                        Int32 IntTerm;

                        if (Int32.TryParse(term[1], out IntTerm))
                        {
                            Calc.AddParameter(term[0], IntTerm);

                            //
                            // As I'm adding these values, I'll keep a note of any that may be useful later..
                            switch (term[0])
                            {
                            case "param_ledger_number_i":
                            {
                                LedgerNumber = IntTerm;
                                break;
                            }

                            case "param_batch_number_i":
                            {
                                BatchNumber = IntTerm;
                                break;
                            }
                            }
                        }
                        else
                        {
                            MessageBox.Show("Error: Parameter not recognised: " + param, "FastReportWrapper.PrintReportNoUi");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Error: malformed Parameter: " + param, "FastReportWrapper.PrintReportNoUi");
                }
            } // foreach

            //
            // Get Data for report:
            switch (ReportName)
            {
            case "Batch Posting Register":
            {
                if ((LedgerNumber != -1) && (BatchNumber != -1))
                {
                    GLBatchTDS BatchTDS = TRemote.MFinance.GL.WebConnectors.LoadABatchAndContent(LedgerNumber, BatchNumber);
                    ReportingEngine.RegisterData(BatchTDS.ABatch, "ABatch");
                    ReportingEngine.RegisterData(BatchTDS.AJournal, "AJournal");
                    ReportingEngine.RegisterData(BatchTDS.ATransaction, "ATransaction");
                }
                else
                {
                    MessageBox.Show("Error: Can't get data for Batch Posting Register", "FastReportWrapper.PrintReportNoUi");
                }

                break;
            }
            } // switch

            ReportingEngine.GenerateReport(Calc);
        } // PrintReportNoUi
        /// <summary>
        /// Print out the Hierarchy using FastReports template.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilePrint(object sender, EventArgs e)
        {
            TLogging.Log("CostCentreHierarchy.File Print..");
            FastReportsWrapper ReportingEngine = new FastReportsWrapper("Cost Centre Hierarchy");

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            if (!FMainDS.ACostCentre.Columns.Contains("CostCentrePath"))
            {
                FMainDS.ACostCentre.Columns.Add("CostCentrePath", typeof(String));
                FMainDS.ACostCentre.Columns.Add("CostCentreLevel", typeof(Int32));
            }

            DataView PathView = new DataView(FMainDS.ACostCentre);
            PathView.Sort = "a_cost_centre_code_c";
            TLogging.Log("CostCentreHierarchy.File Print calculating paths..");

            // I need to make the "CostCentrePath" field that will be used to sort the table for printout:
            foreach (DataRowView rv in PathView)
            {
                DataRow Row = rv.Row;
                String Path = Row["a_cost_centre_code_c"].ToString() + '~';
                Int32 Level = 0;
                String ReportsTo = Row["a_cost_centre_to_report_to_c"].ToString();

                while (ReportsTo != "")
                {
                    Int32 ParentIdx = PathView.Find(ReportsTo);

                    if (ParentIdx >= 0)
                    {
                        DataRow ParentRow = PathView[ParentIdx].Row;
                        ReportsTo = ParentRow["a_cost_centre_to_report_to_c"].ToString();
                        Path = ParentRow["a_cost_centre_code_c"].ToString() + "~" + Path;
                        Level++;

                        if (Level > 100) // Surely this is a fault. If I just break here,
                        {
                            break;  // the report will print and I should be able to see what the fault is.
                        }
                    }
                    else
                    {
                        ReportsTo = "";
                    }
                }

                Row["CostCentrePath"] = Path;
                Row["CostCentreLevel"] = Level;
            }

            PathView.Sort = "CostCentrePath";
            DataTable SortedByPath = PathView.ToTable();

            TLogging.Log("CostCentreHierarchy.File Print paths all done.");

            ReportingEngine.RegisterData(SortedByPath, "CostCentreHierarchy");
            TRptCalculator Calc = new TRptCalculator();
            ALedgerRow LedgerRow = FMainDS.ALedger[0];
            Calc.AddParameter("param_ledger_nunmber", LedgerRow.LedgerNumber);
            Calc.AddStringParameter("param_ledger_name", LedgerRow.LedgerName);

            TLogging.Log("CostCentreHierarchy.File Print calling FastReport...");

            if (ModifierKeys.HasFlag(Keys.Control))
            {
                ReportingEngine.DesignReport(Calc);
            }
            else
            {
                ReportingEngine.GenerateReport(Calc);
            }
        }
        /// <summary>
        /// Print out the Motivation Details using FastReports template.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilePrint(object sender, EventArgs e)
        {
            FastReportsWrapper ReportingEngine = new FastReportsWrapper("Motivation Details");

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            // Add in the Fees applicable for each row:

            if (!FMainDS.AMotivationDetail.Columns.Contains("Fees"))
            {
                FMainDS.AMotivationDetail.Columns.Add("Fees", typeof(String));
                FMainDS.AMotivationDetail.Columns.Add("KeyMin", typeof(String));
            }

            foreach (AMotivationDetailRow Row in FMainDS.AMotivationDetail.Rows)
            {
                FMainDS.AMotivationDetailFee.DefaultView.RowFilter = String.Format(
                    "a_motivation_group_code_c='{0}' AND a_motivation_detail_code_c='{1}'",
                    Row.MotivationGroupCode,
                    Row.MotivationDetailCode);
                String Fees = "";

                foreach (DataRowView rv in FMainDS.AMotivationDetailFee.DefaultView)
                {
                    AMotivationDetailFeeRow FeeRow = (AMotivationDetailFeeRow)rv.Row;

                    if (Fees != "")
                    {
                        Fees += ", ";
                    }

                    Fees += FeeRow.FeeCode;
                }

                Row["Fees"] = Fees;

                if (Row.RecipientKey != 0)
                {
                    String mPartnerShortName;
                    TPartnerClass mPartnerClass;

                    if (TServerLookup.TMPartner.GetPartnerShortName(Row.RecipientKey, out mPartnerShortName, out mPartnerClass, true))
                    {
                        Row["KeyMin"] = mPartnerShortName;
                    }
                }
            } // foreach

            //
            // Ensure the proper sorting for the printout:

            FMainDS.AMotivationDetail.DefaultView.Sort = "a_motivation_group_code_c, a_motivation_detail_code_c";
            ReportingEngine.RegisterData(FMainDS.AMotivationDetail.DefaultView.ToTable(), "MotivationDetail");
            TRptCalculator Calc = new TRptCalculator();
            ALedgerRow LedgerRow = FMainDS.ALedger[0];
            Calc.AddParameter("param_ledger_number_i", LedgerRow.LedgerNumber);
            Calc.AddStringParameter("param_ledger_name", LedgerRow.LedgerName);
            Calc.AddParameter("param_TD", FTaxDeductiblePercentageEnabled);

            if (ModifierKeys.HasFlag(Keys.Control))
            {
                ReportingEngine.DesignReport(Calc);
            }
            else
            {
                ReportingEngine.GenerateReport(Calc);
            }
        }
예제 #8
0
        /// <summary>Helper for the report printing ClientTask</summary>
        /// <param name="ReportName"></param>
        /// <param name="paramStr"></param>
        public static void PrintReportNoUi(String ReportName, String paramStr)
        {
            String[] Params       = paramStr.Split(',');
            Int32    LedgerNumber = -1;
            Int32    BatchNumber  = -1;

/*
 *          String Msg = ReportName + "\n";
 *          foreach (String param in Params)
 *          {
 *              Msg += (param + "\n");
 *          }
 *          MessageBox.Show(Msg, "FastReportWrapper.PrintReportNoUi");
 */
            FastReportsWrapper ReportingEngine = new FastReportsWrapper(ReportName);

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            Dictionary <String, TVariant> paramsDictionary = new Dictionary <string, TVariant>();
            TRptCalculator Calc = new TRptCalculator();

            //
            // Copy paramters to report:
            foreach (String param in Params)
            {
                String[] term = param.Split('=');

                if (term.Length > 1)
                {
                    if (term[1][0] == '"') // This is a string
                    {
                        String val = term[1].Substring(1, term[1].Length - 2);
                        Calc.AddStringParameter(term[0], val);
                        paramsDictionary.Add(term[0], new TVariant(val));
                    }
                    else // This is a number - Int32 assumed.
                    {
                        Int32 IntTerm;

                        if (Int32.TryParse(term[1], out IntTerm))
                        {
                            Calc.AddParameter(term[0], IntTerm);
                            paramsDictionary.Add(term[0], new TVariant(IntTerm));

                            //
                            // As I'm adding these values, I'll keep a note of any that may be useful later..
                            switch (term[0])
                            {
                            case "param_ledger_number_i":
                            {
                                LedgerNumber = IntTerm;
                                break;
                            }

                            case "param_batch_number_i":
                            {
                                BatchNumber = IntTerm;
                                break;
                            }
                            }
                        }
                        else
                        {
                            MessageBox.Show("Error: Parameter not recognised: " + param, "FastReportWrapper.PrintReportNoUi");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Error: malformed Parameter: " + param, "FastReportWrapper.PrintReportNoUi");
                }
            } // foreach param

            //
            // Get Data for report:
            switch (ReportName)
            {
            case "Batch Posting Register":
            {
                if ((LedgerNumber != -1) && (BatchNumber != -1))
                {
                    ReportingEngine.RegisterBatchPostingData(Calc, LedgerNumber, BatchNumber);
                }
                else
                {
                    MessageBox.Show("Error: Can't get data for Batch Posting Register", "FastReportWrapper.PrintReportNoUi");
                }

                break;
            }

            case "Gift Batch Detail":
            {
                DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("GiftBatchDetail", paramsDictionary);
                ReportingEngine.RegisterData(ReportTable, "GiftBatchDetail");
                break;
            }
            } // switch

            // I'm not in the User Interface thread, so I can use an invoke here:

            TFormsList.GFormsList.MainMenuForm.Invoke((ThreadStart) delegate { ReportingEngine.GenerateReport(Calc); });
            //Application.OpenForms[0].Invoke((ThreadStart) delegate { ReportingEngine.GenerateReport(Calc); });
        } // PrintReportNoUi
        /// <summary>
        /// Print out the Hierarchy using FastReports template.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilePrint(object sender, EventArgs e)
        {
            FastReportsWrapper ReportingEngine = new FastReportsWrapper("Duplicate Address Check");

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            ReportingEngine.RegisterData(FDuplicateLocations, "DuplicateLocations");
            TRptCalculator Calc = new TRptCalculator();

            if (ModifierKeys.HasFlag(Keys.Control))
            {
                ReportingEngine.DesignReport(Calc);
            }
            else
            {
                ReportingEngine.GenerateReport(Calc);
            }
        }
예제 #10
0
        /// <summary>
        /// Data loader for HOSA data,
        /// Made static so it can be called from Stewardship Reports
        /// </summary>
        public static Boolean LoadReportDataStaticInner(Form ParentForm,
            TFrmPetraReportingUtils UtilsObject,
            FastReportsWrapper ReportingEngine,
            TRptCalculator ACalc)
        {
            Shared.MReporting.TParameterList pm = ACalc.GetParameters();
            String Csv = "";

            //
            // My "a_transaction" table forms the lower half of the HOSA:
            // All transactions for all the "Expense" accounts for the selected Cost Centre within the selected dates or periods.

            String LedgerFilter = "a_ledger_number_i=" + pm.Get("param_ledger_number_i").ToInt32();
            String TranctDateFilter = ""; // Optional Date Filter, as periods or dates
            String CostCentreCodes = pm.Get("param_cost_centre_codes").ToString();

            if (CostCentreCodes == String.Empty)
            {
                MessageBox.Show(Catalog.GetString("Please select one or more Cost Centres."), "HOSA");
                return false;
            }

            String CostCentreFilter = "";

            if (CostCentreCodes == "ALL")
            {
                CostCentreFilter = " AND a_cost_centre.a_cost_centre_type_c='Foreign' ";
            }
            else
            {
                CostCentreCodes = CostCentreCodes.Replace('"', '\'');
                ACalc.AddStringParameter("param_cost_centre_codes", CostCentreCodes);
                CostCentreFilter = " AND a_cost_centre.a_cost_centre_code_c IN (" + CostCentreCodes + ") ";
            }

            if (pm.Get("param_period").ToBool() == true)
            {
                Int32 PeriodStart = pm.Get("param_start_period_i").ToInt32();
                Int32 PeriodEnd = pm.Get("param_end_period_i").ToInt32();

                DateTime DateStart = pm.Get("param_start_date").ToDate();
                DateTime DateEnd = pm.Get("param_end_date").ToDate();

                ALedgerTable LedgerDetailsTable = (ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(
                    TCacheableFinanceTablesEnum.LedgerDetails);
                ALedgerRow LedgerRow = LedgerDetailsTable[0];
                Boolean IsClosed = (!pm.Get("param_current_financial_year").ToBool() || (PeriodEnd < LedgerRow.CurrentPeriod));
                ACalc.AddParameter("param_period_closed", IsClosed);
                Boolean IsCurrent = (pm.Get("param_current_financial_year").ToBool() && (PeriodEnd == LedgerRow.CurrentPeriod));
                ACalc.AddParameter("param_period_current", IsCurrent);

                String PeriodTitle = " (" + DateStart.ToString("dd-MMM-yyyy") + " - " + DateEnd.ToString("dd-MMM-yyyy") + ")";

                if (PeriodEnd > PeriodStart)
                {
                    PeriodTitle = String.Format("{0} - {1}", PeriodStart, PeriodEnd) + PeriodTitle;
                }
                else
                {
                    PeriodTitle = String.Format("{0}", PeriodStart) + PeriodTitle;
                }

                pm.Add("param_date_title", PeriodTitle);
            }
            else
            {
                String PeriodTitle = " " + pm.Get("param_start_date").DateToString("yyyy-MM-dd") + " - " +
                                     pm.Get("param_end_date").DateToString("yyyy-MM-dd");

                pm.Add("param_date_title", PeriodTitle);
            }

            TranctDateFilter = "a_transaction_date_d>='" + pm.Get("param_start_date").DateToString("yyyy-MM-dd") +
                               "' AND a_transaction_date_d<='" + pm.Get("param_end_date").DateToString("yyyy-MM-dd") + "'";

            Csv = StringHelper.AddCSV(Csv,
                "AAccount/SELECT * FROM a_account WHERE " + LedgerFilter + " AND a_posting_status_l=true AND a_account_active_flag_l=true");
            Csv = StringHelper.AddCSV(Csv,
                "ACostCentre/SELECT * FROM a_cost_centre WHERE " + LedgerFilter + CostCentreFilter +
                " AND a_posting_cost_centre_flag_l=true AND a_cost_centre_active_flag_l=true");
            Csv = StringHelper.AddCSV(
                Csv,
                "ATransaction/SELECT a_transaction.* FROM a_transaction, a_cost_centre WHERE a_transaction." + LedgerFilter +
                " AND " + TranctDateFilter +
                " AND NOT (a_system_generated_l = true AND (a_narrative_c LIKE 'Gifts received - Gift Batch%' OR a_narrative_c LIKE 'GB - Gift Batch%' OR a_narrative_c LIKE 'Year end re-allocation%'))"
                +
                " AND a_transaction.a_ledger_number_i = a_cost_centre.a_ledger_number_i " +
                " AND a_transaction.a_cost_centre_code_c = a_cost_centre.a_cost_centre_code_c " +
                CostCentreFilter +
                " ORDER BY a_account_code_c, a_transaction_date_d");

            GLReportingTDS ReportDs = TRemote.MReporting.WebConnectors.GetReportingDataSet(Csv);
            ArrayList reportParam = ACalc.GetParameters().Elems;
            Dictionary <String, TVariant>paramsDictionary = new Dictionary <string, TVariant>();

            foreach (Shared.MReporting.TParameter p in reportParam)
            {
                if (p.name.StartsWith("param") && (p.name != "param_calculation"))
                {
                    paramsDictionary.Add(p.name, p.value);
                }
            }

            DataTable GiftsTable = TRemote.MReporting.WebConnectors.GetReportDataTable("HOSA", paramsDictionary);
            DataTable KeyMinGiftsTable = TRemote.MReporting.WebConnectors.GetReportDataTable("FieldGifts", paramsDictionary);

            //
            // I'm going to get rid of any Cost Centres that saw no activity in the requested period:
            for (Int32 Idx = ReportDs.ACostCentre.Rows.Count - 1; Idx >= 0; Idx--)
            {
                ACostCentreRow Row = ReportDs.ACostCentre[Idx];
                ReportDs.ATransaction.DefaultView.RowFilter = String.Format("a_cost_centre_code_c='{0}'", Row.CostCentreCode);
                GiftsTable.DefaultView.RowFilter = String.Format("CostCentre='{0}'", Row.CostCentreCode);

                if ((ReportDs.ATransaction.DefaultView.Count == 0) && (GiftsTable.DefaultView.Count == 0))
                {
                    ReportDs.ACostCentre.Rows.Remove(Row);
                }
            }

            if (ParentForm.IsDisposed)
            {
                return false;
            }

            if (GiftsTable == null)
            {
                UtilsObject.WriteToStatusBar("Report Cancelled.");
                return false;
            }

            ReportingEngine.RegisterData(GiftsTable, "Gifts");
            ReportingEngine.RegisterData(KeyMinGiftsTable, "FieldGifts");
            ReportingEngine.RegisterData(ReportDs.AAccount, "a_account");
            ReportingEngine.RegisterData(ReportDs.ACostCentre, "a_costCentre");
            ReportingEngine.RegisterData(ReportDs.ATransaction, "a_transaction");

            Boolean HasData = (ReportDs.ATransaction.Rows.Count > 0) || (GiftsTable.Rows.Count > 0);

            if (!HasData)
            {
                MessageBox.Show(Catalog.GetString("No Transactions found for selected Cost Centres."), "HOSA");
            }

            return HasData;
        }
        /// <summary>
        /// Print out the Motivation Details using FastReports template.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilePrint(object sender, EventArgs e)
        {
            FastReportsWrapper ReportingEngine = new FastReportsWrapper("Motivation Details");

            if (!ReportingEngine.LoadedOK)
            {
                ReportingEngine.ShowErrorPopup();
                return;
            }

            ReportingEngine.RegisterData(FMainDS.AMotivationDetail, "MotivationDetail");
            TRptCalculator Calc = new TRptCalculator();
            ALedgerRow LedgerRow = FMainDS.ALedger[0];
            Calc.AddParameter("param_ledger_number_i", LedgerRow.LedgerNumber);
            Calc.AddStringParameter("param_ledger_name", LedgerRow.LedgerName);

            if (ModifierKeys.HasFlag(Keys.Control))
            {
                ReportingEngine.DesignReport(Calc);
            }
            else
            {
                ReportingEngine.GenerateReport(Calc);
            }
        }