Exemplo n.º 1
0
        private void PerformOperation(object sender, EventArgs e)
        {
            PosBatchStaging selectedShift = shiftsData[grdView.GetSelectedRows()[0]];
            PosisOperations operation     = (PosisOperations)((Control)sender).Tag;

            EOD.InternalApplication.RunOperation(operation, selectedShift);

            // If operation changed the batch status (E.g. closed) then delete from list.
            if (selectedShift.Status != PosBatchStatus.BlindClosed)
            {
                shiftsData.Remove(selectedShift);
                grdView.RefreshData();
            }

            UpdateControlButtons();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Processes the shift action.
        /// </summary>
        /// <param name="shiftActionResult">The shift action result.</param>
        /// <param name="openedShifts">The opened shifts.</param>
        /// <param name="suspendedShifts">The suspended shifts.</param>
        /// <param name="shift">The shift.</param>
        /// <returns>
        /// True if processed, false if canceled.
        /// </returns>
        private bool ProcessShiftAction(ShiftActionResult shiftActionResult, IList <IPosBatchStaging> openedShifts, IList <IPosBatchStaging> suspendedShifts, ref IPosBatchStaging shift)
        {
            BatchData batchData  = new BatchData(Application.Settings.Database.Connection, Application.Settings.Database.DataAreaID);
            bool      result     = false;
            string    cashDrawer = null;

            switch (shiftActionResult)
            {
            case ShiftActionResult.New:

                if (TryGetCashDrawerForShift(openedShifts, ref cashDrawer))
                {
                    PosBatchStaging newPosBatch = new PosBatchStaging();

                    newPosBatch.StoreId       = ApplicationSettings.Terminal.StoreId;
                    newPosBatch.TerminalId    = newPosBatch.OpenedAtTerminal = ApplicationSettings.Terminal.TerminalId;
                    newPosBatch.CashDrawer    = cashDrawer;
                    newPosBatch.StaffId       = ApplicationSettings.Terminal.TerminalOperator.OperatorId;
                    newPosBatch.StartDateTime = newPosBatch.StatusDateTime = DateTime.Now;
                    newPosBatch.Status        = PosBatchStatus.Open;
                    if (!ApplicationSettings.Terminal.TrainingMode)     // Don't create shift in traning mode.
                    {
                        newPosBatch.BatchId = Application.Services.ApplicationService.GetAndIncrementTerminalSeed(NumberSequenceSeedType.BatchId);
                        batchData.CreateBatch(newPosBatch);
                    }
                    shift = newPosBatch;

                    result = true;
                }
                break;

            case ShiftActionResult.Resume:
                // Let user select the shift to resume.
                shift = ShowShiftSelectionForm(ShiftSelectionMode.Resume, suspendedShifts);

                if (shift != null && TryGetCashDrawerForShift(openedShifts, ref cashDrawer))
                {
                    shift.Status           = PosBatchStatus.Open;
                    shift.StatusDateTime   = DateTime.Now;
                    shift.OpenedAtTerminal = ApplicationSettings.Terminal.TerminalId;
                    shift.CashDrawer       = cashDrawer;
                    if (!ApplicationSettings.Terminal.TrainingMode)     // Don't update batch in traning mode.
                    {
                        batchData.UpdateBatch(shift);
                    }

                    result = true;
                }
                break;

            case ShiftActionResult.UseOpened:

                if (openedShifts.Count == 1)
                {
                    shift = openedShifts.First();
                }
                else
                {
                    // Let user select the opened shift to use.
                    shift = ShowShiftSelectionForm(ShiftSelectionMode.UseOpened, openedShifts);
                }

                if (shift != null)
                {
                    ShiftUsersCache.Add(shift, ApplicationSettings.Terminal.TerminalOperator.OperatorId);
                    result = true;
                }
                break;

            case ShiftActionResult.NonDrawer:
                shift  = null;
                result = true;
                break;
            }

            return(result);
        }