Ejemplo n.º 1
0
        private void ReverseBatch(System.Object sender, EventArgs e)
        {
            // This will throw an exception if insufficient permissions
            TSecurityChecks.CheckUserModulePermissions("FINANCE-2", "ReverseBatch [raised by Client Proxy for ModuleAccessManager]");

            //get index position of row to post
            int newCurrentRowPos = GetSelectedRowIndex();

            if (FReverseLogicObject.ReverseBatch(FPreviouslySelectedDetailRow, dtpDetailDateEffective.Date.Value, FStartDateCurrentPeriod,
                                                 FEndDateLastForwardingPeriod))
            {
                // AlanP - commenting out most of this because it should be unnecessary - or should move to ShowDetailsManual()
                //Select unposted batch row in same index position as batch just posted
                //grdDetails.DataSource = null;
                //grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.ABatch.DefaultView);

                if (grdDetails.Rows.Count > 1)
                {
                    //Needed because posting process forces grid events which sets FDetailGridRowsCountPrevious = FDetailGridRowsCountCurrent
                    // such that a removal of a row is not detected
                    SelectRowInGrid(newCurrentRowPos);
                }
                else
                {
                    EnableButtonControl(false);
                    ClearDetailControls();
                    btnNew.Focus();
                    pnlDetails.Enabled = false;
                }

                UpdateRecordNumberDisplay();
                FFilterAndFindObject.SetRecordNumberDisplayProperties();
            }
        }
Ejemplo n.º 2
0
        private void ReverseGift(System.Object sender, System.EventArgs e)
        {
            // This will throw an exception if insufficient permissions
            TSecurityChecks.CheckUserModulePermissions("FINANCE-2", "ReverseGift [raised by Client Proxy for ModuleAccessManager]");

            ShowRevertAdjustForm(GiftAdjustmentFunctionEnum.ReverseGift);
        }
        /// <summary>
        /// Opens a Modal instance of the Donor Recipient Screen
        /// </summary>
        /// <param name="ADonor">True if Donor, false if Recipient</param>
        /// <param name="APartnerKey"></param>
        /// <param name="AParentForm"></param>
        /// <returns></returns>
        public static void OpenForm(bool ADonor,
                                    long APartnerKey,
                                    Form AParentForm)
        {
            TSecurityChecks.CheckUserModulePermissions(SharedConstants.PETRAMODULE_FINANCE1, AParentForm.Text);

            TFrmDonorRecipientHistory.OpenWindowDonorRecipientHistory(ADonor, APartnerKey, AParentForm);
        }
Ejemplo n.º 4
0
        private void PostBatch(System.Object sender, EventArgs e)
        {
            // Although the screen can be used with FINANCE-1, Posting requires FINANCE-2
            TSecurityChecks.CheckUserModulePermissions("FINANCE-2", "PostBatch [raised by Client Proxy for ModuleAccessManager]");

            if ((GetSelectedRowIndex() < 0) || (FPreviouslySelectedDetailRow == null))
            {
                MessageBox.Show(Catalog.GetString("Please select a GL Batch before posting!"));
                return;
            }

            //get index position of row to post
            int NewCurrentRowPos = GetSelectedRowIndex();

            TFrmGLBatch MainForm = (TFrmGLBatch)this.ParentForm;

            try
            {
                MainForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.POSTING;

                if (FPostLogicObject.PostBatch(FPreviouslySelectedDetailRow, dtpDetailDateEffective.Date.Value, FStartDateCurrentPeriod,
                                               FEndDateLastForwardingPeriod))
                {
                    // AlanP - commenting out most of this because it should be unnecessary - or should move to ShowDetailsManual()
                    ////Select unposted batch row in same index position as batch just posted
                    //grdDetails.DataSource = null;
                    //grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.ABatch.DefaultView);

                    if (grdDetails.Rows.Count > 1)
                    {
                        //Needed because posting process forces grid events which sets FDetailGridRowsCountPrevious = FDetailGridRowsCountCurrent
                        // such that a removal of a row is not detected
                        SelectRowInGrid(NewCurrentRowPos);
                    }
                    else
                    {
                        EnableButtonControl(false);
                        ClearDetailControls();
                        btnNew.Focus();
                        pnlDetails.Enabled = false;
                    }

                    UpdateRecordNumberDisplay();
                    FFilterAndFindObject.SetRecordNumberDisplayProperties();
                }
            }
            finally
            {
                MainForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.NONE;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// use the permissions of the user to get all offices that this user has permissions for
        /// </summary>
        /// <returns></returns>
        private static List <Int64> GetRegistrationOfficeKeysOfUser(TDBTransaction ATransaction)
        {
            List <Int64> AllowedRegistrationOffices = new List <long>();

            // get all offices that have registrations for this event
            DataTable offices = ATransaction.DataBaseObj.SelectDT(
                String.Format("SELECT DISTINCT {0} FROM PUB_{1}",
                              PmShortTermApplicationTable.GetRegistrationOfficeDBName(),
                              PmShortTermApplicationTable.GetTableDBName()),
                "registrationoffice", ATransaction);

            // if there are no REG-... module permissions for anyone, allow all offices? this would help with a base database for testing?
            Int32 CountRegModules =
                Convert.ToInt32(ATransaction.DataBaseObj.ExecuteScalar("SELECT COUNT(*) FROM " + SModuleTable.GetTableDBName() + " WHERE " +
                                                                       SModuleTable.GetModuleIdDBName() + " LIKE 'REG-%'", ATransaction));

            foreach (DataRow officeRow in offices.Rows)
            {
                Int64 RegistrationOffice = Convert.ToInt64(officeRow[0]);
                try
                {
                    if ((CountRegModules == 0) || TSecurityChecks.CheckUserModulePermissions(String.Format("REG-{0:10}",
                                                                                                           StringHelper.PartnerKeyToStr(RegistrationOffice))))
                    {
                        AllowedRegistrationOffices.Add(RegistrationOffice);
                    }
                }
                catch (ESecurityModuleAccessDeniedException)
                {
                    // no permissions for this registration office
                }
            }

            // the organizer has access to all attendees
            if (AllowedRegistrationOffices.Count > MINIMUM_OFFICES_TO_BECOME_ORGANIZER)
            {
                AllowedRegistrationOffices = new List <long>();

                foreach (DataRow officeRow in offices.Rows)
                {
                    Int64 RegistrationOffice = Convert.ToInt64(officeRow[0]);
                    AllowedRegistrationOffices.Add(RegistrationOffice);
                }
            }

            return(AllowedRegistrationOffices);
        }
        /// <summary>
        /// Pay all tagged documents
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void PayAllTagged(object sender, EventArgs e)
        {
            // This will throw an exception if insufficient permissions
            TSecurityChecks.CheckUserModulePermissions("FINANCE-2", "PayAllTagged [raised by Client Proxy for ModuleAccessManager]");

            string MsgTitle = Catalog.GetString("Document Payment");

            this.Cursor = Cursors.WaitCursor;
            AccountsPayableTDS TempDS        = LoadTaggedDocuments();
            TFrmAPPayment      PaymentScreen = new TFrmAPPayment(FMainForm);

            List <int> PayTheseDocs = new List <int>();

            foreach (DataRowView rv in grdInvoices.PagedDataTable.DefaultView)
            {
                if ((rv.Row["Selected"].Equals(true) &&
                     ("|POSTED|PARTPAID|".IndexOf("|" + rv.Row["DocumentStatus"].ToString() + "|") >= 0)))
                {
                    PayTheseDocs.Add(Convert.ToInt32(rv.Row["ApDocumentId"]));
                }
            }

            if (PayTheseDocs.Count > 0)
            {
                if (PaymentScreen.AddDocumentsToPayment(TempDS, FMainForm.LedgerNumber, PayTheseDocs))
                {
                    this.Cursor = Cursors.Default;
                    PaymentScreen.Show();
                }

                this.Cursor = Cursors.Default;
            }
            else
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(Catalog.GetString("There are no tagged documents to be paid."), MsgTitle);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// checks if the user has access to the navigation node
        /// </summary>
        public bool HasAccessPermission(XmlNode ANode, TPetraPrincipal AUserInfo)
        {
            // TODO: if this is an action node, eg. opens a screen, check the static function that tells RequiredPermissions of the screen

            string PermissionsRequired = TXMLParser.GetAttributeRecursive(ANode, "PermissionsRequired", true);

            try
            {
                if (PermissionsRequired.StartsWith("\"") && PermissionsRequired.EndsWith("\""))
                {
                    PermissionsRequired = PermissionsRequired.Substring(1, PermissionsRequired.Length - 2);
                }

                if (PermissionsRequired.Contains(",") && !PermissionsRequired.EndsWith(")"))
                {
                    PermissionsRequired = "AND(" + PermissionsRequired + ")";
                }

                if (PermissionsRequired == "")
                {
                    PermissionsRequired = "USER";
                }

                TSecurityChecks.CheckUserModulePermissions(PermissionsRequired, "UINavigation");
                return(true);
            }
            catch (ESecurityModuleAccessDeniedException)
            {
                return(false);
            }
            catch (ArgumentException e)
            {
                TLogging.Log("Issue for node " + ANode.Name + Environment.NewLine +
                             e.ToString());
                return(false);
            }
        }
        /// <summary>
        /// Reverse all tagged rows
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ReverseAllTagged(object sender, EventArgs e)
        {
            // This will throw an exception if insufficient permissions
            TSecurityChecks.CheckUserModulePermissions("FINANCE-2", "ReverseAllTagged [raised by Client Proxy for ModuleAccessManager]");

            string MsgTitle = Catalog.GetString("Document Reversal");

            // I can only reverse invoices that are POSTED.
            // This method is only enabled when the grid shows rows for paying
            // This will include rows that are PARTPAID - we need to test for those
            List <int> ReverseTheseDocs = new List <int>();
            int        taggedCount      = 0;

            foreach (DataRowView rv in grdInvoices.PagedDataTable.DefaultView)
            {
                if (rv.Row["Selected"].Equals(true))
                {
                    taggedCount++;

                    if (MFinanceConstants.AP_DOCUMENT_POSTED == rv.Row["DocumentStatus"].ToString())
                    {
                        ReverseTheseDocs.Add(Convert.ToInt32(rv.Row["ApDocumentId"]));
                    }
                }
            }

            if (ReverseTheseDocs.Count < taggedCount)
            {
                string msg = Catalog.GetString("A document cannot be reversed if it has been part-paid.");

                if (ReverseTheseDocs.Count == 0)
                {
                    MessageBox.Show(msg, MsgTitle);
                }
                else
                {
                    msg += Environment.NewLine + Environment.NewLine;
                    msg += Catalog.GetString("Do you want to continue and reverse the 'Posted' documents?");

                    if (MessageBox.Show(msg, MsgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                }
            }

            if (ReverseTheseDocs.Count > 0)
            {
                TVerificationResultCollection Verifications;
                TDlgGLEnterDateEffective      dateEffectiveDialog = new TDlgGLEnterDateEffective(
                    FMainForm.LedgerNumber,
                    Catalog.GetString("Select reversal date"),
                    Catalog.GetString("The date effective for this reversal") + ":");

                if (dateEffectiveDialog.ShowDialog(FMainForm) != DialogResult.OK)
                {
                    MessageBox.Show(Catalog.GetString("Reversal was cancelled."), MsgTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                DateTime PostingDate = dateEffectiveDialog.SelectedDate;

                this.Cursor = Cursors.WaitCursor;
                Int32 glBatchNumber;

                if (TRemote.MFinance.AP.WebConnectors.PostAPDocuments(
                        FMainForm.LedgerNumber,
                        ReverseTheseDocs,
                        PostingDate,
                        true,
                        out glBatchNumber,
                        out Verifications))
                {
                    if (glBatchNumber >= 0)
                    {
                        TFrmBatchPostingRegister ReportGui = new TFrmBatchPostingRegister(null);
                        ReportGui.PrintReportNoUi(FMainForm.LedgerNumber, glBatchNumber);
                    }

                    this.Cursor = Cursors.Default;
                    MessageBox.Show(Catalog.GetString("The tagged invoices have been reversed to 'Approved' status."), MsgTitle);
                    FMainForm.IsInvoiceDataChanged = true;

                    LoadInvoices();
                    return;
                }
                else
                {
                    this.Cursor = Cursors.Default;
                    string ErrorMessages = Verifications.BuildVerificationResultString();
                    MessageBox.Show(ErrorMessages, MsgTitle);
                }
            }
            else
            {
                MessageBox.Show(Catalog.GetString("There are no tagged invoices to be reversed."), MsgTitle);
            }
        }
        /// <summary>
        /// Post all tagged documents
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void PostAllTagged(object sender, EventArgs e)
        {
            // This will throw an exception if insufficient permissions
            TSecurityChecks.CheckUserModulePermissions("FINANCE-2", "PostAllTagged [raised by Client Proxy for ModuleAccessManager]");

            string MsgTitle = Catalog.GetString("Document Posting");

            AccountsPayableTDS TempDS = LoadTaggedDocuments();

            List <int> PostTheseDocs = new List <int>();

            TempDS.AApDocument.DefaultView.Sort = AApDocumentDetailTable.GetApDocumentIdDBName();

            string testString = "|CANCELLED|POSTED|PARTPAID|PAID|";

            if (FRequireApprovalBeforePosting)
            {
                testString += "OPEN|";
            }

            foreach (DataRowView rv in grdInvoices.PagedDataTable.DefaultView)
            {
                if ((rv.Row["Selected"].Equals(true) && (testString.IndexOf("|" + rv.Row["DocumentStatus"].ToString()) < 0)))
                {
                    int DocId = Convert.ToInt32(rv.Row["ApDocumentId"]);

                    int RowIdx = TempDS.AApDocument.DefaultView.Find(DocId);

                    if (RowIdx >= 0)
                    {
                        AApDocumentRow DocumentRow = (AApDocumentRow)TempDS.AApDocument.DefaultView[RowIdx].Row;

                        if (TFrmAPEditDocument.ApDocumentCanPost(TempDS, DocumentRow)) // This will produce an message box if there's a problem.
                        {
                            PostTheseDocs.Add(DocId);
                        }
                    }
                }
            }

            if (PostTheseDocs.Count > 0)
            {
                string msg = String.Format(Catalog.GetString("Are you sure that you want to post the {0} tagged document(s)?"), PostTheseDocs.Count);

                if (MessageBox.Show(msg, MsgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    return;
                }

                if (TFrmAPEditDocument.PostApDocumentList(TempDS, FMainForm.LedgerNumber, PostTheseDocs, FMainForm))
                {
                    // TODO: print reports on successfully posted batch
                    MessageBox.Show(Catalog.GetString("The tagged documents have been posted successfully!"), MsgTitle);
                    FMainForm.IsInvoiceDataChanged = true;

                    LoadInvoices();

                    // TODO: show posting register of GL Batch?
                }
            }
            else
            {
                MessageBox.Show(Catalog.GetString("There are no tagged documents to be posted."), MsgTitle);
            }
        }
        public static void GetData(string ATablename, TSearchCriteria[] ASearchCriteria, out TTypedDataTable AResultTable,
                                   TDBTransaction AReadTransaction)
        {
            AResultTable = null;
            string context = string.Format("GetData {0}", SharedConstants.MODULE_ACCESS_MANAGER);

            // check access permissions for the current user
            TModuleAccessManager.CheckUserPermissionsForTable(ATablename, TTablePermissionEnum.eCanRead);

            // TODO: auto generate
            if (ATablename == AApSupplierTable.GetTableDBName())
            {
                AResultTable = AApSupplierAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == AApDocumentTable.GetTableDBName())
            {
                AResultTable = AApDocumentAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == ATransactionTypeTable.GetTableDBName())
            {
                AResultTable = ATransactionTypeAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == ACurrencyTable.GetTableDBName())
            {
                AResultTable = ACurrencyAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == ADailyExchangeRateTable.GetTableDBName())
            {
                AResultTable = ADailyExchangeRateAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == ACorporateExchangeRateTable.GetTableDBName())
            {
                AResultTable = ACorporateExchangeRateAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == ACurrencyLanguageTable.GetTableDBName())
            {
                AResultTable = ACurrencyLanguageAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == AFeesPayableTable.GetTableDBName())
            {
                AResultTable = AFeesPayableAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == AFeesReceivableTable.GetTableDBName())
            {
                AResultTable = AFeesReceivableAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == AAnalysisTypeTable.GetTableDBName())
            {
                AResultTable = AAnalysisTypeAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == AGiftBatchTable.GetTableDBName())
            {
                AResultTable = AGiftBatchAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == AJournalTable.GetTableDBName())
            {
                AResultTable = AJournalAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == ALedgerTable.GetTableDBName())
            {
                AResultTable = ALedgerAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == MExtractMasterTable.GetTableDBName())
            {
                if (ASearchCriteria == null)
                {
                    AResultTable = MExtractMasterAccess.LoadAll(AReadTransaction);
                }
                else
                {
                    AResultTable = MExtractMasterAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
                }
            }
            else if (ATablename == MExtractTable.GetTableDBName())
            {
                // it does not make sense to load ALL extract rows for all extract masters so search criteria needs to be set
                if (ASearchCriteria != null)
                {
                    AResultTable = MExtractAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
                }
            }
            else if (ATablename == PcAttendeeTable.GetTableDBName())
            {
                AResultTable = PcAttendeeAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == PcConferenceCostTable.GetTableDBName())
            {
                AResultTable = PcConferenceCostAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == PcEarlyLateTable.GetTableDBName())
            {
                AResultTable = PcEarlyLateAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == PcSupplementTable.GetTableDBName())
            {
                AResultTable = PcSupplementAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == PcDiscountTable.GetTableDBName())
            {
                AResultTable = PcDiscountAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == PCountryTable.GetTableDBName())
            {
                AResultTable = PCountryAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == PFormTable.GetTableDBName())
            {
                string[]         columns   = TTypedDataTable.GetColumnStringList(PFormTable.TableId);
                StringCollection fieldList = new StringCollection();

                for (int i = 0; i < columns.Length; i++)
                {
                    // Do not load the template document - we don't display it and it is big!
                    if (columns[i] != PFormTable.GetTemplateDocumentDBName())
                    {
                        fieldList.Add(columns[i]);
                    }
                }

                AResultTable = PFormAccess.LoadAll(fieldList, AReadTransaction);
            }
            else if (ATablename == PInternationalPostalTypeTable.GetTableDBName())
            {
                AResultTable = PInternationalPostalTypeAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == PtApplicationTypeTable.GetTableDBName())
            {
                AResultTable = PtApplicationTypeAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == PFormalityTable.GetTableDBName())
            {
                AResultTable = PFormalityAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == PMailingTable.GetTableDBName())
            {
                AResultTable = PMailingAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == PPartnerGiftDestinationTable.GetTableDBName())
            {
                AResultTable = PPartnerGiftDestinationAccess.LoadUsingTemplate(ASearchCriteria, AReadTransaction);
            }
            else if (ATablename == PmDocumentTypeTable.GetTableDBName())
            {
                AResultTable = PmDocumentTypeAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == SGroupTable.GetTableDBName())
            {
                TSecurityChecks.CheckUserModulePermissions(SharedConstants.PETRAMODULE_SYSADMIN, context);
                AResultTable = SGroupAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == SSystemDefaultsTable.GetTableDBName())
            {
                TSecurityChecks.CheckUserModulePermissions(SharedConstants.PETRAMODULE_SYSADMIN, context);
                AResultTable = SSystemDefaultsAccess.LoadAll(AReadTransaction);
            }
            else if (ATablename == SSystemDefaultsGuiTable.GetTableDBName())
            {
                AResultTable = SSystemDefaultsGuiAccess.LoadAll(AReadTransaction);
            }
            else
            {
                throw new Exception("TCommonDataReader.GetData: unknown table " + ATablename);
            }

            // Accept row changes here so that the Client gets 'unmodified' rows
            AResultTable.AcceptChanges();
        }
        public static TSubmitChangesResult SaveData(string ATablename,
                                                    ref TTypedDataTable ASubmitTable, out TVerificationResultCollection AVerificationResult,
                                                    TDBTransaction AWriteTransaction)
        {
            AVerificationResult = null;

            // TODO: check write permissions
            string context = string.Format("SaveData {0}", SharedConstants.MODULE_ACCESS_MANAGER);

            if (ASubmitTable != null)
            {
                AVerificationResult = new TVerificationResultCollection();

                try
                {
                    if (ATablename == AAccountingPeriodTable.GetTableDBName())
                    {
                        AAccountingPeriodAccess.SubmitChanges((AAccountingPeriodTable)ASubmitTable, AWriteTransaction);

                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheableFinanceTablesEnum.AccountingPeriodList.ToString());
                    }
                    else if (ATablename == ACurrencyTable.GetTableDBName())
                    {
                        ACurrencyAccess.SubmitChanges((ACurrencyTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ADailyExchangeRateTable.GetTableDBName())
                    {
                        TSecurityChecks.CheckUserModulePermissions(
                            string.Format("AND({0},{1})", SharedConstants.PETRAGROUP_FINANCE1, SharedConstants.PETRAMODULE_FINEXRATE),
                            context);
                        ADailyExchangeRateAccess.SubmitChanges((ADailyExchangeRateTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ACorporateExchangeRateTable.GetTableDBName())
                    {
                        // AlanP:  I don't think this is used any more.  There is a TDS Save method instead
                        ACorporateExchangeRateAccess.SubmitChanges((ACorporateExchangeRateTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ACurrencyLanguageTable.GetTableDBName())
                    {
                        ACurrencyLanguageAccess.SubmitChanges((ACurrencyLanguageTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == AFeesPayableTable.GetTableDBName())
                    {
                        AFeesPayableAccess.SubmitChanges((AFeesPayableTable)ASubmitTable, AWriteTransaction);

                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheableFinanceTablesEnum.FeesPayableList.ToString());
                    }
                    else if (ATablename == AFeesReceivableTable.GetTableDBName())
                    {
                        AFeesReceivableAccess.SubmitChanges((AFeesReceivableTable)ASubmitTable, AWriteTransaction);

                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheableFinanceTablesEnum.FeesReceivableList.ToString());
                    }
                    else if (ATablename == AGiftBatchTable.GetTableDBName())
                    {
                        // This method is called from ADailyExchangeRate Setup - please do not remove
                        // The method is not required for changes made to the gift batch screens, which use a TDS
                        AGiftBatchAccess.SubmitChanges((AGiftBatchTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == AJournalTable.GetTableDBName())
                    {
                        // This method is called from ADailyExchangeRate Setup - please do not remove
                        // The method is not required for changes made to the journal screens, which use a TDS
                        AJournalAccess.SubmitChanges((AJournalTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ARecurringJournalTable.GetTableDBName())
                    {
                        // This method is called from Submit Recurring GL Batch form - please do not remove
                        // The method is not required for changes made to the journal screens, which use a TDS
                        ARecurringJournalAccess.SubmitChanges((ARecurringJournalTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ALedgerTable.GetTableDBName())
                    {
                        // This method is called from ADailyExchangeRate Testing - please do not remove
                        ALedgerAccess.SubmitChanges((ALedgerTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == AAnalysisTypeTable.GetTableDBName())
                    {
                        AAnalysisTypeAccess.SubmitChanges((AAnalysisTypeTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == ASuspenseAccountTable.GetTableDBName())
                    {
                        ASuspenseAccountAccess.SubmitChanges((ASuspenseAccountTable)ASubmitTable, AWriteTransaction);

                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheableFinanceTablesEnum.SuspenseAccountList.ToString());
                    }
                    else if (ATablename == PcAttendeeTable.GetTableDBName())
                    {
                        PcAttendeeAccess.SubmitChanges((PcAttendeeTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcConferenceTable.GetTableDBName())
                    {
                        PcConferenceAccess.SubmitChanges((PcConferenceTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcConferenceCostTable.GetTableDBName())
                    {
                        PcConferenceCostAccess.SubmitChanges((PcConferenceCostTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcEarlyLateTable.GetTableDBName())
                    {
                        PcEarlyLateAccess.SubmitChanges((PcEarlyLateTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcSupplementTable.GetTableDBName())
                    {
                        PcSupplementAccess.SubmitChanges((PcSupplementTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PcDiscountTable.GetTableDBName())
                    {
                        PcDiscountAccess.SubmitChanges((PcDiscountTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PInternationalPostalTypeTable.GetTableDBName())
                    {
                        ValidateInternationalPostalType(ref AVerificationResult, ASubmitTable);
                        ValidateInternationalPostalTypeManual(ref AVerificationResult, ASubmitTable);

                        if (TVerificationHelper.IsNullOrOnlyNonCritical(AVerificationResult))
                        {
                            PInternationalPostalTypeAccess.SubmitChanges((PInternationalPostalTypeTable)ASubmitTable, AWriteTransaction);
                        }
                    }
                    else if (ATablename == PtApplicationTypeTable.GetTableDBName())
                    {
                        PtApplicationTypeAccess.SubmitChanges((PtApplicationTypeTable)ASubmitTable, AWriteTransaction);

                        // mark dependent lists for needing to be refreshed since there was a change in base list
                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheablePersonTablesEnum.EventApplicationTypeList.ToString());
                        TCacheableTablesManager.GCacheableTablesManager.MarkCachedTableNeedsRefreshing(
                            TCacheablePersonTablesEnum.FieldApplicationTypeList.ToString());
                    }
                    else if (ATablename == PFormTable.GetTableDBName())
                    {
                        PFormAccess.SubmitChanges((PFormTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PFormalityTable.GetTableDBName())
                    {
                        PFormalityAccess.SubmitChanges((PFormalityTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PMailingTable.GetTableDBName())
                    {
                        PMailingAccess.SubmitChanges((PMailingTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PPartnerGiftDestinationTable.GetTableDBName())
                    {
                        PPartnerGiftDestinationAccess.SubmitChanges((PPartnerGiftDestinationTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == PmDocumentTypeTable.GetTableDBName())
                    {
                        PmDocumentTypeAccess.SubmitChanges((PmDocumentTypeTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == SGroupTable.GetTableDBName())
                    {
                        SGroupAccess.SubmitChanges((SGroupTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == SSystemDefaultsTable.GetTableDBName())
                    {
                        SSystemDefaultsAccess.SubmitChanges((SSystemDefaultsTable)ASubmitTable, AWriteTransaction);
                    }
                    else if (ATablename == SSystemDefaultsGuiTable.GetTableDBName())
                    {
                        SSystemDefaultsGuiAccess.SubmitChanges((SSystemDefaultsGuiTable)ASubmitTable, AWriteTransaction);
                    }
                    else
                    {
                        throw new EOPAppException("TCommonDataReader.SaveData: unknown table '" + ATablename + "'");
                    }
                }
                catch (Exception Exc)
                {
                    AVerificationResult.Add(
                        new TVerificationResult(null, "Cannot SubmitChanges:" + Environment.NewLine +
                                                Exc.Message, "UNDEFINED", TResultSeverity.Resv_Critical));
                }
            }

            if ((AVerificationResult != null) &&
                (AVerificationResult.Count > 0))
            {
                // Downgrade TScreenVerificationResults to TVerificationResults in order to allow
                // Serialisation (needed for .NET Remoting).
                TVerificationResultCollection.DowngradeScreenVerificationResults(AVerificationResult);

                return(AVerificationResult.HasCriticalErrors ? TSubmitChangesResult.scrError : TSubmitChangesResult.scrOK);
            }

            return(TSubmitChangesResult.scrOK);
        }
Ejemplo n.º 12
0
        /// throws an exception if the current user does not have enough permission to access the method;
        /// this uses a custom attribute associated with the method of the connector
        static public bool CheckUserPermissionsForMethod(System.Type AConnectorType, string AMethodName, string AParameterTypes, Int32 ALedgerNumber = -1)
        {
            MethodInfo[] methods = AConnectorType.GetMethods();

            MethodInfo MethodToTest = null;

            AParameterTypes = AParameterTypes.Replace("[]", ".ARRAY");

            foreach (MethodInfo method in methods)
            {
                if (method.Name == AMethodName)
                {
                    string          ParameterTypes = ";";
                    ParameterInfo[] Parameters     = method.GetParameters();

                    foreach (ParameterInfo Parameter in Parameters)
                    {
                        string ParameterName = Parameter.ParameterType.ToString().Replace("&", "");

                        ParameterName = ParameterName.Replace("System.Collections.Generic.Dictionary`2", "DICTIONARY");
                        ParameterName = ParameterName.Replace("Ict.Common.", string.Empty);
                        ParameterName = ParameterName.Replace("Ict.Petra.Shared.MCommon.", string.Empty);
                        ParameterName = ParameterName.Replace("System.", string.Empty);

                        if (ParameterName.Contains("."))
                        {
                            ParameterName = ParameterName.Substring(ParameterName.LastIndexOf(".") + 1);
                        }

                        ParameterName = ParameterName.Replace("`1", string.Empty);
                        ParameterName = ParameterName.Replace("`2", string.Empty);
                        ParameterName = ParameterName.Replace("Boolean", "bool");
                        ParameterName = ParameterName.Replace("Int32", "int");
                        ParameterName = ParameterName.Replace("Int64", "long");
                        ParameterName = ParameterName.Replace("[]", ".Array");

                        ParameterTypes += ParameterName + ";";
                    }

                    ParameterTypes = ParameterTypes.ToUpper();

                    if (ParameterTypes == AParameterTypes)
                    {
                        MethodToTest = method;
                        break;
                    }
                }
            }

            if (MethodToTest != null)
            {
                System.Object[] attributes = MethodToTest.GetCustomAttributes(typeof(RequireModulePermissionAttribute), false);

                if ((attributes != null) && (attributes.Length > 0))
                {
                    RequireModulePermissionAttribute requiredModules = (RequireModulePermissionAttribute)attributes[0];

                    string moduleExpression = requiredModules.RequiredModulesExpression.ToUpper();

                    if (moduleExpression == "NONE")
                    {
                        return(true);
                    }

                    // authenticated user
                    if (moduleExpression == "USER")
                    {
                        if (UserInfo.GUserInfo != null && UserInfo.GUserInfo.UserID != null)
                        {
                            return(true);
                        }
                    }

                    try
                    {
                        TSecurityChecks.CheckUserModulePermissions(moduleExpression);

                        if (ALedgerNumber != -1)
                        {
                            TSecurityChecks.CheckUserModulePermissions(SharedConstants.LEDGER_MODULESTRING + ALedgerNumber.ToString("0000"));
                        }
                    }
                    catch (ESecurityModuleAccessDeniedException Exc)
                    {
                        string msg =
                            String.Format(Catalog.GetString(
                                              "Module access permission was violated for method '{0}' in Connector class '{1}':  Required Module access permission: {2}, UserName: {3}"),
                                          AMethodName, AConnectorType, Exc.Module, Exc.UserName);
                        TLogging.Log(msg);

                        Exc.Context = AMethodName + " [raised by ModuleAccessManager]";

                        throw;
                    }
                    catch (ArgumentException argException)
                    {
                        throw new EOPAppException("Problem with ModulePermissions, " +
                                                  argException.Message + ": '" +
                                                  moduleExpression + "' for " +
                                                  AConnectorType.ToString() + "." +
                                                  AMethodName + "()", argException);
                    }

                    return(true);
                }
            }

            // TODO: resolve module permission from namespace?

            throw new EOPAppException(
                      "Missing definition of access permission for method " + AMethodName + " in Connector class " + AConnectorType);
        }