Beispiel #1
0
        private static void postReceiveLine(ReceiveLine receiveLine, ReceiveHeader receiveHeader)
        {
            WarehouseEntry warehouseEntry = new WarehouseEntry();

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


                warehouseEntry.ItemID              = receiveLine.ItemID;
                warehouseEntry.DocumentNumber      = receiveLine.DocumentID;
                warehouseEntry.EntryType           = EntryType.Receive;
                warehouseEntry.TotalQuantity       = receiveLine.ReceiveQuantity * stku.QuantityPerUnit;
                warehouseEntry.Quantity            = receiveLine.ReceiveQuantity;
                warehouseEntry.QuantityPerUnit     = stku.QuantityPerUnit;
                warehouseEntry.KeepUnit            = receiveLine.StockKeepUnit;
                warehouseEntry.WarehouseNumber     = receiveLine.WarehouseNumber;
                warehouseEntry.WarehousePlace      = receiveLine.WarehousePlace;
                warehouseEntry.VendorID            = receiveHeader.VendorID;
                warehouseEntry.DocumentDate        = receiveHeader.ReceiveDate;
                warehouseEntry.DocumentDescription = receiveHeader.Description;

                dBCtx.WarehouseEntries.Add(warehouseEntry);

                ReceiveLine receiveLineUpdate = dBCtx.ReceiveLines.First(x => x.DocumentID == receiveLine.DocumentID && x.PositionNumber == receiveLine.PositionNumber);
                dBCtx.ReceiveLines.Attach(receiveLineUpdate);
                receiveLineUpdate.ReceivedQuantity = receiveLineUpdate.ReceivedQuantity + receiveLine.ReceiveQuantity;
                receiveLineUpdate.ReceiveQuantity  = 0.00;
                dBCtx.SaveChanges();
            }
        }
Beispiel #2
0
        public static string isReceiveHeaderValid(ReceiveHeader receiveHeader)
        {
            string errorMsg = null;

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

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

            if (receiveHeader.ReceiveDate < DateTime.Today)
            {
                errorMsg += "\nNieprawidłowa data";
            }
            if (String.IsNullOrEmpty(receiveHeader.VendorID))
            {
                errorMsg += "\nPusta nazwa sprzedawcy";
            }

            return(errorMsg);
        }
Beispiel #3
0
        public static string isReceiveHeaderAvaibleToDelete(ReceiveHeader receiveHeader)
        {
            string errorMsg = null;

            using (DBContext dBCtx = new DBContext())
            {
                if (dBCtx.ReceiveLines.Any(x => x.DocumentID == receiveHeader.DocumentID))
                {
                    errorMsg = "Nie można usunąć nagłówka przyjęcia, ponieważ istnieją dla niego zdefiniowane linie przyjęć.";
                    return(errorMsg);
                }
                return(errorMsg);
            }
        }
Beispiel #4
0
        //Receive
        public static string postReceiveHeader(ReceiveHeader receiveHeader)
        {
            string             errorMsg     = null;
            bool               isLineToPost = false;
            List <ReceiveLine> receiveLines;

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

                receiveLines = dBCtx.ReceiveLines.Where(x => x.DocumentID == receiveHeader.DocumentID).ToList();
                foreach (ReceiveLine receiveLine in receiveLines)
                {
                    errorMsg = chceckReceiveLine(receiveLine);
                    if (!String.IsNullOrEmpty(errorMsg))
                    {
                        return(errorMsg);
                    }

                    if (chceckQuantityToReceive(receiveLine))
                    {
                        isLineToPost = true;
                    }

                    if (!String.IsNullOrEmpty(errorMsg))
                    {
                        return(errorMsg);
                    }
                }
            }

            if (!isLineToPost)
            {
                return("Nie uzupełniono ilości do realizacji");
            }

            foreach (ReceiveLine receiveLine in receiveLines)
            {
                if (receiveLine.ReceiveQuantity > 0.00)
                {
                    postReceiveLine(receiveLine, receiveHeader);
                }
            }

            return("");
        }