Esempio n. 1
0
        public virtual void CheckRelatedGLTranDoesNotExist(int?[] branchIDs)
        {
            if (branchIDs == null || branchIDs.IsEmpty())
            {
                return;
            }

            GLTran tran = PXSelectReadonly <GLTran,
                                            Where <GLTran.branchID, In <Required <GLTran.branchID> > > >
                          .SelectSingleBound(Graph, null, branchIDs);

            if (tran != null)
            {
                Branch branch = BranchMaint.FindBranchByID(Graph, tran.BranchID);

                throw new PXException(Messages.TheBranchOrBranchesCannotBeDeletedBecauseTheRelatedTransactionHasBeenPosted,
                                      branch.BranchCD.Trim(),
                                      tran.ToString());
            }
        }
Esempio n. 2
0
        public virtual void CheckRelatedGLHistoryDoesNotExist(int?[] branchIDs)
        {
            if (branchIDs == null || branchIDs.IsEmpty())
            {
                return;
            }

            GLHistory history = GLUtility.GetRelatedToBranchGLHistory(Graph, branchIDs);

            if (history != null)
            {
                Branch branch = BranchMaint.FindBranchByID(Graph, history.BranchID);

                if (branch != null)
                {
                    throw new PXException(Messages.BranchCanNotBeDeletedBecausePostedGLTransExist,
                                          branch.BranchCD.Trim());
                }
            }
        }
Esempio n. 3
0
        public virtual void CheckRelatedWarehousesDontExist(int?[] branchIDs, string exceptionMessage)
        {
            if (branchIDs == null || branchIDs.IsEmpty())
            {
                return;
            }

            INSite[] sites = PXSelectReadonly <INSite,
                                               Where <INSite.branchID, In <Required <INSite.branchID> > > >
                             .SelectWindowed(Graph, 0, EntityCountInErrorMessage + 1, branchIDs)
                             .RowCast <INSite>()
                             .ToArray();

            if (sites.Any())
            {
                IEnumerable <Branch> branches =
                    BranchMaint.FindBranchesByID(Graph, sites.Take(EntityCountInErrorMessage).Select(a => a.BranchID).ToArray());

                throw new PXSetPropertyException(exceptionMessage,
                                                 branches.Select(b => b.BranchCD.Trim()).ToArray().JoinIntoStringForMessage(),
                                                 sites.Select(s => s.SiteCD.Trim()).ToArray().JoinIntoStringForMessage(EntityCountInErrorMessage));
            }
        }
Esempio n. 4
0
        public virtual void CheckRelatedCashAccountsDontExist(int?[] branchIDs)
        {
            if (branchIDs == null || branchIDs.IsEmpty())
            {
                return;
            }

            CA.CashAccount[] cashAccounts = PXSelectReadonly <CA.CashAccount,
                                                              Where <CA.CashAccount.branchID, In <Required <CA.CashAccount.branchID> >,
                                                                     And <CA.CashAccount.restrictVisibilityWithBranch, Equal <boolTrue> > > >
                                            .SelectWindowed(Graph, 0, EntityCountInErrorMessage + 1, branchIDs)
                                            .RowCast <CA.CashAccount>()
                                            .ToArray();

            if (cashAccounts.Any())
            {
                IEnumerable <Branch> branches = BranchMaint.FindBranchesByID(Graph, branchIDs).ToArray();

                throw new PXException(Messages.CashAccountsForBranch,
                                      branches.Select(b => b.BranchCD.Trim()).ToArray().JoinIntoStringForMessage(),
                                      cashAccounts.Select(a => a.CashAccountCD.Trim()).ToArray().JoinIntoStringForMessage(EntityCountInErrorMessage));
            }
        }