示例#1
0
 protected virtual IEnumerable ResetGroup(PXAdapter adapter)
 {
     if (VendorClassRecord.Ask(Messages.Warning, Messages.GroupUpdateConfirm, MessageButtons.OKCancel) == WebDialogResult.OK)
     {
         Save.Press();
         string classID = VendorClassRecord.Current.VendorClassID;
         PXLongOperation.StartOperation(this, delegate()
         {
             Reset(classID);
         });
     }
     return(adapter.Get());
 }
        protected virtual void INItemSite_DfltShipLocationID_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            INItemSite is_row = (INItemSite)e.Row;

            INLocation l = PXSelect <INLocation, Where <INLocation.locationID, Equal <Required <INLocation.locationID> > > > .Select(this, e.NewValue);

            if (l == null)
            {
                return;
            }
            if (!(l.SalesValid ?? true))
            {
                if (itemsiterecord.Ask(AP.Messages.Warning, Messages.IssuesAreNotAllowedFromThisLocationContinue, MessageButtons.YesNo, false) == WebDialogResult.No)
                {
                    e.NewValue = is_row.DfltShipLocationID;
                    e.Cancel   = true;
                }
            }
        }
        private IEnumerable PerformPaste(PXAdapter adapter)
        {
            var buffer = CutBuffer.Cache.Cached.Cast <ItemBuffer>().ToArray();

            if (buffer.Any() == false)
            {
                return(adapter.Get());
            }

            int newItemClassID = (int)ItemClasses.Current.ItemClassID;

            object[] inventoryIDs = buffer.Select(b => b.InventoryID).Cast <object>().ToArray();
            var      inventories  =
                PXSelectReadonly <InventoryItem,
                                  Where <InventoryItem.inventoryID, In <Required <InventoryItem.inventoryID> > > >
                .Select(this, new[] { inventoryIDs }).RowCast <InventoryItem>().ToArray();

            var notMatchItems = inventories.Where(i => i.StkItem != ItemClasses.Current.StkItem).ToArray();

            if (notMatchItems.Any())
            {
                String segmentedItemClassID = ItemClasses.Current.SegmentedClassCD.FirstSegment(' ');
                if (notMatchItems.Length == 1)
                {
                    throw new PXInvalidOperationException(
                              Messages.ItemClassAndInventoryItemStkItemShouldBeSameSingleItem,
                              notMatchItems[0].InventoryCD.TrimEnd(),
                              segmentedItemClassID);
                }
                else
                {
                    PXTrace.WriteInformation(
                        notMatchItems.Aggregate(
                            new StringBuilder().AppendLine(PXMessages.LocalizeFormatNoPrefix(Messages.CouldNotBeMovedToItemClassItemsList, segmentedItemClassID)),
                            (sb, item) => sb.AppendLine(item.InventoryCD.TrimEnd()),
                            sb => sb.ToString()));

                    throw new PXInvalidOperationException(
                              Messages.ItemClassAndInventoryItemStkItemShouldBeSameManyItems,
                              segmentedItemClassID);
                }
            }

            bool needToDefault = Inventories.Ask(AR.Messages.Warning, Messages.ItemClassChangeWarning, MessageButtons.YesNo) == WebDialogResult.Yes;

            Lazy <InventoryItemMaint> stockItemMaint    = new Lazy <InventoryItemMaint>(CreateInstance <InventoryItemMaint>);
            Lazy <NonStockItemMaint>  nonStockItemMaint = new Lazy <NonStockItemMaint>(CreateInstance <NonStockItemMaint>);

            foreach (InventoryItem inventory in inventories)
            {
                if (needToDefault)
                {
                    InventoryItemMaintBase inventoryItemMaint = inventory.StkItem == true ? (InventoryItemMaintBase)stockItemMaint.Value : nonStockItemMaint.Value;

                    inventoryItemMaint.Item.Current = inventory;
                    using (inventoryItemMaint.MakeRuleWeakeningScopeFor <InventoryItem.lotSerClassID>(RuleWeakenLevel.SuppressError))
                        using (inventoryItemMaint.MakeRuleWeakeningScopeFor <InventoryItem.baseUnit>(RuleWeakenLevel.SuppressError))
                            using (stockItemMaint.Value.MakeRuleWeakeningScopeFor <InventoryItem.decimalBaseUnit>(RuleWeakenLevel.SuppressError))
                            {
                                var copy = (InventoryItem)inventoryItemMaint.Item.Cache.CreateCopy(inventory);
                                copy.ItemClassID = newItemClassID;
                                inventoryItemMaint.Item.Update(copy);
                            }
                    inventoryItemMaint.Actions.PressSave();
                }
                else
                {
                    inventory.ItemClassID = newItemClassID;
                    Inventories.Cache.Update(inventory);
                }
                Inventories.SetValueExt <InventoryItem.selected>(Inventories.Locate(inventory), false);
            }

            CutBuffer.Cache.Clear();

            if (needToDefault)
            {
                Actions.PressCancel();
            }
            else
            {
                Actions.PressSave();
            }

            return(adapter.Get());
        }