Inheritance: System.Web.UI.Page
        /// <summary>
        /// Updates the quanity of products the specified location has
        /// </summary>
        /// <param name="location">The location who's inventory will be updated</param>
        /// <param name="product">The product who's qauntity will be changed</param>
        /// <returns>An instance of ProductInventory with the resulting changes after the update.</returns>
        public ProductInventory UpdateInventory(Location location, Product product, int quantity)
        {
            ProductInventory productInventory = ctx.LocationInventory.Include(pI => pI.ProductLocation).Include(pI => pI.Product)
                                                .FirstOrDefault(pI => pI.ProductLocation.LocationId == location.LocationId && pI.Product.ProductId == product.ProductId);

            productInventory.Quanitity = quantity;
            ctx.SaveChanges();

            return(productInventory);
        }
Example #2
0
 /// <summary>
 /// converts a production entry object into a production entry entity
 /// </summary>
 /// <param name="product">production entry object to be converted</param>
 /// <returns>protuction entry entity</returns>
 public static Entities.ProductInventory MapProductInventory(ProductInventory productInventory)
 {
     return(new Entities.ProductInventory
     {
         Id = productInventory.Id,
         LocationId = productInventory.LocationId,
         ProductId = productInventory.Product.Id,
         Quantity = productInventory.Quantity,
     });
 }
        public ProductInventory GetInventoryByProductNo(string productNo)
        {
            ProductInventory pinventory = new ProductInventory();
            string           xml        = string.Empty;

            try
            {
                StockWebService.StockWebService stock = new StockWebService.StockWebService();
                if (AppSettingManager.AppSettings["InventoryFlag"].ToLower() == "true")
                {
                    stock.Url = AppSettingManager.AppSettings["ErpInventoryService"];
                    xml       = stock.GetInventorySumByProductNo(productNo, 1); //1,正品;2,残次品;3,赠品
                }
                else
                {
                    xml = stock.GetInventorySumByProductNo(productNo, 1);//1,正品;2,残次品;3,赠品
                }
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xml);

                int sumQuantity     = 0; //库存总数
                int sumLockQuantity = 0; //锁定的总库存
                int inventory       = 0; //库存总数 减去 锁定的总库存

                if (doc != null)
                {
                    XmlNodeList inventoryNodeList = doc.SelectNodes("/ErpInventorySums/ErpInventorySum");
                    if (inventoryNodeList != null && inventoryNodeList.Count > 0)
                    {
                        string nodeName          = string.Empty;
                        int    inventoryQuantity = 0;
                        int    lockQuantity      = 0;
                        foreach (XmlNode inventoryNode in inventoryNodeList)
                        {
                            if (inventoryNode.ChildNodes.Count > 0)
                            {
                                inventoryQuantity = Convert.ToInt32(inventoryNode.ChildNodes[2].InnerText);
                                lockQuantity      = Convert.ToInt32(inventoryNode.ChildNodes[3].InnerText);
                            }
                            sumQuantity     += inventoryQuantity;
                            sumLockQuantity += lockQuantity;
                            inventory        = inventory + inventoryQuantity - lockQuantity;
                        }
                    }
                }
                pinventory.ProductNo       = productNo;
                pinventory.SumQuantity     = sumQuantity;
                pinventory.SumLockQuantity = sumLockQuantity;
                pinventory.Inventory       = inventory;
            }
            catch (Exception ex)
            {
            }
            return(pinventory);
        }
Example #4
0
        private void CreateSnapshot(ProductInventory inventory)
        {
            var snapshot = new ProductInventorySnapshot
            {
                SnapshotTime   = DateTime.UtcNow,
                QuantityOnHand = inventory.QuantityOnHand,
                Product        = inventory.Product
            };

            _db.Add(snapshot);
        }
 public ActionResult Edit([Bind(Include = "ProductID,LocationID,Shelf,Bin,Quantity,rowguid,ModifiedDate,isDeleted")] ProductInventory productInventory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productInventory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.LocationID = new SelectList(db.Locations, "LocationID", "Name", productInventory.LocationID);
     ViewBag.ProductID  = new SelectList(db.Products, "ProductID", "Name", productInventory.ProductID);
     return(View(productInventory));
 }
Example #6
0
 //Serializes an inventory data model to a inventoryVM
 public static InventoryViewModel SerializeInventory(ProductInventory inventory)
 {
     return(new InventoryViewModel
     {
         Id = inventory.Id,
         CreatedOn = inventory.CreatedOn,
         UpdatedOn = inventory.UpdatedOn,
         QuantityOnHand = inventory.QuantityOnHand,
         IdealQuantity = inventory.IdealQuantity,
         InventoryProduct = ProductMapper.SerializeProductViewModel(inventory.InventoryProduct)
     });
 }
        // PUT api/awbuildversion/5
        public void Put(ProductInventory value)
        {
            var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault();

            if (GetActionType.Key != null)
            {
                if (GetActionType.Value.ToList()[0].Equals("DELETE"))
                    adventureWorks_BC.ProductInventoryDelete(value);
                if (GetActionType.Value.ToList()[0].Equals("UPDATE"))
                    adventureWorks_BC.ProductInventoryUpdate(value);
            }
        }
Example #8
0
        ///<summary>
        ///  Returns a Typed ProductInventory Entity with mock values.
        ///</summary>
        static public ProductInventory CreateMockInstance(TransactionManager tm)
        {
            // get the default mock instance
            ProductInventory mock = ProductInventoryTest.CreateMockInstance_Generated(tm);

            // make any alterations necessary
            // (i.e. for DB check constraints, special test cases, etc.)
            SetSpecialTestData(mock);

            // return the modified object
            return(mock);
        }
Example #9
0
        public IActionResult Update(ProductEditModel model)
        {
            var newProduct = new ProductInventory();

            newProduct.Name     = model.Name;
            newProduct.Price    = model.Price;
            newProduct.Quantity = model.Quantity;
            newProduct.Type     = model.Type;

            newProduct = _productData.Add(newProduct);
            return(RedirectToAction("Updated"));
        }
Example #10
0
        //public List<ProductInventory> ProductNameListforStock()
        //{
        //    try
        //    {
        //        return _context.ProductInventory.ToList();

        //    }
        //    catch (Exception e)
        //    {

        //        Console.WriteLine(e);
        //        return new List<ProductInventory>();
        //    };
        //}

        public void UpdateProduct(ProductInventory productInventory)
        {
            try
            {
                _context.ProductInventory.Update(productInventory);
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #11
0
        public void CSV_Build_No_Variants_Multiple_Locations()
        {
            var inventory = new ProductInventory();
            var converter = new ShopifyCSVConverter();

            inventory.AddProduct(new Product()
            {
                Body = "Body Text",
                FulfillmentService = FufillmentServices.Manual,
                GiftCard           = false,
                Grams             = 50,
                Handle            = "123",
                InventoryPolicy   = InventoryPolicies.Deny,
                InventoryQuantity = 50,
                InventoryTracker  = InventoryTrackers.Shopify,
                Price             = 19.99m,
                Published         = true,
                RequiresShipping  = true,
                SKU        = "2345",
                Taxable    = true,
                Title      = "Title",
                Type       = "Type",
                Vendor     = "RDA",
                WeightUnit = WeigthUnits.Pound
            })
            .AddImage(new Image()
            {
                AltText = "Alt Text Image 1",
                Source  = @"https://storageaccountshopia6d8.blob.core.windows.net/artwork/10022.jpg"
            })
            .AddImage(new Image()
            {
                AltText = "Alt Text Image 2",
                Source  = @"https://storageaccountshopia6d8.blob.core.windows.net/artwork/10281.jpg"
            })
            .AddTag("Tag1").AddTag("Tag2")
            .AddInventory(new LocationInventory()
            {
                InventoryAmount     = 53,
                IsStockedAtLocation = true,
                LocationName        = "Location1"
            });

            (string productCsv, string inventoryCsv) = converter.Convert(inventory);

            Assert.IsTrue(productCsv != null);

            //Header + 1 product + 1 image = 3 lines
            Assert.IsTrue(productCsv.Split('\n').Length == 3);

            Assert.IsTrue(inventoryCsv.Split('\n').Length == 2);
        }
Example #12
0
 public void AddNewProduct(ProductInventory productInventory)
 {
     try
     {
         _context.ProductInventory.Add(productInventory);
         _context.SaveChanges();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
     //throw new NotImplementedException();
 }
        /// <summary>
        /// Создает чек товара
        /// </summary>
        /// <param name="inventory"></param>
        private void CreateSnapshot(ProductInventory inventory)
        {
            var now = DateTime.UtcNow;

            var snapshot = new ProductInventorySnapshot
            {
                CreatedSnapshotOn = now,
                Product           = inventory.Product,
                QuantityOnHand    = inventory.QuantityOnHand
            };

            _db.Add(snapshot);
        }
        public void UpdateProductInventory(ProductInventory changes)
        {
            var entity = GetProductInventory(changes);

            if (entity != null)
            {
                entity.ProductID = changes.ProductID;
                entity.EntryDate = changes.EntryDate;
                entity.Quantity  = changes.Quantity;

                DbContext.SaveChanges();
            }
        }
Example #15
0
 public bool AddProductInventory(ProductInventory pi)
 {
     try
     {
         var context = new NeevDatabaseContainer();
         context.AddProductInventoryItem(pi.Id, pi.Name, pi.Quantity, pi.UnitPrice, pi.SoldFlag, pi.ReturnedFlag);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        private void ReduceFakeStock(Product product, TradevineGateway gateway)
        {
            var adjustment = new ProductInventory
            {
                ProductID = product.ProductID,
                InventoryType = Constants.CVs.InventoryEntryType.Values.Stocktake,
                QuantityInStockSnapshot = 0M,
                WarehouseCode = "WH2"
            };

            gateway.Products.AdjustProductInventory(adjustment);

            Console.WriteLine("Reducing fake stock for product " + product.Code);
        }
Example #17
0
 internal ProductInventory SaveProductInventory(ProductInventory productInventory)
 {
     try
     {
         SetService();
         return SerClient.SaveProductInventory(productInventory);
     }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
             SerClient.Abort();
     }
       
 }
Example #18
0
 internal IList<ProductInventory> GetProductInventoryByProduct(ProductInventory productInventory, List<int> productList)
 {
     try
     {
         SetService();
         return SerClient.GetProductInventoryByProduct(productInventory, productList);
     }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
             SerClient.Abort();
     }
 }
 // POST api/awbuildversion
 public void Post(ProductInventory value)
 {
     adventureWorks_BC.ProductInventoryAdd(value);
 }
Example #20
0
 internal void ResetQtyInUse(ProductInventory productInventory)
 {
     try
     {
         SetService();
         SerClient.ResetQtyInUse(productInventory);
     }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
             SerClient.Abort();
     }
 }
 /// <summary>
 /// Create a new ProductInventory object.
 /// </summary>
 /// <param name="productID">Initial value of ProductID.</param>
 /// <param name="locationID">Initial value of LocationID.</param>
 /// <param name="shelf">Initial value of Shelf.</param>
 /// <param name="bin">Initial value of Bin.</param>
 /// <param name="quantity">Initial value of Quantity.</param>
 /// <param name="rowguid">Initial value of rowguid.</param>
 /// <param name="modifiedDate">Initial value of ModifiedDate.</param>
 public static ProductInventory CreateProductInventory(int productID, short locationID, string shelf, byte bin, short quantity, global::System.Guid rowguid, global::System.DateTime modifiedDate)
 {
     ProductInventory productInventory = new ProductInventory();
     productInventory.ProductID = productID;
     productInventory.LocationID = locationID;
     productInventory.Shelf = shelf;
     productInventory.Bin = bin;
     productInventory.Quantity = quantity;
     productInventory.rowguid = rowguid;
     productInventory.ModifiedDate = modifiedDate;
     return productInventory;
 }
        private void LoadDetails(System.Data.DataRow dr)
        {
            if (dr == null)
                return;

            View.Model.DocNumber = dr["DocNumber"].ToString();
            View.Model.DocID = int.Parse(dr["DocID"].ToString());

            pw = new ProcessWindow("Loading lines for document " + View.Model.DocNumber + " ...");

            View.Model.CurrentDetails = View.Model.OrdersDetail.Where(f => f.Document.DocID == View.Model.DocID).ToList();

            //Ejecuta la disponibilidad para los current details       

            //if (View.Model.CurrentDetails.Any(f => f.IsDebit != true))
            //{

                #region INVENTORY LINE BY LINE

                //1. Obtener el Stock de los productos de los documentos de ese cliente.
                View.Model.DocumentProductStock = service.GetDocumentProductStock(new Document
                {
                    Customer = new Account { AccountID = View.Model.Customer.AccountID },
                    Location = App.curLocation,
                    DocType = new DocumentType { DocTypeID = SDocType.SalesOrder } //,
                    //DocID = View.Model.DocID 
                }, null);

                //Allocated, Available de los productos del documento.
                //Obtiene la lista de productos para obtener su stock en uso (Product Inventory).
                List<int> productList = new List<int>();
                foreach (Int32 p in View.Model.CurrentDetails.Select(f => f.Product.ProductID).Distinct())
                    productList.Add(p);

                productInUseList = service.GetProductInUseForMerged(productList, App.curLocation);

                double qtyAvailable, qtyInUse;

                ProductStock piInUse;

                for (int i = 0; i < View.Model.CurrentDetails.Count; i++)
                {

                    qtyInUse = 0; qtyAvailable = 0;

                    if (View.Model.CurrentDetails[i].IsDebit == true)
                        continue;

                    if (View.Model.CurrentDetails[i].IsDebit == null)
                        View.Model.CurrentDetails[i].IsDebit = false;

                    View.Model.CurrentDetails[i].Note = View.Model.CurrentDetails[i].Document.DocNumber;

                    //QTY AVAILABLE DE INVENTARIO - Debe Restarsele lo allocated y lo que este en uso
                    //que sale de la clase product Inventory.
                    try
                    {
                        qtyAvailable = View.Model.DocumentProductStock
                           .Where(f => f.Product.ProductID == View.Model.CurrentDetails[i].Product.ProductID)
                           .First().FullStock;
                    }
                    catch { qtyAvailable = 0; }

                    //Cantidad en Uso - PROGRAMA. Allocated y Reservada
                    qtyAvailable = (double)((int)(qtyAvailable * availabilityMark));
                    View.Model.CurrentDetails[i].QtyOnHand = qtyAvailable; //ON HAND

                    try
                    {
                     
                        piInUse = productInUseList
                           .Where(f => f.Product.ProductID == View.Model.CurrentDetails[i].Product.ProductID)
                           .First();

                        qtyInUse = piInUse.Stock;
                    }
                    catch{}


                    //try {

                    //    //Adicionar En uso del order detail de otras lineas y el mismo producto
                    //    qtyInUse += View.Model.OrdersDetail
                    //       .Where(f => f.Product.ProductID == View.Model.CurrentDetails[i].Product.ProductID)
                    //        //&& f.LineID != View.Model.CurrentDetails[i].LineID)
                    //       .Sum(f => f.QtyInvoiced);  

                    //}
                    //catch { }

                    qtyAvailable -= qtyInUse;

                    //Cantidad final disponible
                    //View.Model.CurrentDetails[i].QtyInvoiced = qtyInUse; //Allocated

                    //View.Model.CurrentDetails[i].QtyAvailable = ((qtyAvailable > 0) ? qtyAvailable : 0) / View.Model.CurrentDetails[i].Unit.BaseAmount;
                    
                    View.Model.CurrentDetails[i].QtyAllocated = 0; //qtyAllocated;
                    
                    View.Model.CurrentDetails[i].Sequence = 0; //BALANCE
                    //Jun 08 2010
                    //View.Model.CurrentDetails[i].Quantity = View.Model.CurrentDetails[i].Quantity; // - View.Model.CurrentDetails[i].QtyShipped);


                    //Limpiar Qty in use
                    //View.Model.StockInUse = null;
                }

                #endregion

                //productInUseList = null;
                //View.Model.DocumentProductStock = null;

            //}

            pw.Close();

            View.DgDetails.Items.Refresh();
            View.TabStep.Visibility = Visibility.Visible;
        }
 /// <summary>
 /// There are no comments for ProductInventory in the schema.
 /// </summary>
 public void AddToProductInventory(ProductInventory productInventory)
 {
     base.AddObject("ProductInventory", productInventory);
 }