Esempio n. 1
0
        internal bool WriteStickerFact(long stickerId, long cellId, long previousStickerId, long trayId, long linerId, int linersQuantity, int packsCount, int unitsCount)
        {
            var goodsRows = findStickerRows(stickerId);

            var isReturnFromHaul = Contractor.Empty;

            if (isReturnFromHaul)
            {
                var sticker = new Stickers()
                {
                    ReadingId = stickerId
                };

                if (goodsRows.WareRow == null)
                {
                    goodsRows.WareRow = addNewNomenclatureRow(stickerId, sticker.GetRef("Nomenclature"));
                    goodsRows.WareRow[NomenclatureParty] = sticker.GetRef("Party");
                }

                if (packsCount > 0 && goodsRows.BoxRow == null)
                {
                    var packId = sticker.Nomenclature.GetRef("BoxType");
                    if (packId > 0)
                    {
                        goodsRows.BoxRow = addNewNomenclatureRow(stickerId, packId);
                    }
                }
            }

            setFactOnRow(goodsRows.WareRow, unitsCount, cellId, false);
            goodsRows.WareRow[PreviousPalletCode] = previousStickerId;

            if (goodsRows.BoxRow != null)
            {
                setFactOnRow(goodsRows.BoxRow, packsCount, cellId, true);
            }

            if (linersQuantity > 0 && linerId > 0)
            {
                if (goodsRows.LinerRow == null)
                {
                    goodsRows.LinerRow = addNewNomenclatureRow(stickerId, linerId);
                }
                setFactOnRow(goodsRows.LinerRow, linersQuantity, cellId, true);
            }

            int traysQuantity = trayId > 0 ? 1 : 0;

            if (goodsRows.TrayRow == null && traysQuantity > 0)
            {
                goodsRows.TrayRow = addNewNomenclatureRow(stickerId, trayId);
            }
            if (goodsRows.TrayRow != null)
            {
                setFactOnRow(goodsRows.TrayRow, traysQuantity, cellId, true);
            }

            SetSubtableModified(NomenclatureInfo.TableName);

            var result = Write() == WritingResult.Success;

            return(result);
        }