コード例 #1
0
        private void grdChargedFields_ReadControls(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            String SelectedFieldKeys = "";

            if ((FFieldTable != null)
                && rbtSelectedFields.Checked)
            {
                foreach (DataRow Row in FFieldTable.Rows)
                {
                    if (((bool)Row["Selection"])
                        && (ucoConferenceSelection.AllConferenceSelected
                            || (!ucoConferenceSelection.AllConferenceSelected && (bool)Row["Used_in_Conference"])))
                    {
                        SelectedFieldKeys = SelectedFieldKeys + Row["Unit Key"].ToString() + ',';
                    }
                }
            }

            if (SelectedFieldKeys.Length > 0)
            {
                // Remove the last comma
                SelectedFieldKeys = SelectedFieldKeys.Remove(SelectedFieldKeys.Length - 1);
            }

            ACalc.AddStringParameter("param_selectedfieldkeys", SelectedFieldKeys);

            if (rbtSelectedFields.Checked)
            {
                ACalc.AddParameter("param_chargedfields", "Selected Fields");

                if ((SelectedFieldKeys.Length == 0)
                    && (AReportAction == TReportActionEnum.raGenerate))
                {
                    TVerificationResult VerificationResult = new TVerificationResult(
                        Catalog.GetString("Select at least one field to calculate the extra costs."),
                        Catalog.GetString("No field was selected!"),
                        TResultSeverity.Resv_Critical);
                    FPetraUtilsObject.AddVerificationResult(VerificationResult);
                }
            }
            else
            {
                ACalc.AddParameter("param_chargedfields", "All Fields");
            }
        }
コード例 #2
0
        //
        // New methods using the Fast-reports DLL:

        private Boolean LoadReportData(TRptCalculator ACalc)
        {
            Shared.MReporting.TParameterList pm = ACalc.GetParameters();
            //
            // My report doesn't need a ledger row - only the name of the ledger. And I need the currency formatter..
            String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(FLedgerNumber);
            ACalc.AddStringParameter("param_ledger_name", LedgerName);
            ACalc.AddStringParameter("param_currency_formatter", "0,0.000");
            ACalc.AddParameter("param_period", true);
            ACalc.AddStringParameter("param_linked_partner_cc", ""); // Used for auto-emailing HOSAs, this is usually blank.

            // 0 = Full Report. Currently the only option for this report.
            pm.Add("param_ich_number", 0);
            return LoadReportDataStaticInner(this, FPetraUtilsObject, FPetraUtilsObject.FFastReportsPlugin, ACalc);
        }
コード例 #3
0
        /// <summary>Helper for the report printing ClientTask</summary>
        /// <param name="ReportName"></param>
        /// <param name="paramStr"></param>
        public static void PrintReportNoUi(String ReportName, String paramStr)
        {
            String[] Params = paramStr.Split(',');
            Int32 LedgerNumber = -1;
            Int32 BatchNumber = -1;

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

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

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

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

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

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

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

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

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

                    break;
                }

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

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

            Application.OpenForms[0].Invoke((ThreadStart) delegate { ReportingEngine.GenerateReport(Calc); });
        } // PrintReportNoUi
コード例 #4
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
コード例 #5
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);
            }
        }
コード例 #6
0
        } // AutoEmailReports

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

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

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

            TRptCalculator Calc = new TRptCalculator();

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

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

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

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

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

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

                    break;
                }
            } // switch

            ReportingEngine.GenerateReport(Calc);
        } // PrintReportNoUi
コード例 #7
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;
        }
コード例 #8
0
        private Dictionary <String, TVariant>InitialiseDictionary(TRptCalculator ACalc)
        {
            Shared.MReporting.TParameterList pm = ACalc.GetParameters();
            pm.Add("param_ledger_number_i", FLedgerNumber);
            String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(FLedgerNumber);
            ACalc.AddStringParameter("param_ledger_name", LedgerName);
            ACalc.AddParameter("param_currency_name", FLedgerRow.BaseCurrency); // Stewardship reports are always in Base Currency.

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

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

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

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

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

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

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

            return paramsDictionary;
        } // Initialise Dictionary
コード例 #9
0
        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
コード例 #10
0
        private Boolean LoadStewardshipReportData(TRptCalculator ACalc)
        {
            Shared.MReporting.TParameterList pm = ACalc.GetParameters();
            pm.Add("param_ledger_number_i", FLedgerNumber);

            ArrayList reportParam = pm.Elems;
            Dictionary <String, TVariant>paramsDictionary = new Dictionary <string, TVariant>();

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

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

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

            if (this.IsDisposed)
            {
                return false;
            }

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

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

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

            if (!HasData)
            {
                MessageBox.Show(Catalog.GetString("No Stewardship entries found for selected Run Number."), "Stewardship");
            }

            return HasData;
        }
コード例 #11
0
        /// <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);
            }
        }
コード例 #12
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));
            }

            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;
        }
コード例 #13
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);
            }
        }
コード例 #14
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));
        }
コード例 #15
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)
        {
            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);
            }
        }
コード例 #16
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;
        }
        //
        // New methods using the Fast-reports DLL:

        private Boolean LoadReportData(TRptCalculator ACalc)
        {
            ArrayList reportParam = ACalc.GetParameters().Elems;

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

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

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

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

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

            Boolean HasData = ReportTable.Rows.Count > 0;

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

            return HasData;
        }
コード例 #18
0
        private Boolean LoadReportData(TRptCalculator ACalc)
        {
            ArrayList reportParam = ACalc.GetParameters().Elems;

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

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

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

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

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

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

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

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

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

            return HasData;
        }
コード例 #19
0
        } // Initialise Dictionary

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

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

            return DataOk;
        }  // Load Hosa Report Data
コード例 #20
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)
                {
                    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 Cost Centre 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...
        }
コード例 #21
0
        /// <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
コード例 #22
0
        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);
        }
コード例 #23
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;
        }
コード例 #24
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)
        {
            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");
            }
        }
コード例 #25
0
        /// <summary>
        /// Print or reprint the posting report for this batch.
        /// </summary>
        public static void PrintPostingRegister(Int32 ALedgerNumber, Int32 ABatchNumber, Boolean AEditTemplate = false)
        {
            FastReportsWrapper ReportingEngine = new FastReportsWrapper("Batch Posting Register");

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

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

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

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

            if (AEditTemplate)
            {
                ReportingEngine.DesignReport(Calc);
            }
            else
            {
                ReportingEngine.GenerateReport(Calc);
            }
        }
コード例 #26
0
        /// <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);
            }
        }
コード例 #27
0
        } // AutoEmailReports

        /// <summary>Get all the data for the report</summary>
        /// <remarks>Called from the server during batch posting, and also from File/Print gui</remarks>
        /// <param name="ACalc"></param>
        /// <param name="ALedgerNumber"></param>
        /// <param name="ABatchNumber"></param>
        /// <returns></returns>
        public Boolean RegisterBatchPostingData(TRptCalculator ACalc, Int32 ALedgerNumber, Int32 ABatchNumber)
        {
            GLBatchTDS BatchTDS = TRemote.MFinance.GL.WebConnectors.LoadABatchAndContent(ALedgerNumber, ABatchNumber);

            if (BatchTDS.ABatch.Rows.Count < 1)
            {
                MessageBox.Show(Catalog.GetString("Batch not found"),
                    Catalog.GetString("Batch Posting Register"),
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return false;
            }

            //Call RegisterData to give the data to the template
            RegisterData(BatchTDS.ABatch, "ABatch");
            RegisterData(BatchTDS.AJournal, "AJournal");
            RegisterData(BatchTDS.ATransaction, "ATransaction");
            RegisterData(TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList,
                    ALedgerNumber), "AAccount");
            RegisterData(TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.CostCentreList,
                    ALedgerNumber), "ACostCentre");

            ACalc.AddParameter("param_batch_number_i", ABatchNumber);
            ACalc.AddParameter("param_ledger_number_i", ALedgerNumber);
            String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(ALedgerNumber);
            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.
            ACalc.AddParameter("param_currency_name",
                TRemote.MFinance.Reporting.WebConnectors.GetTransactionCurrency(ALedgerNumber, ABatchNumber));
            return true;
        }
コード例 #28
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 = 99;
            String DepthOption = paramsDictionary["param_depth"].ToString();

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            return true;
        }
コード例 #29
0
ファイル: AFO.ManualCode.cs プロジェクト: js1987/openpetragit
        //
        // New methods using the Fast-reports DLL:

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

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

            ArrayList reportParam = ACalc.GetParameters().Elems;
            Dictionary <String, TVariant>paramsDictionary = new Dictionary <string, TVariant>();

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

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

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

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

            Boolean HasData = ReportTable.Rows.Count > 0;

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

            return HasData;
        }
コード例 #30
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;
        }