Esempio n. 1
0
        protected virtual void ShipmentLine_LineQty_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            ShipmentLine line = (ShipmentLine)e.Row;

            if (e.NewValue == null)
            {
                return;
            }

            if ((decimal)e.NewValue < 0)
            {
                throw new PXSetPropertyException("Item Qty. cannot be negative.");
            }

            Product product = PXSelect <Product,
                                        Where <Product.productID, Equal <Required <Product.productID> > > >
                              .Select(this, line.ProductID);

            if (product != null && (decimal)e.NewValue < product.MinAvailQty)
            {
                e.NewValue = product.MinAvailQty;
                sender.RaiseExceptionHandling <ShipmentLine.lineQty>(line, e.NewValue,
                                                                     new PXSetPropertyException("Item Qty. was too small for the selected product.", PXErrorLevel.Warning));
            }
        }
Esempio n. 2
0
        protected virtual void ShipmentLine_RowUpdating(PXCache sender, PXRowUpdatingEventArgs e)
        {
            ShipmentLine line         = (ShipmentLine)e.NewRow;
            ShipmentLine originalLine = (ShipmentLine)e.Row;
            Shipment     row          = Shipments.Current;

            if (row.ShipmentType != ShipmentTypes.Single &&
                !sender.ObjectsEqual <ShipmentLine.shipmentTime,
                                      ShipmentLine.shipmentMinTime,
                                      ShipmentLine.shipmentMaxTime>(line, originalLine))
            {
                if (line.ShipmentTime != null && line.ShipmentMinTime != null &&
                    line.ShipmentTime < line.ShipmentMinTime)
                {
                    sender.RaiseExceptionHandling <ShipmentLine.shipmentTime>(line, line.ShipmentTime,
                                                                              new PXSetPropertyException("Delivery Time is too early."));
                    e.Cancel = true;
                }
                if (line.ShipmentTime != null && line.ShipmentMaxTime != null &&
                    line.ShipmentTime > line.ShipmentMaxTime)
                {
                    line.ShipmentTime = line.ShipmentMaxTime;
                    sender.RaiseExceptionHandling <ShipmentLine.shipmentTime>(line, line.ShipmentTime,
                                                                              new PXSetPropertyException("Specified Delivery Time was too late.", PXErrorLevel.Warning));
                }
            }
        }
Esempio n. 3
0
        protected virtual void ShipmentLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            ShipmentLine line = (ShipmentLine)e.Row;
            Shipment     row  = Shipments.Current;

            if (line == null || row == null)
            {
                return;
            }

            PXUIFieldAttribute.SetEnabled(sender, line, line.Gift != true);
            PXUIFieldAttribute.SetEnabled <ShipmentLine.lineQty>(sender, line, line.Gift != true && row.Status != ShipmentStatus.Shipping);
            PXUIFieldAttribute.SetEnabled <ShipmentLine.cancelled>(sender, line, line.Gift != true && row.Status != ShipmentStatus.Shipping);
            if (row.ShipmentType != ShipmentTypes.Single)
            {
                PXUIFieldAttribute.SetEnabled <ShipmentLine.cancelled>(sender, line,
                                                                       line.Gift != true && row.Status != ShipmentStatus.Shipping && line.ShipmentDate == null);
            }
            else
            {
                PXUIFieldAttribute.SetEnabled <ShipmentLine.cancelled>(sender, line, line.Gift != true && row.Status != ShipmentStatus.Shipping);
            }
            PXUIFieldAttribute.SetEnabled <ShipmentLine.shipmentDate>(sender, line, row.Status == ShipmentStatus.Shipping && line.Cancelled != true);
            PXUIFieldAttribute.SetEnabled <ShipmentLine.shipmentTime>(sender, line, row.Status == ShipmentStatus.Shipping && line.Cancelled != true);
            PXUIFieldAttribute.SetEnabled <ShipmentLine.shipmentMinTime>(sender, line, row.Status != ShipmentStatus.Shipping && line.Cancelled != true);
            PXUIFieldAttribute.SetEnabled <ShipmentLine.shipmentMaxTime>(sender, line, row.Status != ShipmentStatus.Shipping && line.Cancelled != true);
        }
Esempio n. 4
0
        protected virtual void ShipmentLine_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            ShipmentLine line = (ShipmentLine)e.Row;
            Shipment     row  = Shipments.Current;

            row.TotalQty += line.LineQty;
            Shipments.Update(row);
        }
Esempio n. 5
0
        protected virtual void ShipmentLine_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
        {
            ShipmentLine line = (ShipmentLine)e.Row;
            Shipment     row  = Shipments.Current;

            if (line.Cancelled != true &&
                Shipments.Cache.GetStatus(row) != PXEntryStatus.InsertedDeleted &&
                Shipments.Cache.GetStatus(row) != PXEntryStatus.Deleted)
            {
                row.TotalQty -= line.LineQty;
                Shipments.Update(row);
            }
        }
Esempio n. 6
0
        protected virtual void ShipmentLine_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            ShipmentLine newLine    = (ShipmentLine)e.Row;
            ShipmentLine oldLine    = (ShipmentLine)e.OldRow;
            Shipment     row        = Shipments.Current;
            bool         rowUpdated = false;

            if (!sender.ObjectsEqual <ShipmentLine.lineQty>(newLine, oldLine) && newLine.Cancelled != true)
            {
                row.TotalQty -= oldLine.LineQty;
                row.TotalQty += newLine.LineQty;
                rowUpdated    = true;
            }
            if (!sender.ObjectsEqual <ShipmentLine.cancelled>(newLine, oldLine))
            {
                if (newLine.Cancelled == true)
                {
                    row.TotalQty -= oldLine.LineQty;
                }
                else if (oldLine.Cancelled == true)
                {
                    row.TotalQty += newLine.LineQty;
                }
                rowUpdated = true;
            }

            if (row.ShipmentType != ShipmentTypes.Single)
            {
                if (!sender.ObjectsEqual <ShipmentLine.shipmentDate, ShipmentLine.shipmentTime>(newLine, oldLine))
                {
                    if (newLine.ShipmentDate != null && newLine.ShipmentTime != null)
                    {
                        row.ShippedQty += newLine.LineQty;
                        rowUpdated      = true;
                    }
                    if (oldLine.ShipmentDate != null && oldLine.ShipmentTime != null)
                    {
                        row.ShippedQty -= oldLine.LineQty;
                        rowUpdated      = true;
                    }
                }
            }

            if (rowUpdated == true)
            {
                Shipments.Update(row);
            }
        }
Esempio n. 7
0
        protected virtual void ShipmentLine_ProductID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            ShipmentLine line = (ShipmentLine)e.Row;

            line.Description = string.Empty;
            if (line.ProductID != null)
            {
                Product product =
                    PXSelectorAttribute.Select <ShipmentLine.productID>(
                        sender, line) as Product;
                if (product != null)
                {
                    line.Description = product.ProductName;
                }
            }
        }
Esempio n. 8
0
        protected virtual void ShipmentLine_Gift_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            ShipmentLine line = (ShipmentLine)e.Row;

            if (line == null)
            {
                return;
            }

            Product card = GiftCard.Select();

            if (card != null && line.ProductID == card.ProductID)
            {
                e.NewValue = true;
                e.Cancel   = true;
            }
        }
Esempio n. 9
0
        protected virtual void Shipment_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            if (ShipmentLines.Select().Count == 0)
            {
                bool    oldDirty = ShipmentLines.Cache.IsDirty;
                Product card     = GiftCard.Select();
                if (card != null)
                {
                    ShipmentLine line = new ShipmentLine();
                    line.ProductID = card.ProductID;
                    line.LineQty   = card.MinAvailQty;
                    ShipmentLines.Insert(line);

                    ShipmentLines.Cache.IsDirty = oldDirty;
                }
            }
        }
Esempio n. 10
0
        protected virtual void ShipmentLine_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            ShipmentLine line = (ShipmentLine)e.Row;

            if (!e.ExternalCall)
            {
                return;
            }

            if (line.Gift == true)
            {
                throw new PXException("Product {0} cannot be deleted", ShipmentLine.GiftCard);
            }
            else if (sender.GetStatus(line) != PXEntryStatus.InsertedDeleted)
            {
                if (ShipmentLines.Ask("Confirm Delete", "Are you sure?", MessageButtons.YesNo) != WebDialogResult.Yes)
                {
                    e.Cancel = true;
                }
            }
        }
Esempio n. 11
0
        protected virtual void ShipmentLine_ShipmentDate_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            ShipmentLine line = (ShipmentLine)e.Row;

            line.ShipmentTime = null;
        }