protected virtual void GLConsolAccount_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
        {
            GLConsolAccount consol = (GLConsolAccount)e.Row;

            foreach (Account acct in Accounts.Select(consol.AccountCD))
            {
                acct.GLConsolAccountCD = null;
                Accounts.Update(acct);
            }
        }
        protected static void Synchronize(GLConsolSetupMaint graph, GLConsolSetup consolSetup)
        {
            using (PXSoapScope scope = new PXSoapScope(consolSetup.Url, consolSetup.Login, consolSetup.Password))
            {
                GLConsolSetupMaint foreign = PXGraph.CreateInstance <GLConsolSetupMaint>();
                foreign.ConsolAccounts.Select();
                foreign.Ledgers.Select();
                foreign.Branches.Select();
                scope.Process(foreign);

                PXSelect <Account> select = new PXSelect <Account>(graph);
                List <Account>     list   = new List <Account>();
                foreach (Account acct in select.Select())
                {
                    list.Add(acct);
                }

                List <GLConsolLedger> listConsolLedger = new List <GLConsolLedger>();
                foreach (GLConsolLedger ledger in graph.ConsolLedgers.Select(consolSetup.SetupID))
                {
                    listConsolLedger.Add(ledger);
                }

                List <GLConsolBranch> listConsolBranch = new List <GLConsolBranch>();
                foreach (GLConsolBranch branch in graph.ConsolBranches.Select(consolSetup.SetupID))
                {
                    listConsolBranch.Add(branch);
                }

                foreach (GLConsolAccount consol in foreign.ConsolAccounts.Select())
                {
                    Account acct = new Account();
                    acct.AccountCD = consol.AccountCD;
                    acct           = select.Locate(acct);
                    if (acct == null)
                    {
                        foreign.ConsolAccounts.Delete(consol);
                    }
                    else
                    {
                        list.Remove(acct);
                        if (acct.Description != consol.Description)
                        {
                            consol.Description = acct.Description;
                            foreign.ConsolAccounts.Update(consol);
                        }
                    }
                }

                foreach (Ledger ledger in foreign.Ledgers.Select())
                {
                    GLConsolLedger l = new GLConsolLedger();
                    l.SetupID  = consolSetup.SetupID;
                    l.LedgerCD = ledger.LedgerCD;
                    l          = graph.ConsolLedgers.Locate(l);
                    if (l != null)
                    {
                        listConsolLedger.Remove(l);
                        if (l.Description != ledger.Descr || l.BalanceType != ledger.BalanceType)
                        {
                            l.Description = ledger.Descr;
                            l.BalanceType = ledger.BalanceType;
                            graph.ConsolLedgers.Cache.SetStatus(l, PXEntryStatus.Updated);
                        }
                    }
                    else
                    {
                        l             = new GLConsolLedger();
                        l.SetupID     = consolSetup.SetupID;
                        l.LedgerCD    = ledger.LedgerCD;
                        l.Description = ledger.Descr;
                        l.BalanceType = ledger.BalanceType;
                        graph.ConsolLedgers.Insert(l);
                    }
                }

                foreach (GLConsolLedger ledger in listConsolLedger)
                {
                    graph.ConsolLedgers.Delete(ledger);
                    if (consolSetup.SourceLedgerCD == ledger.LedgerCD)
                    {
                        consolSetup.SourceLedgerCD = null;
                        graph.ConsolSetupRecords.Update(consolSetup);
                    }
                }

                foreach (Branch branch in foreign.Branches.Select())
                {
                    GLConsolBranch l = new GLConsolBranch();
                    l.SetupID  = consolSetup.SetupID;
                    l.BranchCD = branch.BranchCD;
                    l          = graph.ConsolBranches.Locate(l);
                    if (l != null)
                    {
                        listConsolBranch.Remove(l);

                        if (l.Description != branch.AcctName || l.LedgerCD != branch.LedgerCD)
                        {
                            l.LedgerCD    = branch.LedgerCD;
                            l.Description = branch.AcctName;
                            graph.ConsolBranches.Cache.SetStatus(l, PXEntryStatus.Updated);
                        }
                    }
                    else
                    {
                        l             = new GLConsolBranch();
                        l.SetupID     = consolSetup.SetupID;
                        l.BranchCD    = branch.BranchCD;
                        l.LedgerCD    = branch.LedgerCD;
                        l.Description = branch.AcctName;
                        graph.ConsolBranches.Insert(l);
                    }
                }

                foreach (GLConsolBranch branch in listConsolBranch)
                {
                    graph.ConsolBranches.Delete(branch);
                    if (consolSetup.SourceBranchCD == branch.BranchCD)
                    {
                        consolSetup.SourceBranchCD = null;
                        graph.ConsolSetupRecords.Update(consolSetup);
                    }
                }

                foreach (Account acct in list)
                {
                    GLConsolAccount consol = new GLConsolAccount();
                    consol.AccountCD   = acct.AccountCD;
                    consol.Description = acct.Description;
                    foreign.ConsolAccounts.Insert(consol);
                }

                scope.Process(foreign, foreign.Save);
            }

            graph.Save.Press();
        }