Exemple #1
0
        public static Boolean CanDetachTypeCodeFromAccount(Int32 ALedgerNumber, String AAccountCode, String ATypeCode, out String Message)
        {
            TDBTransaction ReadTrans = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);

            try
            {
                {
                    AApAnalAttribTable tbl = new AApAnalAttribTable();
                    AApAnalAttribRow Template = tbl.NewRowTyped(false);
                    Template.LedgerNumber = ALedgerNumber;
                    Template.AccountCode = AAccountCode;
                    Template.AnalysisTypeCode = ATypeCode;
                    tbl = AApAnalAttribAccess.LoadUsingTemplate(Template, ReadTrans);

                    if (tbl.Rows.Count > 0)
                    {
                        Message = String.Format(Catalog.GetString("Cannot remove {0} from {1}: "), ATypeCode, AAccountCode) +
                                  String.Format(Catalog.GetString("Analysis Type is used in AP documents ({0} entries)."), tbl.Rows.Count);
                        return false;
                    }
                }

                {
                    ATransAnalAttribTable tbl = new ATransAnalAttribTable();
                    ATransAnalAttribRow Template = tbl.NewRowTyped(false);
                    Template.LedgerNumber = ALedgerNumber;
                    Template.AccountCode = AAccountCode;
                    Template.AnalysisTypeCode = ATypeCode;
                    tbl = ATransAnalAttribAccess.LoadUsingTemplate(Template, ReadTrans);

                    if (tbl.Rows.Count > 0)
                    {
                        Message = String.Format(Catalog.GetString("Cannot remove {0} from {1}: "), ATypeCode, AAccountCode) +
                                  String.Format(Catalog.GetString("Analysis Type is used in Transactions ({0} entries)."), tbl.Rows.Count);
                        return false;
                    }
                }
                {
                    ARecurringTransAnalAttribTable tbl = new ARecurringTransAnalAttribTable();
                    ARecurringTransAnalAttribRow Template = tbl.NewRowTyped(false);
                    Template.LedgerNumber = ALedgerNumber;
                    Template.AccountCode = AAccountCode;
                    Template.AnalysisTypeCode = ATypeCode;
                    tbl = ARecurringTransAnalAttribAccess.LoadUsingTemplate(Template, ReadTrans);

                    if (tbl.Rows.Count > 0)
                    {
                        Message = String.Format(Catalog.GetString("Cannot remove {0} from {1}: "), ATypeCode, AAccountCode) +
                                  String.Format(Catalog.GetString("Analysis Type is used in recurring Transactions ({0} entries)."), tbl.Rows.Count);
                        return false;
                    }
                }
            }
            finally
            {
                DBAccess.GDBAccessObj.RollbackTransaction();
            }
            Message = "";
            return true;
        }