Ejemplo n.º 1
0
        protected virtual void ARTran_UsrDiscountReasonID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            ARTran row = (ARTran)e.Row;

            if (row != null)
            {
                PXCache hCache            = Base.Transactions.Cache;
                ARTran  hdr               = Base.Transactions.Current;
                CAMPDiscountReasonCode rc = (CAMPDiscountReasonCode)PXSelectorAttribute.Select <ARTranExt.usrDiscountReasonID>(hCache, hdr);
                if (rc != null)
                {
                    row.DiscPct = rc.DefaultPct;
                }
            }
        }
Ejemplo n.º 2
0
        protected virtual void ARTran_DiscPct_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e, PXFieldVerifying del)
        {
            ARTran row = (ARTran)e.Row;

            // Event handler body before the base BLC event handler collection
            if (row != null)
            {
                ARTranExt distEx = PXCache <ARTran> .GetExtension <ARTranExt>(row);

                if (distEx != null && distEx.UsrDiscountReasonID > 0)
                {
                    PXCache hCache            = Base.Transactions.Cache;
                    ARTran  hdr               = Base.Transactions.Current;
                    CAMPDiscountReasonCode rc = (CAMPDiscountReasonCode)PXSelectorAttribute.Select <ARTranExt.usrDiscountReasonID>(hCache, hdr);
                    if (rc != null)
                    {
                        if ((bool)rc.AllowChanges)
                        {
                            if ((bool)rc.AllowChanges && !(bool)rc.AllowOverMax)
                            {
                                if ((decimal)e.NewValue > rc.MaxPct)
                                {
                                    throw new PXSetPropertyException <ARTran.discPct>(
                                              "discount % greater then allowed Max % for discount reason code.", PXErrorLevel.Error);
                                }
                            }
                        }
                        else
                        {
                            throw new PXSetPropertyException <ARTran.discPct>(
                                      "Cannot make changes to discount %", PXErrorLevel.Error);
                        }
                    }
                }
            }
            // Event handler body after the base BLC event handler collection
            if (del != null)
            {
                del(sender, e);
            }
        }