protected virtual void GLConsolSetup_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { GLConsolSetup setup = (GLConsolSetup)e.Row; if (setup != null) { PXUIFieldAttribute.SetEnabled <GLConsolSetup.selected>(sender, setup, setup.IsActive == true); } GLConsolLedger coledger = PXSelect <GLConsolLedger, Where <GLConsolLedger.setupID, Equal <Current <GLConsolSetup.setupID> >, And <GLConsolLedger.ledgerCD, Equal <Current <GLConsolSetup.sourceLedgerCD> > > > > .Select(this); PXUIFieldAttribute.SetEnabled <GLConsolSetup.sourceBranchCD>(sender, e.Row, coledger != null); }
protected virtual void GLConsolSetup_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e) { GLConsolSetup setup = (GLConsolSetup)e.Row; if (!sender.ObjectsEqual <GLConsolSetup.sourceLedgerCD>(e.Row, e.OldRow)) { string oldbranchid = (string)sender.GetValue <GLConsolSetup.sourceBranchCD>(e.Row); sender.SetValue <GLConsolSetup.sourceBranchCD>(e.Row, null); GLConsolLedger coledger = PXSelect <GLConsolLedger, Where <GLConsolLedger.setupID, Equal <Current <GLConsolSetup.setupID> >, And <GLConsolLedger.ledgerCD, Equal <Current <GLConsolSetup.sourceLedgerCD> > > > > .Select(this); if (coledger != null && coledger.PostInterCompany == true) { sender.SetValueExt <GLConsolSetup.sourceBranchCD>(e.Row, oldbranchid); } } }
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(); }