Esempio n. 1
0
        protected virtual void ARInvoice_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected bs)
        {
            if (bs != null)
            {
                bs(sender, e);
            }
            ARInvoice row = e.Row as ARInvoice;

            if (row == null)
            {
                return;
            }
            bool           isWithinContext = Base.IsWithinContext;
            GLVoucher      voucher         = this.Voucher.Select();
            GLVoucherBatch voucherBatch    = this.VoucherBatch.Select();
            PXCache        voucherCache    = this.Voucher.Cache;
            bool           isDetached      = (voucher == null);

            PXUIFieldAttribute.SetEnabled <GLVoucher.refNbr>(voucherCache, voucher, false);
            PXUIFieldAttribute.SetVisible <GLVoucher.refNbr>(voucherCache, voucher, !isDetached);
            PXUIFieldAttribute.SetEnabled <ARInvoice.refNbr>(sender, e.Row, !isWithinContext);
            this.SaveAndAdd.SetVisible(!isDetached && isWithinContext);
            this.SaveAndAdd.SetEnabled(!isDetached && isWithinContext);
            if (isWithinContext)
            {
                Base.release.SetVisible(false);
                Base.release.SetEnabled(false);
            }
            if (!isDetached)
            {
                try
                {
                    Base.action.SetEnabled("Add to Schedule", false);
                }
                catch { }
                Base.createSchedule.SetEnabled(false);
            }
            PXUIFieldAttribute.SetVisible <GLVoucher.voucherBatchNbr>(Voucher.Cache, null, !isDetached && !isWithinContext);
            PXUIFieldAttribute.SetVisible <GLVoucher.workBookID>(Voucher.Cache, null, !isDetached && !isWithinContext);
            if (isWithinContext && !isDetached)
            {
                sender.AllowInsert = !(voucherBatch != null && voucherBatch.Released == true);
            }
        }
        protected virtual void CAAdj_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected bs)
        {
            if (bs != null)
            {
                bs(sender, e);
            }
            CAAdj row = e.Row as CAAdj;

            if (row == null)
            {
                return;
            }
            bool           isWithinContext = Base.IsWithinContext;
            GLVoucher      voucher         = this.Voucher.Select();
            GLVoucherBatch voucherBatch    = this.VoucherBatch.Select();
            PXCache        voucherCache    = this.Voucher.Cache;
            bool           isDetached      = (voucher == null);

            PXUIFieldAttribute.SetEnabled <GLVoucher.refNbr>(voucherCache, voucher, false);
            PXUIFieldAttribute.SetVisible <GLVoucher.refNbr>(voucherCache, voucher, !isDetached);
            PXUIFieldAttribute.SetEnabled <CAAdj.adjRefNbr>(sender, e.Row, !isWithinContext);
            this.SaveAndAdd.SetVisible(!isDetached && isWithinContext);
            this.SaveAndAdd.SetEnabled(!isDetached && isWithinContext);
            if (isWithinContext)
            {
                Base.Release.SetVisible(false);
                Base.Release.SetEnabled(false);
                Base.Reverse.SetVisible(false);
                Base.Reverse.SetEnabled(false);
            }
            PXUIFieldAttribute.SetVisible <GLVoucher.voucherBatchNbr>(Voucher.Cache, null, !isDetached && !isWithinContext);
            PXUIFieldAttribute.SetVisible <GLVoucher.workBookID>(Voucher.Cache, null, !isDetached && !isWithinContext);
            if (isWithinContext && !isDetached)
            {
                sender.AllowInsert = !(voucherBatch != null && voucherBatch.Released == true);
            }
        }
        public static bool IsAttached(PXGraph aGraph, Guid?aNoteID, out GLVoucherBatch aVoucherBatch, out GLVoucher aVoucher)
        {
            aVoucher      = null;
            aVoucherBatch = null;
            if (aNoteID.HasValue)
            {
                PXResult <GLVoucher, GLVoucherBatch> result = (PXResult <GLVoucher, GLVoucherBatch>) PXSelectJoin <GLVoucher,
                                                                                                                   InnerJoin <GLVoucherBatch, On <GLVoucherBatch.workBookID, Equal <GLVoucher.workBookID>,
                                                                                                                                                  And <GLVoucherBatch.voucherBatchNbr, Equal <GLVoucher.voucherBatchNbr> > > >,
                                                                                                                   Where <GLVoucher.refNoteID, Equal <Required <GLVoucher.refNoteID> > > > .Select(aGraph, aNoteID);

                if (result != null && !String.IsNullOrEmpty(((GLVoucher)result).RefNbr))
                {
                    aVoucher      = result;
                    aVoucherBatch = result;
                    return(true);
                }
            }
            return(false);
        }
 public virtual bool IsAttached(APInvoice aRow, out GLVoucherBatch aVoucherBatch, out GLVoucher aVoucher)
 {
     return(IsAttached(Base, aRow.NoteID, out aVoucherBatch, out aVoucher));
 }