Example #1
0
        private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            ACalc.AddParameter("param_ledger_number_i", FLedgerNumber);
            ACalc.AddColumnLayout(0, 8, 0, 3);
            ACalc.AddColumnLayout(1, 11, 0, 3);
            ACalc.AddColumnLayout(2, 14, 0, 7);
            ACalc.SetMaxDisplayColumns(3);
            ACalc.AddColumnCalculation(0, "Debit");
            ACalc.AddColumnCalculation(1, "Credit");
            ACalc.AddColumnCalculation(2, "Transaction Narrative");
            ACalc.AddParameter("param_daterange", "false");
            ACalc.AddParameter("param_rgrAccounts", "AllAccounts");
            ACalc.AddParameter("param_rgrCostCentres", "CostCentreList");
            // TODO need to allow to specify an ICH run number
            ACalc.AddParameter("param_ich_number", 0);
            ACalc.AddParameter("param_include_rgs", false);

            ACalc.AddStringParameter("param_cost_centre_codes", clbCostCentres.GetCheckedStringList(true));
        }
Example #2
0
        /// <summary>
        /// Called after MonthEnd. No GUI will be displayed.
        /// </summary>
        public void PrintPeriodEndReport(Int32 ALedgerNumber, Boolean AMonthMode)
        {
            LedgerNumber = ALedgerNumber;
            TRptCalculator Calc   = new TRptCalculator();
            ALedgerRow     Ledger =
                ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, ALedgerNumber))[0];

            int currentPeriod = Ledger.CurrentPeriod;

            Calc.AddParameter("param_ledger_number_i", ALedgerNumber);
            Calc.AddParameter("param_current_period", currentPeriod);
            Calc.AddParameter("param_period", true);
            Calc.AddParameter("param_current_financial_year", true);
            Calc.AddStringParameter("param_rgrAccounts", "All");
            Calc.AddStringParameter("param_rgrCostCentres", "All");
            Calc.AddStringParameter("param_account_list_title", "All Accounts");
            Calc.AddStringParameter("param_cost_centre_list_title", "All Cost Centres");

            Calc.AddParameter("param_year_i", Ledger.CurrentFinancialYear);
            Calc.AddParameter("param_start_period_i", currentPeriod - 1);
            Calc.AddParameter("param_end_period_i", currentPeriod - 1);
            DateTime startDate = TRemote.MFinance.GL.WebConnectors.GetPeriodStartDate(
                ALedgerNumber, Ledger.CurrentFinancialYear, -1, currentPeriod);

            Calc.AddParameter("param_start_date", new TVariant(startDate));
            DateTime endDate = TRemote.MFinance.GL.WebConnectors.GetPeriodEndDate(
                ALedgerNumber, Ledger.CurrentFinancialYear, -1, currentPeriod);

            Calc.AddParameter("param_end_date", new TVariant(endDate));

            Calc.AddStringParameter("param_sortby", "Account");
            Calc.AddStringParameter("param_currency", "Base");
            Calc.AddStringParameter("param_currency_name", Ledger.BaseCurrency);

            Calc.AddParameter("param_paginate", false);
            Calc.AddParameter("param_auto_email", false);
            Calc.AddParameter("param_with_analysis_attributes", false);

            FPetraUtilsObject.FFastReportsPlugin.GenerateReport(Calc);
        }
Example #3
0
        /// <summary>
        /// read the values from the controls and give them to the calculator
        /// </summary>
        /// <param name="ACalculator"></param>
        /// <param name="AReportAction"></param>
        public void ReadControls(TRptCalculator ACalculator, TReportActionEnum AReportAction)
        {
            if (rbtConference.Checked)
            {
                ACalculator.AddParameter("param_conferenceselection", "one conference");
            }
            else if (rbtAllConferences.Checked)
            {
                ACalculator.AddParameter("param_conferenceselection", "all conferences");
            }

            if (rbtAllAttendees.Checked)
            {
                ACalculator.AddParameter("param_attendeeselection", "all attendees");
            }
            else if (rbtExtract.Checked)
            {
                ACalculator.AddParameter("param_attendeeselection", "from extract");
            }
            else if (rbtOneAttendee.Checked)
            {
                ACalculator.AddParameter("param_attendeeselection", "one attendee");
            }

            ACalculator.AddParameter("param_partnerkey", txtOneAttendee.Text);
            ACalculator.AddParameter("param_conferencekey", txtConference.Text);
            ACalculator.AddParameter("param_conferencename", txtConference.LabelText);
            ACalculator.AddParameter("param_extractname", txtExtract.Text);

            TVerificationResult VerificationResult;

            if ((AReportAction == TReportActionEnum.raGenerate) &&
                (rbtExtract.Checked) &&
                (txtExtract.Text.Length == 0))
            {
                VerificationResult = new TVerificationResult(Catalog.GetString("Select an extract for running the report."),
                                                             Catalog.GetString("No extract was selected!"),
                                                             TResultSeverity.Resv_Critical);
                FPetraUtilsObject.AddVerificationResult(VerificationResult);
            }

            if ((AReportAction == TReportActionEnum.raGenerate) &&
                (rbtOneAttendee.Checked) &&
                (txtOneAttendee.Text == "0000000000"))
            {
                VerificationResult = new TVerificationResult(Catalog.GetString("Select a partner for whom to run the report."),
                                                             Catalog.GetString("No partner was selected!"),
                                                             TResultSeverity.Resv_Critical);
                FPetraUtilsObject.AddVerificationResult(VerificationResult);
            }

            if ((AReportAction == TReportActionEnum.raGenerate) &&
                (rbtConference.Checked) &&
                (txtConference.Text == "0000000000"))
            {
                VerificationResult = new TVerificationResult(Catalog.GetString("Select a conference to run the report against to."),
                                                             Catalog.GetString("No conference was selected!"),
                                                             TResultSeverity.Resv_Critical);
                FPetraUtilsObject.AddVerificationResult(VerificationResult);
            }

            if (FShowSelectOutreachOptionsDialog &&
                (AReportAction == TReportActionEnum.raGenerate) &&
                (rbtConference.Checked) &&
                (FPetraUtilsObject.GetVerificationResultCount() == 0))
            {
                List <KeyValuePair <long, string> > ConferenceList;
                DialogResult DlgResult = TFrmSelectOutreachOption.OpenSelectOutreachOptionDialog(
                    Convert.ToInt64(txtConference.Text), FPetraUtilsObject.GetForm(), true, out ConferenceList);

                if (((DlgResult != DialogResult.OK) || (ConferenceList.Count == 0)) &&
                    (DlgResult != DialogResult.None))
                {
                    VerificationResult = new TVerificationResult(
                        Catalog.GetString("You must chose at least one outreach option from the \"Select Outreach Option\" Dialog."),
                        Catalog.GetString("No outreach option was selected!"),
                        TResultSeverity.Resv_Critical);
                    FPetraUtilsObject.AddVerificationResult(VerificationResult);
                }

                string OutreachOptions     = "";
                string OutreachOptionsCode = "";

                foreach (KeyValuePair <long, string> OutreachOption in ConferenceList)
                {
                    OutreachOptions     = OutreachOptions + OutreachOption.Key.ToString() + ",";
                    OutreachOptionsCode = OutreachOptionsCode + OutreachOption.Value + ",";
                }

                if (OutreachOptions.Length > 0)
                {
                    // Remove the last comma
                    OutreachOptions     = OutreachOptions.Remove(OutreachOptions.Length - 1);
                    OutreachOptionsCode = OutreachOptionsCode.Remove(OutreachOptionsCode.Length - 1);
                }
                else
                {
                    OutreachOptions     = txtConference.Text;
                    OutreachOptionsCode = txtConference.LabelText;
                }

                ACalculator.AddStringParameter("param_conferenceoptions", OutreachOptions);
                ACalculator.AddParameter("param_conferenceoptionscode", OutreachOptionsCode);
            }
        }
        /// <summary>
        /// Reads the selected values from the controls,
        /// and stores them into the parameter system of FCalculator
        ///
        /// </summary>
        /// <param name="ACalculator"></param>
        /// <param name="AReportAction"></param>
        /// <returns>void</returns>
        public void ReadControls(TRptCalculator ACalculator, TReportActionEnum AReportAction)
        {
            if (rbtSelectedCostCentres.Checked &&
                (clbCostCentres.GetCheckedStringList().Length == 0) &&
                (AReportAction == TReportActionEnum.raGenerate))
            {
                TVerificationResult VerificationResult = new TVerificationResult(Catalog.GetString("Selected Cost Centres"),
                                                                                 Catalog.GetString("No cost centre was selected!"),
                                                                                 TResultSeverity.Resv_Critical);
                FPetraUtilsObject.AddVerificationResult(VerificationResult);
            }

            /* cost centre options */
            if (rbtAccountLevel.Checked)
            {
                ACalculator.AddParameter("param_costcentreoptions", "AccountLevel");
            }
            else if (rbtAllCostCentres.Checked)
            {
                ACalculator.AddParameter("param_costcentreoptions", "AllCostCentres");
            }
            else if (rbtAllActiveCostCentres.Checked)
            {
                ACalculator.AddParameter("param_costcentreoptions", "AllActiveCostCentres");
            }
            else if (rbtSelectedCostCentres.Checked)
            {
                ACalculator.AddParameter("param_costcentreoptions", "SelectedCostCentres");
            }

            ACalculator.AddParameter("param_paginate", chkPaginate.Checked);
            ACalculator.AddParameter("param_auto_email", chkAutoEmail.Checked);

            String CostCentreListTitle;

            if (rbtAllCostCentres.Checked || rbtAllActiveCostCentres.Checked)
            {
                CostCentreListTitle = clbCostCentres.GetAllStringList();
            }
            else
            {
                CostCentreListTitle = clbCostCentres.GetCheckedStringList();
            }

            ACalculator.AddStringParameter("param_cost_centre_codes", CostCentreListTitle);
            CostCentreListTitle = CostCentreListTitle.Replace("\"", "");

            if (CostCentreListTitle.Length > 25)
            {
                CostCentreListTitle = "Selected Cost Centres";
            }

            ACalculator.AddParameter("param_cost_centre_list_title", CostCentreListTitle);

            ACalculator.AddParameter("param_cost_centre_summary", chkCostCentreBreakdown.Checked);
            ACalculator.AddParameter("param_cost_centre_breakdown", chkCostCentreBreakdown.Checked);
            ACalculator.AddParameter("ExcludeInactiveCostCentres", chkExcludeInactiveCostCentres.Checked);

            /* Level of Detail */
            if (this.rbtDetail.Checked)
            {
                ACalculator.AddParameter("param_depth", "detail");
            }
            else if (this.rbtStandard.Checked)
            {
                ACalculator.AddParameter("param_depth", "standard");
            }
            else
            {
                ACalculator.AddParameter("param_depth", "summary");
            }
        }
        //
        // 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)
        {
            ACurrencyRow CurrencyRow;
            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);
                }
            }

            DataSet ReportSet = TRemote.MReporting.WebConnectors.GetReportDataSet("GiftsOverMinimum", paramsDictionary);

            if (this.IsDisposed)
            {
                return(false);
            }

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

            //
            // I need to get the name of the current ledger..
            ALedgerRow LedgerDetailsRow = (ALedgerRow)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails,
                                                                                                    FLedgerNumber).Rows[0];

            //
            // The ledger's name is stored in its partner record, not in its ledger record. Sigh.
            if (LedgerDetailsRow.LedgerName == "")
            {
                DataTable LedgerNameTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerNameList);
                DataView  LedgerView      = new DataView(LedgerNameTable);
                LedgerView.RowFilter = "LedgerNumber=" + FLedgerNumber;

                if (LedgerView.Count > 0)
                {
                    ACalc.AddStringParameter("param_ledger_name", LedgerView[0].Row["LedgerName"].ToString());
                }
            }
            else
            {
                ACalc.AddStringParameter("param_ledger_name", LedgerDetailsRow.LedgerName);
            }

            switch (ACalc.GetParameters().Get("param_currency").ToString())
            {
            case "Base":
                ACalc.AddStringParameter("param_currency_code", LedgerDetailsRow.BaseCurrency);
                CurrencyRow = (ACurrencyRow)TDataCache.TMCommon.GetCacheableCommonTable(TCacheableCommonTablesEnum.CurrencyCodeList).Rows.Find(
                    LedgerDetailsRow.BaseCurrency);
                ACalc.AddStringParameter("param_currency_format", CurrencyRow.DisplayFormat);
                break;

            case "International":
                ACalc.AddStringParameter("param_currency_code", LedgerDetailsRow.IntlCurrency);
                CurrencyRow = (ACurrencyRow)TDataCache.TMCommon.GetCacheableCommonTable(TCacheableCommonTablesEnum.CurrencyCodeList).Rows.Find(
                    LedgerDetailsRow.IntlCurrency);
                ACalc.AddStringParameter("param_currency_format", CurrencyRow.DisplayFormat);
                break;

            default:
                ACalc.AddStringParameter("param_currency_code", "Unknown");
                ACalc.AddStringParameter("param_currency_format", "->>>,>>>,>>>,>>9.99");
                break;
            }

            //Uncomment this to log the parameter list:
            //foreach (Shared.MReporting.TParameter p in reportParam)
            //{
            //    TLogWriter.Log(p.name.ToString() + " => " + p.value.ToString());
            //}
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportSet.Tables["Donors"], "Donors");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportSet.Tables["Contacts"], "Contacts");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportSet.Tables["GiftsOverMinimum"], "GiftsOverMinimum");

            return(true);
        }
Example #6
0
        //
        // New methods using the Fast-reports DLL:

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

            pm.Add("param_current_period", uco_GeneralSettings.GetCurrentPeiod());

            // 0 = Full Report. Currently the only option for this report.
            pm.Add("param_run_number", 0);

            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);
            }

            CostCentreCodes = CostCentreCodes.Replace('"', '\'');
            ACalc.AddStringParameter("param_cost_centre_codes", CostCentreCodes);

            if (pm.Get("param_period").ToBool() == true)
            {
                DataTable AccountingPeriodTbl =
                    (AAccountingPeriodTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountingPeriodList,
                                                                                          pm.Get("param_ledger_number_i").ToInt32());
                Int32 PeriodStart = pm.Get("param_start_period_i").ToInt32();
                Int32 PeriodEnd   = pm.Get("param_end_period_i").ToInt32();
                AccountingPeriodTbl.DefaultView.RowFilter = LedgerFilter + " AND a_accounting_period_number_i=" + PeriodStart;
                DateTime DateStart = Convert.ToDateTime(AccountingPeriodTbl.DefaultView[0].Row["a_period_start_date_d"]);
                pm.Add("param_start_date", DateStart);
                AccountingPeriodTbl.DefaultView.RowFilter = LedgerFilter + " AND a_accounting_period_number_i=" + PeriodEnd;
                DateTime DateEnd = Convert.ToDateTime(AccountingPeriodTbl.DefaultView[0].Row["a_period_end_date_d"]);
                pm.Add("param_end_date", DateEnd);

                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") + "'";
            String TranctCostCentreFilter = " AND a_cost_centre_code_c IN (" + CostCentreCodes + ") ";

            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 + " AND a_cost_centre_code_c IN (" + CostCentreCodes +
                                      ")  AND a_posting_cost_centre_flag_l=true AND a_cost_centre_active_flag_l=true");
            Csv = StringHelper.AddCSV(
                Csv,
                "ATransaction/SELECT * FROM a_transaction WHERE " + LedgerFilter +
                TranctCostCentreFilter + " 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%'))"
                +
                " 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 ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("HOSA", paramsDictionary);

            if (this.IsDisposed)
            {
                return(false);
            }

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

            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "Gifts");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDs.AAccount, "a_account");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDs.ACostCentre, "a_costCentre");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDs.ATransaction, "a_transaction");
            //
            // 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 = (ReportDs.ATransaction.Rows.Count > 0) || (ReportTable.Rows.Count > 0);

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

            return(HasData);
        }
Example #7
0
        /// <summary>
        /// Takes a report and a list of cost centres; it runs the report for each of the cost centres and emails the results to the address(es)
        /// associated with that cost centre. Used by Account Detail, Income Expense reports and HOSAs.
        /// </summary>
        /// <remarks>If ACostCentreFilter is an SQL clause selecting cost centres, the associated email address is the Primary E-Mail Address of
        /// every Partner linked to the cost centre. If ACostCentreFilter is "Foreign", the list is every cost centre in the a_email_destination
        /// table with a File Code of "HOSA".</remarks>
        /// <param name="FormUtils">The report selection form, to write to the status bar.</param>
        /// <param name="ReportEngine">FastReport wrapper object.</param>
        /// <param name="ACalc">The report parameters.</param>
        /// <param name="ALedgerNumber">The ledger number.</param>
        /// <param name="ACostCentreFilter">SQL clause to select the list of cost centres to run the report for, or "Foreign" </param>
        /// <returns>List of status strings that should be shown to the user.</returns>
        public static List <String> AutoEmailReports(TFrmPetraReportingUtils FormUtils, FastReportsWrapper ReportEngine,
                                                     TRptCalculator ACalc, Int32 ALedgerNumber, String ACostCentreFilter)
        {
            TSmtpSender EmailSender;
            Int32       SuccessfulCount = 0;
            var         NoEmailAddr     = new List <String>();
            var         FailedAddresses = new List <String>();
            var         SendReport      = new List <String>();

            // FastReport will use a temporary folder to store HTML files.
            // I need to ensure that the CurrectDirectory is somewhere writable:
            String prevCurrentDir = Directory.GetCurrentDirectory();


            //Get a path in the Public Documents folder
            String newDir = Path.Combine(Environment.GetFolderPath(
                                             Environment.SpecialFolder.CommonDocuments), "OpenPetraOrg");

            //Check it exists, and if not create it
            if (!Directory.Exists(newDir))
            {
                try
                {
                    Directory.CreateDirectory(newDir);
                }
                catch (Exception ex)
                {
                    //Could not create the path so return useful debugging information:
                    SendReport.Add(Catalog.GetString("Error - could not create directory: "));
                    SendReport.Add(newDir);
                    SendReport.Add(ex.Message);

                    return(SendReport);
                }
            }

            Directory.SetCurrentDirectory(newDir);

            // This gets email defaults from the user settings table
            //TUC_EmailPreferences.LoadEmailDefaults();

            try
            {
                EmailSender = new TSmtpSender();

                EmailSender.SetSender(TUserDefaults.GetStringDefault("SmtpFromAccount"), TUserDefaults.GetStringDefault("SmtpDisplayName"));
                EmailSender.CcEverythingTo = TUserDefaults.GetStringDefault("SmtpCcTo");
                EmailSender.ReplyTo        = TUserDefaults.GetStringDefault("SmtpReplyTo");
            }
            catch (ESmtpSenderInitializeException e)
            {
                if (e.InnerException != null)
                {
                    // I'd write the full exception to the log file, but it still gets transferred to the client window status bar and is _really_ ugly.
                    //TLogging.Log("AutoEmailReports: " + e.InnerException.ToString());
                    TLogging.Log("AutoEmailReports: " + e.InnerException.Message);
                }

                SendReport.Add(e.Message);

                if (e.ErrorClass == TSmtpErrorClassEnum.secClient)
                {
                    SendReport.Add(Catalog.GetString("Check the Email tab in User Settings >> Preferences."));
                }

                return(SendReport);
            }

            // I need to find the email addresses for the linked partners I'm sending to.
            DataTable LinkedPartners = null;

            LinkedPartners = TRemote.MFinance.Setup.WebConnectors.GetLinkedPartners(ALedgerNumber, ACostCentreFilter);
            LinkedPartners.DefaultView.Sort = "CostCentreCode";
            String    myLedgerName   = "";
            DataTable CostCentreList = null;

            if (ACostCentreFilter == "Foreign")
            {
                myLedgerName   = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(ALedgerNumber);
                CostCentreList = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.CostCentreList,
                                                                               ALedgerNumber);
            }

            foreach (DataRowView rv in LinkedPartners.DefaultView)
            {
                DataRow LinkedPartner      = rv.Row;
                Boolean reportAsAttachment = TUserDefaults.GetBooleanDefault("SmtpSendAsAttachment", true);

                if (LinkedPartner["EmailAddress"].ToString() != "")
                {
                    ACalc.AddStringParameter("param_linked_partner_cc", LinkedPartner["CostCentreCode"].ToString());
                    FormUtils.WriteToStatusBar("Generate " + ReportEngine.FReportName + " Report for " + LinkedPartner["PartnerShortName"]);
                    MemoryStream ReportStream = ReportEngine.ExportToStream(ACalc,
                                                                            reportAsAttachment ? FastReportsWrapper.ReportExportType.Pdf : FastReportsWrapper.ReportExportType.Html);

                    // in OpenSource OpenPetra, we do not have and use the FastReport dlls
                    // if (ReportEngine.FfastReportInstance.ReportInfo.Description == "Empty")
                    // {
                    //    continue; // Don't send an empty report
                    // }

                    ReportStream.Position = 0;

                    String EmailBody = "";

                    if (reportAsAttachment)
                    {
                        EmailBody = TUserDefaults.GetStringDefault("SmtpEmailBody");
                        EmailSender.AttachFromStream(ReportStream, ReportEngine.FReportName + ".pdf");
                    }
                    else
                    {
                        StreamReader sr = new StreamReader(ReportStream);
                        EmailBody = sr.ReadToEnd();
                    }

                    String subjectLine;

                    if (ACostCentreFilter == "Foreign")
                    {
                        String recipientLedgerName = "";
                        CostCentreList.DefaultView.RowFilter = "a_cost_centre_code_c='" + LinkedPartner["CostCentreCode"].ToString() + "'";

                        if (CostCentreList.DefaultView.Count > 0)
                        {
                            recipientLedgerName = CostCentreList.DefaultView[0].Row["a_cost_centre_name_c"].ToString();
                        }

                        subjectLine = "HOSA & RGS from " + myLedgerName + " to " + recipientLedgerName;
                    }
                    else
                    {
                        subjectLine = ReportEngine.FReportName + " Report for " + LinkedPartner["PartnerShortName"];
                    }

                    Boolean SentOk = EmailSender.SendEmail(
                        LinkedPartner["EmailAddress"].ToString(),
                        subjectLine,
                        EmailBody);

                    if (SentOk)
                    {
                        SuccessfulCount++;
                    }
                    else // Email didn't send for some reason
                    {
                        SendReport.Add(String.Format(
                                           Catalog.GetString("Failed to send to {0}. Message returned: \"{1}\"."),
                                           LinkedPartner["EmailAddress"],
                                           EmailSender.ErrorStatus
                                           ));

                        FailedAddresses.Add("    " + LinkedPartner["EmailAddress"]);
                    }
                }
                else // No Email Address for this Partner
                {
                    NoEmailAddr.Add("    " + String.Format("{0:D10}", LinkedPartner["PartnerKey"]) + " " + LinkedPartner["PartnerShortName"]);
                }
            }

            if (SuccessfulCount == 1)
            {
                SendReport.Add(
                    String.Format(Catalog.GetString("{0} emailed to {1} partner."), ReportEngine.FReportName, SuccessfulCount));
            }
            else if (SuccessfulCount > 1)
            {
                SendReport.Add(
                    String.Format(Catalog.GetString("{0} emailed to {1} partners."), ReportEngine.FReportName, SuccessfulCount));
            }
            else
            {
                SendReport.Add(Catalog.GetString(
                                   "Error – no cost centre in the report was linked to a Partner with a valid Primary E-mail Address."));
            }

            if (NoEmailAddr.Count > 0)
            {
                SendReport.Add(Catalog.GetString("These Partners have no Primary E-mail Address:"));
                SendReport.AddRange(NoEmailAddr);
            }

            if (FailedAddresses.Count > 0)
            {
                SendReport.Add(Catalog.GetString("Failed to send email to these addresses:"));
                SendReport.AddRange(FailedAddresses);
            }

            FormUtils.WriteToStatusBar("");
            Directory.SetCurrentDirectory(prevCurrentDir);
            EmailSender.Dispose();
            return(SendReport);
        } // AutoEmailReports
Example #8
0
        } // AutoEmailReports

        /// <summary>Helper for the report printing ClientTask</summary>
        /// <remarks>This way of printing reports shows some reliability concerns so it is not currently used.</remarks>
        /// <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;

            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

            // I'm not in the User Interface thread, so I can use an invoke here:
            TFormsList.GFormsList.MainMenuForm.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)
        {
            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);
            }
        }
Example #10
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
Example #11
0
        /// <summary>
        /// The report will be sent to a list of email addresses derived from the Cost Centres in the supplied CostCentreFilter.
        /// </summary>
        /// <returns>Status string that should be shown to the user</returns>
        public static String AutoEmailReports(TFrmPetraReportingUtils FormUtils, FastReportsWrapper ReportEngine,
                                              TRptCalculator ACalc, Int32 ALedgerNumber, String ACostCentreFilter)
        {
            Int32  SuccessfulCount = 0;
            String NoEmailAddr     = "";
            String FailedAddresses = "";
            String SendReport      = "Auto Email\r\n";

            //
            // FastReport will use a temporary folder to store HTML files.
            // I need to ensure that the CurrectDirectory is somewhere writable:
            String prevCurrentDir = Directory.GetCurrentDirectory();


            //Get a path in the Public Documents folder
            String newDir = Path.Combine(Environment.GetFolderPath(
                                             Environment.SpecialFolder.CommonDocuments), "OpenPetraOrg");

            //Check it exists, and if not create it
            if (!Directory.Exists(newDir))
            {
                try
                {
                    Directory.CreateDirectory(newDir);
                }
                catch (Exception ex)
                {
                    //could not create the path so return useful debugging information:
                    SendReport += Catalog.GetString("\r\nError - could not create directory: " + newDir);
                    SendReport += Catalog.GetString("\r\n" + newDir);
                    SendReport += ex.Message;

                    return(SendReport);
                }
            }

            Directory.SetCurrentDirectory(newDir);

            //
            // I need to find the email addresses for the linked partners I'm sending to.
            DataTable LinkedPartners = null;

            LinkedPartners = TRemote.MFinance.Setup.WebConnectors.GetLinkedPartners(ALedgerNumber, ACostCentreFilter);
            LinkedPartners.DefaultView.Sort = "CostCentreCode";

            foreach (DataRowView rv in LinkedPartners.DefaultView)
            {
                DataRow LinkedPartner = rv.Row;

                if (LinkedPartner["EmailAddress"].ToString() != "")
                {
                    ACalc.AddStringParameter("param_linked_partner_cc", LinkedPartner["CostCentreCode"].ToString());
                    FormUtils.WriteToStatusBar("Generate " + ReportEngine.FReportName + " Report for " + LinkedPartner["PartnerShortName"]);
                    MemoryStream ReportStream = ReportEngine.ExportToStream(ACalc, FastReportsWrapper.ReportExportType.Html);

                    // in OpenSource OpenPetra, we do not have and use the FastReport dlls
                    // if (ReportEngine.FfastReportInstance.ReportInfo.Description == "Empty")
                    // {
                    //    continue; // Don't send an empty report
                    // }

                    ReportStream.Position = 0;

                    // This gets email defaults from the user settings table
                    TUC_EmailPreferences.LoadEmailDefaults();

                    // This gets some of the settings from the server configuration.  We no longer get these items from local PC.
                    // SmtpUsername and SmtpPassword will usually be null
                    string smtpHost, smtpUsername, smtpPassword;
                    int    smtpPort;
                    bool   smtpUseSSL;
                    TRemote.MSysMan.Application.WebConnectors.GetServerSmtpSettings(out smtpHost,
                                                                                    out smtpPort,
                                                                                    out smtpUseSSL,
                                                                                    out smtpUsername,
                                                                                    out smtpPassword);

                    if ((smtpHost == string.Empty) || (smtpPort < 0))
                    {
                        return(Catalog.GetString(
                                   "Cannot send email because 'smtpHost' and/or 'smtpPort' are not configured in the OP server configuration file."));
                    }

                    TSmtpSender EmailSender = new TSmtpSender(smtpHost, smtpPort, smtpUseSSL, smtpUsername, smtpPassword, "");

                    EmailSender.CcEverythingTo = TUserDefaults.GetStringDefault("SmtpCcTo");
                    EmailSender.ReplyTo        = TUserDefaults.GetStringDefault("SmtpReplyTo");

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

                    String EmailBody = "";

                    if (TUserDefaults.GetBooleanDefault("SmtpSendAsAttachment"))
                    {
                        EmailBody = TUserDefaults.GetStringDefault("SmtpEmailBody");
                        EmailSender.AttachFromStream(ReportStream, ReportEngine.FReportName + ".html");
                    }
                    else
                    {
                        StreamReader sr = new StreamReader(ReportStream);
                        EmailBody = sr.ReadToEnd();
                    }

                    Boolean SentOk = EmailSender.SendEmail(
                        TUserDefaults.GetStringDefault("SmtpFromAccount"),
                        TUserDefaults.GetStringDefault("SmtpDisplayName"),
                        LinkedPartner["EmailAddress"].ToString(),
                        ReportEngine.FReportName + " Report for " + LinkedPartner["PartnerShortName"] + ", Address=" + LinkedPartner["EmailAddress"],
                        EmailBody);

                    if (SentOk)
                    {
                        SuccessfulCount++;
                    }
                    else // Email didn't send for some reason
                    {
                        SendReport += String.Format(
                            Catalog.GetString("\r\nFailed to send to {0}. Message returned: \"{1}\"."),
                            LinkedPartner["EmailAddress"],
                            EmailSender.FErrorStatus
                            );

                        FailedAddresses += ("\r\n    " + LinkedPartner["EmailAddress"]);
                    }
                }
                else // No Email Address for this Partner
                {
                    NoEmailAddr += ("\r\n    " + LinkedPartner["PartnerKey"] + " " + LinkedPartner["PartnerShortName"]);
                }
            }

            if (SuccessfulCount > 0)
            {
                SendReport +=
                    String.Format(Catalog.GetString("\r\n{0} emailed to {1} addresses."), ReportEngine.FReportName, SuccessfulCount) + "\r\n\r\n";
            }
            else
            {
                SendReport += Catalog.GetString("\r\nError - no page had a linked email address.");
            }

            if (NoEmailAddr != "")
            {
                SendReport += (Catalog.GetString("\r\nThese Partners have no email addresses:") + NoEmailAddr + "\r\n");
            }

            if (FailedAddresses != "")
            {
                SendReport += (Catalog.GetString("Failed to send email to these addresses:") + FailedAddresses + "\r\n\r\n");
            }

            FormUtils.WriteToStatusBar("");
            Directory.SetCurrentDirectory(prevCurrentDir);
            return(SendReport);
        } // AutoEmailReports
        private Boolean LoadReportData(TRptCalculator ACalc)
        {
            //
            // I need the name of the ledger, and 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_recipient", "All Recipients");

            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
            // Previous code:
            // DataSet ReportDataSet = TRemote.MReporting.WebConnectors.GetReportDataSet("DonorGiftStatement", paramsDictionary);
            DataSet ReportDataSet  = null;
            Boolean ThreadFinished = false;
            Boolean ThreadOK       = true;
            string  ThreadFailMsg  = "GetDGSDataSet completed successfully"; // This message should not be displayed!  Hence it is not translated.
            Thread  t = new Thread(() => GetDGSDataSet(ref ReportDataSet, paramsDictionary, ref ThreadFinished, ACalc));

            using (TProgressDialog dialog = new TProgressDialog(t, AWaitForThreadComplete: true))
            {
                dialog.ShowDialog();
                if (dialog.Cancelled)
                {
                    ThreadOK      = false;
                    ThreadFailMsg = Catalog.GetString("Query generation cancelled");
                }
            }

            while (!ThreadFinished)
            {
                Thread.Sleep(50);
            }

            // if no Donors
            if (ThreadOK && ((ReportDataSet == null) || (ReportDataSet.Tables["Donors"] == null) || (ReportDataSet.Tables["Donors"].Rows.Count == 0)))
            {
                ThreadOK      = false;
                ThreadFailMsg = Catalog.GetString("No Donors found.");
            }

            // so if ThreadOK was set false, show the user why.
            if (!ThreadOK)
            {
                MessageBox.Show(ThreadFailMsg, "Donor Gift Statement");
                return(false);
            }

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

            return(ThreadOK);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="ACalculator"></param>
        /// <param name="AReportAction"></param>
        private void ReadControlsManual(TRptCalculator ACalculator, TReportActionEnum AReportAction)
        {
            TVerificationResult VerificationResult;

            string PublicationCodesToAdd = string.Empty;

            // Disabled selecting all publications for now as report currently cuts them off.
            // Can show a maximum of 8.

            /*if (rbtFromList.Checked)
             * {*/
            string SelectedPublicationCodes = clbPublicationCode.GetCheckedStringList(true);

            PublicationCodesToAdd = clbPublicationCode.GetCheckedStringList(false);

            if (AReportAction == TReportActionEnum.raGenerate)
            {
                if (clbPublicationCode.CheckedItemsCount == 0)
                {
                    VerificationResult = new TVerificationResult(Catalog.GetString("Select Publication Codes"),
                                                                 Catalog.GetString("No Publication Code was selected!"),
                                                                 TResultSeverity.Resv_Critical);
                    FPetraUtilsObject.AddVerificationResult(VerificationResult);
                }
                else if (clbPublicationCode.CheckedItemsCount > 8)
                {
                    VerificationResult = new TVerificationResult(Catalog.GetString("Select Publication Codes"),
                                                                 string.Format(Catalog.GetString("You have selected {0} publications. Please reduce this number to 8 or fewer."),
                                                                               clbPublicationCode.CheckedItemsCount),
                                                                 TResultSeverity.Resv_Critical);
                    FPetraUtilsObject.AddVerificationResult(VerificationResult);
                }
            }

            ACalculator.AddStringParameter("param_clbPublicationCode", SelectedPublicationCodes);

            if (SelectedPublicationCodes.Length > 25)
            {
                SelectedPublicationCodes = "Selected Accounts";
            }

            ACalculator.AddParameter("param_publication_list_title", SelectedPublicationCodes);

            /*}
             * else
             * {
             *  PublicationCodesToAdd = clbPublicationCode.GetAllStringList();
             * }*/

            if (AReportAction == TReportActionEnum.raGenerate)
            {
                StringCollection PublicationCodesToAddSC = StringHelper.GetCSVList(PublicationCodesToAdd, ",");
                int    ColumnCounter = 0;
                double Position      = 0;

                // add extra parameters for user defined columns
                while (ACalculator.GetParameters().GetParameter("param_calculation", ColumnCounter, -1, eParameterFit.eAllColumnFit) != null)
                {
                    string Description =
                        ACalculator.GetParameters().GetParameter("param_calculation", ColumnCounter, -1, eParameterFit.eAllColumnFit).value.ToString();
                    double Width =
                        ACalculator.GetParameters().GetParameter("ColumnWidth", ColumnCounter, -1, eParameterFit.eAllColumnFit).value.ToDouble();

                    ACalculator.AddParameter("param_label", Description, ColumnCounter);
                    ACalculator.AddParameter("ColumnAlign", "left", ColumnCounter);
                    ACalculator.AddParameter("ColumnCaption", Description, ColumnCounter);
                    ACalculator.AddParameter("ColumnPosition", Position, ColumnCounter);

                    Position += Width;

                    ++ColumnCounter;
                }

                double ColumnWidth = 2.3;

                // add a new column for each publication
                foreach (string Code in PublicationCodesToAddSC)
                {
                    ACalculator.AddParameter("param_calculation", "Publication", ColumnCounter);
                    ACalculator.AddParameter("param_label", "Publication", ColumnCounter);
                    ACalculator.AddParameter("ColumnAlign", "left", ColumnCounter);
                    ACalculator.AddParameter("ColumnCaption", Code, ColumnCounter);
                    ACalculator.AddParameter("ColumnPosition", Position, ColumnCounter);
                    ACalculator.AddParameter("ColumnWidth", ColumnWidth, ColumnCounter);

                    Position += ColumnWidth;

                    ++ColumnCounter;
                }

                ACalculator.SetMaxDisplayColumns(ColumnCounter);

                // get the country code for this openpetra's site ledger
                string CountryCode = TRemote.MPartner.Partner.ServerLookups.WebConnectors.GetCountryCodeFromSiteLedger();
                ACalculator.AddParameter("param_cmbCountryCode", CountryCode);
            }
        }
        //
        // 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)
        {
            ACurrencyRow CurrencyRow;

            // I need to get the name of the current ledger..
            ALedgerRow LedgerDetailsRow = (ALedgerRow)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails,
                                                                                                    FLedgerNumber).Rows[0];

            //
            // The ledger's name is stored in its partner record, not in its ledger record. Sigh.
            if (LedgerDetailsRow.LedgerName == "")
            {
                DataTable LedgerNameTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerNameList);
                DataView  LedgerView      = new DataView(LedgerNameTable);
                LedgerView.RowFilter = "LedgerNumber=" + FLedgerNumber;

                if (LedgerView.Count > 0)
                {
                    ACalc.AddStringParameter("param_ledger_name", LedgerView[0].Row["LedgerName"].ToString());
                }
            }
            else
            {
                ACalc.AddStringParameter("param_ledger_name", LedgerDetailsRow.LedgerName);
            }

            switch (ACalc.GetParameters().Get("param_currency").ToString())
            {
            case "Base":
                ACalc.AddStringParameter("param_currency_code", LedgerDetailsRow.BaseCurrency);
                CurrencyRow = (ACurrencyRow)TDataCache.TMCommon.GetCacheableCommonTable(TCacheableCommonTablesEnum.CurrencyCodeList).Rows.Find(
                    LedgerDetailsRow.BaseCurrency);
                ACalc.AddStringParameter("param_currency_format", CurrencyRow.DisplayFormat);
                break;

            case "International":
                ACalc.AddStringParameter("param_currency_code", LedgerDetailsRow.IntlCurrency);
                CurrencyRow = (ACurrencyRow)TDataCache.TMCommon.GetCacheableCommonTable(TCacheableCommonTablesEnum.CurrencyCodeList).Rows.Find(
                    LedgerDetailsRow.IntlCurrency);
                ACalc.AddStringParameter("param_currency_format", CurrencyRow.DisplayFormat);
                break;

            default:
                ACalc.AddStringParameter("param_currency_code", "Unknown");
                ACalc.AddStringParameter("param_currency_format", "->>>,>>>,>>>,>>9.99");
                break;
            }

            //Uncomment this to log the parameter list:
            //foreach (Shared.MReporting.TParameter p in reportParam)
            //{
            //    TLogWriter.Log(p.name.ToString() + " => " + p.value.ToString());
            //}

            return(FPetraUtilsObject.FFastReportsPlugin.LoadReportData("GiftsOverMinimum",
                                                                       true,
                                                                       new string[] { "Donors", "Contacts", "GiftsOverMinimum" },
                                                                       ACalc,
                                                                       this,
                                                                       false));
        }
Example #15
0
        /// <summary>
        /// The report will be sent to a list of email addresses derived from the Cost Centres in the supplied CostCentreFilter.
        /// </summary>
        /// <returns>Status string that should be shown to the user</returns>
        public static String AutoEmailReports(TFrmPetraReportingUtils FormUtils, FastReportsWrapper ReportEngine,
                                              TRptCalculator ACalc, Int32 ALedgerNumber, String ACostCentreFilter)
        {
            Int32  SuccessfulCount = 0;
            String NoEmailAddr     = "";
            String FailedAddresses = "";
            String SendReport      = "";

            //
            // I need to find the email addresses for the linked partners I'm sending to.
            DataTable LinkedPartners = null;

            LinkedPartners = TRemote.MFinance.Setup.WebConnectors.GetLinkedPartners(ALedgerNumber, ACostCentreFilter);
            LinkedPartners.DefaultView.Sort = "CostCentreCode";

            foreach (DataRowView rv in LinkedPartners.DefaultView)
            {
                DataRow LinkedPartner = rv.Row;

                if (LinkedPartner["EmailAddress"].ToString() != "")
                {
                    ACalc.AddStringParameter("param_linked_partner_cc", LinkedPartner["CostCentreCode"].ToString());
                    FormUtils.WriteToStatusBar("Generate " + ReportEngine.FReportName + " Report for " + LinkedPartner["PartnerShortName"]);
                    MemoryStream ReportStream = ReportEngine.ExportToStream(ACalc, FastReportsWrapper.ReportExportType.Html);

                    if (ReportStream.Position < 1000)
                    {
                        continue; // Don't send an empty report
                    }

                    ReportStream.Position = 0;

                    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)
                    {
                        return(String.Format(
                                   Catalog.GetString(
                                       "Failed to set up the email server.\n    Please check the settings in Preferences / Email.\n    Message returned : \"{0}\""),
                                   EmailSender.FErrorStatus));
                    }

                    String EmailBody = "";

                    if (TUserDefaults.GetBooleanDefault("SmtpSendAsAttachment"))
                    {
                        EmailBody = TUserDefaults.GetStringDefault("SmtpEmailBody");
                        EmailSender.AttachFromStream(ReportStream, ReportEngine.FReportName + ".html");
                    }
                    else
                    {
                        StreamReader sr = new StreamReader(ReportStream);
                        EmailBody = sr.ReadToEnd();
                    }

                    Boolean SentOk = EmailSender.SendEmail(
                        TUserDefaults.GetStringDefault("SmtpFromAccount"),
                        TUserDefaults.GetStringDefault("SmtpDisplayName"),
                        "*****@*****.**", //LinkedPartner["EmailAddress"]
                        ReportEngine.FReportName + " Report for " + LinkedPartner["PartnerShortName"] + ", Address=" + LinkedPartner["EmailAddress"],
                        EmailBody);

                    if (SentOk)
                    {
                        SuccessfulCount++;
                    }
                    else // Email didn't send for some reason
                    {
                        SendReport += String.Format(
                            Catalog.GetString("\r\nFailed to send to {0}. Message returned: \"{1}\"."),
                            LinkedPartner["EmailAddress"],
                            EmailSender.FErrorStatus
                            );

                        FailedAddresses += ("\r\n    " + LinkedPartner["EmailAddress"]);
                    }
                }
                else // No Email Address for this Partner
                {
                    NoEmailAddr += ("\r\n    " + LinkedPartner["PartnerKey"] + " " + LinkedPartner["PartnerShortName"]);
                }
            }

            if (SuccessfulCount > 0)
            {
                SendReport +=
                    String.Format(Catalog.GetString("\r\n{0} emailed to {1} addresses."), ReportEngine.FReportName, SuccessfulCount) + "\r\n\r\n";
            }

            if (NoEmailAddr != "")
            {
                SendReport += (Catalog.GetString("\r\nThese Partners have no email addresses:") + NoEmailAddr + "\r\n");
            }

            if (FailedAddresses != "")
            {
                SendReport += (Catalog.GetString("Failed to send email to these addresses:") + FailedAddresses + "\r\n\r\n");
            }

            FormUtils.WriteToStatusBar("");
            return(SendReport);
        } // AutoEmailReports
        } // 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>
        /// Reads the selected values from the controls, and stores them into the parameter system of FCalculator
        /// </summary>
        /// <param name="ACalc"></param>
        /// <param name="AReportAction"></param>
        public void ReadControls(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            ACalc.AddStringParameter("param_motivation_group", this.clbMotivationGroup.GetCheckedStringList());
            ACalc.AddStringParameter("param_motivation_detail", this.clbMotivationDetail.GetCheckedStringList());
            string MotivationGroups = string.Empty;

            // are all motivation groups selected?
            if (clbMotivationGroup.GetAllStringList() == clbMotivationGroup.GetCheckedStringList())
            {
                ACalc.AddParameter("param_all_motivation_groups", true);

                MotivationGroups = "All";
            }
            else
            {
                ACalc.AddParameter("param_all_motivation_groups", false);

                // we need these list items enclosed with single quotes for SQL
                MotivationGroups = clbMotivationGroup.GetCheckedStringList(true);
                MotivationGroups = MotivationGroups.Replace("\"", "'");
            }

            ACalc.AddParameter("param_motivation_group_quotes", MotivationGroups);

            string Group_Detail_Pairs             = string.Empty;
            string Group_Detail_Individual        = string.Empty;
            string Group_Detail_Individual_quotes = string.Empty;

            // are all motivation details selected?
            if ((clbMotivationDetail.GetAllStringList() == clbMotivationDetail.GetCheckedStringList()) &&
                (clbMotivationGroup.GetAllStringList() == clbMotivationGroup.GetCheckedStringList()))
            {
                ACalc.AddParameter("param_all_motivation_details", true);

                Group_Detail_Pairs             = "All";
                Group_Detail_Individual        = "All";
                Group_Detail_Individual_quotes = "All";
            }
            else
            {
                ACalc.AddParameter("param_all_motivation_details", false);

                // Motivation Group and Detail Code in Pairs. First value is group code, second is detail code.
                List <String> param_motivation_detail = new List <String>(ACalc.GetParameters().Get("param_motivation_detail").ToString().Split(','));

                int Index = 0;

                foreach (String KeyPart in param_motivation_detail)
                {
                    if (Index % 2 == 0)
                    {
                        if (Group_Detail_Pairs.Length > 0)
                        {
                            Group_Detail_Pairs             += ",";
                            Group_Detail_Individual        += ",";
                            Group_Detail_Individual_quotes += ",";
                        }

                        // even Index: Group Code
                        Group_Detail_Pairs += "('" + KeyPart + "','";
                    }
                    else
                    {
                        // odd Index: Detail Code
                        Group_Detail_Pairs             += KeyPart + "')";
                        Group_Detail_Individual        += KeyPart;
                        Group_Detail_Individual_quotes += ("'" + KeyPart + "'");
                    }

                    // increase Index for next element
                    Index += 1;
                }
            }

            ACalc.AddParameter("param_motivation_group_detail_pairs", Group_Detail_Pairs);
            ACalc.AddParameter("param_motivation_details", Group_Detail_Individual);
            ACalc.AddParameter("param_motivation_details_quotes", Group_Detail_Individual_quotes);

            ACalc.AddParameter("param_number_of_mot_details", clbMotivationDetail.CheckedItemsCount);

            // create a header description for the motivation groups and details used
            if (ACalc.GetParameters().Get("param_all_motivation_groups").ToBool() &&
                ACalc.GetParameters().Get("param_all_motivation_details").ToBool())
            {
                ACalc.AddParameter("param_group_detail_desc", "All");
            }
            else
            {
                string GroupsAndDetails = ACalc.GetParameters().Get("param_motivation_group_detail_pairs").ToString().Replace("\'", "");

                ACalc.AddParameter("param_group_detail_desc", GroupsAndDetails);
            }
        }
Example #18
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);
        }
Example #19
0
        //
        // 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);
        }
        private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            int Years = Convert.ToInt16(txtYears.Text);

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

            ACalc.AddParameter("param_ledger_number_i", FLedgerNumber);
            //
            // 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();
            }

            ALedgerTable LedgerDetailsTable = (ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails);
            ALedgerRow   Row           = LedgerDetailsTable[0];
            Int32        LedgerYear    = Row.CurrentFinancialYear;
            Int32        NumPeriods    = Row.NumberOfAccountingPeriods;
            String       CurrencyName  = (cmbCurrency.SelectedItem.ToString() == "Base") ? Row.BaseCurrency : Row.IntlCurrency;
            Int32        CurrentPeriod = Row.CurrentPeriod;

            ACalc.AddStringParameter("param_ledger_name", LedgerName);
            ACalc.AddStringParameter("param_currency_name", CurrencyName);

            DateTime PeriodEndDate = TRemote.MFinance.GL.WebConnectors.GetPeriodEndDate(
                FLedgerNumber,
                LedgerYear,
                0,
                CurrentPeriod);

            Int32 PeriodThisYear = PeriodEndDate.Month;

            DateTime StartDate = TRemote.MFinance.GL.WebConnectors.GetPeriodStartDate(
                FLedgerNumber,
                LedgerYear - Years + 1,
                0,
                1);

            DateTime EndDate = TRemote.MFinance.GL.WebConnectors.GetPeriodEndDate(
                FLedgerNumber,
                LedgerYear,
                0,
                NumPeriods);

            ACalc.AddParameter("param_PeriodThisYear", PeriodThisYear);
            ACalc.AddParameter("param_StartDate", StartDate);
            ACalc.AddParameter("param_EndDate", EndDate);
            ACalc.AddParameter("param_TD", FTaxDeductiblePercentageEnabled);
        }
Example #21
0
        /// <summary>
        /// Helper function to load the Report Data in the standard case where no client-side processing is required.
        /// </summary>
        /// <param name="AUseProgressBar">Use a ProgressBar?</param>
        /// <param name="AReportName">The Name of the Report</param>
        /// <param name="AUseDataSet">True, if a ReportSet is used</param>
        /// <param name="ATableNames">The Names of the Tables</param>
        /// <param name="ACalc">ACalc object</param>
        /// <param name="AWindow">"Parent" Window</param>
        /// <param name="AUseColumnTab">"Parent" Window</param>
        /// <param name="AAddLedger">"Adds the Ledger Name to the Parameters"</param>
        /// <param name="ALedgerNumber">"The Ledger Number if used"</param>
        /// <param name="AMainTableName">Indicating Table (name) whether a report would be blank. Only if DataSet is used and Main Table isn't the first in the DataSet. </param>
        /// <param name="ASortBy">"Sort By..."</param>
        /// <returns></returns>
        public bool LoadReportData(
            bool AUseProgressBar,
            string AReportName,
            bool AUseDataSet,
            string[] ATableNames,
            TRptCalculator ACalc,
            Form AWindow,
            bool AUseColumnTab,
            bool AAddLedger       = false,
            Int32 ALedgerNumber   = -1,
            string AMainTableName = "",
            string ASortBy        = ""
            )
        {
            if (AUseColumnTab)
            {
                TColumnSettingCollection tcsc = new TColumnSettingCollection();

                for (int counter = 0; counter <= ACalc.GetParameters().Get("MaxDisplayColumns").ToInt() - 1; counter += 1)
                {
                    TColumnSetting tcs = new TColumnSetting(ACalc.GetParameters().Get("param_calculation", counter).ToString().Replace(" ",
                                                                                                                                       "").Replace("/", ""),
                                                            float.Parse(ACalc.GetParameters().Get("ColumnWidth", counter).ToString()), counter + 1);
                    tcsc.SetSettingForColumn(tcs);
                }

                ACalc.AddParameter("param_columns", tcsc.SerialiseCollection());
            }

            //paramsDictionary also contains the selected columns as serialised string
            Dictionary <String, TVariant> paramsDictionary = ParamsToDictionary(ACalc);

            DataTable ReportTable = null;
            DataSet   ReportSet   = null;


            Thread t;
            bool   ThreadFinished = false;

            if (AUseDataSet)
            {
                t = new Thread(() => ReportSet = GetReportDataSet(AReportName, paramsDictionary, ref ThreadFinished));
            }
            else
            {
                t = new Thread(() => ReportTable = GetReportDataTable(AReportName, paramsDictionary, ref ThreadFinished));
            }

            if (AUseProgressBar)
            {
                using (TProgressDialog dialog = new TProgressDialog(t))
                {
                    dialog.SetRefreshInterval(200);
                    dialog.ShowDialog();
                }

                // wait here until Thread is really finished
                while (!ThreadFinished)
                {
                    Thread.Sleep(50);
                }
            }
            else
            {
                t.Start();
                t.Join();
            }

            if ((AWindow == null) || AWindow.IsDisposed)
            {
                return(false);
            }

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

            //Message if Report would be blank
            string Message = Catalog.GetString("No data has been found for the current selection.");

            if (AUseDataSet)
            {
                bool error = false;

                if (AMainTableName == String.Empty)
                {
                    if (ReportSet.Tables[0].Rows.Count == 0)
                    {
                        error = true;
                    }
                }
                else
                {
                    if (ReportSet.Tables[AMainTableName].Rows.Count == 0)
                    {
                        error = true;
                    }
                }

                if (error)
                {
                    MessageBox.Show(Message, "Error");
                    FPetraUtilsObject.WriteToStatusBar(Catalog.GetString("No data found for current selection."));
                    return(false);
                }
            }
            else if (ReportTable.Rows.Count == 0)
            {
                MessageBox.Show(Message, "Error");
                FPetraUtilsObject.WriteToStatusBar(Catalog.GetString("No data found for current selection."));
                return(false);
            }

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

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

                ACalc.AddStringParameter("param_ledger_name", LedgerName);
            }

            if (!AUseDataSet && (ASortBy != ""))
            {
                DataView dv = ReportTable.DefaultView;
                dv.Sort     = ASortBy;
                ReportTable = dv.ToTable();
            }

            if (AUseDataSet)
            {
                foreach (string TableName in ATableNames)
                {
                    RegisterData(ReportSet.Tables[TableName], TableName);
                }
            }
            else
            {
                RegisterData(ReportTable, ATableNames[0]);
            }

            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 = 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 using the AutoEmailReports method which calls 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() + "'";
                }

                List <String> Status = FastReportsWrapper.AutoEmailReports(FPetraUtilsObject,
                                                                           FPetraUtilsObject.FFastReportsPlugin,
                                                                           ACalc,
                                                                           FLedgerNumber,
                                                                           CostCentreFilter);
                MessageBox.Show(String.Join("\n", Status), Catalog.GetString("Auto Email") + " " + Catalog.GetString("Income Expense Report"));
                return(false);
            }

            return(true);
        }
        private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            String paramFields = clbFields.GetCheckedStringList(true);

            if (AReportAction == TReportActionEnum.raGenerate)
            {
                if (rbtSelectedFields.Checked && (paramFields.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 (rbtAllFields.Checked)
                {
                    paramFields = clbFields.GetAllStringList(true);
                }

                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 (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);
                }
            }

            paramFields = paramFields.Replace("\"", "'");           // single quotes for SQL field names.
            ACalc.AddParameter("param_clbFields", paramFields);


            ACalc.AddParameter("param_ledger_number_i", FLedgerNumber);
            //
            // 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);
            ALedgerTable LedgerDetailsTable = (ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails);
            ALedgerRow   Row          = LedgerDetailsTable[0];
            Int32        LedgerYear   = Row.CurrentFinancialYear;
            Int32        NumPeriods   = Row.NumberOfAccountingPeriods;
            String       CurrencyName = (cmbCurrency.SelectedItem.ToString() == "Base") ? Row.BaseCurrency : Row.IntlCurrency;

            ACalc.AddStringParameter("param_currency_name", CurrencyName);

            ACalc.AddParameter("param_year0", DateTime.Today.Year);
            ACalc.AddParameter("param_year1", DateTime.Today.Year - 1);
            ACalc.AddParameter("param_year2", DateTime.Today.Year - 2);
            ACalc.AddParameter("param_year3", DateTime.Today.Year - 3);
        } // Read Controls Manual
        /// <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);
            }
        }
Example #25
0
        //
        // 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)
        {
            Shared.MReporting.TParameterList parameters = ACalc.GetParameters();
            String LedgerFilter = "a_ledger_number_i=" + parameters.Get("param_ledger_number_i").ToInt32();

            String    AccountCodeFilter    = ""; // Account Filter, as range or list:
            String    GlmAccountCodeFilter = "";
            DataTable Balances             = new DataTable();

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

            if (parameters.Get("param_rgrAccounts").ToString() == "AccountList")
            {
                String Filter = "'" + parameters.Get("param_account_codes") + "'";
                Filter               = Filter.Replace(",", "','");
                AccountCodeFilter    = "AND a_account_code_c in (" + Filter + ")";
                GlmAccountCodeFilter = " AND glm.a_account_code_c in (" + Filter + ")";
            }

            if (parameters.Get("param_rgrAccounts").ToString() == "AccountRange")
            {
                AccountCodeFilter = "AND a_account_code_c BETWEEN '" + parameters.Get("param_account_code_start") + "' AND '" +
                                    parameters.Get("param_account_code_end") + "'";
                GlmAccountCodeFilter = " AND glm.a_account_code_c BETWEEN '" + parameters.Get("param_account_code_start") + "' AND '" +
                                       parameters.Get("param_account_code_end") + "'";
            }

            String CostCentreFilter    = ""; // Cost Centre Filter, as range or list:
            String GlmCostCentreFilter = "";

            if (parameters.Get("param_rgrCostCentres").ToString() == "CostCentreList")
            {
                String Filter = "'" + parameters.Get("param_cost_centre_codes") + "'";
                Filter              = Filter.Replace(",", "','");
                CostCentreFilter    = " AND a_cost_centre_code_c in (" + Filter + ")";
                GlmCostCentreFilter = " AND glm.a_cost_centre_code_c in (" + Filter + ")";
            }

            if (parameters.Get("param_rgrCostCentres").ToString() == "CostCentreRange")
            {
                CostCentreFilter = " AND a_cost_centre_code_c BETWEEN '" + parameters.Get("param_cost_centre_code_start") +
                                   "' AND  '" + parameters.Get("param_cost_centre_code_end") + "'";
                GlmCostCentreFilter = " AND glm.a_cost_centre_code_c BETWEEN '" + parameters.Get("param_cost_centre_code_start") +
                                      "' AND '" + parameters.Get("param_cost_centre_code_end") + "'";
            }

            String TranctDateFilter = "a_transaction_date_d BETWEEN '" + parameters.Get("param_start_date").DateToString("yyyy-MM-dd") +
                                      "' AND '" + parameters.Get("param_end_date").DateToString("yyyy-MM-dd") + "'";

            String ReferenceFilter    = "";
            String AnalysisTypeFilter = "";
            String GroupField         = "a_account_code_c, a_cost_centre_code_c";
            String Sortby             = parameters.Get("param_sortby").ToString();

            if (Sortby == "Cost Centre")
            {
                GroupField = "a_cost_centre_code_c, a_account_code_c";
            }

            if (Sortby == "Reference")
            {
                GroupField = "a_reference_c";
                String FilterItem = parameters.Get("param_reference_start").ToString();

                if (FilterItem != "")
                {
                    ReferenceFilter = " AND a_reference_c >='" + FilterItem + "'";
                }

                FilterItem = parameters.Get("param_reference_end").ToString();

                if (FilterItem != "")
                {
                    ReferenceFilter += " AND a_reference_c <='" + FilterItem + "'";
                }
            }

            if (Sortby == "Analysis Type")
            {
                GroupField = "a_analysis_type_code_c";
                String FilterItem = parameters.Get("param_analyis_type_start").ToString();

                if (FilterItem != "")
                {
                    AnalysisTypeFilter = " AND a_analysis_type_code_c >='" + FilterItem + "'";
                }

                FilterItem = parameters.Get("param_analyis_type_end").ToString();

                if (FilterItem != "")
                {
                    AnalysisTypeFilter += " AND a_analysis_type_code_c <='" + FilterItem + "'";
                }
            }

            parameters.Add("param_groupfield", GroupField);

            String Csv = "";

            Csv = StringHelper.AddCSV(Csv, "ALedger/SELECT * FROM a_ledger WHERE " + LedgerFilter);
            Csv = StringHelper.AddCSV(
                Csv,
                "AAccount/SELECT * FROM a_account WHERE " + LedgerFilter + AccountCodeFilter +
                " 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");

            Boolean InternationalCurrencySelected = parameters.Get("param_currency").ToString().StartsWith("Int");
            String  AmountField = InternationalCurrencySelected ? "a_amount_in_intl_currency_n" : "a_amount_in_base_currency_n";

            if (Sortby == "Analysis Type")  // To sort by analysis type, I need a different (and more horible) query:
            {
                Csv = StringHelper.AddCSV(
                    Csv,
                    "Transactions/" +
                    "SELECT a_transaction.a_account_code_c AS AccountCode," +
                    "a_transaction.a_cost_centre_code_c AS CostCentreCode," +
                    "a_transaction.a_transaction_date_d AS TransactionDate," +
                    "a_transaction." + AmountField + " AS Amount," +
                    "a_transaction.a_debit_credit_indicator_l AS Debit," +
                    "a_transaction.a_narrative_c AS Narrative," +
                    "a_transaction.a_reference_c AS Reference," +
                    "a_trans_anal_attrib.a_analysis_type_code_c AS AnalysisTypeCode," +
                    "a_analysis_type.a_analysis_type_description_c AS AnalysisTypeDescr," +
                    "a_trans_anal_attrib.a_analysis_attribute_value_c AS AnalysisValue" +
                    " FROM a_transaction, a_trans_anal_attrib, a_analysis_type" +
                    " WHERE a_transaction." + LedgerFilter +
                    " AND a_trans_anal_attrib.a_ledger_number_i = a_transaction.a_ledger_number_i " +
                    " AND a_trans_anal_attrib.a_batch_number_i = a_transaction.a_batch_number_i" +
                    " AND a_trans_anal_attrib.a_journal_number_i = a_transaction.a_journal_number_i" +
                    " AND a_trans_anal_attrib.a_transaction_number_i = a_transaction.a_transaction_number_i" +
                    " AND a_trans_anal_attrib.a_analysis_type_code_c = a_analysis_type.a_analysis_type_code_c" +
                    AnalysisTypeFilter +
                    AccountCodeFilter + CostCentreFilter + " AND " + TranctDateFilter +
                    " AND a_transaction_status_l=true AND NOT (a_system_generated_l=true AND a_narrative_c LIKE 'Year end re-allocation%')" +
                    " ORDER BY " + GroupField + ", a_transaction_date_d");
            }
            else
            {
                Csv = StringHelper.AddCSV(Csv, "Transactions/" +
                                          "SELECT a_transaction.a_account_code_c AS AccountCode," +
                                          "a_transaction.a_cost_centre_code_c AS CostCentreCode," +
                                          "a_transaction.a_transaction_date_d AS TransactionDate," +
                                          "a_transaction." + AmountField + " AS Amount," +
                                          "a_journal.a_transaction_currency_c AS Currency," +
                                          "a_transaction.a_debit_credit_indicator_l AS Debit," +
                                          "a_transaction.a_narrative_c AS Narrative," +
                                          "a_transaction.a_reference_c AS Reference," +
                                          "'' AS AnalysisTypeCode," +
                                          "'' AS AnalysisTypeDescr," +
                                          "'' AS AnalysisValue" +
                                          " FROM a_transaction, a_journal WHERE " +
                                          " a_transaction." + LedgerFilter +
                                          " AND a_transaction.a_ledger_number_i = a_journal.a_ledger_number_i " +
                                          " AND a_transaction.a_batch_number_i = a_journal.a_batch_number_i " +
                                          " AND a_transaction.a_journal_number_i = a_journal.a_journal_number_i " +
                                          AccountCodeFilter +
                                          CostCentreFilter + " AND " +
                                          TranctDateFilter + ReferenceFilter +
                                          " AND a_transaction_status_l=true AND NOT (a_system_generated_l=true AND a_narrative_c LIKE 'Year end re-allocation%')" +
                                          " ORDER BY " + GroupField + ", a_transaction_date_d");
            }

            GLReportingTDS ReportDs = TRemote.MReporting.WebConnectors.GetReportingDataSet(Csv);

            if ((this.IsDisposed) || // If the user has pressed Esc the form is closed!
                (TRemote.MReporting.WebConnectors.DataTableGenerationWasCancelled()))
            {
                return(false);
            }

            //
            // I want to include opening and closing balances for each Cost Centre / Account, in the selected currency.
            // Following a revision in Oct 2014, this table is the master table, and the transactions are the slave.

            Int32 Year = parameters.Get("param_year_i").ToInt32();

            Balances = TRemote.MFinance.Reporting.WebConnectors.GetPeriodBalances(
                LedgerFilter,
                GlmAccountCodeFilter,
                GlmCostCentreFilter,
                Year,
                Sortby,
                ReportDs.Tables["Transactions"],
                parameters.Get("param_start_period_i").ToInt32(),
                parameters.Get("param_end_period_i").ToInt32(),
                InternationalCurrencySelected
                );

            if ((this.IsDisposed) || (Balances == null))
            {
                return(false);
            }

            // My report doesn't need a ledger row - only the name of the ledger. And I need the currency formatter..
            {
                ALedgerRow Row = ReportDs.ALedger[0];
                ACalc.AddStringParameter("param_ledger_name", Row.LedgerName);
                ACalc.AddStringParameter("param_currency_formatter", "0,0.000");
            }

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

            //
            // If I need to show Analysis Attributes, I need to get the rows that pertain to the Transactions I've selected above.
            if (ReportDs.ATransaction.Rows.Count > 0)
            {
                DataView BatchSorted = new DataView(ReportDs.ATransaction);
                BatchSorted.Sort = "a_batch_number_i";
                ATransactionRow Row        = (ATransactionRow)BatchSorted[0].Row;
                Int32           FirstBatch = Row.BatchNumber;
                Row = (ATransactionRow)BatchSorted[BatchSorted.Count - 1].Row;
                Int32 LastBatch = Row.BatchNumber;

                Csv = "";
                Csv = StringHelper.AddCSV(
                    Csv,
                    "ATransAnalAttrib/SELECT * FROM a_trans_anal_attrib WHERE " + LedgerFilter +
                    " AND a_batch_number_i >= " + FirstBatch +
                    " AND a_batch_number_i <= " + LastBatch);
                Csv = StringHelper.AddCSV(Csv, "AAnalysisType/SELECT * FROM a_analysis_type");
                ReportDs.Merge(TRemote.MReporting.WebConnectors.GetReportingDataSet(Csv));
            }

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

            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDs.ATransAnalAttrib, "a_trans_anal_attrib");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDs.AAnalysisType, "a_analysis_type");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDs.AAccount, "a_account");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDs.ACostCentre, "a_costCentre");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDs.Tables["Transactions"], "Transactions");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(Balances, "balances");

            //
            // For Account Detail 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.

            if ((parameters.Get("param_sortby").ToString() == "Cost Centre") &&
                (parameters.Get("param_auto_email").ToBool()) &&
                !parameters.Get("param_design_template").ToBool()
                )
            {
                FPetraUtilsObject.FFastReportsPlugin.AutoEmailReports(ACalc, FLedgerNumber, CostCentreFilter);
                return(false);
            }

            return(true);
        }
Example #26
0
        /// <summary>
        /// Reads the selected values from the controls,
        /// and stores them into the parameter system of FCalculator
        ///
        /// </summary>
        /// <param name="ACalculator"></param>
        /// <param name="AReportAction"></param>
        /// <returns>void</returns>
        public void ReadControls(TRptCalculator ACalculator, TReportActionEnum AReportAction)
        {
            TVerificationResult VerificationResult;

            if (rbtAllAccounts.Checked)
            {
                ACalculator.AddParameter("param_rgrAccounts", "AllAccounts");
                ACalculator.AddParameter("param_account_list_title", "All Accounts");
            }
            else if (rbtAccountFromList.Checked)
            {
                String SelectedAccountCodes = clbAccountCodes.GetCheckedStringList();

                if ((SelectedAccountCodes.Length == 0) &&
                    (AReportAction == TReportActionEnum.raGenerate))
                {
                    VerificationResult = new TVerificationResult(Catalog.GetString("Select Account Codes"),
                                                                 Catalog.GetString("No Account Code was selected!"),
                                                                 TResultSeverity.Resv_Critical);
                    FPetraUtilsObject.AddVerificationResult(VerificationResult);
                }

                ACalculator.AddStringParameter("param_account_codes", SelectedAccountCodes);

                if (SelectedAccountCodes.Length > 25)
                {
                    SelectedAccountCodes = "Selected Accounts";
                }

                // need to set NOTUSED,
                // otherwise the report generator complains about the missing parameter
                // *NOTUSED* is used as an invalid value, there is no account with this name
                ACalculator.AddParameter("param_account_list_title", SelectedAccountCodes);
                ACalculator.AddParameter("param_account_code_start", "*NOTUSED*");
                ACalculator.AddParameter("param_account_code_end", "*NOTUSED*");
                ACalculator.AddParameter("param_rgrAccounts", "AccountList");
            }
            else
            {
                ACalculator.AddParameter("param_account_list_title",
                                         cmbFromAccountCode.GetSelectedString() + " To " + cmbToAccountCode.GetSelectedString());
                ACalculator.AddParameter("param_account_codes", "*NOTUSED*");
                ACalculator.AddParameter("param_account_code_start", cmbFromAccountCode.GetSelectedString());
                ACalculator.AddParameter("param_account_code_end", cmbToAccountCode.GetSelectedString());
                ACalculator.AddParameter("param_rgrAccounts", "AccountRange");

                VerificationResult = TStringChecks.FirstLesserOrEqualThanSecondString(
                    cmbFromAccountCode.GetSelectedString(),
                    cmbToAccountCode.GetSelectedString(),
                    Catalog.GetString("Account Range From"),
                    Catalog.GetString("Account Range To"));

                if (VerificationResult != null)
                {
                    FPetraUtilsObject.AddVerificationResult(VerificationResult);
                }
            }

            if (rbtAllCostCentres.Checked)
            {
                ACalculator.AddParameter("param_cost_centre_list_title", "All Cost Centres");
                ACalculator.AddParameter("param_rgrCostCentres", "AllCostCentres");
            }
            else if (rbtCostCentreFromList.Checked)
            {
                VerificationResult = TGuiChecks.ValidateCheckedListBoxVersatile(clbCostCentres);

                if (VerificationResult != null)
                {
                    VerificationResult = new TVerificationResult(Catalog.GetString("Select CostCentre Codes from list"),
                                                                 Catalog.GetString("No cost centre was selected!"),
                                                                 TResultSeverity.Resv_Critical);
                    FPetraUtilsObject.AddVerificationResult(VerificationResult);
                }

                String CostCentreListTitle = clbCostCentres.GetCheckedStringList();
                ACalculator.AddStringParameter("param_cost_centre_codes", CostCentreListTitle);
                CostCentreListTitle = CostCentreListTitle.Replace("\"", "");

                if (CostCentreListTitle.Length > 25)
                {
                    CostCentreListTitle = "Selected Cost Centres";
                }

                // need to set NOTUSED,
                // otherwise the report generator complains about the missing parameter
                // NOTUSED is used as an invalid value, there is no Cost Centre with this name
                ACalculator.AddParameter("param_cost_centre_list_title", CostCentreListTitle);
                ACalculator.AddParameter("param_cost_centre_code_start", "*NOTUSED*");
                ACalculator.AddParameter("param_cost_centre_code_end", "*NOTUSED*");
                ACalculator.AddParameter("param_rgrCostCentres", "CostCentreList");
            }
            else
            {
                ACalculator.AddParameter("param_cost_centre_list_title",
                                         cmbFromCostCentre.GetSelectedString() + " To " + cmbToCostCentre.GetSelectedString());
                ACalculator.AddParameter("param_cost_centre_codes", "*NOTUSED*");
                ACalculator.AddParameter("param_cost_centre_code_start", cmbFromCostCentre.GetSelectedString());
                ACalculator.AddParameter("param_cost_centre_code_end", cmbToCostCentre.GetSelectedString());

                VerificationResult = TStringChecks.FirstLesserOrEqualThanSecondString(
                    cmbFromCostCentre.GetSelectedString(),
                    cmbToCostCentre.GetSelectedString(),
                    Catalog.GetString("Cost Centre Range From"),
                    Catalog.GetString("Cost Centre Range To"));

                if (VerificationResult != null)
                {
                    FPetraUtilsObject.AddVerificationResult(VerificationResult);
                }

                ACalculator.AddParameter("param_rgrCostCentres", "CostCentreRange");
            }

            ACalculator.AddParameter("param_depth", "standard"); // I don't want this, but I'll keep it for a while...
        }
Example #27
0
        //
        // 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)
        {
            //
            // 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();
            }

            if (!Int32.TryParse(txtBatchNumber.Text, out FBatchNumber))
            {
                MessageBox.Show(
                    Catalog.GetString("Fault: No valid Batch number"),
                    Catalog.GetString("Gift Batch Detail"));
                return(false);
            }

            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.

            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, FBatchNumber, true));
            }

            ACalc.AddParameter("param_ledger_number_i", FLedgerNumber);
            ACalc.AddParameter("param_batch_number_i", FBatchNumber);


            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");

            return(true);
        }
        /// <summary>
        /// The report will be sent to a list of email addresses derived from the Cost Centres in the supplied CostCentreFilter.
        /// </summary>
        /// <param name="ACalc"></param>
        /// <param name="ALedgerNumber"></param>
        /// <param name="ACostCentreFilter"></param>
        public void AutoEmailReports(TRptCalculator ACalc, Int32 ALedgerNumber, String ACostCentreFilter)
        {
            Int32  SuccessfulCount = 0;
            String NoEmailAddr     = "";
            String FailedAddresses = "";

            //
            // I need to find the email addresses for the linked partners I'm sending to.

            DataTable LinkedPartners = TRemote.MFinance.Setup.WebConnectors.GetLinkedPartners(ALedgerNumber, ACostCentreFilter);

            LinkedPartners.DefaultView.Sort = "CostCentreCode";

            foreach (DataRowView rv in LinkedPartners.DefaultView)
            {
                DataRow LinkedPartner = rv.Row;

                if (LinkedPartner["EmailAddress"].ToString() != "")
                {
                    ACalc.AddStringParameter("param_linked_partner_cc", LinkedPartner["CostCentreCode"].ToString());
                    FPetraUtilsObject.WriteToStatusBar("Generate " + FReportName + " Report for " + LinkedPartner["PartnerShortName"]);
                    MemoryStream ReportStream = FPetraUtilsObject.FFastReportsPlugin.ExportToStream(ACalc, FastReportsWrapper.ReportExportType.Html);
                    ReportStream.Position = 0;

                    TUC_EmailPreferences.LoadEmailDefaults();
                    TSmtpSender EmailSender;
                    try
                    {
                        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");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show(Catalog.GetString(
                                            "Failed to set up the email server.\nPlease check the settings in Preferences / Email."),
                                        Catalog.GetString("Auto-email to linked partners"));
                        return;
                    }

                    String EmailBody = "";

                    if (TUserDefaults.GetBooleanDefault("SmtpSendAsAttachment"))
                    {
                        EmailBody = TUserDefaults.GetStringDefault("SmtpEmailBody");
                        EmailSender.AttachFromStream(ReportStream, FReportName + ".html");
                    }
                    else
                    {
                        StreamReader sr = new StreamReader(ReportStream);
                        EmailBody = sr.ReadToEnd();
                    }

                    Boolean SentOk = EmailSender.SendEmail(
                        TUserDefaults.GetStringDefault("SmtpFromAccount"),
                        TUserDefaults.GetStringDefault("SmtpDisplayName"),
                        "*****@*****.**", //LinkedPartner["EmailAddress"]
                        FReportName + " Report for " + LinkedPartner["PartnerShortName"] + ", Address=" + LinkedPartner["EmailAddress"],
                        EmailBody);

                    if (SentOk)
                    {
                        SuccessfulCount++;
                    }
                    else // Email didn't send for some reason
                    {
                        FailedAddresses += ("\r\n" + LinkedPartner["EmailAddress"]);
                    }
                }
                else // No Email Address for this Partner
                {
                    NoEmailAddr += ("\r\n" + LinkedPartner["PartnerKey"] + " " + LinkedPartner["PartnerShortName"]);
                }
            }

            String SendReport = "";

            if (SuccessfulCount > 0)
            {
                SendReport += String.Format(Catalog.GetString("Reports emailed to {0} addresses."), SuccessfulCount) + "\r\n\r\n";
            }

            if (NoEmailAddr != "")
            {
                SendReport += (Catalog.GetString("These Partners have no email addresses:") + NoEmailAddr + "\r\n\r\n");
            }

            if (FailedAddresses != "")
            {
                SendReport += (Catalog.GetString("Failed to send email to these addresses:") + FailedAddresses + "\r\n\r\n");
            }

            MessageBox.Show(SendReport, Catalog.GetString("Auto-email to linked partners"));
            FPetraUtilsObject.WriteToStatusBar("");
        } // AutoEmailReports
Example #29
0
        /// <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);
            }
        }
Example #30
0
        //
        // 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);
        }