public virtual IEnumerable viewAPDocument(PXAdapter adapter) { CABatchDetail detail = this.BatchPayments.Current; if (detail == null) { return(adapter.Get()); } APRegister apDocument = PXSelect <APRegister, Where <APRegister.docType, Equal <Required <APRegister.docType> >, And <APRegister.refNbr, Equal <Required <APRegister.refNbr> > > > > .Select(this, detail.OrigDocType, detail.OrigRefNbr); if (apDocument == null) { return(adapter.Get()); } if (apDocument.DocType == APDocType.Check) { APPaymentEntry apGraph = PXGraph.CreateInstance <APPaymentEntry>(); apGraph.Document.Current = apGraph.Document.Search <APRegister.refNbr>(apDocument.RefNbr, apDocument.DocType); if (apGraph.Document.Current != null) { throw new PXRedirectRequiredException(apGraph, true, "") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } else if (apDocument.DocType == APDocType.QuickCheck) { APQuickCheckEntry apGraph = PXGraph.CreateInstance <APQuickCheckEntry>(); apGraph.Document.Current = apGraph.Document.Search <APRegister.refNbr>(apDocument.RefNbr, apDocument.DocType); if (apGraph.Document.Current != null) { throw new PXRedirectRequiredException(apGraph, true, "") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } return(adapter.Get()); }
public static void Redirect(PXCache sender, CATran catran) { if (catran == null) { return; } if (catran.OrigTranType == CAAPARTranType.GLEntry) { JournalEntry graph = PXGraph.CreateInstance <JournalEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.BatchModule.Current = PXSelect <Batch, Where <Batch.module, Equal <Required <Batch.module> >, And <Batch.batchNbr, Equal <Required <Batch.batchNbr> > > > > .Select(graph, catran.OrigModule, catran.OrigRefNbr); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.AP && (catran.OrigTranType == AP.APDocType.QuickCheck || catran.OrigTranType == AP.APDocType.VoidQuickCheck)) { APQuickCheckEntry graph = PXGraph.CreateInstance <APQuickCheckEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = PXSelect <APQuickCheck, Where <APQuickCheck.refNbr, Equal <Required <APQuickCheck.refNbr> >, And <APQuickCheck.docType, Equal <Required <APQuickCheck.docType> > > > > .Select(graph, catran.OrigRefNbr, catran.OrigTranType); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.AP && catran.OrigTranType == CATranType.CABatch) { CABatchEntry graph = PXGraph.CreateInstance <CABatchEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = PXSelect <CABatch, Where <CABatch.batchNbr, Equal <Required <CATran.origRefNbr> > > > .Select(graph, catran.OrigRefNbr); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.AP) { APPaymentEntry graph = PXGraph.CreateInstance <APPaymentEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = (APPayment)PXSelect <APPayment, Where <APPayment.refNbr, Equal <Required <APPayment.refNbr> >, And <APPayment.docType, Equal <Required <APPayment.docType> > > > > .Select(graph, catran.OrigRefNbr, catran.OrigTranType); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.AR && (catran.OrigTranType == ARDocType.CashSale || catran.OrigTranType == ARDocType.CashReturn)) { ARCashSale document = (ARCashSale)PXSelect <ARCashSale, Where <ARCashSale.refNbr, Equal <Required <ARCashSale.refNbr> >, And <ARCashSale.docType, Equal <Required <ARCashSale.docType> > > > > .Select(sender.Graph, catran.OrigRefNbr, catran.OrigTranType); if (document.OrigModule == BatchModule.SO && document.Released == false) { SO.SOInvoiceEntry graph = PXGraph.CreateInstance <SO.SOInvoiceEntry>(); graph.Clear(); sender.IsDirty = false; graph.Document.Current = (ARInvoice)PXSelect <ARInvoice, Where <ARInvoice.refNbr, Equal <Required <ARInvoice.refNbr> >, And <ARInvoice.docType, Equal <Required <ARInvoice.docType> > > > > .Select(sender.Graph, catran.OrigRefNbr, catran.OrigTranType); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else { ARCashSaleEntry graph = PXGraph.CreateInstance <ARCashSaleEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = document; throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } else if (catran.OrigModule == GL.BatchModule.AR) { ARPaymentEntry graph = PXGraph.CreateInstance <ARPaymentEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = (ARPayment)PXSelect <ARPayment, Where <ARPayment.refNbr, Equal <Required <ARPayment.refNbr> >, And <ARPayment.docType, Equal <Required <ARPayment.docType> > > > > .Select(graph, catran.OrigRefNbr, catran.OrigTranType); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.CA && catran.OrigTranType == CATranType.CAAdjustment) { CATranEntry graph = PXGraph.CreateInstance <CATranEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.CAAdjRecords.Current = PXSelect <CAAdj, Where <CAAdj.tranID, Equal <Required <CAAdj.tranID> > > > .Select(graph, catran.TranID); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.CA && catran.OrigTranType == CATranType.CATransferExp) { CATranEntry graph = PXGraph.CreateInstance <CATranEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.CAAdjRecords.Current = PXSelect <CAAdj, Where <CAAdj.adjTranType, Equal <CAAPARTranType.cATransferExp>, And <CAAdj.transferNbr, Equal <Required <CATran.origRefNbr> > > > > .Select(graph, catran.OrigRefNbr); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.CA) { if (catran.OrigTranType == CATranType.CADeposit || catran.OrigTranType == CATranType.CAVoidDeposit) { CADepositEntry graph = PXGraph.CreateInstance <CADepositEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = PXSelect <CADeposit, Where <CADeposit.tranType, Equal <Required <CADeposit.tranType> >, And <CADeposit.refNbr, Equal <Required <CADeposit.refNbr> > > > > .Select(graph, catran.OrigTranType, catran.OrigRefNbr); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else { CashTransferEntry graph = PXGraph.CreateInstance <CashTransferEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Transfer.Current = PXSelect <CATransfer, Where <CATransfer.tranIDOut, Equal <Required <CATransfer.tranIDOut> >, Or <CATransfer.tranIDIn, Equal <Required <CATransfer.tranIDIn> > > > > .Select(graph, catran.TranID, catran.TranID); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } }