Beispiel #1
0
        /*public string PromptText
         * {
         *      get
         *      {
         *              return promptText;
         *      }
         *      set
         *      {
         *              promptText= value;
         *      }
         * }*/

        #endregion

        /**
         * Customized for event type on top of stack
         * - PosError, pop the next event and update dialogs.
         * - If there is input line data, (i.e. user is in the
         *   middle inputing a number, remove the last number.
         * - else, clear input, pops the stack and update dialogs.
         */

        public override void  Engage(int keyValue)
        {
            Logger.Info(
                this.GetType().FullName,
                this.GetType().FullName + "Key value:" + PosContext.Instance.InputLine.ToString(),
                PosSettings.Default.Debug
                );

            //	MessageBox.Show("*** ClearKey ***");
            //PosContext.Instance.InputLine = "";
            //PosContext.Instance.Operprompt.Update(this);
            PosContext.Instance.PosPrompt.EnableInput();

            PosEvent posEventCurrent = PosEventStack.Instance.Peek() as PosEvent;

            // Clear the error event, update dialogs and return

            if (posEventCurrent is PosError)
            {
                PosEventStack.Instance.PopEvent();

                PosEvent posEventNext = PosEventStack.Instance.Peek() as PosEvent;
                if (posEventNext is FinishTransaction)
                {
                    PosEventStack.Instance.NextEvent();
                }



                if (posEventNext is LogOn)
                {
                    LogOn logOn = posEventNext as LogOn;
                    PosContext.Instance.Operprompt.Update(this);
                    logOn.States().PushState((int)LogonStates.EnterUser);
                    PosEventStack.Instance.NextEvent();
                    return;
                }

                if (posEventNext is SelectTable)
                {
                    PosContext.Instance.CurrentPosDisplay.UnloadTableSelect();
                    PosContext.Instance.HomeGUI();
                }

                PosContext.Instance.ClearInput();
                PosContext.Instance.HomeGUI();
                PosEventStack.Instance.ClearPending();
                PosEventStack.Instance.ClearProcessed();
                PosEventStack.Instance.NextEvent();
                return;
            }



            if (posEventCurrent is UnLock)
            {
                return;
            }

            if (posEventCurrent is FinishTransaction)
            {
                PosEventStack.Instance.NextEvent();
                return;
            }

            if (posEventCurrent is CloseCashDrawer)
            {
                PosEventStack.Instance.NextEvent();
                return;
            }

            if (posEventCurrent is PromptPrintReceipt)
            {
                // get rid of this event and continue
                PosContext.Instance.ClearInput();
                PosContext.Instance.HomeGUI();
                PosEventStack.Instance.PopEvent();
                PosEventStack.Instance.NextEvent();
                return;
            }

            // If this is a finish trans then the user wants to
            // cancel the current tender, clean up the operator
            // reciept, remove the tender ej and continue.

            if (posEventCurrent is FinishTransaction)
            {
                PosContext.Instance.Receipt.ClearLine();

                PosContext.Instance.ClearInput();
                //PosContext.Instance.CurrentEj.RemoveCurrLine();
                PosContext.Instance.HomeGUI();
                PosEventStack.Instance.ClearPending();
                PosEventStack.Instance.NextEvent();

                return;
            }

            if (posEventCurrent is EjItem)
            {
                EjItem ejItem = posEventCurrent as EjItem;
                if (ejItem.DialogStep != EjItem.ITEM_FINAL)
                {
                    ejItem.States().PopState();
                    ejItem.States().PushState(EjItem.ITEM_CLEAR);
                    PosEventStack.Instance.NextEvent();
                }


                return;
            }



            if (posEventCurrent is EjLine)
            {
                PosContext.Instance.ClearInput();
                //PosContext.Instance.CurrentEj.RemoveCurrLine ();
                PosContext.Instance.HomeGUI();
                PosEventStack.Instance.ClearPending();
                PosContext.Instance.EnableKeys();
                PosEventStack.Instance.NextEvent();

                return;
            }

            if (posEventCurrent is LogOn)
            {
                PosContext.Instance.ClearInput();
                LogOn logOn = posEventCurrent as LogOn;
                logOn.ResetState();
                PosEventStack.Instance.NextEvent();
                return;
            }


            if (posEventCurrent is RegisterOpen)
            {
                // if ( (PosContext.Instance.CurrentEj.TransHeader.State == (int) Transaction.Status.COMPLETE) ||
                //     (PosContext.Instance.CurrentEj.TransHeader.State == (int) Transaction.Status.VOIDED) )
                // {
                //     PosContext.Instance.Receipt.ClearLine();
                // }
                PosContext.Instance.HomeGUI();
                PosContext.Instance.EnableKeys();
                PosContext.Instance.Operprompt.Update(this);
                PosContext.Instance.Receipt.Update(this);
            }

            if (posEventCurrent is TerminalReport)
            {
                PosContext.Instance.HomeGUI();
                PosContext.Instance.EnableKeys();
                PosContext.Instance.Operprompt.Update(this);
                PosContext.Instance.Receipt.Update(this);
            }


            if (posEventCurrent is SelectTable)
            {
                PosContext.Instance.HomeGUI();
                PosContext.Instance.CurrentPosDisplay.UnloadTableSelect();
                PosContext.Instance.Operprompt.Update(this);
                PosContext.Instance.Receipt.Update(this);
            }


            if (posEventCurrent is PosNumberDialog)
            {
                PosNumberDialog dialog = posEventCurrent as PosNumberDialog;
                PosContext.Instance.EnableKeys();
                dialog.Clear();
                if (PosContext.Instance.Input() > 0)
                {
                    PosContext.Instance.ClearInput();
                    PosContext.Instance.Operprompt.Update(dialog);
                }
                else
                {
                    PosContext.Instance.ClearInput();
                    PosEventStack.Instance.ClearPending();
                    PosEventStack.Instance.ClearProcessed();
                    PosEventStack.Instance.NextEvent();
                }
            }
            else
            {
                PosContext.Instance.HomeGUI();
                PosContext.Instance.ClearInput();
                PosEventStack.Instance.ClearPending();
                //	PosEventStack.Instance.ClearPending();
                PosEventStack.Instance.NextEvent();
            }

            return;
        }
Beispiel #2
0
        //	public NumKey(PosContext pContext)
        //	{
        //this.Context = pContext;
        //	}



        /*
         * If the input is >= 0, assume valid number is entered.
         * Else look at the current PosEvent and figure out what to do
         * Logon, get the prompt text from that event
         * EjCheckTender, get the prompt text from that event
         * etc.
         */

        public override void  Engage(int keyValue)
        {
            //MessageBox.Show( keyValue.ToString() );
            if (keyValue >= 0)
            {
                PosContext.Instance.AddToInput(keyValue);
            }

            PosEvent posEvent = PosEventStack.Instance.CurrentEvent;

            if (posEvent is PosError)
            {
                PosError posError = posEvent as PosError;
                PosContext.Instance.Operprompt.Update(posError);
                return;
            }

            if (posEvent is PosNumberDialog)
            {
                PosNumberDialog numberDialog = posEvent as PosNumberDialog;
                this.PromptText = numberDialog.PromptText;
                numText         = PosContext.Instance.InputLine;

                switch (numberDialog.Type)
                {
                case (PosNumberDialogTypes.Clear):
                    break;

                case (PosNumberDialogTypes.Currency):
                    double currVal = PosContext.Instance.InputDouble() / 100.0;

                    string argToConvert = currVal.ToString(System.Globalization.CultureInfo.CurrentCulture.NumberFormat);
                    // Convert the specified argument using the specified format.
                    try
                    {
                        numText = string.Format(new PosTextFormatter( ), "{0:Money}", argToConvert);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }

                    break;
                //

                case (PosNumberDialogTypes.Decimal):
                    double val1 = PosContext.Instance.InputDouble() / 100.0;
                    numText = val1.ToString("#########.##");
                    break;

                case (PosNumberDialogTypes.Mask):
                    StringBuilder tmp = new StringBuilder();
                    tmp.Append('*', numText.Length);
                    numText = tmp.ToString();
                    break;
                }
            }
            else
            if (posEvent is EjLine)
            {
                numText = PosContext.Instance.InputLine;
            }
            else
            {
                numText = PosContext.Instance.InputLine;
            }

            PosContext.Instance.Operprompt.Update(this);
        }
Beispiel #3
0
        public void Update(char keyValue)
        {
            PosEvent posEvent = PosEventStack.Instance.CurrentEvent;

            if (keyValue == '\r')
            {
                new EnterKey().Engage(0);
                return;
            }

            if (keyValue == ' ')
            {
                PosContext.Instance.AddToInput(" ");
                return;
            }

            if (keyValue == '\b')
            {
                new ClearPreviousKeyStroke().Engage(0);
                return;
            }


            PosContext.Instance.AddToInput(keyValue.ToString()); //inputKey.ToString());


            //	PosContext.Instance.InputLine = PosContext.Instance.InputLine + inputKey.ToString();
            //inputText = PosContext.Instance.InputLine;

            if (posEvent is PosNumberDialog)
            {
                PosNumberDialog numberDialog = posEvent as PosNumberDialog;
                //this.inputText = numberDialog.PromptText;
                inputText = PosContext.Instance.InputLine;

                switch (numberDialog.Type)
                {
                case (PosNumberDialogTypes.Clear):
                    break;

                case (PosNumberDialogTypes.Currency):
                    double currVal = PosContext.Instance.InputDouble() / 100.0;

                    string argToConvert = currVal.ToString(System.Globalization.CultureInfo.CurrentCulture.NumberFormat);
                    // Convert the specified argument using the specified format.
                    try
                    {
                        inputText = string.Format(new PosTextFormatter(), "{0:Money}", argToConvert);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }

                    break;
                //

                case (PosNumberDialogTypes.Decimal):
                    double val1 = PosContext.Instance.InputDouble() / 100.0;
                    inputText = val1.ToString("#########.##");
                    break;

                case (PosNumberDialogTypes.Mask):
                    StringBuilder tmp = new StringBuilder();
                    tmp.Append('*', inputText.Length);
                    inputText = tmp.ToString();
                    break;
                }
            }
            else
            if (posEvent is EjLine)
            {
                inputText = PosContext.Instance.InputLine;
            }
            else
            {
                inputText = PosContext.Instance.InputLine;
            }

            PosContext.Instance.Operprompt.Update(this);
        }