示例#1
0
        protected virtual void APDiscount_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            APDiscount row = e.Row as APDiscount;

            if (row != null)
            {
                if (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update)
                {
                    if (PXSelectReadonly <ARDiscount, Where <ARDiscount.discountID, Equal <Required <ARDiscount.discountID> > > > .Select(this, row.DiscountID).Count != 0)
                    {
                        sender.RaiseExceptionHandling <APDiscount.discountID>(row, row.DiscountID, new PXSetPropertyException(Messages.DiscountCodeAlreadyExistAR, PXErrorLevel.Error));
                    }
                    if ((row.Type == DiscountType.Line || row.Type == DiscountType.Document) && row.SkipDocumentDiscounts == true)
                    {
                        row.SkipDocumentDiscounts = false;
                    }
                    if ((row.Type == DiscountType.Group || row.Type == DiscountType.Document) && row.ExcludeFromDiscountableAmt == true)
                    {
                        row.ExcludeFromDiscountableAmt = false;
                    }
                }
                if (e.Operation == PXDBOperation.Insert)
                {
                    if (PXSelectReadonly <APDiscount, Where <APDiscount.discountID, Equal <Required <APDiscount.discountID> > > > .Select(this, row.DiscountID).Count != 0)
                    {
                        sender.RaiseExceptionHandling <APDiscount.discountID>(row, row.DiscountID, new PXSetPropertyException(Messages.DiscountCodeAlreadyExist, PXErrorLevel.Error));
                    }
                }
            }
        }
示例#2
0
        protected virtual void APDiscount_Type_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            APDiscount discount = e.Row as APDiscount;

            if (discount == null)
            {
                return;
            }

            DiscountSequence sequence = PXSelect <
                DiscountSequence,
                Where <
                    DiscountSequence.discountID, Equal <Required <DiscountSequence.discountID> > > >
                                        .SelectWindowed(this, 0, 1, discount.DiscountID);

            if (sequence != null)
            {
                discount.Type = (string)e.OldValue;
                sender.RaiseExceptionHandling <APDiscount.type>(discount, e.OldValue, new PXSetPropertyException(AR.Messages.DiscountTypeCannotChanged));
            }
            else if (
                discount.Type == DiscountType.Document &&
                discount.ApplicableTo != DiscountTarget.Vendor)
            {
                sender.SetValueExt <APDiscount.applicableTo>(e.Row, DiscountTarget.Vendor);
            }
        }
        protected virtual void APDiscount_ApplicableTo_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            APDiscount row = e.Row as APDiscount;

            if (row != null)
            {
                if (row.Type == SO.DiscountType.Document)
                {
                    e.ReturnState = PXStringState.CreateInstance(e.ReturnValue, 1, false, "ApplicableTo", false, 1, null,
                                                                 new string[] { DiscountTarget.Vendor },
                                                                 new string[] { Messages.VendorUnconditional }.Select(l => PXMessages.LocalizeNoPrefix(l)).ToArray(),
                                                                 true, DiscountTarget.Unconditional);
                    return;
                }
            }
            if (!PXAccess.FeatureInstalled <FeaturesSet.accountLocations>())
            {
                e.ReturnState = PXStringState.CreateInstance(e.ReturnValue, 1, false, "ApplicableTo", false, 1, null,
                                                             new string[] { DiscountTarget.VendorAndInventory, DiscountTarget.VendorAndInventoryPrice, DiscountTarget.Vendor },
                                                             new string[] { Messages.VendorAndInventory, Messages.VendorInventoryPrice, Messages.VendorUnconditional }.Select(l => PXMessages.LocalizeNoPrefix(l)).ToArray(),
                                                             true, DiscountTarget.Inventory);
                return;
            }

            e.ReturnState = PXStringState.CreateInstance(e.ReturnValue, 1, false, "ApplicableTo", false, 1, null,
                                                         new string[] { DiscountTarget.VendorAndInventory, DiscountTarget.VendorAndInventoryPrice, DiscountTarget.VendorLocation, DiscountTarget.VendorLocationAndInventory, DiscountTarget.Vendor },
                                                         new string[] { Messages.VendorAndInventory, Messages.VendorInventoryPrice, Messages.Vendor_Location, Messages.VendorLocationaAndInventory, Messages.VendorUnconditional }.Select(l => PXMessages.LocalizeNoPrefix(l)).ToArray(),
                                                         true, DiscountTarget.Inventory);
        }
        protected virtual void APDiscount_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            APDiscount row = e.Row as APDiscount;

            if (row != null)
            {
                PXUIFieldAttribute.SetEnabled <APDiscount.excludeFromDiscountableAmt>(sender, row, row.Type == DiscountType.Line);
                PXUIFieldAttribute.SetEnabled <APDiscount.skipDocumentDiscounts>(sender, row, row.Type == DiscountType.Group);
            }
        }
示例#5
0
        protected virtual void APDiscount_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            APDiscount row = e.Row as APDiscount;

            if (row != null)
            {
                PXUIFieldAttribute.SetEnabled <APDiscount.excludeFromDiscountableAmt>(sender, row, row.Type == DiscountType.Line);
                PXUIFieldAttribute.SetEnabled <APDiscount.skipDocumentDiscounts>(sender, row, row.Type == DiscountType.Group);
                PXStringListAttribute.SetList <APDiscount.type>(sender, null, new Tuple <string, string>[] {
                    new Tuple <string, string> (DiscountType.Line, AR.Messages.Line),
                    new Tuple <string, string> (DiscountType.Group, AR.Messages.Group),
                    new Tuple <string, string> (DiscountType.Document, AR.Messages.Document)
                });
            }
        }
        protected virtual void APDiscount_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            APDiscount row = e.Row as APDiscount;

            if (row != null)
            {
                if (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update)
                {
                    if (PXSelectReadonly <ARDiscount, Where <ARDiscount.discountID, Equal <Required <ARDiscount.discountID> > > > .Select(this, row.DiscountID).Count != 0)
                    {
                        sender.RaiseExceptionHandling <APDiscount.discountID>(row, row.DiscountID, new PXSetPropertyException(Messages.DiscountCodeAlreadyExist, PXErrorLevel.Error));
                    }
                }
                if (e.Operation == PXDBOperation.Insert)
                {
                    if (PXSelectReadonly <APDiscount, Where <APDiscount.discountID, Equal <Required <APDiscount.discountID> > > > .Select(this, row.DiscountID).Count != 0)
                    {
                        sender.RaiseExceptionHandling <APDiscount.discountID>(row, row.DiscountID, new PXSetPropertyException(Messages.DiscountCodeAlreadyExist, PXErrorLevel.Error));
                    }
                }
            }
        }
        protected virtual void APDiscount_Type_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            APDiscount row = e.Row as APDiscount;

            if (row != null)
            {
                DiscountSequence sequence = PXSelect <DiscountSequence, Where <DiscountSequence.discountID, Equal <Required <DiscountSequence.discountID> > > > .SelectWindowed(this, 0, 1, row.DiscountID);

                if (sequence != null)
                {
                    row.Type = (string)e.OldValue;
                    sender.RaiseExceptionHandling <APDiscount.type>(row, e.OldValue, new PXSetPropertyException(SO.Messages.DiscountTypeCannotChanged));
                }
                if (row.Type == SO.DiscountType.Flat)
                {
                    row.IsAutoNumber = true;
                    if (string.IsNullOrEmpty(row.LastNumber))
                    {
                        row.LastNumber = "000000000";
                    }
                }
            }
        }
示例#8
0
        protected virtual void APDiscount_ApplicableTo_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            APDiscount row = e.Row as APDiscount;

            string[] allowedValues;
            string[] allowedLabels;

            if (row != null)
            {
                if (row.Type == DiscountType.Document)
                {
                    allowedValues = new[] { DiscountTarget.Vendor };
                    allowedLabels = new[] { Messages.VendorUnconditional }
                    .Select(PXMessages.LocalizeNoPrefix)
                    .ToArray();

                    e.ReturnState = PXStringState.CreateInstance(
                        e.ReturnValue,
                        1,
                        false,
                        nameof(APDiscount.ApplicableTo),
                        false,
                        1,
                        null,
                        allowedValues,
                        allowedLabels,
                        true,
                        DiscountTarget.Unconditional);

                    return;
                }
            }

            if (!PXAccess.FeatureInstalled <FeaturesSet.accountLocations>())
            {
                allowedValues = new[]
                {
                    DiscountTarget.VendorAndInventory,
                    DiscountTarget.VendorAndInventoryPrice,
                    DiscountTarget.Vendor
                };
                allowedLabels = new[]
                {
                    Messages.VendorAndInventory,
                    Messages.VendorInventoryPrice,
                    Messages.VendorUnconditional
                }
                .Select(PXMessages.LocalizeNoPrefix)
                .ToArray();

                e.ReturnState = PXStringState.CreateInstance(
                    e.ReturnValue,
                    1,
                    false,
                    nameof(APDiscount.ApplicableTo),
                    false,
                    1,
                    null,
                    allowedValues,
                    allowedLabels,
                    true,
                    DiscountTarget.Inventory);

                return;
            }

            allowedValues = new[]
            {
                DiscountTarget.VendorAndInventory,
                DiscountTarget.VendorAndInventoryPrice,
                DiscountTarget.VendorLocation,
                DiscountTarget.VendorLocationAndInventory,
                DiscountTarget.Vendor
            };
            allowedLabels = new[]
            {
                Messages.VendorAndInventory,
                Messages.VendorInventoryPrice,
                Messages.Vendor_Location,
                Messages.VendorLocationaAndInventory,
                Messages.VendorUnconditional
            }
            .Select(PXMessages.LocalizeNoPrefix)
            .ToArray();

            e.ReturnState = PXStringState.CreateInstance(
                e.ReturnValue,
                1,
                false,
                nameof(APDiscount.ApplicableTo),
                false,
                1,
                null,
                allowedValues,
                allowedLabels,
                true,
                DiscountTarget.Inventory);
        }