Ejemplo n.º 1
0
        public virtual void ViewInSMEquipment()
        {
            FSEquipment fsEquipmentRow = GetRelatedFSEquipmentRow(Base);

            if (fsEquipmentRow == null)
            {
                return;
            }

            switch (fsEquipmentRow.SourceType)
            {
            case ID.SourceType_Equipment.VEHICLE:
                VehicleMaint graphVehicleMaint = PXGraph.CreateInstance <VehicleMaint>();

                graphVehicleMaint.EPEquipmentRecords.Current = graphVehicleMaint.EPEquipmentRecords.Search <EPEquipment.equipmentCD>(fsEquipmentRow.SourceRefNbr);

                throw new PXRedirectRequiredException(graphVehicleMaint, null)
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };

            default:
                SMEquipmentMaint graphSMEquipmentMaint = PXGraph.CreateInstance <SMEquipmentMaint>();

                graphSMEquipmentMaint.EquipmentRecords.Current = graphSMEquipmentMaint.EquipmentRecords.Search <FSEquipment.refNbr>(fsEquipmentRow.RefNbr);

                throw new PXRedirectRequiredException(graphSMEquipmentMaint, null)
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
        }
Ejemplo n.º 2
0
        protected virtual void _(Events.RowPersisted <EPEquipment> e)
        {
            if (e.Row == null)
            {
                return;
            }

            if (e.TranStatus == PXTranStatus.Open)
            {
                EPEquipment epEquipmentRow = (EPEquipment)e.Row;
                FSEquipment fsEquipmentRow = GetRelatedFSEquipmentRow(e.Cache.Graph);

                if (fsEquipmentRow != null)
                {
                    PXCache <FSEquipment> cacheFSEquipment = new PXCache <FSEquipment>(Base);

                    // This is to prevent an error on the FSEquipment cache trying to change a common field (status, description)
                    // after extending an equipment to FSEquipment.
                    cacheFSEquipment.Graph.SelectTimeStamp();

                    if (EquipmentHelper.UpdateFSEquipmentWithEPEquipment(cacheFSEquipment, fsEquipmentRow, e.Cache, epEquipmentRow))
                    {
                        cacheFSEquipment.Update(fsEquipmentRow);
                        cacheFSEquipment.Persist(PXDBOperation.Update);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected virtual void _(Events.RowSelected <EPEquipment> e)
        {
            if (e.Row == null)
            {
                return;
            }

            EPEquipment epEquipmentRow = (EPEquipment)e.Row;

            FSEquipment fsEquipmentRow = GetRelatedFSEquipmentRow(e.Cache.Graph);

            extendToSMEquipment.SetEnabled(e.Cache.GetStatus(epEquipmentRow) != PXEntryStatus.Inserted && fsEquipmentRow == null);
            viewInSMEquipment.SetEnabled(fsEquipmentRow != null);
        }
        protected void EPEquipment_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            EPEquipment epEquipmentRow = (EPEquipment)e.Row;

            FSEquipment fsEquipmentRow = GetRelatedFSEquipmentRow(cache.Graph);

            extendToSMEquipment.SetEnabled(cache.GetStatus(epEquipmentRow) != PXEntryStatus.Inserted && fsEquipmentRow == null);
            viewInSMEquipment.SetEnabled(fsEquipmentRow != null);
        }
Ejemplo n.º 5
0
        public virtual void ExtendToSMEquipment()
        {
            SMEquipmentMaint graphSMEquipmentMaint = PXGraph.CreateInstance <SMEquipmentMaint>();
            FSEquipment      fsEquipmentRow        = new FSEquipment();

            fsEquipmentRow.SourceID     = Base.Equipment.Current.EquipmentID;
            fsEquipmentRow.SourceRefNbr = Base.Equipment.Current.EquipmentCD;
            fsEquipmentRow.SourceType   = ID.SourceType_Equipment.EP_EQUIPMENT;

            fsEquipmentRow.RequireMaintenance = false;
            fsEquipmentRow.ResourceEquipment  = true;

            graphSMEquipmentMaint.EquipmentRecords.Current = graphSMEquipmentMaint.EquipmentRecords.Insert(fsEquipmentRow);
            EquipmentHelper.UpdateFSEquipmentWithEPEquipment(graphSMEquipmentMaint.EquipmentRecords.Cache, graphSMEquipmentMaint.EquipmentRecords.Current, Base.Equipment.Cache, Base.Equipment.Current);
            EquipmentHelper.SetDefaultValuesFromFixedAsset(graphSMEquipmentMaint.EquipmentRecords.Cache, graphSMEquipmentMaint.EquipmentRecords.Current, Base.Equipment.Current.FixedAssetID);

            throw new PXRedirectRequiredException(graphSMEquipmentMaint, null)
                  {
                      Mode = PXBaseRedirectException.WindowMode.NewWindow
                  };
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Set default values in FSEquipment from the Fixed Asset specified.
        /// </summary>
        public static void SetDefaultValuesFromFixedAsset(PXCache cacheFSEquipment, FSEquipment fsEquipmentRow, int?fixedAssetID)
        {
            if (fixedAssetID == null)
            {
                return;
            }

            FADetails faDetailsRow = PXSelect <FADetails,
                                               Where <
                                                   FADetails.assetID, Equal <Required <FADetails.assetID> > > >
                                     .Select(cacheFSEquipment.Graph, fixedAssetID);

            if (faDetailsRow != null)
            {
                cacheFSEquipment.SetValueExt <FSEquipment.purchDate>(fsEquipmentRow, faDetailsRow.ReceiptDate);
                cacheFSEquipment.SetValueExt <FSEquipment.registeredDate>(fsEquipmentRow, faDetailsRow.DepreciateFromDate);
                cacheFSEquipment.SetValueExt <FSEquipment.purchAmount>(fsEquipmentRow, faDetailsRow.AcquisitionCost);
                cacheFSEquipment.SetValueExt <FSEquipment.purchPONumber>(fsEquipmentRow, faDetailsRow.PONumber);
                cacheFSEquipment.SetValueExt <FSEquipment.propertyType>(fsEquipmentRow, faDetailsRow.PropertyType);
                cacheFSEquipment.SetValueExt <FSEquipment.serialNumber>(fsEquipmentRow, faDetailsRow.SerialNumber);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Update a EPEquipment record with the values in the FSEquipment record.
 /// </summary>
 /// <param name="cacheEPEquipment">The cache of the EPEquipment record.</param>
 /// <param name="epEquipmentRow">The EPEquipment record.</param>
 /// <param name="cacheFSEquipment">The cache of the FSEquipment record.</param>
 /// <param name="fsEquipmentRow">The FSEquipment record.</param>
 /// <returns>Returns true if some value changes, otherwise it returns false.</returns>
 public static bool UpdateEPEquipmentWithFSEquipment(PXCache cacheEPEquipment, EPEquipment epEquipmentRow, PXCache cacheFSEquipment, FSEquipment fsEquipmentRow)
 {
     return(CopyEPEquipmentFields(cacheEPEquipment, epEquipmentRow, cacheFSEquipment, fsEquipmentRow));
 }
Ejemplo n.º 8
0
        public virtual void Create_Replace_Equipments(SMEquipmentMaint graphSMEquipmentMaint,
                                                      PXResultset <InventoryItem> inventoryItemSet,
                                                      ARRegister arRegisterRow,
                                                      Dictionary <int?, int?> newEquiments,
                                                      string action)
        {
            foreach (PXResult <InventoryItem, ARTran, SOLine> bqlResult in inventoryItemSet)
            {
                ARTran arTranRow = (ARTran)bqlResult;

                //Fetching the cached data record for ARTran that will be updated later
                arTranRow = PXSelect <ARTran,
                                      Where <
                                          ARTran.tranType, Equal <Required <ARTran.tranType> >,
                                          And <ARTran.refNbr, Equal <Required <ARTran.refNbr> >,
                                               And <ARTran.lineNbr, Equal <Required <ARTran.lineNbr> > > > > >
                            .Select(Base, arTranRow.TranType, arTranRow.RefNbr, arTranRow.LineNbr);

                InventoryItem inventoryItemRow = (InventoryItem)bqlResult;
                SOLine        soLineRow        = (SOLine)bqlResult;

                FSEquipment fsEquipmentRow = null;
                FSxARTran   fsxARTranRow   = PXCache <ARTran> .GetExtension <FSxARTran>(arTranRow);

                FSxEquipmentModel fsxEquipmentModelRow = PXCache <InventoryItem> .GetExtension <FSxEquipmentModel>(inventoryItemRow);

                for (int i = 0; i < arTranRow.Qty; i++)
                {
                    SoldInventoryItem soldInventoryItemRow = new SoldInventoryItem();

                    soldInventoryItemRow.CustomerID         = arRegisterRow.CustomerID;
                    soldInventoryItemRow.CustomerLocationID = arRegisterRow.CustomerLocationID;
                    soldInventoryItemRow.InventoryID        = inventoryItemRow.InventoryID;
                    soldInventoryItemRow.InventoryCD        = inventoryItemRow.InventoryCD;
                    soldInventoryItemRow.InvoiceRefNbr      = arTranRow.RefNbr;
                    soldInventoryItemRow.InvoiceLineNbr     = arTranRow.LineNbr;
                    soldInventoryItemRow.DocType            = arRegisterRow.DocType;
                    soldInventoryItemRow.DocDate            = arTranRow.TranDate != null ? arTranRow.TranDate : arRegisterRow.DocDate;

                    if (fsxARTranRow != null)
                    {
                        if (fsxARTranRow.AppointmentID != null)
                        {
                            soldInventoryItemRow.DocDate = fsxARTranRow.AppointmentDate;
                        }
                        else if (fsxARTranRow.SOID != null)
                        {
                            soldInventoryItemRow.DocDate = fsxARTranRow.ServiceOrderDate;
                        }
                    }

                    soldInventoryItemRow.Descr           = inventoryItemRow.Descr;
                    soldInventoryItemRow.SiteID          = arTranRow.SiteID;
                    soldInventoryItemRow.ItemClassID     = inventoryItemRow.ItemClassID;
                    soldInventoryItemRow.SOOrderType     = arTranRow.SOOrderType;
                    soldInventoryItemRow.SOOrderNbr      = arTranRow.SOOrderNbr;
                    soldInventoryItemRow.SOOrderDate     = soLineRow.OrderDate;
                    soldInventoryItemRow.EquipmentTypeID = fsxEquipmentModelRow.EquipmentTypeID;
                    soldInventoryItemRow.LotSerialNumber = arTranRow.LotSerialNbr;

                    fsEquipmentRow = SharedFunctions.CreateSoldEquipment(graphSMEquipmentMaint, soldInventoryItemRow, arTranRow, fsxARTranRow, soLineRow, action, inventoryItemRow);
                }

                if (fsEquipmentRow != null)
                {
                    if (fsxARTranRow.SuspendedSMEquipmentID == null &&
                        action == ID.Equipment_Action.REPLACING_TARGET_EQUIPMENT)
                    {
                        fsxARTranRow.SuspendedSMEquipmentID = fsxARTranRow.SMEquipmentID;
                    }

                    fsxARTranRow.SMEquipmentID = fsEquipmentRow.SMEquipmentID;
                    Base.ARTran_TranType_RefNbr.Update(arTranRow);

                    if (action == ID.Equipment_Action.SELLING_TARGET_EQUIPMENT)
                    {
                        int?smEquipmentID = -1;
                        if (newEquiments.TryGetValue(arTranRow.LineNbr, out smEquipmentID) == false)
                        {
                            newEquiments.Add(
                                arTranRow.LineNbr,
                                fsEquipmentRow.SMEquipmentID);
                        }
                    }
                    else if (action == ID.Equipment_Action.REPLACING_TARGET_EQUIPMENT)
                    {
                        if (fsxARTranRow != null)
                        {
                            graphSMEquipmentMaint.EquipmentRecords.Current = graphSMEquipmentMaint.EquipmentRecords.Search <FSEquipment.SMequipmentID>(fsxARTranRow.SuspendedSMEquipmentID);
                            graphSMEquipmentMaint.EquipmentRecords.Current.ReplaceEquipmentID = fsEquipmentRow.SMEquipmentID;
                            graphSMEquipmentMaint.EquipmentRecords.Current.Status             = ID.Equipment_Status.DISPOSED;
                            graphSMEquipmentMaint.EquipmentRecords.Current.DisposalDate       = soLineRow.OrderDate != null ? soLineRow.OrderDate : arTranRow.TranDate;
                            graphSMEquipmentMaint.EquipmentRecords.Current.DispServiceOrderID = fsxARTranRow.SOID;
                            graphSMEquipmentMaint.EquipmentRecords.Current.DispAppointmentID  = fsxARTranRow.AppointmentID;
                            graphSMEquipmentMaint.EquipmentRecords.Cache.SetStatus(graphSMEquipmentMaint.EquipmentRecords.Current, PXEntryStatus.Updated);
                            graphSMEquipmentMaint.Save.Press();
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private void Create_Replace_Equipments(
            SMEquipmentMaint graphSMEquipmentMaint,
            PXResultset <InventoryItem> inventoryItemSet,
            ARRegister arRegisterRow,
            Dictionary <int?, int?> newEquiments,
            string action)
        {
            foreach (PXResult <InventoryItem, ARTran, SOLineSplit, SOLine, SOShipLineSplit> bqlResult in inventoryItemSet)
            {
                ARTran          arTranRow          = (ARTran)bqlResult;
                InventoryItem   inventoryItemRow   = (InventoryItem)bqlResult;
                SOLine          soLineRow          = (SOLine)bqlResult;
                SOLineSplit     soLineSplitRow     = (SOLineSplit)bqlResult;
                SOShipLineSplit soShipLineSplitRow = (SOShipLineSplit)bqlResult;
                FSEquipment     fsEquipmentRow     = null;
                FSxSOLine       fsxSOLineRow       = PXCache <SOLine> .GetExtension <FSxSOLine>(soLineRow);

                FSxARTran fsxARTranRow = PXCache <ARTran> .GetExtension <FSxARTran>(arTranRow);

                FSxEquipmentModel fsxEquipmentModelRow = PXCache <InventoryItem> .GetExtension <FSxEquipmentModel>(inventoryItemRow);

                int?iteratorMax = (int?)(soShipLineSplitRow == null || soShipLineSplitRow.Qty == null ? soLineSplitRow.Qty : soShipLineSplitRow.Qty);


                for (int i = 0; i < iteratorMax; i++)
                {
                    SoldInventoryItem soldInventoryItemRow = new SoldInventoryItem();

                    soldInventoryItemRow.CustomerID         = arRegisterRow.CustomerID;
                    soldInventoryItemRow.CustomerLocationID = arRegisterRow.CustomerLocationID;
                    soldInventoryItemRow.InventoryID        = inventoryItemRow.InventoryID;
                    soldInventoryItemRow.InventoryCD        = inventoryItemRow.InventoryCD;
                    soldInventoryItemRow.InvoiceRefNbr      = arTranRow.RefNbr;
                    soldInventoryItemRow.InvoiceLineNbr     = arTranRow.LineNbr;
                    soldInventoryItemRow.DocType            = arRegisterRow.DocType;
                    soldInventoryItemRow.DocDate            = arTranRow.TranDate != null ? arTranRow.TranDate : arRegisterRow.DocDate;

                    if (fsxSOLineRow != null)
                    {
                        if (fsxSOLineRow.AppointmentID != null)
                        {
                            soldInventoryItemRow.DocDate = fsxSOLineRow.AppointmentDate;
                        }
                        else if (fsxSOLineRow.SOID != null)
                        {
                            soldInventoryItemRow.DocDate = fsxSOLineRow.ServiceOrderDate;
                        }
                    }

                    soldInventoryItemRow.Descr           = inventoryItemRow.Descr;
                    soldInventoryItemRow.SiteID          = arTranRow.SiteID;
                    soldInventoryItemRow.ItemClassID     = inventoryItemRow.ItemClassID;
                    soldInventoryItemRow.SOOrderType     = soLineRow.OrderType;
                    soldInventoryItemRow.SOOrderNbr      = soLineRow.OrderNbr;
                    soldInventoryItemRow.SOOrderDate     = soLineRow.OrderDate;
                    soldInventoryItemRow.EquipmentTypeID = fsxEquipmentModelRow.EquipmentTypeID;


                    if (soLineSplitRow != null)
                    {
                        soldInventoryItemRow.LotSerialNumber = soLineSplitRow.LotSerialNbr;
                    }

                    if (soldInventoryItemRow.LotSerialNumber == null &&
                        soShipLineSplitRow != null)
                    {
                        soldInventoryItemRow.LotSerialNumber = soShipLineSplitRow.LotSerialNbr;
                    }

                    fsEquipmentRow = SharedFunctions.CreateSoldEquipment(graphSMEquipmentMaint, soldInventoryItemRow, soLineRow, fsxSOLineRow, action, inventoryItemRow);
                }

                if (fsEquipmentRow != null)
                {
                    fsxARTranRow.SMEquipmentID = fsEquipmentRow.SMEquipmentID;
                    Base.ARTran_TranType_RefNbr.Update(arTranRow);

                    if (action == ID.Equipment_Action.SELLING_TARGET_EQUIPMENT)
                    {
                        int?smEquipmentID = -1;
                        if (newEquiments.TryGetValue(soLineRow.LineNbr, out smEquipmentID) == false)
                        {
                            newEquiments.Add(
                                soLineRow.LineNbr,
                                fsEquipmentRow.SMEquipmentID);
                        }
                    }
                    else if (action == ID.Equipment_Action.REPLACING_TARGET_EQUIPMENT)
                    {
                        if (fsxSOLineRow != null)
                        {
                            graphSMEquipmentMaint.EquipmentRecords.Current = graphSMEquipmentMaint.EquipmentRecords.Search <FSEquipment.SMequipmentID>(fsxSOLineRow.SMEquipmentID);
                            graphSMEquipmentMaint.EquipmentRecords.Current.ReplaceEquipmentID = fsEquipmentRow.SMEquipmentID;
                            graphSMEquipmentMaint.EquipmentRecords.Current.Status             = ID.Equipment_Status.DISPOSED;
                            graphSMEquipmentMaint.EquipmentRecords.Current.DisposalDate       = soLineRow.OrderDate;
                            graphSMEquipmentMaint.EquipmentRecords.Current.DispServiceOrderID = fsxSOLineRow.SOID;
                            graphSMEquipmentMaint.EquipmentRecords.Current.DispAppointmentID  = fsxSOLineRow.AppointmentID;
                            graphSMEquipmentMaint.EquipmentRecords.Cache.SetStatus(graphSMEquipmentMaint.EquipmentRecords.Current, PXEntryStatus.Updated);
                            graphSMEquipmentMaint.Save.Press();
                        }
                    }
                }
            }
        }