Beispiel #1
0
        public bool ComplateMovement(long documentId, bool forceCompletion, out string errorMessage)
        {
            errorMessage = string.Empty;
            var document = new Moving() { ReadingId = documentId };
            using (var locker = new DatabaseObjectLocker(document))
                {
                if (!locker.LockForCurrentPdtThread()) return false;

                document.State = StatesOfDocument.Completed;
                return document.Write() == WritingResult.Success;
                }
        }
Beispiel #2
0
        private bool createMoving(long shipmentId)
        {
            var document = new Moving();
            document.SetRef("PickingPlan", shipmentId);
            document.Date = DateTime.Now;

            var q = DB.NewQuery(@"select Nomenclature, sum(Quantity) [Quantity], min(LineNumber) LineNumber
            from SubShipmentPlanNomenclatureInfo
            where IdDoc = @IdDoc
            group by Nomenclature
            order by LineNumber");
            q.AddInputParameter("IdDoc", shipmentId);
            var docTable = document.NomenclatureInfo;
            q.Foreach(qResult =>
                {
                    var nomenclarute = Convert.ToInt64(qResult["Nomenclature"]);
                    var quantity = Convert.ToDecimal(qResult["Quantity"]);

                    var docRow = docTable.GetNewRow(document);
                    docRow[document.Nomenclature] = nomenclarute;
                    docRow[document.PlanValue] = quantity;
                    docRow[document.RowState] = RowsStates.PlannedPicking;
                    docRow.AddRowToTable(document);
                });

            var result = document.Write();

            return result == WritingResult.Success;
        }
Beispiel #3
0
        public bool WritePickingResult(long documentId, int currentLineNumber, DataTable resultTable, long partyId, out int sameWareNextTaskLineNumber)
        {
            sameWareNextTaskLineNumber = 0;
            var currentTime = SystemConfiguration.ServerDateTime;

            var document = new Moving() { ReadingId = documentId };

            using (var locker = new DatabaseObjectLocker(document))
                {
                if (!locker.LockForCurrentPdtThread()) return false;

                var docTable = document.NomenclatureInfo;
                var palletCode = Convert.ToInt64(resultTable.Rows[0][document.PalletCode.ColumnName]);

                var wareRow = docTable.Rows[currentLineNumber - 1];
                var newPickingTaskPlan = 0M;

                for (int rowIndex = 0; rowIndex < resultTable.Rows.Count; rowIndex++)
                    {
                    var resultWareRow = resultTable.Rows[rowIndex];

                    var plan = Convert.ToDecimal(resultWareRow[document.PlanValue.ColumnName]);
                    var fact = Convert.ToDecimal(resultWareRow[document.FactValue.ColumnName]);

                    DataRow docRow = null;
                    var isTare = rowIndex != 0;
                    if (isTare)
                        {
                        docRow = docTable.GetNewRow(document);
                        docRow[document.Nomenclature] = Convert.ToInt64(resultWareRow[document.Nomenclature.ColumnName]);
                        }
                    else
                        {
                        docRow = wareRow;
                        docRow[document.Party] = partyId;

                        newPickingTaskPlan = plan - fact;
                        }

                    docRow[document.PlanValue] = plan;
                    docRow[document.FactValue] = fact;
                    docRow[document.StartCell] = resultWareRow[document.StartCell.ColumnName];
                    docRow[document.FinalCell] = Consts.RedemptionCell.Id;
                    docRow[document.StartCodeOfPreviousPallet] =
                        resultWareRow[document.StartCodeOfPreviousPallet.ColumnName];
                    docRow[document.FinalCodeOfPreviousPallet] = 0L;
                    docRow[document.RowState] = (int)RowsStates.Completed;
                    docRow[document.RowDate] = currentTime;
                    docRow[document.PalletCode] = palletCode;

                    if (isTare)
                        {
                        docRow.AddRowToTable(document);
                        }
                    }

                var boxesFinder = new BoxesFinder(resultTable, palletCode);

                if (boxesFinder.BoxesRowAdded)
                    {
                    var boxesRow = document.NomenclatureInfo.GetNewRow(document);

                    boxesRow[document.Nomenclature] = boxesFinder.BoxesRow[document.Nomenclature.ColumnName];

                    boxesRow[document.StartCodeOfPreviousPallet] = 0L;
                    boxesRow[document.FinalCodeOfPreviousPallet] = 0L;
                    boxesRow[document.RowState] = (int)RowsStates.Completed;
                    boxesRow[document.RowDate] = currentTime;

                    boxesRow[document.FactValue] = boxesFinder.BoxesRow[document.FactValue.ColumnName];

                    boxesRow[document.FinalCell] = wareRow[document.FinalCell];
                    boxesRow[document.StartCell] = wareRow[document.StartCell];

                    boxesRow[document.PalletCode] = palletCode;

                    boxesRow.AddRowToTable(document);
                    }

                if (newPickingTaskPlan > 0)
                    {
                    var newTaskRow = document.NomenclatureInfo.GetNewRow(document);

                    newTaskRow[document.PlanValue] = newPickingTaskPlan;
                    newTaskRow[document.Nomenclature] = wareRow[document.Nomenclature.ColumnName];
                    newTaskRow[document.RowState] = (int)RowsStates.PlannedPicking;

                    newTaskRow.AddRowToTable(document);

                    sameWareNextTaskLineNumber = Convert.ToInt32(newTaskRow[CONSTS.LINE_NUMBER_COLUMN_NAME]);

                    wareRow[document.PlanValue] = wareRow[document.FactValue];
                    }

                var result = document.Write();
                return result == WritingResult.Success;
                }
        }
Beispiel #4
0
        public bool GetPickingTask(long documentId, long palletId, int predefinedTaskLineNumber, int currentLineNumber,
            out long stickerId, out long wareId, out string wareDescription,
            out long cellId, out string cellDescription,
            out long partyId, out DateTime productionDate,
            out int unitsPerBox, out int unitsToPick,
            out int lineNumber)
        {
            const string sql =
            @"
            select top 1 cap.[State],
            task.PalletCode stickerId, task.LineNumber,
            task.Nomenclature wareId, rtrim(n.[description]) wareDescription,
            task.StartCell cellId, ISNULL(rtrim(c.[Description]), '') cellDescription,
            task.Party partyId, isnull(p.DateOfManufacture, '0001-01-01') productionDate,
            n.UnitsQuantityPerPack unitsPerBox, task.PlanValue unitsToPick

            from SubMovingNomenclatureInfo task
            join Nomenclature n on n.Id = task.Nomenclature
            left join Cells c on c.Id = task.StartCell
            left join Parties p on p.Id = task.Party
            join Moving cap on cap.Id = task.IdDoc

            where IdDoc = @IdDoc and (RowState = @PlannedPickingState or (RowState = @ProcessingState and Employee = @userId))
            and (@currentLineNumber = 0 or task.LineNumber = @currentLineNumber)
            and (@nomenclature = 0 or task.Nomenclature = @nomenclature)
            order by [LineNumber]";
            var q = DB.NewQuery(sql);
            q.AddInputParameter("IdDoc", documentId);
            q.AddInputParameter("PlannedPickingState", RowsStates.PlannedPicking);
            q.AddInputParameter("ProcessingState", RowsStates.Processing);
            q.AddInputParameter("userId", getUserId());
            q.AddInputParameter("currentLineNumber", predefinedTaskLineNumber);

            var nomenclatureId = 0L;
            if (palletId != 0)
                {
                var sticker = new Stickers() { ReadingId = palletId };
                nomenclatureId = sticker.GetRef("Nomenclature");
                }
            q.AddInputParameter("nomenclature", nomenclatureId);

            stickerId = wareId = cellId = partyId = unitsToPick = unitsPerBox = lineNumber = 0;
            wareDescription = cellDescription = string.Empty;
            productionDate = DateTime.MinValue;

            // � ���������� ����� ������������� �������� ������ � ���������� �������� palletId, � ����� � �� �������������
            using (var locker = new DatabaseObjectLocker(typeof(Moving), documentId))
                {
                if (!locker.LockForCurrentPdtThread()) return false;

                var qResult = q.SelectRow();

                if (qResult == null)
                    {
                    return true;
                    }

                var documentState = (StatesOfDocument)Convert.ToInt32(qResult["State"]);
                if (documentState == StatesOfDocument.Planned)
                    {
                    var moving = new Moving() { ReadingId = documentId };
                    moving.State = StatesOfDocument.Processing;
                    moving.Write();
                    }

                stickerId = Convert.ToInt64(qResult["stickerId"]);
                wareId = Convert.ToInt64(qResult["wareId"]);
                wareDescription = qResult["wareDescription"].ToString();
                cellId = Convert.ToInt64(qResult["cellId"]);
                cellDescription = qResult["cellDescription"].ToString();
                partyId = Convert.ToInt64(qResult["partyId"]);
                productionDate = (DateTime)qResult["productionDate"];
                unitsPerBox = Convert.ToInt32(qResult["unitsPerBox"]);
                unitsToPick = Convert.ToInt32(qResult["unitsToPick"]);
                lineNumber = Convert.ToInt32(qResult["LineNumber"]);

                if (currentLineNumber > 0)
                    {
                    documentId.SetRowState(typeof(Moving), currentLineNumber, RowsStates.PlannedPicking);
                    }
                documentId.SetRowState(typeof(Moving), lineNumber, RowsStates.Processing, employee: getUserId());
                }
            return true;
        }
Beispiel #5
0
        public bool GetNewMovementId(out long documentId)
        {
            var doc = new Moving();
            doc.SetRef("Responsible", getUserId());
            doc.Date = SystemConfiguration.ServerDateTime;
            doc.SetRef("Responsible", getUserId());
            var writeResult = doc.Write();

            documentId = doc.Id;
            return writeResult == WritingResult.Success;
        }