Пример #1
0
        public static string GetPath <G> (long groupId, CacheEntityCollection <G> cache) where G : GroupBase <G>, ICacheableEntity <G>, new ()
        {
            if (groupId < 0)
            {
                return(null);
            }

            cache.EnsureCompleteLoad();
            G g = cache.GetById(groupId);

            StringBuilder ret = new StringBuilder();

            while (g != null)
            {
                ret.Insert(0, g.name);
                ret.Insert(0, pathSeparator);
                g = g.parent ?? cache.GetByCode(g.ParentCode);
            }

            return(ret.ToString());
        }
Пример #2
0
        public static Item GetByAny(string input, out bool barCodeUsed, out double qtty, out string lot, out long storeId, long?locationId = null)
        {
            barCodeUsed = false;
            qtty        = 0;
            lot         = null;
            storeId     = -1;

            // Empty field is never correct
            if (input.Length == 0)
            {
                return(null);
            }

            // Check if we have a qtty*item record
            qtty = GetSearchQuantity(ref input);

            Item item = GetByBarCode(input);

            if (item != null)
            {
                barCodeUsed = true;
                if (!item.quantity.IsZero())
                {
                    if (qtty.IsZero())
                    {
                        qtty = item.quantity;
                    }
                    else
                    {
                        qtty *= item.quantity;
                    }
                }

                if (item.useMeasUnit2 && !item.mUnitRatio.IsZero())
                {
                    if (qtty.IsZero())
                    {
                        qtty = item.mUnitRatio;
                    }
                    else
                    {
                        qtty *= item.mUnitRatio;
                    }
                }

                item.quantity = qtty;
                lot           = item.LotNumber;
            }

            // If we can't find Item with such a barcode try to search for such a name or code
            item = item ?? cache.GetByName(input) ?? cache.GetByCode(input);

            if (item == null && BusinessDomain.AppConfiguration.ItemsManagementUseLots && locationId != null)
            {
                item = GetBySerial(input, locationId.Value);
                if (item != null)
                {
                    storeId       = (int)item.quantity;
                    item.quantity = 0;
                }
            }

            return(item);
        }