Exemple #1
0
        public static G EnsureByPath <G> (string path, CacheEntityCollection <G> cache) where G : GroupBase <G>, ICacheableEntity <G>, new ()
        {
            string [] pathParts = path.Split(new [] { pathSeparator }, StringSplitOptions.RemoveEmptyEntries);
            G         g         = null;

            foreach (string part in pathParts)
            {
                G last = g;
                g = last != null?
                    last.Children.FirstOrDefault(c => c.name == part) :
                        cache.GetByName(part);

                if (g != null)
                {
                    continue;
                }

                g = new G {
                    Parent = last, Name = part
                };
                g.CommitChanges();
                if (last != null)
                {
                    last.children.Add(g);
                }
            }

            return(g);
        }
Exemple #2
0
        public static G GetByPath <G> (string path, CacheEntityCollection <G> cache) where G : GroupBase <G>, ICacheableEntity <G>, new ()
        {
            string [] pathParts = path.Split(new [] { pathSeparator }, StringSplitOptions.RemoveEmptyEntries);
            G         g         = null;

            foreach (string part in pathParts)
            {
                G last = g;
                g = last != null?
                    last.Children.FirstOrDefault(c => c.name == part) :
                        cache.GetByName(part);

                if (g == null)
                {
                    return(null);
                }
            }

            return(g);
        }
Exemple #3
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);
        }