示例#1
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();
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Show or hide Components tab.
        /// </summary>
        /// <param name="cache">Cache of the Inventory Item.</param>
        /// <param name="inventoryItemRow">Inventory Item Row.</param>
        private void ShowOrHideComponetsTab(PXCache cache, InventoryItem inventoryItemRow)
        {
            FSxEquipmentModel fsxEquipmemtModelRow = cache.GetExtension <FSxEquipmentModel>(inventoryItemRow);

            this.ModelComponents.AllowSelect = fsxEquipmemtModelRow.Mem_ShowComponent == true;
        }