示例#1
0
        /// <summary>
        /// Need to ensure that the Analysis Attributes grid has all the entries
        /// that are required for the selected account.
        /// There may or may not already be attribute assignments for this transaction.
        /// </summary>
        /// <param name="AGLBatchDS"></param>
        /// <param name="AAccountCode"></param>
        /// <param name="ATransactionNumber"></param>
        public void ReconcileRecurringTransAnalysisAttributes(ref GLBatchTDS AGLBatchDS,
                                                              string AAccountCode,
                                                              int ATransactionNumber)
        {
            if (string.IsNullOrEmpty(AAccountCode))
            {
                return;
            }

            StringCollection RequiredAnalAttrCodes = TRemote.MFinance.Setup.WebConnectors.RequiredAnalysisAttributesForAccount(FLedgerNumber,
                                                                                                                               AAccountCode, false);

            SetRecurringTransAnalAttributeDefaultView(AGLBatchDS, ATransactionNumber,
                                                      TAnalysisAttributes.ConvertStringCollectionToCSV(RequiredAnalAttrCodes, "'"));

            // If the AnalysisType list I'm currently using is the same as the list of required types, I can keep it (with any existing values).
            bool existingListIsOk = (RequiredAnalAttrCodes.Count == AGLBatchDS.ARecurringTransAnalAttrib.DefaultView.Count);

            if (existingListIsOk)
            {
                foreach (DataRowView rv in AGLBatchDS.ARecurringTransAnalAttrib.DefaultView)
                {
                    ARecurringTransAnalAttribRow row = (ARecurringTransAnalAttribRow)rv.Row;

                    if (!RequiredAnalAttrCodes.Contains(row.AnalysisTypeCode))
                    {
                        existingListIsOk = false;
                        break;
                    }
                }
            }

            if (existingListIsOk)
            {
                return;
            }

            // Delete any existing Analysis Type records and re-create the list (Removing any prior selections by the user).
            foreach (DataRowView rv in AGLBatchDS.ARecurringTransAnalAttrib.DefaultView)
            {
                ARecurringTransAnalAttribRow attrRowCurrent = (ARecurringTransAnalAttribRow)rv.Row;
                attrRowCurrent.Delete();
            }

            foreach (String analysisTypeCode in RequiredAnalAttrCodes)
            {
                ARecurringTransAnalAttribRow newRow = AGLBatchDS.ARecurringTransAnalAttrib.NewRowTyped(true);
                newRow.LedgerNumber      = FLedgerNumber;
                newRow.BatchNumber       = FBatchNumber;
                newRow.JournalNumber     = FJournalNumber;
                newRow.TransactionNumber = ATransactionNumber;
                newRow.AnalysisTypeCode  = analysisTypeCode;
                newRow.AccountCode       = AAccountCode;

                AGLBatchDS.ARecurringTransAnalAttrib.Rows.Add(newRow);
            }
        }
示例#2
0
        /// <summary>
        /// Used for the validation of Analysis Attributes
        /// </summary>
        /// <param name="ATransactionNumber"></param>
        /// <param name="AAccountCode"></param>
        /// <param name="AGLBatchDS"></param>
        /// <param name="ValueRequiredForType"></param>
        /// <param name="AIsUnposted"></param>
        /// <returns></returns>
        public bool AccountAnalysisAttributesValuesExist(int ATransactionNumber,
                                                         string AAccountCode,
                                                         GLBatchTDS AGLBatchDS,
                                                         out String ValueRequiredForType,
                                                         bool AIsUnposted = true)
        {
            ValueRequiredForType = "";

            if (!AIsUnposted || string.IsNullOrEmpty(AAccountCode) || (AGLBatchDS.ATransAnalAttrib.DefaultView.Count == 0))
            {
                return(true);
            }

            StringCollection RequiredAnalAttrCodes = TRemote.MFinance.Setup.WebConnectors.RequiredAnalysisAttributesForAccount(FLedgerNumber,
                                                                                                                               AAccountCode, true);

            string AnalysisCodeFilterValues = TAnalysisAttributes.ConvertStringCollectionToCSV(RequiredAnalAttrCodes, "'");

            DataView analAttrib = new DataView(AGLBatchDS.ATransAnalAttrib);

            analAttrib.RowFilter = String.Format("{0}={1} AND {2}={3} AND {4}={5} AND {6} IN ({7})",
                                                 ATransAnalAttribTable.GetBatchNumberDBName(),
                                                 FBatchNumber,
                                                 ATransAnalAttribTable.GetJournalNumberDBName(),
                                                 FJournalNumber,
                                                 ATransAnalAttribTable.GetTransactionNumberDBName(),
                                                 ATransactionNumber,
                                                 ATransAnalAttribTable.GetAnalysisTypeCodeDBName(),
                                                 AnalysisCodeFilterValues);

            foreach (DataRowView drv in analAttrib)
            {
                ATransAnalAttribRow rw = (ATransAnalAttribRow)drv.Row;

                string analysisCode = rw.AnalysisTypeCode;

                if (TRemote.MFinance.Setup.WebConnectors.AccountAnalysisAttributeRequiresValues(FLedgerNumber, analysisCode, true))
                {
                    if (rw.IsAnalysisAttributeValueNull() || (rw.AnalysisAttributeValue == string.Empty))
                    {
                        ValueRequiredForType = rw.AnalysisTypeCode;
                        return(false);
                    }
                }
            }

            return(true);
        }