Exemplo n.º 1
0
 void AddSKUItem(string key, int index)
 {
     if (!string.IsNullOrEmpty(key))
     {
         key = key.ToUpperInvariant();
         if (!SKUDictionary.ContainsKey(key))
         {
             SKUDictionary.Add(key, index);
         }
     }
 }
Exemplo n.º 2
0
        protected override void RemoveItem(int index)
        {
            ActiveInventoryObject item = this[index];

            UPCDictionary.Remove(item.UPC.ToUpperInvariant());
            SKUDictionary.Remove(item.SKU.ToUpperInvariant());
            ProductIDDictionary.Remove(item.ProductID);
            item.UnSubscribeToChangeEvents(item_UPCChanged, item_SKUChanged);
            base.RemoveItem(index);
            TotalInvested -= (item.WholeSalePrice + item.AdditionalOverhead) * item.Quantity;
        }
Exemplo n.º 3
0
        //public void Save(string file)
        //{
        //    List<byte> FullData = new List<byte>();
        //    foreach (ActiveInventoryObject obj in this)
        //    {
        //        List<byte> data = new List<byte>();
        //        data.AddRange(obj.GetByteArray());
        //        FullData.AddRange(BitConverter.GetBytes(data.Count));
        //        FullData.AddRange(data);
        //    }

        //    using (System.IO.FileStream fs = new System.IO.FileStream(file, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Write))
        //    {
        //        fs.Write(FullData.ToArray(), 0, FullData.Count);
        //    }
        //}
        //public void Load(string file)
        //{
        //    List<byte> FullData = new List<byte>();
        //    if (System.IO.File.Exists(file))
        //    {
        //        using (System.IO.FileStream fs = new System.IO.FileStream(file, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
        //        {
        //            byte[] buffer = new byte[32768];
        //            int byteRead = 0;
        //            do
        //            {
        //                byteRead = fs.Read(buffer, 0, buffer.Length);
        //                if (byteRead > 0)
        //                {
        //                    for (int i = 0; i < byteRead; i++)
        //                    {
        //                        FullData.Add(buffer[i]);
        //                    }
        //                }
        //            } while (byteRead > 0);

        //        }
        //        int pos = 0;
        //        byte[] data = FullData.ToArray();
        //        while (pos < data.Length)
        //        {
        //            int objectLength = BitConverter.ToInt32(data, pos);
        //            pos += 4;

        //            List<byte> work = new List<byte>();
        //            for (int i = pos; i < objectLength + pos; i++)
        //            {
        //                work.Add(data[i]);
        //            }

        //            ActiveInventoryObject aio = new ActiveInventoryObject();

        //            aio.LoadProperties(work.ToArray());
        //            this.Add(aio);
        //            pos += objectLength;
        //        }
        //    }
        //}


        protected override void ClearItems()
        {
            foreach (ActiveInventoryObject item in Items)
            {
                item.UnSubscribeToChangeEvents(item_UPCChanged, item_SKUChanged);
            }
            base.ClearItems();
            UPCDictionary.Clear();
            SKUDictionary.Clear();
            ProductIDDictionary.Clear();
            TotalInvested = 0;
        }
Exemplo n.º 4
0
        void item_SKUChanged(object sender, ItemChangedEventArgs e)
        {
            string key = e.OldValue as string;

            if (!string.IsNullOrEmpty(key))
            {
                key = key.ToUpperInvariant();
                int index = SKUDictionary[key];
                SKUDictionary.Remove(key);
                key = e.NewValue as string;
                AddSKUItem(key, index);
            }
        }
Exemplo n.º 5
0
        public List <ActiveInventoryObject> GetByUPCorSKU(string key)
        {
            List <ActiveInventoryObject> retVal = new List <ActiveInventoryObject>();

            if (key != null)
            {
                key = key.ToUpperInvariant();
                if (UPCDictionary.ContainsKey(key))
                {
                    retVal.Add(Items[UPCDictionary[key]]);
                }
                if (SKUDictionary.ContainsKey(key))
                {
                    retVal.Add(Items[SKUDictionary[key]]);
                }
            }
            return(retVal);
        }