private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            ACalc.AddParameter("param_ledger_number_i", FLedgerNumber);
            ACalc.AddParameter("param_recipientkey", txtRecipient.Text);
            ACalc.AddParameter("param_extract_name", txtExtract.Text);

            if (dtpToDate.Date.HasValue)
            {
                Int32 ToDateYear = dtpToDate.Date.Value.Year;
                //TODO: Calendar vs Financial Date Handling - Confirm that these should not be ledger dates, i.e. allowing for >12 periods and non-calendar period boundaries
                DateTime FromDateThisYear = new DateTime(ToDateYear, 1, 1);
                DateTime ToDatePreviousYear = new DateTime(ToDateYear - 1, 12, 31);
                DateTime FromDatePreviousYear = new DateTime(ToDateYear - 1, 1, 1);

                ACalc.AddParameter("param_from_date_this_year", FromDateThisYear);
                ACalc.AddParameter("param_to_date_previous_year", ToDatePreviousYear);
                ACalc.AddParameter("param_from_date_previous_year", FromDatePreviousYear);
            }

            int MaxColumns = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt();

            for (int Counter = 0; Counter <= MaxColumns; ++Counter)
            {
                String ColumnName = ACalc.GetParameters().Get("param_calculation", Counter, 0).ToString();

                if (ColumnName == "Gift Amount")
                {
                    ACalc.AddParameter("param_gift_amount_column", Counter);
                }
            }
        }
        private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            if ((AReportAction == TReportActionEnum.raGenerate)
                && (dtpFromDate.Date > dtpToDate.Date))
            {
                TVerificationResult VerificationResult = new TVerificationResult(
                    Catalog.GetString("From date is later than to date."),
                    Catalog.GetString("Please change from date or to date."),
                    TResultSeverity.Resv_Critical);
                FPetraUtilsObject.AddVerificationResult(VerificationResult);
            }

            ACalc.AddParameter("param_currency", "Base");
            ACalc.AddParameter("param_ledger_number_i", FLedgerNumber);
            // Set the values for accumulating the costs to 0
            ACalc.AddParameter("CostCentreCredit", 0);
            ACalc.AddParameter("CostCentreDebit", 0);
            ACalc.AddParameter("AccountCodeCredit", 0);
            ACalc.AddParameter("AccountCodeDebit", 0);
            ACalc.AddParameter("TotalCredit", 0);
            ACalc.AddParameter("TotalDebit", 0);

            int MaxColumns = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt();

            // we need to know some indices of the columns
            for (int Counter = 0; Counter < MaxColumns; ++Counter)
            {
                String ColumnName = "param_column_" + ACalc.GetParameters().Get("param_calculation", Counter, 0).ToString();
                ACalc.AddParameter(ColumnName, Counter);
            }
        }
        private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            ACalc.AddParameter("param_ledger_number_i", FLedgerNumber);
            ACalc.AddParameter("param_recipientkey", txtRecipient.Text);
            ACalc.AddParameter("param_extract_name", txtExtract.Text);

            if (dtpToDate.Date.HasValue)
            {
                Int32 ToDateYear = dtpToDate.Date.Value.Year;
                DateTime FromDateThisYear = new DateTime(ToDateYear, 1, 1);
                DateTime ToDatePreviousYear = new DateTime(ToDateYear - 1, 12, 31);
                DateTime FromDatePreviousYear = new DateTime(ToDateYear - 1, 1, 1);

                ACalc.AddParameter("param_from_date_this_year", FromDateThisYear);
                ACalc.AddParameter("param_to_date_previous_year", ToDatePreviousYear);
                ACalc.AddParameter("param_from_date_previous_year", FromDatePreviousYear);
            }

            int MaxColumns = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt();

            for (int Counter = 0; Counter <= MaxColumns; ++Counter)
            {
                String ColumnName = ACalc.GetParameters().Get("param_calculation", Counter, 0).ToString();

                if (ColumnName == "Gift Amount")
                {
                    ACalc.AddParameter("param_gift_amount_column", Counter);
                }
            }
        }
        private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            if ((AReportAction == TReportActionEnum.raGenerate)
                && (dtpFromDate.Date > dtpToDate.Date))
            {
                TVerificationResult VerificationResult = new TVerificationResult(
                    Catalog.GetString("From date is later than to date."),
                    Catalog.GetString("Please change from date or to date."),
                    TResultSeverity.Resv_Critical);
                FPetraUtilsObject.AddVerificationResult(VerificationResult);
            }

            ACalc.AddParameter("param_ledger_number_i", FLedgerNumber);
            ACalc.AddParameter("TransactionCount", 0);
            ACalc.AddParameter("TransactionCountAccount", 0);
            ACalc.AddParameter("SumDebitAccount", 0);
            ACalc.AddParameter("SumCreditAccount", 0);

            int MaxColumns = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt();

            for (int Counter = 0; Counter <= MaxColumns; ++Counter)
            {
                String ColumnName = ACalc.GetParameters().Get("param_calculation", Counter, 0).ToString();

                if (ColumnName == "Debits")
                {
                    ACalc.AddParameter("param_debit_column", Counter);
                }

                if (ColumnName == "Credits")
                {
                    ACalc.AddParameter("param_credit_column", Counter);
                }
            }
        }
        //
        // This will be called if the Fast Reports Wrapper loaded OK.
        // Returns True if the data apparently loaded OK and the report should be printed.
        private bool LoadReportData(TRptCalculator ACalc)
        {
            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.ContainsKey(p.name)))
                {
                    paramsDictionary.Add(p.name, p.value);
                }
            }

            DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("GiftBatchDetail", paramsDictionary);

            if (this.IsDisposed) // There's no cancel function as such - if the user has pressed Esc the form is closed!
            {
                return false;
            }

            if (ReportTable == null)
            {
                FPetraUtilsObject.WriteToStatusBar("Report Cancelled.");
                return false;
            }

            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "GiftBatchDetail");

            //
            // I need to get the name of the current ledger..

            DataTable LedgerNameTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerNameList);
            DataView LedgerView = new DataView(LedgerNameTable);
            LedgerView.RowFilter = "LedgerNumber=" + FLedgerNumber;
            String LedgerName = "";

            if (LedgerView.Count > 0)
            {
                LedgerName = LedgerView[0].Row["LedgerName"].ToString();
            }

            ACalc.AddStringParameter("param_ledger_name", LedgerName);
            ACalc.AddStringParameter("param_linked_partner_cc", ""); // I may want to use this for auto_email, but usually it's unused.

            bool TaxDeductiblePercentageEnabled = Convert.ToBoolean(
                TSystemDefaults.GetSystemDefault(SharedConstants.SYSDEFAULT_TAXDEDUCTIBLEPERCENTAGE, "FALSE"));

            ACalc.AddParameter("param_tax_deductible_pct", TaxDeductiblePercentageEnabled);

            if (ACalc.GetParameters().Exists("param_currency")
                && (ACalc.GetParameters().Get("param_currency").ToString() == Catalog.GetString("Transaction")))
            {
                ACalc.RemoveParameter("param_currency_name");
                ACalc.AddParameter("param_currency_name",
                    TRemote.MFinance.Reporting.WebConnectors.GetTransactionCurrency(FLedgerNumber, Convert.ToInt32(txtBatchNumber.Text)));
            }

            return true;
        }
        //
        // This will be called if the Fast Reports Wrapper loaded OK.
        // Returns True if the data apparently loaded OK and the report should be printed.
        private bool LoadReportData(TRptCalculator ACalc)
        {
            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.ContainsKey(p.name)))
                {
                    paramsDictionary.Add(p.name, p.value);
                }
            }

            String RootCostCentre = "[" + FLedgerNumber + "]";
            paramsDictionary.Add("param_cost_centre_code", new TVariant(RootCostCentre));

            DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("SurplusDeficit", paramsDictionary);

            if (ReportTable == null)
            {
                FPetraUtilsObject.WriteToStatusBar("Report Cancelled.");
                return false;
            }

            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "SurplusDeficit");

            String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(FLedgerNumber);

            ACalc.AddStringParameter("param_ledger_name", LedgerName);

            return true;
        }
        //
        // This will be called if the Fast Reports Wrapper loaded OK.
        // Returns True if the data apparently loaded OK and the report should be printed.
        private bool LoadReportData(TRptCalculator ACalc)
        {
            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.ContainsKey(p.name)))
                {
                    paramsDictionary.Add(p.name, p.value);
                }
            }

            Int32 ParamNestingDepth = 6;
            String DepthOption = paramsDictionary["param_depth"].ToString();

            if (DepthOption == "standard")
            {
                ParamNestingDepth = 3;
            }

            paramsDictionary.Add("param_nesting_depth", new TVariant(ParamNestingDepth));
            String RootCostCentre = "[" + FLedgerNumber + "]";
            paramsDictionary.Add("param_cost_centre_code", new TVariant(RootCostCentre));

            //
            // The table contains extra rows for "headers" and "footers", facilitating the hierarchical printout.

            DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("BalanceSheet", paramsDictionary);

            if (this.IsDisposed)
            {
                return false;
            }

            if (ReportTable == null)
            {
                FPetraUtilsObject.WriteToStatusBar("Report Cancelled.");
                return false;
            }

            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "BalanceSheet");

            //
            // I need to get the name of the current ledger..

            DataTable LedgerNameTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerNameList);
            DataView LedgerView = new DataView(LedgerNameTable);
            LedgerView.RowFilter = "LedgerNumber=" + FLedgerNumber;
            String LedgerName = "";

            if (LedgerView.Count > 0)
            {
                LedgerName = LedgerView[0].Row["LedgerName"].ToString();
            }

            ACalc.AddStringParameter("param_ledger_name", LedgerName);
            return true;
        }
        private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            ACalc.AddParameter("param_ledger_number_i", FLedgerNumber);

            int MaxColumns = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt();

            for (int Counter = 0; Counter <= MaxColumns; ++Counter)
            {
                String ColumnName = ACalc.GetParameters().Get("param_calculation", Counter, 0).ToString();

                if (ColumnName == "Gift Amount")
                {
                    ACalc.AddParameter("param_gift_amount_column", Counter);
                }
            }
        }
        //
        // This will be called if the Fast Reports Wrapper loaded OK.
        // Returns True if the data apparently loaded OK and the report should be printed.
        private bool LoadReportData(TRptCalculator ACalc)
        {
            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.ContainsKey(p.name)))
                {
                    paramsDictionary.Add(p.name, p.value);
                }
            }

            String RootCostCentre = "[" + FLedgerNumber + "]";
            paramsDictionary.Add("param_cost_centre_code", new TVariant(RootCostCentre));

            DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("TrialBalance", paramsDictionary);

            if (ReportTable == null)
            {
                FPetraUtilsObject.WriteToStatusBar("Report Cancelled.");
                return false;
            }

            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "TrialBalance");

            //
            // I need to get the name of the current ledger..

            ALedgerTable LedgerTbl = TRemote.MFinance.AP.WebConnectors.GetLedgerInfo(FLedgerNumber);

            String LedgerName = "";
            Boolean IsClosed = false;

            if (LedgerTbl.Rows.Count > 0)
            {
                ALedgerRow LedgerRow = LedgerTbl[0];
                LedgerName = LedgerRow.LedgerName;
                //
                // I want to tell the user whether the selected period is closed
                // (although they probably know already...)
                Int32 SelPeriod = ACalc.GetParameters().GetParameter("param_end_period_i").value.ToInt32();
                Int32 SelYear = ACalc.GetParameters().GetParameter("param_year_i").value.ToInt32();

                if ((SelYear < LedgerRow.CurrentFinancialYear) || (SelPeriod < LedgerRow.CurrentPeriod))
                {
                    IsClosed = true;
                }
            }

            ACalc.AddStringParameter("param_ledger_name", LedgerName);
            ACalc.AddParameter("param_period_closed", IsClosed);

            return true;
        }
        //
        // This will be called if the Fast Reports Wrapper loaded OK.
        // Returns True if the data apparently loaded OK and the report should be printed.
        private bool LoadReportData(TRptCalculator ACalc)
        {
            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.ContainsKey(p.name)))
                {
                    paramsDictionary.Add(p.name, p.value);
                }
            }

            DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("TotalGiftsThroughField", paramsDictionary);
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "MonthlyGifts");
            return true;
        }
        private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            ACalc.AddParameter("param_ledger_number_i", FLedgerNumber);

            int MaxColumns = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt();

            for (int Counter = 0; Counter <= MaxColumns; ++Counter)
            {
                String ColumnName = ACalc.GetParameters().Get("param_calculation", Counter, 0).ToString();

                if (ColumnName == "Total Gifts")
                {
                    ACalc.AddParameter("param_gift_amount_column", Counter);
                }
            }

            // this parameter is added incorrectly by the generated code
            ACalc.RemoveParameter("param_minimum_amount");
            ACalc.AddParameter("param_minimum_amount", this.txtMinimumAmount.NumberValueDecimal);
        }
        private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            if (AReportAction == TReportActionEnum.raGenerate)
            {
                if (rbtPartner.Checked && (txtDonor.Text == "0000000000"))
                {
                    TVerificationResult VerificationResult = new TVerificationResult(
                        Catalog.GetString("No donor selected."),
                        Catalog.GetString("Please select a donor."),
                        TResultSeverity.Resv_Critical);

                    FPetraUtilsObject.AddVerificationResult(VerificationResult);
                }

                if (rbtExtract.Checked && (txtExtract.Text == ""))
                {
                    TVerificationResult VerificationMessage = new TVerificationResult(
                        Catalog.GetString("Enter an extract name"),
                        Catalog.GetString("No extract name entered!"), TResultSeverity.Resv_Critical);
                    FPetraUtilsObject.AddVerificationResult(VerificationMessage);
                }

                if (txtMinAmount.NumberValueInt > txtMaxAmount.NumberValueInt)
                {
                    TVerificationResult VerificationResult = new TVerificationResult(
                        Catalog.GetString("Gift Limit wrong."),
                        Catalog.GetString("Minimum Amount can't be greater than Maximum Amount."),
                        TResultSeverity.Resv_Critical);
                    FPetraUtilsObject.AddVerificationResult(VerificationResult);
                }

                if (!dtpFromDate.ValidDate() || !dtpToDate.ValidDate())
                {
                    TVerificationResult VerificationResult = new TVerificationResult(
                        Catalog.GetString("Date format problem"),
                        Catalog.GetString("Please check the date entry."),
                        TResultSeverity.Resv_Critical);
                    FPetraUtilsObject.AddVerificationResult(VerificationResult);
                }

                if ((cmbReportType.SelectedItem.ToString() == "Complete")
                    && (dtpFromDate.Date > dtpToDate.Date))
                {
                    TVerificationResult VerificationResult = new TVerificationResult(
                        Catalog.GetString("From date is later than to date."),
                        Catalog.GetString("Please change from date or to date."),
                        TResultSeverity.Resv_Critical);
                    FPetraUtilsObject.AddVerificationResult(VerificationResult);
                }
            }

            ACalc.AddParameter("param_ledger_number_i", FLedgerNumber);
            ACalc.AddParameter("param_donorkey", txtDonor.Text);
            ACalc.AddParameter("param_extract_name", txtExtract.Text);

            //TODO: Calendar vs Financial Date Handling - Confirm that these should not be ledger dates, i.e. allowing for >12 periods and non-calendar period boundaries
            DateTime FromDateThisYear = new DateTime(DateTime.Today.Year, 1, 1);
            DateTime ToDatePreviousYear = new DateTime(DateTime.Today.Year - 1, 12, 31);
            DateTime FromDatePreviousYear = new DateTime(DateTime.Today.Year - 1, 1, 1);

            ACalc.AddParameter("param_end_date_this_year", DateTime.Today);
            ACalc.AddParameter("param_start_date_this_year", FromDateThisYear);
            ACalc.AddParameter("param_end_date_previous_year", ToDatePreviousYear);
            ACalc.AddParameter("param_start_date_previous_year", FromDatePreviousYear);

            if (cmbReportType.SelectedItem.ToString() == "Totals")
            {
                DateTime FromDate = new DateTime(DateTime.Today.Year - 3, 1, 1);
                ACalc.RemoveParameter("param_from_date");
                ACalc.RemoveParameter("param_to_date");
                ACalc.AddParameter("param_from_date", FromDate);
                ACalc.AddParameter("param_to_date", DateTime.Today);

                ACalc.AddParameter("Month0", 1);
                ACalc.AddParameter("Month1", 2);
                ACalc.AddParameter("Year0", DateTime.Today.Year);
                ACalc.AddParameter("Year1", DateTime.Today.Year - 1);
                ACalc.AddParameter("Year2", DateTime.Today.Year - 2);
                ACalc.AddParameter("Year3", DateTime.Today.Year - 3);

                int ColumnCounter = 0;
                ACalc.AddParameter("param_calculation", "Month", ColumnCounter);
                ACalc.AddParameter("ColumnWidth", (float)3.0, ColumnCounter);
                ++ColumnCounter;
                ACalc.AddParameter("param_calculation", "Year-0", ColumnCounter);
                ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter);
                ++ColumnCounter;
                ACalc.AddParameter("param_calculation", "Count-0", ColumnCounter);
                ACalc.AddParameter("ColumnWidth", (float)0.8, ColumnCounter);
                ++ColumnCounter;
                ACalc.AddParameter("param_calculation", "Year-1", ColumnCounter);
                ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter);
                ++ColumnCounter;
                ACalc.AddParameter("param_calculation", "Count-1", ColumnCounter);
                ACalc.AddParameter("ColumnWidth", (float)0.8, ColumnCounter);
                ++ColumnCounter;
                ACalc.AddParameter("param_calculation", "Year-2", ColumnCounter);
                ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter);
                ++ColumnCounter;
                ACalc.AddParameter("param_calculation", "Count-2", ColumnCounter);
                ACalc.AddParameter("ColumnWidth", (float)0.8, ColumnCounter);
                ++ColumnCounter;
                ACalc.AddParameter("param_calculation", "Year-3", ColumnCounter);
                ACalc.AddParameter("ColumnWidth", (float)2.0, ColumnCounter);
                ++ColumnCounter;
                ACalc.AddParameter("param_calculation", "Count-3", ColumnCounter);
                ACalc.AddParameter("ColumnWidth", (float)0.8, ColumnCounter);
                ++ColumnCounter;
                ACalc.SetMaxDisplayColumns(ColumnCounter);
            }
            else
            {
                int MaxColumns = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt();

                for (int Counter = 0; Counter <= MaxColumns; ++Counter)
                {
                    String ColumnName = ACalc.GetParameters().Get("param_calculation", Counter, 0).ToString();

                    if (ColumnName == "Gift Amount")
                    {
                        ACalc.AddParameter("param_gift_amount_column", Counter);
                    }
                }
            }
        }
        /// <summary>
        /// Adds the selected columns to the calculation.
        /// </summary>
        /// <param name="ACalc"></param>
        /// <param name="AReportAction"></param>
        private void ReadLocalDataLabel(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            ACalc.AddParameter("param_label_type", "partner");
            ACalc.AddParameter("param_labeluse", "Personnel");

// TODO: do we need to cater here for applications as well?
//            ACalc.AddParameter("param_label_type", "application");
//            ACalc.AddParameter("param_labeluse", "LongTermApp,ShortTermApp");

            String SelectedColumns = "";

            DataTable ColumnTable = ACalc.GetParameters().ToDataTable();

            foreach (DataRow Row in ColumnTable.Rows)
            {
                if ((Row["name"].ToString() == "param_calculation")
                    && (Row["level"].ToString() == "-1")
                    && (Row["subreport"].ToString() == "-1")
                    && (Row["value"].ToString().Contains("eString:")))
                {
                    int ColumnIndex = Convert.ToInt32(Row["column"].ToString());

                    int Index = Row["value"].ToString().IndexOf("eString:");

                    String ColumnName = Row["value"].ToString().Substring(Index + 8);

                    if ((ColumnName == "Partner Key")
                        || (ColumnName == "Partner Name"))
                    {
                        // don't add partner key and partner name because these are not data labels
                        continue;
                    }

                    if (ColumnName == "DataLabelColumn")
                    {
                        ColumnName = ACalc.GetParameters().Get("param_label", ColumnIndex, -1, eParameterFit.eExact).ToString();
                    }

                    SelectedColumns = SelectedColumns + ColumnName + ",";

                    double ColumnWidth = ACalc.GetParameters().Get("ColumnWidth", ColumnIndex, -1, eParameterFit.eExact).ToDouble();

                    ACalc.AddParameter("param_calculation", "DataLabelColumn", ColumnIndex);
                    ACalc.AddParameter("ColumnWidth", ColumnWidth, ColumnIndex);
                    ACalc.AddParameter("param_label", ColumnName, ColumnIndex);
                }
            }

            if (SelectedColumns.Length > 0)
            {
                SelectedColumns.Substring(0, SelectedColumns.Length - 1);
            }

            ACalc.AddParameter("param_labels", SelectedColumns);
        }
        private Boolean LoadReportData(TRptCalculator ACalc)
        {
            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.ContainsKey(p.name))
                {
                    paramsDictionary.Add(p.name, p.value);
                }
            }

            // get data for this report
            DataSet ReportDataSet = TRemote.MReporting.WebConnectors.GetRecipientGiftStatementDataSet(paramsDictionary);

            if (TRemote.MReporting.WebConnectors.DataTableGenerationWasCancelled() || this.IsDisposed)
            {
                return false;
            }

            // if no recipients
            if (ReportDataSet.Tables["Recipients"] == null)
            {
                FPetraUtilsObject.WriteToStatusBar("No recipients found for this report period.");
                return false;
            }

            // register datatables with the report
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDataSet.Tables["Recipients"], "Recipients");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDataSet.Tables["RecipientTotals"], "RecipientTotals");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDataSet.Tables["Donors"], "Donors");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDataSet.Tables["DonorAddresses"], "DonorAddresses");

            //
            // My report doesn't need a ledger row - only the name of the ledger. And I need the currency formatter..
            String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(FLedgerNumber);
            ACalc.AddStringParameter("param_ledger_name", LedgerName);
            ACalc.AddStringParameter("param_currency_formatter", "0,0.000");

            Boolean HasData = ReportDataSet.Tables["Recipients"].Rows.Count > 0;

            if (!HasData)
            {
                MessageBox.Show(Catalog.GetString(
                        "No Recipients found."), "Recipient Gift Statement");
            }

            return HasData;
        }
        private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            if ((AReportAction == TReportActionEnum.raGenerate)
                && rbtSelectedFields.Checked
                && (clbFields.GetCheckedStringList().Length == 0))
            {
                TVerificationResult VerificationMessage = new TVerificationResult(
                    Catalog.GetString("Please select at least one field."),
                    Catalog.GetString("No fields selected!"), TResultSeverity.Resv_Critical);
                FPetraUtilsObject.AddVerificationResult(VerificationMessage);
            }

            if ((AReportAction == TReportActionEnum.raGenerate) && (rbtAllFields.Checked))
            {
                ACalc.AddParameter("param_clbFields", this.clbFields.GetAllStringList());
            }

            if ((AReportAction == TReportActionEnum.raGenerate)
                && (dtpFromDate.Date > dtpToDate.Date))
            {
                TVerificationResult VerificationResult = new TVerificationResult(
                    Catalog.GetString("From date is later than to date."),
                    Catalog.GetString("Please change from date or to date."),
                    TResultSeverity.Resv_Critical);
                FPetraUtilsObject.AddVerificationResult(VerificationResult);
            }

            int Years = Convert.ToInt16(txtYears.Text);

            if ((AReportAction == TReportActionEnum.raGenerate)
                && ((Years > 4) || (Years < 1)))
            {
                TVerificationResult VerificationMessage = new TVerificationResult(
                    Catalog.GetString("Set the year range between 1 and 4"),
                    Catalog.GetString("Wrong year range entered"), TResultSeverity.Resv_Critical);
                FPetraUtilsObject.AddVerificationResult(VerificationMessage);
            }

            ACalc.AddParameter("param_ledger_number_i", FLedgerNumber);

            ACalc.AddParameter("Year0", DateTime.Today.Year);
            ACalc.AddParameter("Year1", DateTime.Today.Year - 1);
            ACalc.AddParameter("Year2", DateTime.Today.Year - 2);
            ACalc.AddParameter("Year3", DateTime.Today.Year - 3);

            int MaxColumns = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt();

            for (int Counter = 0; Counter <= MaxColumns; ++Counter)
            {
                String ColumnName = ACalc.GetParameters().Get("param_calculation", Counter, 0).ToString();

                if (ColumnName == "Gift Amount")
                {
                    ACalc.AddParameter("param_gift_amount_column", Counter);
                }
            }
        }
Beispiel #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ACalculator"></param>
        protected void PreviewDetailReport(TRptCalculator ACalculator)
        {
            TFrmPrintPreview printWindow;

            // show a print window with all kinds of output options
            printWindow = new TFrmPrintPreview(this, ACalculator.GetParameters().Get("currentReport").ToString(),
                ACalculator.GetDuration(), ACalculator.GetResults(
                    ), ACalculator.GetParameters(), FWrapColumn, ACalculator);
            this.AddOwnedForm(printWindow);
            printWindow.Owner = this;

            // printWindow.SetPrintChartProcedure(GenerateChart);
            printWindow.ShowDialog();

            // EnableDisableToolbar(true);
        }
        }  // Load Hosa Report Data

        private Boolean LoadStewardshipReportData(TRptCalculator ACalc)
        {
            Dictionary <String, TVariant>paramsDictionary = InitialiseDictionary(ACalc);
            DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("Stewardship", paramsDictionary);

            if (this.IsDisposed)
            {
                return false;
            }

            if (ReportTable == null)
            {
                FPetraUtilsObject.WriteToStatusBar("Report Cancelled.");
                return false;
            }

            MyFastReportsPlugin.RegisterData(ReportTable, "Stewardship");

            Boolean HasData = (ReportTable.Rows.Count > 0);

            if (!HasData)
            {
                FStatusMsg += Catalog.GetString("No Stewardship entries found for selected Run Number.");
            }

            TParameterList Params = ACalc.GetParameters();

            if ((!Params.Get("param_design_template").ToBool())
                && (rbtEmailStewardship.Checked))
            {
                TUC_EmailPreferences.LoadEmailDefaults();
                TSmtpSender EmailSender = new TSmtpSender(
                    TUserDefaults.GetStringDefault("SmtpHost"),
                    TUserDefaults.GetInt16Default("SmtpPort"),
                    TUserDefaults.GetBooleanDefault("SmtpUseSsl"),
                    TUserDefaults.GetStringDefault("SmtpUser"),
                    TUserDefaults.GetStringDefault("SmtpPassword"),
                    "");
                EmailSender.CcEverythingTo = TUserDefaults.GetStringDefault("SmtpCcTo");
                EmailSender.ReplyTo = TUserDefaults.GetStringDefault("SmtpReplyTo");

                if (!EmailSender.FInitOk)
                {
                    FStatusMsg += String.Format(
                        Catalog.GetString(
                            "\r\nFailed to set up the email server.\n    Please check the settings in Preferences / Email.\n    Message returned: \"{0}\""),
                        EmailSender.FErrorStatus
                        );
                    return false;
                }

                String MyCostCentreCode = String.Format("{0:##00}00", FLedgerNumber);
                String PeriodEnd = Params.Get("param_end_date").ToDate().ToString("dd/MM/yyyy");
                Int32 RunNumber = Params.Get("param_cmbICHNumber").ToInt32();
                String CsvAttachment = String.Format("\"{0}\",{1},\"{2}\",{3},\"{4}\",{5}\n", // "OP:1",30/11/2014,\"0200\",09/12/2014,\"USD\",0"

                    "OP:1",                                     // software originator and version ID
                    PeriodEnd,
                    MyCostCentreCode,                           // Field Cost Centre Code
                    DateTime.Now.ToString("dd/MM/yyyy"),
                    FLedgerRow.BaseCurrency,                    // Stewardship Report CSV always in Base Currency
                    RunNumber                                   // Run number
                    );

                foreach (DataRow Row in ReportTable.Rows)
                {
                    CsvAttachment += String.Format("\"{0}\",{1},{2},{3}\n",
                        Row["CostCentreCode"].ToString(),
                        Convert.ToDecimal(Row["Income"]).ToString("0.00", CultureInfo.InvariantCulture),  // Stewardship Report CSV always in Base Currency
                        Convert.ToDecimal(Row["Expense"]).ToString("0.00", CultureInfo.InvariantCulture),
                        Convert.ToDecimal(Row["Xfer"]).ToString("0.00", CultureInfo.InvariantCulture)
                        );
                }

                String EmailBody = TUserDefaults.GetStringDefault("SmtpEmailBody");
                EmailSender.AttachFromStream(new MemoryStream(Encoding.ASCII.GetBytes(CsvAttachment)), "Stewardship_" + MyCostCentreCode + ".csv");
                Boolean SentOk = EmailSender.SendEmail(
                    TUserDefaults.GetStringDefault("SmtpFromAccount"),
                    TUserDefaults.GetStringDefault("SmtpDisplayName"),
                    "*****@*****.**", //[email protected]
                    "Stewardship Report [" + MyCostCentreCode + "] Period end: " + PeriodEnd + " Run#: " + RunNumber,
                    EmailBody);

                if (SentOk)
                {
                    FStatusMsg += Catalog.GetString("\r\nStewardship report emailed to ICH.");
                }
                else
                {
                    FStatusMsg += Catalog.GetString("\r\nFailed to send Stewardship email to ICH.");
                }

                return false;
            }

            return HasData;
        } // Load Stewardship Report Data
Beispiel #18
0
        /// <summary>
        /// Called at the end of GenerateReport
        /// </summary>
        /// <param name="Calculator"></param>
        /// <param name="ACallerForm"></param>
        /// <param name="AReportName"></param>
        /// <param name="AWrapColumn"></param>
        public static void ReportCalculationSuccess(TRptCalculator Calculator, Form ACallerForm, String AReportName, bool AWrapColumn)
        {
            if (TClientSettings.DebugLevel >= TClientSettings.DEBUGLEVEL_REPORTINGDATA)
            {
                Calculator.GetParameters().Save(TClientSettings.PathLog + Path.DirectorySeparatorChar + "debugParameterReturn.xml", true);
                Calculator.GetResults().WriteCSV(
                    Calculator.GetParameters(), TClientSettings.PathLog + Path.DirectorySeparatorChar + "debugResultReturn.csv");
            }

            if (Calculator.GetParameters().Exists("SaveCSVFilename")
                && (Calculator.GetParameters().Get("SaveCSVFilename").ToString().Length > 0))
            {
                Calculator.GetResults().WriteCSV(Calculator.GetParameters(), Calculator.GetParameters().Get("SaveCSVFilename").ToString());
            }

            if (!Calculator.CalculatesExtract)
            {
                // this only needs to be considered when running reports
                if (Calculator.GetParameters().GetOrDefault("OnlySaveCSV", -1, new TVariant(false)).ToBool() == false)
                {
                    PreviewReport(Calculator, ACallerForm, AReportName, AWrapColumn);
                }
            }
        }
        /// <summary>
        /// Called from a delegate set up by me.
        /// Or if you're not using a reporting UI, you can call this directly, once the data and params have been set up.
        /// </summary>
        /// <param name="ACalc"></param>
        public void GenerateReport(TRptCalculator ACalc)
        {
            ACalc.GetParameters().Add("param_design_template", false);

            if (FSelectedTemplate != null)
            {
                if (FDataGetter != null)
                {
                    if (!FDataGetter(ACalc))
                    {
                        return;
                    }
                }

                FFastReportType.GetMethod("LoadFromString", new Type[] { FSelectedTemplate.XmlText.GetType() }).Invoke(FfastReportInstance,
                    new object[] { FSelectedTemplate.XmlText });
                LoadReportParams(ACalc);
                FFastReportType.GetMethod("Show", new Type[0]).Invoke(FfastReportInstance, null);
            }

            if (FPetraUtilsObject != null)
            {
                FPetraUtilsObject.UpdateParentFormEndOfReport();
            }
        }
        /// <summary>
        /// Called from a delegate set up by my constructor.
        /// Or if you're not using a reporting UI, you can call this directly, once the data and params have been set up.
        /// </summary>
        /// <param name="ACalc"></param>
        public void DesignReport(TRptCalculator ACalc)
        {
            ACalc.GetParameters().Add("param_design_template", true);

            if (FSelectedTemplate != null)
            {
                if (FDataGetter != null)
                {
                    if (!FDataGetter(ACalc))
                    {
                        return;
                    }
                }

                FFastReportType.GetMethod("LoadFromString", new Type[] { FSelectedTemplate.XmlText.GetType() }).Invoke(FfastReportInstance,
                    new object[] { FSelectedTemplate.XmlText });

                LoadReportParams(ACalc);
                FFastReportType.GetMethod("Design", new Type[0]).Invoke(FfastReportInstance, null);

                //
                // The user can change the report template - if it's changed I'll update the server
                // (unless the template is read-only, in which case I'll need to make a copy.)
                object ret = FFastReportType.GetMethod("SaveToString", new Type[0]).Invoke(FfastReportInstance, null);
                String XmlString = (String)ret;
                //
                // I only want to check part of the report to assess whether it's changed, otherwise it always detects a change
                // (the modified date is changed, and the parameters may also be different.)

                Boolean TemplateChanged = false;
                Int32 Page1Pos = XmlString.IndexOf("<ReportPage");
                Int32 PrevPage1Pos = FSelectedTemplate.XmlText.IndexOf("<ReportPage");

                if ((Page1Pos < 1) || (PrevPage1Pos < 1))
                {
                    TemplateChanged = true;
                }
                else
                {
                    if (XmlString.Substring(Page1Pos) != FSelectedTemplate.XmlText.Substring(PrevPage1Pos))
                    {
                        TemplateChanged = true;
                    }
                }

                if (TemplateChanged)
                {
                    Boolean MakeACopy = false;

                    if (FSelectedTemplate.Readonly)
                    {
                        if (MessageBox.Show(
                                String.Format(Catalog.GetString("{0} cannot be ovewritten.\r\nMake a copy instead?"), FSelectedTemplate.ReportVariant),
                                Catalog.GetString("Design Template"),
                                MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            return;
                        }

                        MakeACopy = true;
                    }
                    else
                    {
                        if (MessageBox.Show(
                                String.Format(Catalog.GetString("Save changes to {0}?"), FSelectedTemplate.ReportVariant),
                                Catalog.GetString("Design Template"),
                                MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            return;
                        }
                    }

                    SReportTemplateTable TemplateTable = new SReportTemplateTable();
                    SReportTemplateRow NewRow = TemplateTable.NewRowTyped();
                    DataUtilities.CopyAllColumnValues(FSelectedTemplate, NewRow);
                    TemplateTable.Rows.Add(NewRow);

                    if (MakeACopy)
                    {
                        NewRow.TemplateId = -1; // The value will come from the sequence
                        NewRow.ReportVariant = "Copy of " + TemplateTable[0].ReportVariant;
                        NewRow.Readonly = false;
                        NewRow.Default = false;
                        NewRow.PrivateDefault = false;
                    }
                    else
                    {
                        TemplateTable.AcceptChanges(); // Don't allow this one-row table to be seen as "new"
                    }

                    NewRow.XmlText = XmlString;
                    SReportTemplateTable Tbl = TRemote.MReporting.WebConnectors.SaveTemplates(TemplateTable);
                    Tbl.AcceptChanges();
                    SetTemplate(Tbl[0]);
                }
            }

            if (FPetraUtilsObject != null)
            {
                FPetraUtilsObject.UpdateParentFormEndOfReport();
            }
        }
Beispiel #21
0
        /// <summary>
        /// Called after the calculation of the report has been finished.
        /// </summary>
        /// <param name="Calculator"></param>
        /// <param name="ACallerForm"></param>
        /// <param name="AReportName"></param>
        /// <param name="AWrapColumn"></param>
        public static void PreviewReport(TRptCalculator Calculator, Form ACallerForm, String AReportName, bool AWrapColumn)
        {
            // Create a print window with all kinds of output options
            TFrmPrintPreview printWindow = new TFrmPrintPreview(ACallerForm, AReportName, Calculator.GetDuration(),
                Calculator.GetResults(), Calculator.GetParameters(), AWrapColumn, Calculator);

            ACallerForm.AddOwnedForm(printWindow);
            printWindow.Owner = ACallerForm;

// TODO     printWindow.SetPrintChartProcedure(GenerateChart);
            printWindow.ShowDialog();
        }
        private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            ACalc.AddParameter("param_ledger_number_i", FLedgerNumber);

            ACalc.AddParameter("param_all_partners", rbtAllPartners.Checked);
            ACalc.AddParameter("param_extract", rbtExtract.Checked);

            if (rbtExtract.Checked)
            {
                ACalc.AddParameter("param_extract_name", txtExtract.Text);
            }

            if ((AReportAction == TReportActionEnum.raGenerate)
                && rbtExtract.Checked
                && (txtExtract.Text.Length == 0))
            {
                TVerificationResult VerificationResult = new TVerificationResult(
                    Catalog.GetString("No recipient selected."),
                    Catalog.GetString("Please select a recipient."),
                    TResultSeverity.Resv_Critical);

                FPetraUtilsObject.AddVerificationResult(VerificationResult);
            }

            int MaxColumns = ACalc.GetParameters().Get("MaxDisplayColumns").ToInt();

            for (int Counter = 0; Counter <= MaxColumns; ++Counter)
            {
                String ColumnName = ACalc.GetParameters().Get("param_calculation", Counter, 0).ToString();

                if (ColumnName == "Total Given")
                {
                    ACalc.AddParameter("param_gift_amount_column", Counter);
                }
            }
        }
        private void LoadReportParams(TRptCalculator ACalc)
        {
            // Add standard parameters for the report header
            ACalc.GetParameters().Add("param_requested_by", UserInfo.GUserInfo.UserID);
            Version ClientVersion = Assembly.GetAssembly(typeof(FastReportsWrapper)).GetName().Version;
            ACalc.GetParameters().Add("param_version", ClientVersion.Major.ToString() + "." +
                ClientVersion.Minor.ToString() + "." +
                ClientVersion.Build.ToString() + "." +
                ClientVersion.Revision.ToString());
            ArrayList reportParam = ACalc.GetParameters().Elems;
            MethodInfo FastReport_SetParameterValue = FFastReportType.GetMethod("SetParameterValue");

            foreach (Shared.MReporting.TParameter p in reportParam)
            {
                if (p.name.StartsWith("param") && (p.name != "param_calculation"))
                {
                    FastReport_SetParameterValue.Invoke(FfastReportInstance, new object[] { p.name, p.value.ToObject() });
                }
            }
        }
        //
        // This will be called if the Fast Reports Wrapper loaded OK.
        // Returns True if the data apparently loaded OK and the report should be printed.
        private bool LoadReportData(TRptCalculator ACalc)
        {
            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.ContainsKey(p.name)))
                {
                    paramsDictionary.Add(p.name, p.value);
                }
            }

            Int32 ParamNestingDepth = 99;
            String DepthOption = paramsDictionary["param_depth"].ToString();

            if (DepthOption == "Summary")
            {
                ParamNestingDepth = 2;
            }

            if (DepthOption == "Standard")
            {
                ParamNestingDepth = 3;
            }

            paramsDictionary.Add("param_nesting_depth", new TVariant(ParamNestingDepth));


            //
            // The table contains Actual and Budget figures, both this period and YTD, also last year and budget last year.
            // It does not contain any variance (actual / budget) figures - these are calculated in the report.

            DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("IncomeExpense", paramsDictionary);

            if (this.IsDisposed) // There's no cancel function as such - if the user has pressed Esc the form is closed!
            {
                return false;
            }

            if (ReportTable == null)
            {
                FPetraUtilsObject.WriteToStatusBar("Report Cancelled.");
                return false;
            }

            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "IncomeExpense");

            //
            // I need to get the name of the current ledger..

            DataTable LedgerNameTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerNameList);
            DataView LedgerView = new DataView(LedgerNameTable);
            LedgerView.RowFilter = "LedgerNumber=" + FLedgerNumber;
            String LedgerName = "";

            if (LedgerView.Count > 0)
            {
                LedgerName = LedgerView[0].Row["LedgerName"].ToString();
            }

            ACalc.AddStringParameter("param_ledger_name", LedgerName);
            ACalc.AddStringParameter("param_linked_partner_cc", ""); // I may want to use this for auto_email, but usually it's unused.

            //
            // For reports that must be sent on email, one page at a time,
            // I'm calling the FastReports plugin multiple times,
            // and then I'm going to return false, which will prevent the default action using this dataset.

            Shared.MReporting.TParameterList pm = ACalc.GetParameters();

            if ((pm.Get("param_auto_email").ToBool())
                && !pm.Get("param_design_template").ToBool()
                )
            {
                String CostCentreFilter = "";
                String CostCentreOptions = pm.Get("param_costcentreoptions").ToString();

                if (CostCentreOptions == "SelectedCostCentres")
                {
                    String CostCentreList = pm.Get("param_cost_centre_codes").ToString();
                    CostCentreList = CostCentreList.Replace(",", "','");                             // SQL IN List items in single quotes
                    CostCentreFilter = " AND a_cost_centre_code_c in ('" + CostCentreList + "')";
                }

                if (CostCentreOptions == "CostCentreRange")
                {
                    CostCentreFilter = " AND a_cost_centre_code_c >='" + pm.Get("param_cost_centre_code_start").ToString() +
                                       "' AND a_cost_centre_code_c >='" + pm.Get("param_cost_centre_code_end").ToString() + "'";
                }

                String Status = FastReportsWrapper.AutoEmailReports(FPetraUtilsObject,
                    FPetraUtilsObject.FFastReportsPlugin,
                    ACalc,
                    FLedgerNumber,
                    CostCentreFilter);
                MessageBox.Show(Status, Catalog.GetString("Income Expense Report"));
                return false;
            }

            return true;
        }
        private void LoadReportParams(TRptCalculator ACalc)
        {
            // Add standard parameters for the report header
            ACalc.GetParameters().Add("param_requested_by", UserInfo.GUserInfo.UserID);
            Version ClientVersion = Assembly.GetAssembly(typeof(FastReportsWrapper)).GetName().Version;
            ACalc.GetParameters().Add("param_version", ClientVersion.Major.ToString() + "." +
                ClientVersion.Minor.ToString() + "." +
                ClientVersion.Build.ToString() + "." +
                ClientVersion.Revision.ToString());
            //
            // Some params are always provided for reports:
            bool TaxDeductiblePercentageEnabled = Convert.ToBoolean(
                TSystemDefaults.GetSystemDefault(SharedConstants.SYSDEFAULT_TAXDEDUCTIBLEPERCENTAGE, "FALSE"));

            ACalc.AddParameter("param_tax_deductible_pct", TaxDeductiblePercentageEnabled);


            ArrayList reportParam = ACalc.GetParameters().Elems;
            MethodInfo FastReport_SetParameterValue = FFastReportType.GetMethod("SetParameterValue");

            foreach (Shared.MReporting.TParameter p in reportParam)
            {
                if (p.name.StartsWith("param") && (p.name != "param_calculation"))
                {
                    FastReport_SetParameterValue.Invoke(FfastReportInstance, new object[] { p.name, p.value.ToObject() });
                }
            }
        }
        //
        // New methods using the Fast-reports DLL:

        private Boolean LoadReportData(TRptCalculator ACalc)
        {
            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 ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("RecipientTaxDeductPct", paramsDictionary);

            if (ReportTable == null)
            {
                FPetraUtilsObject.WriteToStatusBar("Report Cancelled.");
                return false;
            }

            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "RecipientTaxDeductPct");
            //
            // My report doesn't need a ledger row - only the name of the ledger. And I need the currency formatter..
            String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(FLedgerNumber);
            ACalc.AddStringParameter("param_ledger_name", LedgerName);
            ACalc.AddStringParameter("param_currency_formatter", "0,0.000");

            Boolean HasData = ReportTable.Rows.Count > 0;

            if (!HasData)
            {
                MessageBox.Show(Catalog.GetString(
                        "No Recipient Tax Deductible Percentages found for current Ledger."), "Recipient Tax Deductible Percentages");
            }

            return HasData;
        }
        /// <summary>
        /// Called from a delegate set up by me.
        /// </summary>
        /// <param name="ACalc"></param>
        public void GenerateExtract(TRptCalculator ACalc)
        {
            ACalc.GetParameters().Add("param_design_template", false);

            if (FDataGetter == null)
            {
                MessageBox.Show(Catalog.GetString("Fault: No Data Table available."), Catalog.GetString("GenerateExtract"));
                return;
            }

            if (!FDataGetter(ACalc))
            {
                return;
            }

            FExtractPartnerKeyName = SelectColumnNameForExract(FClientDataTable, FExtractPartnerKeyName);

            if (FExtractPartnerKeyName == "")
            {
                return;
            }

            Int32 partnerKeyColumnNum = FClientDataTable.Columns[FExtractPartnerKeyName].Ordinal;

            TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(FPetraUtilsObject.GetForm());
            string ExtractName;
            string ExtractDescription;

            ExtractNameDialog.ShowDialog();

            if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel)
            {
                /* Get values from the Dialog */
                ExtractNameDialog.GetReturnedParameters(out ExtractName, out ExtractDescription);
            }
            else
            {
                // dialog was cancelled, do not continue with extract generation
                return;
            }

            ExtractNameDialog.Dispose();

            FPetraUtilsObject.GetForm().UseWaitCursor = true;

            // Create extract with given name and description and store it
            int ExtractId = 0;
            IPartnerUIConnectorsPartnerNewExtract PartnerExtractObject = TRemote.MPartner.Extracts.UIConnectors.PartnerNewExtract();
            Boolean CreateOk = PartnerExtractObject.CreateExtractFromListOfPartnerKeys(
                ExtractName, ExtractDescription, out ExtractId, FClientDataTable, partnerKeyColumnNum, false);
            FPetraUtilsObject.GetForm().UseWaitCursor = false;

            if (CreateOk)
            {
                MessageBox.Show(String.Format(Catalog.GetString("Extract Created with {0} Partners."),
                        FClientDataTable.Rows.Count),
                    Catalog.GetString("Generate Extract"));
            }
            else
            {
                MessageBox.Show(Catalog.GetString("Creation of extract failed"),
                    Catalog.GetString("Generate Extract"),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Stop);
            }
        }
        private Dictionary <String, TVariant>InitialiseDictionary(TRptCalculator ACalc)
        {
            Shared.MReporting.TParameterList pm = ACalc.GetParameters();
            pm.Add("param_ledger_number_i", FLedgerNumber);
            String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(FLedgerNumber);
            ACalc.AddStringParameter("param_ledger_name", LedgerName);
            ACalc.AddParameter("param_currency_name", FLedgerRow.BaseCurrency); // Stewardship reports are always in Base Currency.

            ACalc.AddStringParameter("param_currency_formatter", "0,0.000");
            ACalc.AddParameter("param_ich_number", pm.Get("param_cmbICHNumber").ToInt32());
            ACalc.AddParameter("param_period", true);

            Int32 period = pm.Get("param_cmbReportPeriod").ToInt32();
            Int32 PeriodStart = Math.Max(1, period);
            Int32 PeriodEnd = period;

            if (PeriodEnd == 0)
            {
                PeriodEnd = TFinanceControls.GetLedgerNumPeriods(FLedgerNumber);
            }

            Int32 Year = pm.Get("param_cmbYearEnding").ToInt32();

            ACalc.AddParameter("param_start_period_i", PeriodStart);
            ACalc.AddParameter("param_end_period_i", PeriodEnd);
            DateTime StartDate = TRemote.MFinance.GL.WebConnectors.GetPeriodStartDate(FLedgerNumber, Year, 0, PeriodStart);
            DateTime EndDate = TRemote.MFinance.GL.WebConnectors.GetPeriodEndDate(FLedgerNumber, Year, 0, PeriodEnd);
            ACalc.AddParameter("param_real_year", StartDate.Year);
            ACalc.AddParameter("param_start_date", StartDate);
            ACalc.AddParameter("param_end_date", EndDate);
            ACalc.AddParameter("param_current_financial_year", FLedgerRow.CurrentFinancialYear == Year);
            Boolean IsClosed = (Year < FLedgerRow.CurrentFinancialYear) || (PeriodEnd < FLedgerRow.CurrentPeriod);
            ACalc.AddParameter("param_period_closed", IsClosed);
            Boolean IsCurrent = (Year == FLedgerRow.CurrentFinancialYear) && (PeriodEnd == FLedgerRow.CurrentPeriod);
            ACalc.AddParameter("param_period_current", IsCurrent);
            ACalc.AddParameter("param_year_i", Year);
            ArrayList reportParam = pm.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);
                }
            }

            return paramsDictionary;
        } // Initialise Dictionary
Beispiel #29
0
        //
        // New methods using the Fast-reports DLL:

        private Boolean LoadReportData(TRptCalculator ACalc)
        {
            Shared.MReporting.TParameterList pm = ACalc.GetParameters();

            pm.RemoveVariable("param_start_period_i");
            pm.Add("param_start_period_i", 1);
            pm.Add("param_current_period", uco_GeneralSettings.GetCurrentPeiod());

            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 ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("AFO", paramsDictionary);

            if (ReportTable == null)
            {
                FPetraUtilsObject.WriteToStatusBar("Report Cancelled.");
                return false;
            }

            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "Accounts");
            //
            // My report doesn't need a ledger row - only the name of the ledger. And I need the currency formatter..
            String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(FLedgerNumber);
            ACalc.AddStringParameter("param_ledger_name", LedgerName);
            ACalc.AddStringParameter("param_currency_formatter", "0,0.000");
            ACalc.AddStringParameter("param_base_currency", uco_GeneralSettings.GetBaseCurrency());
            ACalc.AddStringParameter("param_intl_currency", uco_GeneralSettings.GetInternationalCurrency());

            Boolean HasData = ReportTable.Rows.Count > 0;

            if (!HasData)
            {
                MessageBox.Show(Catalog.GetString("No Summary Accounts found for current Ledger."), "AFO");
            }

            return HasData;
        }
        } // Initialise Dictionary

        private Boolean LoadHosaReportData(TRptCalculator ACalc)
        {
            InitialiseDictionary(ACalc);
            ACalc.AddStringParameter("param_cost_centre_codes", "ALL");
            ACalc.AddStringParameter("param_filter_cost_centres", "");
            ACalc.AddStringParameter("param_linked_partner_cc", ""); // Used for auto-emailing HOSAs, this is usually blank.
            ACalc.AddParameter("param_include_rgs", !chkRecipient.Enabled || chkRecipient.Checked);
            Boolean DataOk = TFrmHOSA.LoadReportDataStaticInner(this, FPetraUtilsObject, MyFastReportsPlugin, ACalc);

            if ((!ACalc.GetParameters().Get("param_design_template").ToBool())
                && (rbtEmailHosa.Checked))
            {
                ACalc.AddStringParameter("param_currency", "Base"); // Always email HOSAs in Base Currency
                FStatusMsg += FastReportsWrapper.AutoEmailReports(FPetraUtilsObject, MyFastReportsPlugin, ACalc, FLedgerNumber, "Foreign");
                return false;
            }

            return DataOk;
        }  // Load Hosa Report Data