Exemplo n.º 1
0
        public ConvertItemsToEquipmentProcess()
        {
            SMEquipmentMaint graphSMEquipmentMaint;

            InventoryItems.SetProcessDelegate(
                delegate(List <SoldInventoryItem> inventoryItemRows)
            {
                graphSMEquipmentMaint = CreateInstance <SMEquipmentMaint>();
                bool error            = false;
                for (int i = 0; i < inventoryItemRows.Count; i++)
                {
                    SoldInventoryItem soldInventoryItemRow = inventoryItemRows[i];
                    error = false;

                    try
                    {
                        for (int j = 0; j < soldInventoryItemRow.ShippedQty; j++)
                        {
                            SharedFunctions.CreateSoldEquipment(graphSMEquipmentMaint, soldInventoryItemRow, null, null, null, null);
                        }
                    }
                    catch (Exception e)
                    {
                        error = true;
                        PXProcessing <SoldInventoryItem> .SetError(i, e.Message);
                    }

                    if (error == false)
                    {
                        PXProcessing <SoldInventoryItem> .SetInfo(i, TX.Messages.RECORD_PROCESSED_SUCCESSFULLY);
                    }
                }
            });
        }
Exemplo n.º 2
0
        public virtual void SoldInventoryItem_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            SoldInventoryItem inventoryItemRow = (SoldInventoryItem)e.Row;

            int components =
                PXSelect <FSModelComponent,
                          Where <
                              FSModelComponent.modelID, Equal <Required <FSModelComponent.modelID> > > >
                .SelectWindowed(this, 0, 1, inventoryItemRow.InventoryID).Count;

            if (components == 0)
            {
                cache.RaiseExceptionHandling <SoldInventoryItem.inventoryCD>(
                    inventoryItemRow,
                    inventoryItemRow.InventoryCD,
                    new PXSetPropertyException(
                        TX.Warning.ITEM_WITH_NO_WARRANTIES_CONFIGURED,
                        PXErrorLevel.RowWarning));
            }
        }
        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();
                        }
                    }
                }
            }
        }
Exemplo n.º 4
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();
                        }
                    }
                }
            }
        }