Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
0
        public static string isInventoryHeaderValid(InventoryHeader inventoryHeader)
        {
            string errorMsg = null;

            if (String.IsNullOrEmpty(inventoryHeader.DocumentID))
            {
                errorMsg += "\nPusty ID dokumentu";
            }

            if (String.IsNullOrEmpty(inventoryHeader.Description))
            {
                errorMsg += "\nPusty opis";
            }


            if (inventoryHeader.InventoryDate < DateTime.Today)
            {
                errorMsg += "\nNieprawidłowa data";
            }

            if (String.IsNullOrEmpty(inventoryHeader.WarehouseName))
            {
                errorMsg += "\nPusta nazwa magazynu";
            }

            return(errorMsg);
        }
Ejemplo n.º 3
0
        public static string isInventoryHeaderAvaibleToDelete(InventoryHeader inventoryHeader)
        {
            string errorMsg = null;

            using (DBContext dBCtx = new DBContext())
            {
                if (dBCtx.InventoryLines.Any(x => x.DocumentID == inventoryHeader.DocumentID))
                {
                    errorMsg = "Nie można usunąć nagłówka inwentarzu, ponieważ istnieją dla niego zdefiniowane linie inwentaryzacyjne.";
                    return(errorMsg);
                }
                return(errorMsg);
            }
        }
Ejemplo n.º 4
0
        public static string PostInventory(InventoryHeader inventoryHeader)
        {
            List <InventoryLine> inventoryLines;

            using (DBContext dBCtx = new DBContext())
            {
                if (!dBCtx.InventoryLines.Any(x => x.DocumentID == inventoryHeader.DocumentID))
                {
                    return("Dokument nie posiada pozycji");
                }

                inventoryLines = dBCtx.InventoryLines.Where(x => x.DocumentID == inventoryHeader.DocumentID).ToList();
            }
            foreach (InventoryLine inventoryLine in inventoryLines)
            {
                if (inventoryLine.CountedQuantity != inventoryLine.Quantity)
                {
                    postInventoryLine(inventoryLine, inventoryHeader);
                }
                else
                {
                    using (DBContext dBCtx = new DBContext())
                    {
                        dBCtx.InventoryLines.Remove(inventoryLine);
                        dBCtx.SaveChanges();
                    }
                }
            }

            using (DBContext dBCtx = new DBContext())
            {
                inventoryHeader = dBCtx.InventoryHeaders.First(x => x.DocumentID == inventoryHeader.DocumentID);
                dBCtx.InventoryHeaders.Remove(inventoryHeader);
                dBCtx.SaveChanges();
            }
            return("");
        }