//
        // This will be called if the Fast Reports Wrapper loaded OK.
        // Returns True if the data apparently loaded OK and the report should be printed.
        private bool LoadReportData(TRptCalculator ACalc)
        {
            ArrayList reportParam = ACalc.GetParameters().Elems;

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

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

            String RootCostCentre = "[" + FLedgerNumber + "]";

            paramsDictionary.Add("param_cost_centre_code", new TVariant(RootCostCentre));

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

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

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

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

            ACalc.AddStringParameter("param_ledger_name", LedgerName);

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

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

            DataView Dv = ReportTable.DefaultView;

            // sort the table
            Dv.Sort = ACalc.GetParameters().Get("param_sortby_readable").ToString().Replace(" ", "");

            ReportTable = Dv.ToTable();

            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "SYBUNT");
            //
            // My report doesn't need a ledger row - only the name of the ledger. And I need the currency formatter..
            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_currency_formatter", "0,0.000");

            Boolean HasData = ReportTable.Rows.Count > 0;

            if (!HasData)
            {
                MessageBox.Show(Catalog.GetString("No Motivation Response data found."), "Motivation Response");
            }

            return(HasData);
        }
        //
        // This will be called if the Fast Reports Wrapper loaded OK.
        // Returns True if the data apparently loaded OK and the report should be printed.
        private bool LoadReportData(TRptCalculator ACalc)
        {
            ArrayList reportParam = ACalc.GetParameters().Elems;

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

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

            String RootCostCentre = "[" + FLedgerNumber + "]";

            paramsDictionary.Add("param_cost_centre_code", new TVariant(RootCostCentre));

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

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

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

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

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

            String  LedgerName = "";
            Boolean IsClosed   = false;

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

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

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

            return(true);
        }
Esempio n. 4
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.GetOneYearMonthGivingDataSet(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["Donors"], "Donors");

            //
            // 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);
            ALedgerTable LedgerDetailsTable = (ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails,
                                                                                                          FLedgerNumber);
            ALedgerRow Row = LedgerDetailsTable[0];

            ACalc.AddStringParameter("param_ledger_name", LedgerName);
            String CurrencyName = (cmbCurrency.SelectedItem.ToString() == "Base") ? Row.BaseCurrency : Row.IntlCurrency;

            ACalc.AddStringParameter("param_currency_name", CurrencyName);

            ACalc.AddStringParameter("param_currency_formatter", "0,0.000");

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

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

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

            pm.Add("param_start_period_i", 1);

            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("Executive Summary", 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.
            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);
            ALedgerRow Ledger =
                ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, FLedgerNumber))[0];

            ACalc.AddStringParameter("param_currency_name", Ledger.BaseCurrency);

            Boolean HasData = ReportTable.Rows.Count > 0;

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

            return(HasData);
        }
        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);
        }
        /// <summary>
        /// open the Partner Edit screen for the supplier
        /// </summary>
        private void EditPartner(object sender, EventArgs e)
        {
            FPetraUtilsObject.WriteToStatusBar("Opening Partner in Partner Edit screen...");
            this.Cursor = Cursors.WaitCursor;

            try
            {
                TFrmPartnerEdit frm = new TFrmPartnerEdit(this);
                frm.SetParameters(TScreenMode.smEdit, FMainDS.AApSupplier[0].PartnerKey);
                frm.Show();
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Esempio n. 8
0
        //
        // New methods using the Fast-reports DLL:

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

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

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

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

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

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

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

            ACalc.AddStringParameter("param_ledger_name", LedgerName);
            ACalc.AddStringParameter("param_currency_formatter", "0,0.000");
            ACalc.AddStringParameter("param_base_currency", uco_GeneralSettings.GetBaseCurrency());
            ACalc.AddStringParameter("param_intl_currency", uco_GeneralSettings.GetInternationalCurrency());

            Boolean HasData = ReportTable.Rows.Count > 0;

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

            return(HasData);
        }
Esempio n. 9
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("StewardshipForPeriod", paramsDictionary);

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

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

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

            //
            // 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);
        }
        } // Load Stewardship Report Data

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

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

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

            String[] SelectedFees = paramsDictionary["param_fee_codes"].ToString().Split(',');
            Int32    FeeCols      = SelectedFees.Length;

            ACalc.AddParameter("param_fee_columns", FeeCols);

            DataTable FeeNames = new DataTable();

            for (Int32 Idx = 0; Idx < uco_SelectedFees.MAX_FEE_COUNT; Idx++)
            {
                FeeNames.Columns.Add();
            }

            DataRow Row = FeeNames.NewRow();

            FeeNames.Rows.Add(Row);

            for (Int32 Idx = 0; Idx < FeeCols; Idx++)
            {
                Row[Idx] = SelectedFees[Idx];
            }

            ACalc.AddParameter("param_full_report", rbtFull.Checked);

            MyFastReportsPlugin.RegisterData(FeeNames, "FeeNames");
            MyFastReportsPlugin.RegisterData(ReportTable, "Fees");
            return(true);
        } // Load Fees Report Data
        //
        // 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);
        }
        private TSubmitChangesResult StoreManualCode(ref GLSetupTDS ASubmitDS, out TVerificationResultCollection AVerificationResult)
        {
            //
            // The Controls might not have changed, but if they have, this will make the tree look right:
            FPetraUtilsObject_ControlChanged(null);

            //
            // I'll look through and check whether any of the cost centres still have "NEWCOSTCENTRE"..
            //
            if (CheckForInvalidCostCentre())
            {
                AVerificationResult = null;
                FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataErrorOccured);
                return TSubmitChangesResult.scrInfoNeeded;
            }

            ucoCostCentreTree.MarkAllNodesCommitted();
            TSubmitChangesResult ServerResult =
                TRemote.MFinance.Setup.WebConnectors.SaveGLSetupTDS(FLedgerNumber, ref ASubmitDS, out AVerificationResult);
            TDataCache.TMFinance.RefreshCacheableFinanceTable(Shared.TCacheableFinanceTablesEnum.CostCentreList, FLedgerNumber);
            return ServerResult;
        }
Esempio n. 13
0
        /// <summary>
        /// save the changes on the screen
        /// </summary>
        /// <returns></returns>
        public bool SaveChanges()
        {
            Boolean ReturnValue;

            FPetraUtilsObject.OnDataSavingStart(this, new System.EventArgs());

            // Don't allow saving if user is still editing a Detail of a List
            if (FPetraUtilsObject.InDetailEditMode())
            {
                ReturnValue = false;
                return(ReturnValue);
            }

            // Clear any validation errors so that the following call to ValidateAllData starts with a 'clean slate'.
            FPetraUtilsObject.VerificationResultCollection.Clear();

            if (ValidateAllData(false, true))
            {
                FMainDS.AApSupplier.Rows[0].BeginEdit();
                GetDataFromControls(FMainDS.AApSupplier[0]);

                if (FMainDS.AApSupplier[0].IsDefaultApAccountNull())
                {
                    MessageBox.Show(Catalog.GetString("Please select an AP account (eg. 9100)"));
                    FMainDS.AApSupplier.Rows[0].EndEdit();

                    ReturnValue = false;
                    return(ReturnValue);
                }

                // The account would usually be 9100-AP account.
                if (FMainDS.AApSupplier[0].DefaultApAccount != "9100")
                {
                    if (MessageBox.Show(Catalog.GetString("You are not using the standard AP account (9100) - is this OK?"),
                                        "Verification", MessageBoxButtons.YesNo)
                        != System.Windows.Forms.DialogResult.Yes)
                    {
                        FMainDS.AApSupplier.Rows[0].EndEdit();
                        return(false);
                    }
                }

                // Don't store with invalid currency value.
                //
                if (FMainDS.AApSupplier[0].CurrencyCode == "")
                {
                    FMainDS.AApSupplier[0].CurrencyCode = FLedgerRow.BaseCurrency;
                }

                // If this is a foreign currency supplier, it must be linked to accounts in that currency.
                // (And if it's not, it mustn't be!)
                if (!ValidateAccountCurrency(FMainDS.AApSupplier[0].DefaultBankAccount, "Bank"))
                {
                    return(false);
                }

                /*
                 * If we wanted to have only expense accounts in a single currency, we could have this,
                 * but that's probably not what we want...
                 *
                 *          if (!ValidateAccountCurrency(FMainDS.AApSupplier[0].DefaultExpAccount, "Expense"))
                 *          {
                 *              return false;
                 *          }
                 */
            }

            ReturnValue = TDataValidation.ProcessAnyDataValidationErrors(false, FPetraUtilsObject.VerificationResultCollection,
                                                                         this.GetType());

            if (ReturnValue)
            {
                foreach (DataTable InspectDT in FMainDS.Tables)
                {
                    foreach (DataRow InspectDR in InspectDT.Rows)
                    {
                        InspectDR.EndEdit();
                    }
                }

                if (FPetraUtilsObject.HasChanges)
                {
                    FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataInProgress);
                    this.Cursor = Cursors.WaitCursor;

                    AccountsPayableTDS SubmitDS = FMainDS.GetChangesTyped(true);

                    TSubmitChangesResult          SubmissionResult;
                    TVerificationResultCollection VerificationResult = new TVerificationResultCollection();

                    // Submit changes to the PETRAServer
                    try
                    {
                        SubmissionResult = FUIConnector.SubmitChanges(ref SubmitDS);
                    }
                    catch (ESecurityDBTableAccessDeniedException Exp)
                    {
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException);
                        this.Cursor = Cursors.Default;
                        TMessages.MsgSecurityException(Exp, this.GetType());

                        ReturnValue = false;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(ReturnValue);
                    }
                    catch (EDBConcurrencyException Exp)
                    {
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException);
                        this.Cursor = Cursors.Default;
                        TMessages.MsgDBConcurrencyException(Exp, this.GetType());

                        ReturnValue = false;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(ReturnValue);
                    }
                    catch (Exception exp)
                    {
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException);
                        this.Cursor = Cursors.Default;
                        TLogging.Log(
                            Catalog.GetString(
                                "An error occurred while trying to connect to the OpenPetra Server!") + Environment.NewLine + exp.ToString(),
                            TLoggingType.ToLogfile);
                        MessageBox.Show(
                            Catalog.GetString("An error occurred while trying to connect to the OpenPetra Server!") + Environment.NewLine +
                            "For details see the log file: " + TLogging.GetLogFileName(),
                            "Server connection error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Stop);

                        ReturnValue = false;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(ReturnValue);
                    }

                    switch (SubmissionResult)
                    {
                    case TSubmitChangesResult.scrOK:

                        // Call AcceptChanges to get rid now of any deleted columns before we Merge with the result from the Server
                        FMainDS.AcceptChanges();

                        // Merge back with data from the Server (eg. for getting Sequence values)
                        FMainDS.Merge(SubmitDS, false);

                        // need to accept the new modification ID
                        FMainDS.AcceptChanges();

                        // Update UI
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataSuccessful);
                        this.Cursor = Cursors.Default;

                        // We don't have unsaved changes anymore
                        FPetraUtilsObject.DisableSaveButton();

                        ReturnValue = true;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        break;

                    case TSubmitChangesResult.scrError:
                        this.Cursor = Cursors.Default;
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataErrorOccured);

                        MessageBox.Show(Messages.BuildMessageFromVerificationResult(null, VerificationResult));

                        FPetraUtilsObject.SubmitChangesContinue = false;

                        ReturnValue = false;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        break;

                    case TSubmitChangesResult.scrNothingToBeSaved:
                        this.Cursor = Cursors.Default;
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataNothingToSave);

                        // We don't have unsaved changes anymore
                        FPetraUtilsObject.DisableSaveButton();

                        ReturnValue = true;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        break;

                    case TSubmitChangesResult.scrInfoNeeded:

                        // TODO scrInfoNeeded
                        this.Cursor = Cursors.Default;
                        break;
                    }
                }
                else
                {
                    // Update UI
                    FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataNothingToSave);
                    this.Cursor = Cursors.Default;
                    FPetraUtilsObject.DisableSaveButton();

                    // We don't have unsaved changes anymore
                    FPetraUtilsObject.HasChanges = false;

                    ReturnValue = true;
                    FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                }
            }
            else
            {
                FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(false));
            }

            return(ReturnValue);
        }
Esempio n. 14
0
        /// <summary>
        /// Creates a new gift or gift detail depending upon the parameter
        /// </summary>
        /// <param name="ACompletelyNewGift"></param>
        private void CreateANewGift(bool ACompletelyNewGift)
        {
            AGiftRow CurrentGiftRow = null;
            bool     IsEmptyGrid    = (grdDetails.Rows.Count == 1);
            bool     HasChanges     = FPetraUtilsObject.HasChanges;
            bool     SelectEndRow   = false;

            bool FPrevRowIsNull = (FPreviouslySelectedDetailRow == null);
            bool CopyDetails    = false;

            bool AutoSaveSuccessful = FAutoSave && HasChanges && ((TFrmGiftBatch)ParentForm).SaveChangesManual();

            FCreatingNewGift = true;

            try
            {
                //May need to copy values down if a new detail row inside current gift
                int    giftTransactionNumber = 0;
                string donorName             = string.Empty;
                string donorClass            = string.Empty;
                bool   confidentialGiftFlag  = false;
                bool   chargeFlag            = false;
                bool   taxDeductible         = false;
                string motivationGroupCode   = string.Empty;
                string motivationDetailCode  = string.Empty;

                if (AutoSaveSuccessful || ((!FAutoSave || !HasChanges) && ValidateAllData(true, TErrorProcessingMode.Epm_IgnoreNonCritical)))
                {
                    if (!ACompletelyNewGift)      //i.e. a gift detail
                    {
                        ACompletelyNewGift = IsEmptyGrid;
                    }

                    CopyDetails = (!ACompletelyNewGift && !FPrevRowIsNull);

                    if (CopyDetails)
                    {
                        //Allow for possibility that FPrev... may have some null column values
                        giftTransactionNumber = FPreviouslySelectedDetailRow.GiftTransactionNumber;
                        donorName             = FPreviouslySelectedDetailRow.IsDonorNameNull() ? string.Empty : FPreviouslySelectedDetailRow.DonorName;
                        donorClass            = FPreviouslySelectedDetailRow.IsDonorClassNull() ? string.Empty : FPreviouslySelectedDetailRow.DonorClass;
                        confidentialGiftFlag  =
                            FPreviouslySelectedDetailRow.IsConfidentialGiftFlagNull() ? false : FPreviouslySelectedDetailRow.ConfidentialGiftFlag;
                        chargeFlag          = FPreviouslySelectedDetailRow.IsChargeFlagNull() ? true : FPreviouslySelectedDetailRow.ChargeFlag;
                        taxDeductible       = FPreviouslySelectedDetailRow.IsTaxDeductibleNull() ? true : FPreviouslySelectedDetailRow.TaxDeductible;
                        motivationGroupCode =
                            FPreviouslySelectedDetailRow.IsMotivationGroupCodeNull() ? string.Empty : FPreviouslySelectedDetailRow.
                            MotivationGroupCode;
                        motivationDetailCode =
                            FPreviouslySelectedDetailRow.IsMotivationDetailCodeNull() ? string.Empty : FPreviouslySelectedDetailRow.
                            MotivationDetailCode;
                    }

                    //Set previous row to Null.
                    FPreviouslySelectedDetailRow = null;

                    if (ACompletelyNewGift)
                    {
                        //Run this if a new gift is requested or required.
                        SelectEndRow = true;

                        // we create the row locally, no dataset
                        AGiftRow giftRow = FMainDS.AGift.NewRowTyped(true);

                        giftRow.LedgerNumber          = FBatchRow.LedgerNumber;
                        giftRow.BatchNumber           = FBatchRow.BatchNumber;
                        giftRow.GiftTransactionNumber = ++FBatchRow.LastGiftNumber;
                        giftRow.MethodOfPaymentCode   = FBatchRow.MethodOfPaymentCode;
                        giftRow.LastDetailNumber      = 1;
                        giftRow.DateEntered           = FBatchRow.GlEffectiveDate;

                        FMainDS.AGift.Rows.Add(giftRow);

                        CurrentGiftRow = giftRow;

                        mniDonorHistory.Enabled = false;

                        //Reset textboxes to zero
                        txtGiftTotal.NumberValueDecimal = 0;
                    }
                    else
                    {
                        CurrentGiftRow = GetGiftRow(giftTransactionNumber);
                        CurrentGiftRow.LastDetailNumber++;

                        //If adding detail to current last gift, then new detail will be bottom row in grid
                        if (FBatchRow.LastGiftNumber == giftTransactionNumber)
                        {
                            SelectEndRow = true;
                        }
                    }

                    //New gifts will require a new detail anyway, so this code always runs
                    GiftBatchTDSAGiftDetailRow newRow = FMainDS.AGiftDetail.NewRowTyped(true);

                    newRow.LedgerNumber          = FBatchRow.LedgerNumber;
                    newRow.BatchNumber           = FBatchRow.BatchNumber;
                    newRow.GiftTransactionNumber = CurrentGiftRow.GiftTransactionNumber;
                    newRow.DetailNumber          = CurrentGiftRow.LastDetailNumber;
                    newRow.MethodOfPaymentCode   = CurrentGiftRow.MethodOfPaymentCode;
                    newRow.MethodOfGivingCode    = CurrentGiftRow.MethodOfGivingCode;
                    newRow.DonorKey = CurrentGiftRow.DonorKey;

                    if (CopyDetails)
                    {
                        newRow.DonorName            = donorName;
                        newRow.DonorClass           = donorClass;
                        newRow.ConfidentialGiftFlag = confidentialGiftFlag;
                        newRow.ChargeFlag           = chargeFlag;
                        newRow.TaxDeductible        = taxDeductible;
                        newRow.MotivationGroupCode  = motivationGroupCode;
                        newRow.MotivationDetailCode = motivationDetailCode;

                        // set the auto-populate comment if needed
                        AMotivationDetailRow motivationDetail = (AMotivationDetailRow)FMainDS.AMotivationDetail.Rows.Find(
                            new object[] { FLedgerNumber, newRow.MotivationGroupCode, newRow.MotivationDetailCode });

                        if ((motivationDetail != null) && motivationDetail.Autopopdesc)
                        {
                            newRow.GiftCommentOne = motivationDetail.MotivationDetailDesc;
                        }
                    }
                    else
                    {
                        newRow.MotivationGroupCode  = MFinanceConstants.MOTIVATION_GROUP_GIFT;
                        newRow.MotivationDetailCode = MFinanceConstants.GROUP_DETAIL_SUPPORT;
                    }

                    newRow.DateEntered    = CurrentGiftRow.DateEntered;
                    newRow.ReceiptPrinted = false;
                    newRow.ReceiptNumber  = 0;

                    if (FTaxDeductiblePercentageEnabled)
                    {
                        newRow.TaxDeductiblePct = newRow.TaxDeductible ? 100.0m : 0.0m;

                        //Set unbound textboxes to 0
                        txtTaxDeductAmount.NumberValueDecimal = 0.0m;
                        txtNonDeductAmount.NumberValueDecimal = 0.0m;
                    }

                    FMainDS.AGiftDetail.Rows.Add(newRow);

                    FPetraUtilsObject.SetChangedFlag();

                    if (!SelectEndRow && !SelectDetailRowByDataTableIndex(FMainDS.AGiftDetail.Rows.Count - 1))
                    {
                        if (!FFilterAndFindObject.IsActiveFilterEqualToBase)
                        {
                            MessageBox.Show(
                                MCommonResourcestrings.StrNewRecordIsFiltered,
                                MCommonResourcestrings.StrAddNewRecordTitle,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                            FFilterAndFindObject.FilterPanelControls.ClearAllDiscretionaryFilters();

                            if (FFilterAndFindObject.FilterFindPanel.ShowApplyFilterButton != TUcoFilterAndFind.FilterContext.None)
                            {
                                FFilterAndFindObject.ApplyFilter();
                            }

                            SelectDetailRowByDataTableIndex(FMainDS.AGiftDetail.Rows.Count - 1);
                        }
                    }

                    btnDeleteAll.Enabled = btnDelete.Enabled;
                    UpdateRecordNumberDisplay();
                    FLastDonor = -1;

                    //Select end row
                    if (SelectEndRow)
                    {
                        grdDetails.SelectRowInGrid(grdDetails.Rows.Count - 1);
                    }

                    //Focus accordingly
                    if (ACompletelyNewGift)
                    {
                        txtDetailDonorKey.Focus();
                    }
                    else
                    {
                        txtDetailRecipientKey.Focus();
                    }

                    //FPreviouslySelectedDetailRow should now be pointing to the newly added row
                    TUC_GiftTransactions_Recipient.UpdateRecipientKeyText(0,
                                                                          FPreviouslySelectedDetailRow,
                                                                          cmbDetailMotivationGroupCode.GetSelectedString(),
                                                                          cmbDetailMotivationDetailCode.GetSelectedString());
                    cmbKeyMinistries.Clear();
                    mniRecipientHistory.Enabled = false;
                }
            }
            finally
            {
                FCreatingNewGift = false;

                if (AutoSaveSuccessful)
                {
                    FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataSuccessful);
                }
            }
        }
        private void SaveDataLabelUseChanges(TTypedDataTable ASubmitChanges)
        {
            // Submit changes to the PETRAServer for the DataLabelUse table
            // This code is basically lifted from a typical auto-generated equivalent
            // TODO: If the standard code changes because TODO's get done, we will need to change this manual code
            TSubmitChangesResult          SubmissionResult;
            TVerificationResultCollection VerificationResult;

            try
            {
                SubmissionResult = TDataCache.SaveChangedCacheableDataTableToPetraServer("DataLabelUseList",
                                                                                         ref ASubmitChanges,
                                                                                         out VerificationResult);
            }
            catch (ESecurityDBTableAccessDeniedException Exp)
            {
                FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException);
                this.Cursor = Cursors.Default;

                TMessages.MsgSecurityException(Exp, this.GetType());

                return;
            }
            catch (EDBConcurrencyException Exp)
            {
                FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException);
                this.Cursor = Cursors.Default;

                TMessages.MsgDBConcurrencyException(Exp, this.GetType());

                return;
            }
            catch (Exception exp)
            {
                TLogging.Log(
                    "An error occured while saving the 'used by' data" + Environment.NewLine + exp.ToString(),
                    TLoggingType.ToLogfile);
                MessageBox.Show(
                    Catalog.GetString("An error occured while saving the 'used by' data") + Environment.NewLine +
                    Catalog.GetString("For details see the log file: ") + TLogging.GetLogFileName(),
                    Catalog.GetString("Failed to Save 'Used By' Data"),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);

                return;
            }

            switch (SubmissionResult)
            {
            case TSubmitChangesResult.scrOK:

                // Call AcceptChanges to get rid now of any deleted columns before we Merge with the result from the Server
                FExtraDS.PDataLabelUse.AcceptChanges();

                // Merge back with data from the Server (eg. for getting Sequence values)
                ASubmitChanges.AcceptChanges();
                FExtraDS.PDataLabelUse.Merge(ASubmitChanges, false);

                // need to accept the new modification ID
                FExtraDS.PDataLabelUse.AcceptChanges();

                // need to refresh the cacheable DataTable 'DataLabelsForPartnerClassesList' (used by Partner Find's Maintain Menu)
                TDataCache.TMPartner.RefreshCacheablePartnerTable(TCacheablePartnerTablesEnum.DataLabelsForPartnerClassesList);

                return;

            case TSubmitChangesResult.scrNothingToBeSaved:

                return;

            case TSubmitChangesResult.scrError:

                MessageBox.Show(Catalog.GetString(
                                    "The 'UsedBy' part of the data could not be saved! There has been an error while making changes to the table."),
                                Catalog.GetString("Submit Changes to Table Error"),
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                break;

            case TSubmitChangesResult.scrInfoNeeded:

                MessageBox.Show(Catalog.GetString(
                                    "The 'UsedBy' part of the data could not be saved! Insufficient information was provided when making changes to the table."),
                                Catalog.GetString("Submit Changes to Table Error"),
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                break;
            }
        }
        //
        // This will be called if the Fast Reports Wrapper loaded OK.
        // Returns True if the data apparently loaded OK and the report should be printed.
        private bool LoadReportData(TRptCalculator ACalc)
        {
            ACurrencyRow CurrencyRow;
            ArrayList    reportParam = ACalc.GetParameters().Elems;

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

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

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

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

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

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

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

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

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

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

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

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

            return(true);
        }
Esempio n. 17
0
        //
        // This will be called if the Fast Reports Wrapper loaded OK.
        // Returns True if the data apparently loaded OK and the report should be printed.
        private bool LoadReportData(TRptCalculator ACalc)
        {
            //
            // I need to get the name of the current ledger..

            DataTable LedgerNameTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerNameList);
            DataView  LedgerView      = new DataView(LedgerNameTable);

            LedgerView.RowFilter = "LedgerNumber=" + FLedgerNumber;
            String LedgerName = "";

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

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

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

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

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


            ArrayList reportParam = ACalc.GetParameters().Elems;

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

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

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

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

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

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

            return(true);
        }
Esempio n. 18
0
 private void tabGiftBatch_GotFocus(object sender, EventArgs e)
 {
     FPetraUtilsObject.WriteToStatusBar(Catalog.GetString(
                                            "Use the left or right arrow keys to switch between Batches and Details"));
 }
        /// <summary>
        /// save the changes on the screen (code is copied from auto-generated code)
        /// </summary>
        /// <returns></returns>
        public bool SaveChanges()
        {
            FPetraUtilsObject.OnDataSavingStart(this, new System.EventArgs());

            if (FPetraUtilsObject.VerificationResultCollection.Count == 0)
            {
                foreach (DataRow InspectDR in FMainDS.MExtract.Rows)
                {
                    InspectDR.EndEdit();
                }

                if (!FPetraUtilsObject.HasChanges)
                {
                    return(true);
                }
                else
                {
                    FPetraUtilsObject.WriteToStatusBar("Saving data...");
                    this.Cursor = Cursors.WaitCursor;

                    TSubmitChangesResult SubmissionResult;

                    //Ict.Common.Data.TTypedDataTable SubmitDT = FMainDS.MExtract.GetChangesTyped();
                    MExtractTable SubmitDT = new MExtractTable();
                    SubmitDT.Merge(FMainDS.MExtract.GetChangesTyped());

                    if (SubmitDT == null)
                    {
                        // There is nothing to be saved.
                        // Update UI
                        FPetraUtilsObject.WriteToStatusBar(Catalog.GetString("There is nothing to be saved."));
                        this.Cursor = Cursors.Default;

                        // We don't have unsaved changes anymore
                        FPetraUtilsObject.DisableSaveButton();

                        return(true);
                    }

                    // Submit changes to the PETRAServer
                    try
                    {
                        SubmissionResult = TRemote.MPartner.Partner.WebConnectors.SaveExtract
                                               (FExtractId, ref SubmitDT);
                    }
                    catch (System.Net.Sockets.SocketException)
                    {
                        FPetraUtilsObject.WriteToStatusBar("Data could not be saved!");
                        this.Cursor = Cursors.Default;
                        MessageBox.Show("The PETRA Server cannot be reached! Data cannot be saved!",
                                        "No Server response",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Stop);
                        bool ReturnValue = false;

                        // TODO OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(ReturnValue);
                    }

                    /* TODO ESecurityDBTableAccessDeniedException
                     *                  catch (ESecurityDBTableAccessDeniedException Exp)
                     *                  {
                     *                      FPetraUtilsObject.WriteToStatusBar("Data could not be saved!");
                     *                      this.Cursor = Cursors.Default;
                     *                      // TODO TMessages.MsgSecurityException(Exp, this.GetType());
                     *                      bool ReturnValue = false;
                     *                      // TODO OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                     *                      return ReturnValue;
                     *                  }
                     */
                    catch (EDBConcurrencyException)
                    {
                        FPetraUtilsObject.WriteToStatusBar("Data could not be saved!");
                        this.Cursor = Cursors.Default;

                        // TODO TMessages.MsgDBConcurrencyException(Exp, this.GetType());
                        bool ReturnValue = false;

                        // TODO OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(ReturnValue);
                    }
                    catch (Exception exp)
                    {
                        FPetraUtilsObject.WriteToStatusBar("Data could not be saved!");
                        this.Cursor = Cursors.Default;
                        TLogging.Log(
                            Catalog.GetString(
                                "An error occurred while trying to connect to the OpenPetra Server!") + Environment.NewLine + exp.ToString(),
                            TLoggingType.ToLogfile);
                        MessageBox.Show(
                            Catalog.GetString("An error occurred while trying to connect to the OpenPetra Server!") + Environment.NewLine +
                            "For details see the log file: " + TLogging.GetLogFileName(),
                            "Server connection error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Stop);

                        // TODO OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(false);
                    }

                    switch (SubmissionResult)
                    {
                    case TSubmitChangesResult.scrOK:

                        // Call AcceptChanges to get rid now of any deleted columns before we Merge with the result from the Server
                        FMainDS.MExtract.AcceptChanges();

                        // Merge back with data from the Server (eg. for getting Sequence values)
                        FMainDS.MExtract.Merge(SubmitDT, false);

                        // need to accept the new modification ID
                        FMainDS.MExtract.AcceptChanges();

                        // Update UI
                        FPetraUtilsObject.WriteToStatusBar("Data successfully saved.");
                        this.Cursor = Cursors.Default;

                        // TODO EnableSave(false);

                        // We don't have unsaved changes anymore
                        FPetraUtilsObject.DisableSaveButton();

                        SetPrimaryKeyReadOnly(true);

                        // TODO OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(true);

                    case TSubmitChangesResult.scrError:

                        // TODO scrError
                        this.Cursor = Cursors.Default;
                        break;

                    case TSubmitChangesResult.scrNothingToBeSaved:

                        // TODO scrNothingToBeSaved
                        this.Cursor = Cursors.Default;
                        return(true);

                    case TSubmitChangesResult.scrInfoNeeded:

                        // TODO scrInfoNeeded
                        this.Cursor = Cursors.Default;
                        break;
                    }
                }
            }

            return(false);
        }
Esempio n. 20
0
        /// <summary>
        /// Creates a new Recurring Gift or Recurring Gift detail depending upon the parameter
        /// </summary>
        /// <param name="ACompletelyNewRecurringGift"></param>
        private void CreateANewRecurringGift(bool ACompletelyNewRecurringGift)
        {
            // Using a button's keyboard shortcut results in a different sequence of Events from clicking it with the mouse. If the current control is in pnlDetails,
            // then when the New or Delete button's processing attempts to save the current record and calls TFrmPetraUtils.ForceOnLeaveForActiveControl(),
            // it inadvertently re-raises the pnlDetails.Enter event which activates BeginEditMode() at a point when it's not supposed to be activated, putting
            // TCmbAutoComplete controls in a state they're not supposed to be in, resulting in a NullReferenceException from FPreviouslySelectedDetailRow
            // in UC_RecurringGiftTransactions.Motivation.ManualCode.cs, MotivationDetailChanged().
            // To fix it, put the focus outside pnlDetails, preventing the whole chain of events from happening.
            grdDetails.Focus();

            ARecurringGiftRow CurrentRecurringGiftRow = null;
            bool IsEmptyGrid  = (grdDetails.Rows.Count == 1);
            bool HasChanges   = FPetraUtilsObject.HasChanges;
            bool SelectEndRow = false;

            bool FPrevRowIsNull = (FPreviouslySelectedDetailRow == null);
            bool CopyDetails    = false;

            bool AutoSaveSuccessful = FSETAutoSaveFlag && HasChanges && ((TFrmRecurringGiftBatch)ParentForm).SaveChangesManual();

            FNewGiftInProcess = true;

            try
            {
                //May need to copy values down if a new detail row inside current Recurring Gift
                int    recurringGiftTransactionNumber = 0;
                string donorName  = string.Empty;
                string donorClass = string.Empty;
                bool   confidentialRecurringGiftFlag = false;
                bool   chargeFlag           = false;
                bool   taxDeductible        = false;
                string motivationGroupCode  = string.Empty;
                string motivationDetailCode = string.Empty;

                if (AutoSaveSuccessful || ((!FSETAutoSaveFlag || !HasChanges) && ValidateAllData(true, TErrorProcessingMode.Epm_IgnoreNonCritical)))
                {
                    if (!ACompletelyNewRecurringGift)      //i.e. a RecurringGift detail
                    {
                        ACompletelyNewRecurringGift = IsEmptyGrid;
                    }

                    CopyDetails = (!ACompletelyNewRecurringGift && !FPrevRowIsNull);

                    if (CopyDetails)
                    {
                        //Allow for possibility that FPrev... may have some null column values
                        recurringGiftTransactionNumber = FPreviouslySelectedDetailRow.GiftTransactionNumber;
                        donorName  = FPreviouslySelectedDetailRow.IsDonorNameNull() ? string.Empty : FPreviouslySelectedDetailRow.DonorName;
                        donorClass = FPreviouslySelectedDetailRow.IsDonorClassNull() ? string.Empty : FPreviouslySelectedDetailRow.DonorClass;
                        confidentialRecurringGiftFlag =
                            FPreviouslySelectedDetailRow.IsConfidentialGiftFlagNull() ? false : FPreviouslySelectedDetailRow.ConfidentialGiftFlag;
                        chargeFlag          = FPreviouslySelectedDetailRow.IsChargeFlagNull() ? true : FPreviouslySelectedDetailRow.ChargeFlag;
                        taxDeductible       = FPreviouslySelectedDetailRow.IsTaxDeductibleNull() ? true : FPreviouslySelectedDetailRow.TaxDeductible;
                        motivationGroupCode =
                            FPreviouslySelectedDetailRow.IsMotivationGroupCodeNull() ? string.Empty : FPreviouslySelectedDetailRow.
                            MotivationGroupCode;
                        motivationDetailCode =
                            FPreviouslySelectedDetailRow.IsMotivationDetailCodeNull() ? string.Empty : FPreviouslySelectedDetailRow.
                            MotivationDetailCode;
                    }

                    //Set previous row to Null.
                    FPreviouslySelectedDetailRow = null;

                    if (ACompletelyNewRecurringGift)
                    {
                        //Run this if a new Recurring Gift is requested or required.
                        SelectEndRow = true;

                        // we create the row locally, no dataset
                        ARecurringGiftRow recurringGiftRow = FMainDS.ARecurringGift.NewRowTyped(true);

                        recurringGiftRow.LedgerNumber          = FBatchRow.LedgerNumber;
                        recurringGiftRow.BatchNumber           = FBatchRow.BatchNumber;
                        recurringGiftRow.GiftTransactionNumber = ++FBatchRow.LastGiftNumber;
                        recurringGiftRow.MethodOfPaymentCode   = FBatchRow.MethodOfPaymentCode;
                        recurringGiftRow.Active           = true;
                        recurringGiftRow.LastDetailNumber = 1;

                        FMainDS.ARecurringGift.Rows.Add(recurringGiftRow);

                        CurrentRecurringGiftRow = recurringGiftRow;

                        mniDonorHistory.Enabled = false;

                        //Reset textboxes to zero
                        txtGiftTotal.NumberValueDecimal = 0;
                    }
                    else
                    {
                        CurrentRecurringGiftRow = GetRecurringGiftRow(recurringGiftTransactionNumber);
                        CurrentRecurringGiftRow.LastDetailNumber++;

                        //If adding detail to current last Recurring Gift, then new detail will be bottom row in grid
                        if (FBatchRow.LastGiftNumber == recurringGiftTransactionNumber)
                        {
                            SelectEndRow = true;
                        }
                    }

                    //New Recurring Gifts will require a new detail anyway, so this code always runs
                    GiftBatchTDSARecurringGiftDetailRow newRow = FMainDS.ARecurringGiftDetail.NewRowTyped(true);

                    newRow.LedgerNumber          = FBatchRow.LedgerNumber;
                    newRow.BatchNumber           = FBatchRow.BatchNumber;
                    newRow.GiftTransactionNumber = CurrentRecurringGiftRow.GiftTransactionNumber;
                    newRow.DetailNumber          = CurrentRecurringGiftRow.LastDetailNumber;
                    newRow.DonorKey            = CurrentRecurringGiftRow.DonorKey;
                    newRow.Active              = CurrentRecurringGiftRow.Active;
                    newRow.MethodOfPaymentCode = CurrentRecurringGiftRow.MethodOfPaymentCode;
                    newRow.MethodOfGivingCode  = CurrentRecurringGiftRow.MethodOfGivingCode;
                    newRow.DateEntered         = DateTime.Now;

                    if (CopyDetails)
                    {
                        newRow.DonorName            = donorName;
                        newRow.DonorClass           = donorClass;
                        newRow.ConfidentialGiftFlag = confidentialRecurringGiftFlag;
                        newRow.ChargeFlag           = chargeFlag;
                        newRow.TaxDeductible        = taxDeductible;
                        newRow.MotivationGroupCode  = motivationGroupCode;
                        newRow.MotivationDetailCode = motivationDetailCode;

                        // set the auto-populate comment if needed
                        AMotivationDetailRow motivationDetail = (AMotivationDetailRow)FMainDS.AMotivationDetail.Rows.Find(
                            new object[] { FLedgerNumber, newRow.MotivationGroupCode, newRow.MotivationDetailCode });

                        if ((motivationDetail != null) && motivationDetail.Autopopdesc)
                        {
                            newRow.GiftCommentOne = motivationDetail.MotivationDetailDesc;
                        }
                    }
                    else
                    {
                        newRow.MotivationGroupCode  = MFinanceConstants.MOTIVATION_GROUP_GIFT;
                        newRow.MotivationDetailCode = MFinanceConstants.GROUP_DETAIL_SUPPORT;
                    }

                    cmbMotivationDetailCode.SetSelectedString(newRow.MotivationDetailCode, -1);
                    txtDetailMotivationDetailCode.Text = newRow.MotivationDetailCode;

                    FMainDS.ARecurringGiftDetail.Rows.Add(newRow);

                    FPetraUtilsObject.SetChangedFlag();

                    if (!SelectEndRow && !SelectDetailRowByDataTableIndex(FMainDS.ARecurringGiftDetail.Rows.Count - 1))
                    {
                        if (!FFilterAndFindObject.IsActiveFilterEqualToBase)
                        {
                            MessageBox.Show(
                                MCommonResourcestrings.StrNewRecordIsFiltered,
                                MCommonResourcestrings.StrAddNewRecordTitle,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                            FFilterAndFindObject.FilterPanelControls.ClearAllDiscretionaryFilters();

                            if (FFilterAndFindObject.FilterFindPanel.ShowApplyFilterButton != TUcoFilterAndFind.FilterContext.None)
                            {
                                FFilterAndFindObject.ApplyFilter();
                            }

                            SelectDetailRowByDataTableIndex(FMainDS.ARecurringGiftDetail.Rows.Count - 1);
                        }
                    }

                    btnDeleteAll.Enabled = btnDelete.Enabled;
                    UpdateRecordNumberDisplay();
                    FLastDonor = -1;

                    //Select end row
                    if (SelectEndRow)
                    {
                        grdDetails.SelectRowInGrid(grdDetails.Rows.Count - 1);
                    }

                    //Focus accordingly
                    if (ACompletelyNewRecurringGift)
                    {
                        txtDetailDonorKey.Focus();
                    }
                    else
                    {
                        txtDetailRecipientKey.Focus();
                    }

                    //FPreviouslySelectedDetailRow should now be pointing to the newly added row
                    UpdateRecipientKeyText(0,
                                           FPreviouslySelectedDetailRow,
                                           cmbDetailMotivationGroupCode.GetSelectedString(),
                                           cmbMotivationDetailCode.GetSelectedString());

                    ClearKeyMinistries();
                    mniRecipientHistory.Enabled = false;
                }
            }
            finally
            {
                FNewGiftInProcess = false;

                if (AutoSaveSuccessful)
                {
                    FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataSuccessful);
                }
            }
        }
Esempio n. 21
0
        //
        // New methods using the Fast-reports DLL:

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

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

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

            String Csv = "";

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "Gifts");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDs.AAccount, "a_account");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDs.ACostCentre, "a_costCentre");
            FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDs.ATransaction, "a_transaction");
            //
            // My report doesn't need a ledger row - only the name of the ledger. And I need the currency formatter..
            String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(FLedgerNumber);

            ACalc.AddStringParameter("param_ledger_name", LedgerName);
            ACalc.AddStringParameter("param_currency_formatter", "0,0.000");

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

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

            return(HasData);
        }
        /// <summary>
        /// Save the changes on the screen
        /// </summary>
        /// <returns></returns>
        public bool SaveChanges()
        {
            Boolean ReturnValue;

            // Be sure to fire the OnLeave event on the active control of any user control
            FPetraUtilsObject.ForceOnLeaveForActiveControl();

            FPetraUtilsObject.OnDataSavingStart(this, new System.EventArgs());

            // Don't allow saving if user is still editing a Detail of a List
            if (FPetraUtilsObject.InDetailEditMode())
            {
                ReturnValue = false;
                return(ReturnValue);
            }

            // Clear any validation errors so that the following call to ValidateAllData starts with a 'clean slate'.
            FPetraUtilsObject.VerificationResultCollection.Clear();

            if (ValidateAllData(false, TErrorProcessingMode.Epm_IgnoreNonCritical))
            {
                // Ask the user about non-critical warnings, if they are the only 'errors' in the collection
                if (FPetraUtilsObject.VerificationResultCollection.HasOnlyNonCriticalErrors &&
                    (TDataValidation.ProcessAnyDataValidationWarnings(FPetraUtilsObject.VerificationResultCollection,
                                                                      MCommonResourcestrings.StrFormSaveDataAnywayQuestion, this.GetType()) == false))
                {
                    return(false);
                }

                FMainDS.AApSupplier.Rows[0].BeginEdit();
                GetDataFromControls(FMainDS.AApSupplier[0]);

                if (FMainDS.AApSupplier[0].IsDefaultApAccountNull())
                {
                    MessageBox.Show(Catalog.GetString("Please select an AP account (eg. 9100)"));
                    FMainDS.AApSupplier.Rows[0].EndEdit();

                    ReturnValue = false;
                    return(ReturnValue);
                }

                // The account would usually be 9100-AP account.
                if (FMainDS.AApSupplier[0].DefaultApAccount != "9100")
                {
                    if (MessageBox.Show(Catalog.GetString("You are not using the standard AP account (9100) - is this OK?"),
                                        "Verification", MessageBoxButtons.YesNo)
                        != System.Windows.Forms.DialogResult.Yes)
                    {
                        FMainDS.AApSupplier.Rows[0].EndEdit();
                        return(false);
                    }
                }

                // Don't store with invalid currency value.
                //
                if (FMainDS.AApSupplier[0].CurrencyCode == "")
                {
                    FMainDS.AApSupplier[0].CurrencyCode = FLedgerRow.BaseCurrency;
                }

                // If this is a foreign currency supplier, it must be linked to accounts in that currency.
                // (And if it's not, it mustn't be!)
                if (!ValidateAccountCurrency(FMainDS.AApSupplier[0].DefaultBankAccount, "Bank"))
                {
                    return(false);
                }

                /*
                 * If we wanted to have only expense accounts in a single currency, we could have this,
                 * but that's probably not what we want...
                 *
                 *          if (!ValidateAccountCurrency(FMainDS.AApSupplier[0].DefaultExpAccount, "Expense"))
                 *          {
                 *              return false;
                 *          }
                 */
            }

            ReturnValue = TDataValidation.ProcessAnyDataValidationErrors(false, FPetraUtilsObject.VerificationResultCollection,
                                                                         this.GetType());

            if (ReturnValue)
            {
                // Fire the DataSavingValidated event, which is the last chance to cancel the save
                System.ComponentModel.CancelEventArgs eCancel = new System.ComponentModel.CancelEventArgs(false);
                FPetraUtilsObject.OnDataSavingValidated(this, eCancel);

                if (eCancel.Cancel == true)
                {
                    return(false);
                }

                foreach (DataTable InspectDT in FMainDS.Tables)
                {
                    foreach (DataRow InspectDR in InspectDT.Rows)
                    {
                        InspectDR.EndEdit();
                    }
                }

                if (FPetraUtilsObject.HasChanges)
                {
                    FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataInProgress);
                    this.Cursor = Cursors.WaitCursor;

                    AccountsPayableTDS SubmitDS = FMainDS.GetChangesTyped(true);

                    TSubmitChangesResult          SubmissionResult;
                    TVerificationResultCollection VerificationResult = new TVerificationResultCollection();

                    // Submit changes to the PETRAServer
                    try
                    {
                        SubmissionResult = FUIConnector.SubmitChanges(ref SubmitDS);
                    }
                    catch (ESecurityDBTableAccessDeniedException Exp)
                    {
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException);
                        this.Cursor = Cursors.Default;

                        TMessages.MsgSecurityException(Exp, this.GetType());

                        ReturnValue = false;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(ReturnValue);
                    }
                    catch (EDBConcurrencyException Exp)
                    {
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException);
                        this.Cursor = Cursors.Default;

                        TMessages.MsgDBConcurrencyException(Exp, this.GetType());

                        ReturnValue = false;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(ReturnValue);
                    }
                    catch (Exception)
                    {
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException);
                        this.Cursor = Cursors.Default;

                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        throw;
                    }

                    switch (SubmissionResult)
                    {
                    case TSubmitChangesResult.scrOK:

                        // Call AcceptChanges to get rid now of any deleted columns before we Merge with the result from the Server
                        FMainDS.AcceptChanges();

                        // Merge back with data from the Server (eg. for getting Sequence values)
                        if (SubmitDS != null)
                        {
                            FMainDS.Merge(SubmitDS, false);

                            // need to accept the new modification ID
                            FMainDS.AcceptChanges();
                        }

                        // Update UI
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataSuccessful);
                        this.Cursor = Cursors.Default;

                        // We don't have unsaved changes anymore
                        FPetraUtilsObject.DisableSaveButton();
                        TFormsMessage broadcastMessage = new TFormsMessage(TFormsMessageClassEnum.mcAPSupplierChanged);
                        TFormsList.GFormsList.BroadcastFormMessage(broadcastMessage);

                        ReturnValue = true;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        break;

                    case TSubmitChangesResult.scrError:
                        this.Cursor = Cursors.Default;
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataErrorOccured);

                        MessageBox.Show(Messages.BuildMessageFromVerificationResult(null, VerificationResult));

                        FPetraUtilsObject.SubmitChangesContinue = false;

                        ReturnValue = false;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        break;

                    case TSubmitChangesResult.scrNothingToBeSaved:
                        this.Cursor = Cursors.Default;
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataNothingToSave);

                        // We don't have unsaved changes anymore
                        FPetraUtilsObject.DisableSaveButton();

                        ReturnValue = true;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        break;

                    case TSubmitChangesResult.scrInfoNeeded:

                        // TODO scrInfoNeeded
                        this.Cursor = Cursors.Default;
                        break;
                    }
                }
                else
                {
                    // Update UI
                    FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataNothingToSave);
                    this.Cursor = Cursors.Default;
                    FPetraUtilsObject.DisableSaveButton();

                    // We don't have unsaved changes anymore
                    FPetraUtilsObject.HasChanges = false;

                    ReturnValue = true;
                    FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                }
            }
            else
            {
                FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(false));
            }

            return(ReturnValue);
        }
Esempio n. 23
0
        }  // Load Hosa Report Data

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

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

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

            MyFastReportsPlugin.RegisterData(ReportTable, "Stewardship");

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

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

            TParameterList Params = ACalc.GetParameters();

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

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

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

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

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

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

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

                return(false);
            }

            return(HasData);
        } // Load Stewardship Report Data
Esempio n. 24
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);
        }
        }  // Load Hosa Report Data

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

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

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

            MyFastReportsPlugin.RegisterData(ReportTable, "Stewardship");

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

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

            TParameterList Params = ACalc.GetParameters();

            if ((!Params.Get("param_design_template").ToBool()) &&
                (rbtEmailStewardship.Checked))
            {
                // This gets email defaults from the user settings table
                TUC_EmailPreferences.LoadEmailDefaults();

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

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

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

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

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

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

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

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

                // Andrea wants this systemj default to be manually added to database when we are ready for a system to send ICH emails
                if (!TSystemDefaults.IsSystemDefaultDefined(STEWARDSHIP_EMAIL_ADDRESS))
                {
                    FStatusMsg += Catalog.GetString("\r\n Stewardship email address not configured in System Defaults.");
                    return(false);
                }

                String EmailRecipient = TSystemDefaults.GetStringDefault(STEWARDSHIP_EMAIL_ADDRESS);

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

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

                return(false);
            }

            return(HasData);
        } // Load Stewardship Report Data
Esempio n. 26
0
        /// <summary>
        /// save the changes on the screen (code is copied from auto-generated code)
        /// </summary>
        /// <returns></returns>
        public bool SaveChanges()
        {
            bool ReturnValue = false;

            FPetraUtilsObject.OnDataSavingStart(this, new System.EventArgs());

            if (FPetraUtilsObject.VerificationResultCollection.Count == 0)
            {
                foreach (DataRow InspectDR in FMainDS.MExtract.Rows)
                {
                    InspectDR.EndEdit();
                }

                if (!FPetraUtilsObject.HasChanges)
                {
                    return(true);
                }
                else
                {
                    FPetraUtilsObject.WriteToStatusBar("Saving data...");
                    this.Cursor = Cursors.WaitCursor;

                    TSubmitChangesResult SubmissionResult;

                    //Ict.Common.Data.TTypedDataTable SubmitDT = FMainDS.MExtract.GetChangesTyped();
                    MExtractTable           SubmitDT  = new MExtractTable();
                    ExtractTDSMExtractTable ChangesDT = FMainDS.MExtract.GetChangesTyped();

                    if (ChangesDT != null)
                    {
                        SubmitDT.Merge(ChangesDT);
                    }
                    else
                    {
                        SubmitDT = null;
                    }

                    if (SubmitDT == null)
                    {
                        // There is nothing to be saved.
                        // Update UI
                        FPetraUtilsObject.WriteToStatusBar(Catalog.GetString("There is nothing to be saved."));
                        this.Cursor = Cursors.Default;

                        // We don't have unsaved changes anymore
                        FPetraUtilsObject.DisableSaveButton();

                        return(true);
                    }

                    // Submit changes to the PETRAServer
                    try
                    {
                        SubmissionResult = TRemote.MPartner.Partner.WebConnectors.SaveExtract
                                               (FExtractId, ref SubmitDT);
                    }
                    catch (ESecurityDBTableAccessDeniedException Exp)
                    {
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException);
                        this.Cursor = Cursors.Default;

                        TMessages.MsgSecurityException(Exp, this.GetType());

                        ReturnValue = false;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(ReturnValue);
                    }
                    catch (EDBConcurrencyException Exp)
                    {
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException);
                        this.Cursor = Cursors.Default;

                        TMessages.MsgDBConcurrencyException(Exp, this.GetType());

                        ReturnValue = false;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(ReturnValue);
                    }
                    catch (Exception)
                    {
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException);
                        this.Cursor = Cursors.Default;

                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        throw;
                    }

                    switch (SubmissionResult)
                    {
                    case TSubmitChangesResult.scrOK:

                        // Call AcceptChanges to get rid now of any deleted columns before we Merge with the result from the Server
                        FMainDS.MExtract.AcceptChanges();

                        // Merge back with data from the Server (eg. for getting Sequence values)
                        FMainDS.MExtract.Merge(SubmitDT, false);

                        // need to accept the new modification ID
                        FMainDS.MExtract.AcceptChanges();

                        // Update UI
                        FPetraUtilsObject.WriteToStatusBar("Data successfully saved.");
                        this.Cursor = Cursors.Default;

                        // TODO EnableSave(false);

                        // We don't have unsaved changes anymore
                        FPetraUtilsObject.DisableSaveButton();

                        SetPrimaryKeyReadOnly(true);

                        // refresh extract master screen if it is open
                        TFormsMessage BroadcastMessage = new TFormsMessage(TFormsMessageClassEnum.mcExtractCreated);
                        BroadcastMessage.SetMessageDataName(ExtractName);
                        TFormsList.GFormsList.BroadcastFormMessage(BroadcastMessage);
                        this.Focus();     // keeps the focus on the current form

                        // TODO OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(true);

                    case TSubmitChangesResult.scrError:

                        // TODO scrError
                        this.Cursor = Cursors.Default;
                        break;

                    case TSubmitChangesResult.scrNothingToBeSaved:

                        // TODO scrNothingToBeSaved
                        this.Cursor = Cursors.Default;
                        return(true);

                    case TSubmitChangesResult.scrInfoNeeded:

                        // TODO scrInfoNeeded
                        this.Cursor = Cursors.Default;
                        break;
                    }
                }
            }

            return(false);
        }
Esempio n. 27
0
        /// <summary>
        /// save the changes on the screen (code is copied from auto-generated code)
        /// </summary>
        /// <returns></returns>
        public bool SaveChanges()
        {
            bool ReturnValue = false;

            FPetraUtilsObject.OnDataSavingStart(this, new System.EventArgs());

            if (ValidateAllData(false, Common.Verification.TErrorProcessingMode.Epm_IgnoreNonCritical))
            {
                foreach (DataRow InspectDR in FMainDS.MExtractMaster.Rows)
                {
                    InspectDR.EndEdit();
                }

                if (!FPetraUtilsObject.HasChanges)
                {
                    return(true);
                }
                else
                {
                    FPetraUtilsObject.WriteToStatusBar("Saving data...");
                    this.Cursor = Cursors.WaitCursor;

                    TSubmitChangesResult SubmissionResult;

                    MExtractMasterTable SubmitDT = new MExtractMasterTable();

                    if (FMainDS.MExtractMaster.GetChangesTyped() != null)
                    {
                        SubmitDT.Merge(FMainDS.MExtractMaster.GetChangesTyped());
                    }
                    else
                    {
                        // There is nothing to be saved.
                        // Update UI
                        FPetraUtilsObject.WriteToStatusBar(Catalog.GetString("There is nothing to be saved."));
                        this.Cursor = Cursors.Default;

                        // We don't have unsaved changes anymore
                        FPetraUtilsObject.DisableSaveButton();

                        return(true);
                    }

                    // Submit changes to the PETRAServer
                    try
                    {
                        SubmissionResult = TRemote.MPartner.Partner.WebConnectors.SaveExtractMaster
                                               (ref SubmitDT);
                    }
                    catch (ESecurityDBTableAccessDeniedException Exp)
                    {
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException);
                        this.Cursor = Cursors.Default;

                        TMessages.MsgSecurityException(Exp, this.GetType());

                        ReturnValue = false;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(ReturnValue);
                    }
                    catch (EDBConcurrencyException Exp)
                    {
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException);
                        this.Cursor = Cursors.Default;

                        TMessages.MsgDBConcurrencyException(Exp, this.GetType());

                        ReturnValue = false;
                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(ReturnValue);
                    }
                    catch (Exception)
                    {
                        FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException);
                        this.Cursor = Cursors.Default;

                        FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        throw;
                    }

                    switch (SubmissionResult)
                    {
                    case TSubmitChangesResult.scrOK:

                        // Call AcceptChanges to get rid now of any deleted columns before we Merge with the result from the Server
                        FMainDS.MExtractMaster.AcceptChanges();

                        // Merge back with data from the Server (eg. for getting Sequence values)
                        FMainDS.MExtractMaster.Merge(SubmitDT, false);

                        // need to accept the new modification ID
                        FMainDS.MExtractMaster.AcceptChanges();

                        // Update UI
                        FPetraUtilsObject.WriteToStatusBar("Data successfully saved.");
                        this.Cursor = Cursors.Default;

                        // TODO EnableSave(false);

                        // We don't have unsaved changes anymore
                        FPetraUtilsObject.DisableSaveButton();

                        SetPrimaryKeyReadOnly(true);

                        // TODO OnDataSaved(this, new TDataSavedEventArgs(ReturnValue));
                        return(true);

                    case TSubmitChangesResult.scrError:

                        // TODO scrError
                        this.Cursor = Cursors.Default;
                        break;

                    case TSubmitChangesResult.scrNothingToBeSaved:

                        // TODO scrNothingToBeSaved
                        this.Cursor = Cursors.Default;
                        return(true);

                    case TSubmitChangesResult.scrInfoNeeded:

                        // TODO scrInfoNeeded
                        this.Cursor = Cursors.Default;
                        break;
                    }
                }
            }

            return(false);
        }
        //
        // This will be called if the Fast Reports Wrapper loaded OK.
        // Returns True if the data apparently loaded OK and the report should be printed.
        private bool LoadReportData(TRptCalculator ACalc)
        {
            ArrayList reportParam = ACalc.GetParameters().Elems;

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

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

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

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

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

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


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

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

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

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

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

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

            DataTable LedgerNameTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerNameList);
            DataView  LedgerView      = new DataView(LedgerNameTable);

            LedgerView.RowFilter = "LedgerNumber=" + FLedgerNumber;
            String LedgerName = "";

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

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

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

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

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

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

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

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

            return(true);
        }
Esempio n. 29
0
 private void tabGLBatch_GotFocus(Object Sender, EventArgs e)
 {
     FPetraUtilsObject.WriteToStatusBar(Catalog.GetString(
                                            "Use the left or right arrow keys to switch between Batches, Journals and Transactions"));
 }
Esempio n. 30
0
        //
        // This will be called if the Fast Reports Wrapper loaded OK.
        // Returns True if the data apparently loaded OK and the report should be printed.
        private bool LoadReportData(TRptCalculator ACalc)
        {
            ArrayList reportParam = ACalc.GetParameters().Elems;

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

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

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