Example #1
0
        private static void postReleaseLine(ReleaseLine releaseLine, ReleaseHeader releaseHeader)
        {
            WarehouseEntry warehouseEntry = new WarehouseEntry();

            using (DBContext dBCtx = new DBContext())
            {
                StockKeepUnit stku = dBCtx.StockKeepUnits.Single(x => x.Code == releaseLine.StockKeepUnit);


                warehouseEntry.ItemID              = releaseLine.ItemID;
                warehouseEntry.DocumentNumber      = releaseLine.DocumentID;
                warehouseEntry.EntryType           = EntryType.Release;
                warehouseEntry.TotalQuantity       = -(releaseLine.ReleaseQuantity * stku.QuantityPerUnit);
                warehouseEntry.Quantity            = -(releaseLine.ReleaseQuantity);
                warehouseEntry.QuantityPerUnit     = stku.QuantityPerUnit;
                warehouseEntry.KeepUnit            = releaseLine.StockKeepUnit;
                warehouseEntry.WarehouseNumber     = releaseLine.WarehouseNumber;
                warehouseEntry.WarehousePlace      = releaseLine.WarehousePlace;
                warehouseEntry.CustomerID          = releaseHeader.CustomerID;
                warehouseEntry.DocumentDate        = releaseHeader.ReleaseDate;
                warehouseEntry.DocumentDescription = releaseHeader.Description;

                dBCtx.WarehouseEntries.Add(warehouseEntry);

                ReleaseLine releaseLineUpdate = dBCtx.ReleaseLines.First(x => x.DocumentID == releaseLine.DocumentID && x.PositionNumber == releaseLine.PositionNumber);
                dBCtx.ReleaseLines.Attach(releaseLineUpdate);
                releaseLineUpdate.ReleasedQuantity = releaseLineUpdate.ReleasedQuantity + releaseLine.ReleaseQuantity;
                releaseLineUpdate.ReleaseQuantity  = 0.00;
                dBCtx.SaveChanges();
            }
        }
Example #2
0
        private static void postInventoryLine(InventoryLine inventoryLine, InventoryHeader inventoryHeader)
        {
            WarehouseEntry warehouseEntry = new WarehouseEntry();

            using (DBContext dBCtx = new DBContext())
            {
                StockKeepUnit stku = dBCtx.StockKeepUnits.Single(x => x.Code == inventoryLine.StockKeepUnit);


                warehouseEntry.ItemID              = inventoryLine.ItemID;
                warehouseEntry.DocumentNumber      = inventoryLine.DocumentID;
                warehouseEntry.EntryType           = EntryType.Correction;
                warehouseEntry.TotalQuantity       = (inventoryLine.CountedQuantity - inventoryLine.Quantity) * stku.QuantityPerUnit;
                warehouseEntry.Quantity            = inventoryLine.CountedQuantity - inventoryLine.Quantity;
                warehouseEntry.QuantityPerUnit     = stku.QuantityPerUnit;
                warehouseEntry.KeepUnit            = inventoryLine.StockKeepUnit;
                warehouseEntry.WarehouseNumber     = inventoryLine.WarehouseNumber;
                warehouseEntry.WarehousePlace      = inventoryLine.WarehousePlace;
                warehouseEntry.DocumentDate        = inventoryHeader.InventoryDate;
                warehouseEntry.DocumentDescription = inventoryHeader.Description;

                dBCtx.WarehouseEntries.Add(warehouseEntry);

                dBCtx.InventoryLines.Remove(inventoryLine);
                dBCtx.SaveChanges();
            }
        }