Exemplo n.º 1
0
        public void RegisterPosKeyAndEvent(int keyValue, int keyCode, string content, Thickness margin, int row, int col, int accessKey, string eventClass)
        {
            PosButton btn = new PosButton();

            btn.Style    = (Style)FindResource("GlassyButtonStyle1");
            btn.Height   = 75;
            btn.KeyValue = keyValue;
            btn.KeyCode  = keyCode;
            btn.Content  = content;
            //   btn.FontSize = 12;
            btn.Margin         = margin;
            btn.AccessKeyValue = accessKey;
            btn.KeyClass       = eventClass;
            btn.Focusable      = false;
            Grid.SetRow(btn, row);
            Grid.SetColumn(btn, col);
            this.MyGrid.Children.Add(btn);

            btn.Click += new RoutedEventHandler(btn_Click);

            try
            {
                Assembly assembly = Assembly.GetExecutingAssembly();
                PosEvent posEvent = assembly.CreateInstance(eventClass) as PosEvent;
                PosContext.Instance.KeysById.Add(keyCode.ToString(), posEvent);
            }
            catch (System.NullReferenceException exNull)
            {
                Logger.Error(this.GetType().ToString(), "Invalid class name " + eventClass, exNull);
            }
            catch (Exception ex)
            {
                Logger.Error(this.GetType().ToString(), ex.ToString(), ex);
            }
        }
Exemplo n.º 2
0
        void btn_Click(object sender, RoutedEventArgs e)
        {
            PosButton posButton = sender as PosButton;

            //MessageBox.Show(posButton.KeyCode.ToString());

            string keyCode = posButton.KeyCode.ToString();

            Hashtable table     = PosContext.Instance.KeysById;
            PosEvent  posEvent1 = (PosEvent)table[keyCode];

            if (posEvent1 != null)
            {
                // posEvent1.Engage(posButton.KeyValue);

                if (posEvent1.isDialog)
                {
                    PosContext.Instance.PosKeyValue = posButton.KeyValue;
                    PosDialogEvent posDialog = posEvent1 as PosDialogEvent;
                    posDialog.PushState(posDialog.StartState);
                    PosEventStack.Instance.PushEvent(posEvent1);
                    PosEventStack.Instance.NextEvent();
                }
                else
                {
                    posEvent1.Engage(posButton.KeyValue);
                }
            }
        }
Exemplo n.º 3
0
        void btn_Click(object sender, RoutedEventArgs e)
        {
            PosButton posButton = sender as PosButton;
            // object keyValue = posButton.Tag;
            // MessageBox.Show(posButton.KeyCode.ToString());
            string keyCode = posButton.KeyCode.ToString();

            Hashtable table     = PosContext.Instance.KeysById;
            PosEvent  posEvent1 = (PosEvent)table[keyCode];

            if (posEvent1 != null)
            {
                //posEvent1.Engage(posButton.KeyValue);
                if (posEvent1.isDialog)
                {
                    PosContext.Instance.PosKeyValue = posButton.KeyValue;
                    PosDialogEvent posDialog = posEvent1 as PosDialogEvent;
                    posDialog.PushState(posDialog.StartState); //Assume "0" as the default state
                    PosEventStack.Instance.PushEvent(posEvent1);
                    PosEventStack.Instance.NextEvent();
                }
                else
                {
                    posEvent1.Engage(posButton.KeyValue);
                }
            }

            //PnlInput input = PosContext.Instance.PosPrompt as PnlInput;
            //input.InputControl.Focus();
            //_contrainer.get
        }
 public void ApplyComp(int iManagerId, int iEmployeeId, int iQueueId, int iTableId, int iCheckId, int iCompTypeId, int iCompId)
 {
     new TaskFactory().StartNew(() =>
     {
         var posEvent = new PosEvent("ApplyComp", TerminalId, _alohaFunctions.GetEmployee(iEmployeeId), _alohaFunctions.GetComp(iCompTypeId, iCompId));
         SenderInfoService.SendInfoToTcpSocket(posEvent);
     });
 }
 public void AdjustPayment(int iManagerId, int iEmployeeId, int iQueueId, int iTableId, int iCheckId, int iTenderId, int iPaymentId)
 {
     new TaskFactory().StartNew(() =>
     {
         var posEvent = new PosEvent("AdjustPayment", TerminalId, _alohaFunctions.GetEmployee(iEmployeeId), _alohaFunctions.GetPayment(iCheckId, iTenderId, iPaymentId));
         SenderInfoService.SendInfoToTcpSocket(posEvent);
     });
 }
Exemplo n.º 6
0
        /**
         * Finds a dialog set in PosConfig and loads it.
         */


        public void LoadDialog(string dialog_name)
        {
            PosEvent posEvent = null;
            Dialog   dialog   = (Dialog)PosContext.Instance.Config.Dialogs[dialog_name];

            if (dialog != null)
            {
                foreach (object obj in dialog.DialogEvents)
                {
                    DialogEvent dialogEvent = obj as DialogEvent;
                    if (dialogEvent.EventClass.Trim().Length != 0)
                    {
                        try
                        {
                            posEvent = Assembly.GetExecutingAssembly().CreateInstance(dialogEvent.EventClass) as PosEvent;                            //eventClass.Trim()) as PosEvent;
                            // Push the event in current event stack
                            //this.PushEvent(posEvent);

                            if (posEvent.isDialog)
                            {
                                int state = dialogEvent.State;
                                ((PosDialogEvent)posEvent).PushState(state);
                            }
                        }
                        catch (System.NullReferenceException exNull)
                        {
                            MessageBox.Show(exNull.ToString() + dialogEvent.EventClass);
                            Logger.Error("PosEventStack.cs", "PosEventStack.cs :" + "Invalid class name " + dialogEvent.EventClass);
                            return;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString() + dialogEvent.EventClass);
                            Logger.Error("PosEventStack.cs", "PosEventStack.cs :" + ex.ToString());
                            return;
                        }

                        if (dialogEvent.EventRequired == 1 || dialogEvent.EventEnabled == 1)
                        {
                            this.PushEvent(posEvent);
                        }
                    }
                    else
                    {
                        //Use the event on top of stack
                        posEvent = this.CurrentPosEvent();
                        if (posEvent.isDialog && (dialogEvent.EventRequired == 1 || dialogEvent.EventEnabled == 1))
                        {
                            int state = dialogEvent.State;
                            ((PosDialogEvent)posEvent).PushState(state);
                        }
                    }
                }
            }
        }
 public static void SendInfoToTcpSocket(PosEvent posEvent)
 {
     try
     {
         var sPosEvent = posEvent.Serialize();
         _socket.Send(sPosEvent);
     }
     catch (Exception ex)
     {
         Logger.Exception(ex);
     }
 }
 public void ApplyPayment(int iManagerId, int iEmployeeId, int iQueueId, int iTableId, int iCheckId, int iTenderId, int iPaymentId)
 {
     try
     {
         var posEvent = new PosEvent("ApplyPayment", TerminalId, _alohaFunctions.GetEmployee(iEmployeeId), _alohaFunctions.GetPayment(iCheckId, iTenderId, iPaymentId));
         new TaskFactory().StartNew(() => SenderInfoService.SendInfoToTcpSocket(posEvent));
     }
     catch (Exception ex)
     {
         Logger.Exception(ex);
     }
 }
 public void AddItem(int iEmployeeId, int iQueueId, int iTableId, int iCheckId, int iEntryId)
 {
     try
     {
         var posEvent = new PosEvent("AddItem", TerminalId, _alohaFunctions.GetEmployee(iEmployeeId), _alohaFunctions.GetItemInfos(iCheckId, iEntryId));
         new TaskFactory().StartNew(() => SenderInfoService.SendInfoToTcpSocket(posEvent));
     }
     catch (Exception ex)
     {
         Logger.Exception(ex);
     }
 }
Exemplo n.º 10
0
        public void NextEvent()
        {
            //this.Dump();

            PosEvent posEvent      = null;
            PosEvent posEventCheck = this.CurrentEvent;


            //Engage the pos error until Clear Key is pressed
            if (this.CurrentEvent is PosError)
            {
                this.CurrentEvent.Engage(0);
                return;
            }

            try
            {
                // if this is a dialog pop it's state stack and invoke
                // the current event

                if (this.CurrentPosEvent().isDialog)
                {
                    PosDialogEvent dialog = this.CurrentPosEvent() as PosDialogEvent;

                    // if there are state events pop

                    if (dialog.States().PendingCount > 0)
                    {
                        posEvent = this.CurrentPosEvent();
                    }
                    else
                    {
                        // if there are no state events in the dialog
                        // pop the entire event, and engage the next one
                        this.PopEvent();
                        //posEvent = PopEvent ();
                        posEvent = this.CurrentPosEvent(); //this.Peek();
                    }
                }
                else
                {
                    posEvent = this.PopEvent();
                }

                posEvent.Engage(0);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                Logger.Error(this.GetType().FullName, this.GetType().FullName + ":" + e.ToString(), e);
            }
        }
Exemplo n.º 11
0
        public void btn_Click(object sender, RoutedEventArgs e)
        {
            PosButton posButton = sender as PosButton;
            string    keyCode   = posButton.KeyCode.ToString();

            Hashtable table     = PosContext.Instance.KeysById;
            PosEvent  posEvent1 = (PosEvent)table[keyCode];

            if (posEvent1 != null)
            {
                posEvent1.Engage(posButton.KeyValue);
            }
        }
Exemplo n.º 12
0
        public void Dump()
        {
            foreach (Object obj in pending)
            {
                PosEvent posEvent = (PosEvent)obj;
                MessageBox.Show("pending " + posEvent.ToString());
            }

            foreach (Object obj1 in processed)
            {
                PosEvent posEvent1 = (PosEvent)obj1;
                MessageBox.Show("processed: " + posEvent1.ToString());
            }
        }
Exemplo n.º 13
0
 public void RegisterEvent(int keyCode, string eventClass)
 {
     try
     {
         Assembly assembly = Assembly.GetExecutingAssembly();
         PosEvent posEvent = assembly.CreateInstance(eventClass) as PosEvent;
         PosContext.Instance.KeysById.Add(keyCode.ToString(), posEvent);
     }
     catch (System.NullReferenceException exNull)
     {
         Logger.Error("InvoiceTotalView.cs", "Invalid class name " + eventClass);
     }
     catch (Exception ex)
     {
         Logger.Error("InvoiceTotalView.cs", ex.ToString());
     }
 }
Exemplo n.º 14
0
        void btn_Click(object sender, RoutedEventArgs e)
        {
            PosButton posButton = sender as PosButton;

            //MessageBox.Show(posButton.KeyCode.ToString());

            string keyCode = posButton.KeyCode.ToString();

            Hashtable table     = PosContext.Instance.KeysById;
            PosEvent  posEvent1 = (PosEvent)table[keyCode];

            if (posEvent1 != null)
            {
                posEvent1.Engage(posButton.KeyValue);
            }

            //PnlInput input = PosContext.Instance.PosPrompt as PnlInput;
            //input.InputControl.Focus();
        }
Exemplo n.º 15
0
        public void SendHashAndSignTransaction()
        {
            // Create the event to sign.

            string pos_serial_nr = "B999000ABC4567";             // BXXXCCCPPPPPPP:
            // BXXX: Producer ID.
            // CCC: Certificate number.
            // PPPPPPP: Last 7 characters of software license key,
            //          ignoring possible control character.
            string terminal_id    = "10";
            string terminal_name  = "FDM DEMO POS";
            string operator_id    = "79100590097"; // INSZ-number or BIS-number (11 characters) or "Guest" (00000000097)
            string operator_name  = "Tony";
            int    transaction_nr = 1;             // ???

            PosEvent posevent = new PosEvent(pos_serial_nr, terminal_id, terminal_name, operator_id, operator_name,
                                             transaction_nr, DateTime.Now);

            Debug.Assert(TrainingButton.IsChecked != null);
            Debug.Assert(RefundButton.IsChecked != null);

            posevent.IsTrainingMode = (bool)TrainingButton.IsChecked;
            posevent.IsRefund       = (bool)RefundButton.IsChecked;
            posevent.IsFinalized    = true;
            posevent.DrawerOpen     = posevent.IsFinalized && (posevent.Payments.Count != 0);

            posevent.SetVatRate(21, 12, 6, 0);

            decimal payment_total = 0.0m;             // DEBUG

            foreach (ReceiptLine l in ReceiptLines)
            {
                // TODO: Determine whether to use 'ID' or 'SKU' for argument 'ProductId'.
                posevent.Products.Add(new ProductLine(l.SKU, l.Description, l.Amount, l.TotalPrice, l.VAT.ToString()));
                payment_total += l.TotalPrice;
            }

            posevent.Payments.Add(new PaymentLine("PAY001", "Euro", PaymentTypes.Cash, 1, payment_total));

            FDMClient.BeginHashAndSign(posevent, HashAndSignCallback, null);             // Argument 3 feeds the callback.
        }
Exemplo n.º 16
0
        public void AddClearPosKey()
        {
            PosButton btn = new PosButton();

            btn.Style          = (Style)FindResource("ClearKeyButtonStyle");
            btn.KeyValue       = 0;
            btn.KeyCode        = 32;
            btn.Content        = " ";
            btn.FontSize       = 14;
            btn.Margin         = new Thickness(10, 0, 12, 12);
            btn.AccessKeyValue = 46;
            btn.KeyClass       = "EclipsePos.Apps.PosEvents.ClearKey";
            btn.Height         = 47;
            btn.Width          = 80;
            btn.Content        = "Clear";

            Grid.SetRow(btn, 0);
            Grid.SetColumn(btn, 0);

            this.TableGroupGrid.Children.Add(btn);



            btn.Click += new RoutedEventHandler(btn_Click);

            try
            {
                Assembly assembly = Assembly.GetExecutingAssembly();
                PosEvent posEvent = assembly.CreateInstance("EclipsePos.Apps.PosEvents.ClearKey") as PosEvent;
                PosContext.Instance.KeysById.Add(btn.KeyCode, posEvent);
            }
            catch (System.NullReferenceException exNull)
            {
                //Logger.Error("FrmMain.cs", "Invalid class name " + eventClass);
            }
            catch (Exception ex)
            {
                //Logger.Error("FrmMain.cs", ex.ToString());
            }
        }
Exemplo n.º 17
0
        public void SendHashAndSignTransaction()
        {
            // Create the event to sign.

            string pos_serial_nr = "B999000ABC4567";             // BXXXCCCPPPPPPP:
            // BXXX: Producer ID.
            // CCC: Certificate number.
            // PPPPPPP: Last 7 characters of software license key,
            //          ignoring possible control character.
            string terminal_id    = "10";
            string terminal_name  = "FDM DEMO POS";
            string operator_id    = "79100590097"; // INSZ-number or BIS-number (11 characters) or "Guest" (00000000097)
            string operator_name  = "Tony";
            int    transaction_nr = 1;             // ???

            PosEvent posevent = new PosEvent(pos_serial_nr, terminal_id, terminal_name, operator_id, operator_name,
                                             transaction_nr, DateTime.Now);

            posevent.IsRefund       = false;
            posevent.IsTrainingMode = false;
            posevent.IsFinalized    = true;
            posevent.DrawerOpen     = (posevent.IsFinalized && posevent.Payments.Count != 0);

            posevent.SetVatRate(21, 12, 6, 0);

            int multiplier = posevent.IsRefund ? -1 : 1;

            decimal total = 2.20m * multiplier + 11.90m * multiplier;             // TODO: DEBUG

            posevent.Products.Add(new ProductLine("BEV021", "SOFTDRINKS", "SOFT004", "Cola", multiplier, 2.20m * multiplier, "A"));
            posevent.Products.Add(new ProductLine("FOO018", "SNACKS", "SNAC007", "Snack", multiplier, 11.90m * multiplier, "B"));

            // string PaymentId, string PaymentName, PaymentTypes Type, int Quantity, decimal Amount
            posevent.Payments.Add(new PaymentLine("PAY001", "Euro", PaymentTypes.Cash, 1, total));

            c.BeginHashAndSign(posevent, HashAndSignCallback, null);             // Argument 3 feeds the callback.
        }
        public void DeleteItems(int iManagerId, int iEmployeeId, int iQueueId, int iTableId, int iCheckId, int iReasonId)
        {
            try
            {
                //Se tiene que realizar de forma secuencial debido a que la información es eliminada después de terminar este evento
                var lstItemsDeleted = _alohaFunctions.GetLstItemsDeleted();

                if(lstItemsDeleted.Any())
                    _alohaFunctions.FillNameByCheckId(iCheckId, lstItemsDeleted);

                new TaskFactory().StartNew(() =>
                {
                    var posEvent = new PosEvent("DeleteItems", TerminalId, _alohaFunctions.GetEmployee(iEmployeeId), lstItemsDeleted, iReasonId);
                    SenderInfoService.SendInfoToTcpSocket(posEvent);
                });
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
            }
        }
Exemplo n.º 19
0
        /*
         *  HandlePosEvent is called from _ui_Notify event listener (above).
         *
         *  Most messages are simply turned into .NET events.  A few do more,
         *  especially:
         *      ADD_TO_BASKET : Updates our own Basket object with new items
         *      REMOVE_FROM_BASKET : Removes item from our own Basket
         *      BASKET_COMMITTED : Updates the Basket state; and fetches all the vouchers
         */
        private void HandlePosEvent(PosEvent posEvent)
        {
            if (posEvent == null)
            {
                // Debug.Assert(false);
                return;
            }
            if (_timeoutTimer != null)
            {
                _timeoutTimer.Enabled = false;
                _timeoutTimer         = null;
            }
            switch (posEvent.EventName)
            {
            case PosEventType.READY:
                Ready?.Invoke(this, null);
                _rollbackHandler.ProcessPendingRollbacks(_config.Url);
                break;

            case PosEventType.SHOW_GUI:
                _ui.Show();
                ShowGUI?.Invoke(this, null);
                break;

            case PosEventType.HIDE_GUI:
                _ui.Hide();
                HideGUI?.Invoke(this, null);
                break;

            case PosEventType.ADD_TO_BASKET:
                var addedItem = (AddToBasketEvent)posEvent;
                _basket.Id = addedItem.BasketId;
                _basket.Items.Add(addedItem.BasketItem);
                ItemAdded?.Invoke(this, addedItem.BasketItem);
                break;

            case PosEventType.BASKET_COMMITTED:
                var basketCommittedEvent = (BasketCommittedEvent)posEvent;
                // Check:
                //  (1) Incoming .BasketId is what we expect.  This is just a sanity check, and should never fail.
                //  (2) basketCommittedEvent.Basket.Committed = TRUE
                //  (3) this.FailOnCommit = FALSE.  This may be set to TRUE to test correct processing of a Commit failure.
                if (_basket.Id == basketCommittedEvent.BasketId && basketCommittedEvent.Basket.Committed && !FailOnCommit)
                {
                    _basket.Clear();
                    _basket.Id = basketCommittedEvent.BasketId;
                    foreach (var basketItem in basketCommittedEvent.Basket.basketItems)
                    {
                        _basket.Items.Add(basketItem);     // Now with Touch ID, and Vouchers (we trust!)
                        if (basketItem is PurchaseBasketItem)
                        {
                            var purchase = (PurchaseBasketItem)basketItem;
                            if (purchase.Vouchers?.Count > 0)
                            {
                                GetVoucher(purchase.Vouchers[0].Link);
                            }
                        }
                        else if (basketItem is RefundBasketItem)
                        {
                            var refund = (RefundBasketItem)basketItem;
                            if (refund.RefundVoucher != null)
                            {
                                GetVoucher(refund.RefundVoucher.Link);
                            }
                        }
                    }
                    _basket.Committed = true;
                    BasketCommitted?.Invoke(this, _basket);
                }
                else
                {
                    ProcessFailedCommit();
                }
                // _basket.Clear();
                break;

            case PosEventType.REMOVE_FROM_BASKET:
                var removeFromBasketEvent = (RemoveFromBasketEvent)posEvent;
                foreach (var basketItem in _basket.Items)
                {
                    if (basketItem.Id == removeFromBasketEvent.BasketItemId)
                    {
                        _basket.Items.Remove(basketItem);
                        ItemRemoved?.Invoke(this, basketItem);
                        break;
                    }
                }
                break;

            case PosEventType.PRINT_VOUCHER:     // This is an "unexpected" ad hoc voucher...
                var PrintVoucherEvent = (PrintVoucherEvent)posEvent;
                VoucherAvailable?.Invoke(this, PrintVoucherEvent.Data);
                break;

            case PosEventType.VOUCHER_HTML:     //...whereas this is the response to the BasketGetVoucherEvent message
                var voucherHtmlEvent = (VoucherHtmlEvent)posEvent;
                if (!string.IsNullOrEmpty(voucherHtmlEvent.VoucherHtml))
                {
                    VoucherAvailable?.Invoke(this, voucherHtmlEvent.VoucherHtml);
                }
                break;

            case PosEventType.START_DEVICE:
                var startDeviceEvent = (StartDeviceEvent)posEvent;
                StartDevice?.Invoke(this, startDeviceEvent.Device);
                break;

            case PosEventType.STOP_DEVICE:
                var stopDeviceEvent = (StopDeviceEvent)posEvent;
                StopDevice?.Invoke(this, stopDeviceEvent.Device);
                break;

            case PosEventType.DISPLAY_MESSAGE:
                var displayMessageEvent = (DisplayMessageEvent)posEvent;
                DisplayMessage?.Invoke(this, displayMessageEvent.Message);
                break;

            case PosEventType.SIMPLE_PRODUCT:
                var simpleProductEvent = (SimpleProductEvent)posEvent;
                SimpleProduct?.Invoke(this, new SimpleProductInfo(simpleProductEvent));
                break;

            case PosEventType.SYNC_BASKET:
                var synBasketEvent = (SyncBasketEvent)posEvent;
                SyncBasket?.Invoke(this, null);
                break;

            case PosEventType.ERROR:
                var errorEvent = (ErrorEvent)posEvent;
                if (errorEvent.Method == "BasketCommitBasket")
                {
                    ProcessFailedCommit();
                }
                Error?.Invoke(this, errorEvent.Reason);
                break;

            default:
                Debug.Assert(false);     // Unknown PosEventType
                break;
            }
        }
 public void OpenItem(int iEmployeeId, int iEntryId, int iItemId, string sDescription, double dPrice)
 {
     new TaskFactory().StartNew(() =>
     {
         var posEvent = new PosEvent("OpenItem", TerminalId, _alohaFunctions.GetEmployee(iEmployeeId),
             new List<PosEventItem>
             {
                 new PosEventItem
                 {
                     Id = iItemId, Name = sDescription, Price = dPrice
                 }
             });
         SenderInfoService.SendInfoToTcpSocket(posEvent);
     });
 }
 public void LogIn(int iEmployeeId, string sName)
 {
     Logger.Write("LogIn entrar");
     new TaskFactory().StartNew(() =>
     {
         var posEvent = new PosEvent("Login", TerminalId, _alohaFunctions.GetEmployee(iEmployeeId));
         SenderInfoService.SendInfoToTcpSocket(posEvent);
     });
 }
 public void OpenCheck(int iEmployeeId, int iQueueId, int iTableId, int iCheckId)
 {
     new TaskFactory().StartNew(() =>
     {
         var posEvent = new PosEvent("OpenCheck", TerminalId, _alohaFunctions.GetEmployee(iEmployeeId));
         SenderInfoService.SendInfoToTcpSocket(posEvent);
     });
 }
Exemplo n.º 23
0
        /// <summary>
        /// </summary>
        public void AddPosKeys(int subMenuID, string menuName)
        {
            this.txtBlockMenuName.Text = menuName;


            PosKey posKey = new PosKey();

            posKey.Panel_id  = subMenuID;
            posKey.Config_no = PosSettings.Default.Configuration; //PosContext.Instance.Config.ConfigNo;
            DataSet   data   = posKey.LoadBySubMenu();
            DataTable dt     = data.Tables[0];
            int       rowNum = 0;
            int       colNum = 0;

            foreach (DataRow dr in dt.Rows)
            {
                ++rowNum;
                PosButton btn = new PosButton();
                btn.Style = (Style)FindResource("GlassyButtonStyle");
                //  btn.Height = 60;
                //  btn.Width = 100;
                btn.KeyValue       = int.Parse(dr["key_val"].ToString());
                btn.KeyCode        = int.Parse(dr["key_code"].ToString());
                btn.KeyClass       = dr["key_class"].ToString();
                btn.Content        = dr["param"].ToString(); //dr["image"].ToString();
                btn.AccessKeyValue = int.Parse(dr["attr"].ToString());
                // btn.FontSize = 12;
                btn.Margin    = new Thickness(5, 0, 5, 10);
                btn.Focusable = false;
                btn.KeyText   = dr["param"].ToString();
                btn.Tag       = "..\\..\\Images\\" + dr["image"].ToString().Trim();
                Grid.SetRow(btn, rowNum);

                Grid.SetColumn(btn, colNum);

                if (rowNum == 8)
                {
                    ++colNum;
                    rowNum = 0;
                }

                // Grid.SetColumn(btn, 3);
                // Grid.SetColumn(btn, 0);

                /*
                 * if (dr["flags"].ToString().Trim().Length > 0)
                 * {
                 *  try
                 *  {
                 *      Image img = new Image();
                 *      BitmapImage src = new BitmapImage();
                 *      src.BeginInit();
                 *      src.UriSource = new Uri(Environment.CurrentDirectory +"\\Images\\"+dr["flags"].ToString().Trim(), UriKind.RelativeOrAbsolute);
                 *      src.EndInit();
                 *      img.VerticalAlignment = VerticalAlignment.Center;
                 *      img.HorizontalAlignment = HorizontalAlignment.Center;
                 *      img.Source = src;
                 *      img.Width = 25;
                 *      img.Height = 25;
                 *      Grid.SetRow(img, rowNum);
                 *      Grid.SetColumn(img, 1);
                 *      this.MyGrid.Children.Add(img);
                 *  }
                 *  catch
                 *  {
                 *  }
                 * }
                 *
                 */

                TextBlock txtBlock = new TextBlock();
                txtBlock.Text = dr["param"].ToString();
                // txtBlock.FontSize = 16;
                txtBlock.Margin        = new Thickness(5, 5, 0, 0);
                txtBlock.TextAlignment = TextAlignment.Justify;
                txtBlock.Foreground    = Brushes.White;

                Grid.SetColumn(txtBlock, 0);
                Grid.SetRow(txtBlock, rowNum);

                this.MyGrid.Children.Add(btn);
                //this.MyGrid.Children.Add(txtBlock);

                btn.Click += new RoutedEventHandler(btn_Click);

                string eventClass = dr["key_class"].ToString();

                try
                {
                    Assembly assembly = Assembly.GetExecutingAssembly();
                    PosEvent posEvent = assembly.CreateInstance(eventClass) as PosEvent;
                    posEvent.PromptText = txtBlock.Text;
                    PosContext.Instance.KeysById.Add(dr["key_code"].ToString(), posEvent);
                    // PosContext.Instance.KeysByControl.Add(btn, posEvent);
                }
                catch (System.NullReferenceException exNull)
                {
                    Logger.Error(this.GetType().ToString(), "Invalid class name " + exNull.ToString() + exNull);
                }
                catch (Exception ex)
                {
                    Logger.Error(this.GetType().ToString(), ex.ToString(), ex);
                }
            }


            this.KeyDisable();
        }
Exemplo n.º 24
0
 /**
  * Set the fist event in the pending stack
  * to the object.
  */
 public void SetEvent(PosEvent posEvent1)
 {
     this.Clear();
     this.PushPending(posEvent1);
 }
Exemplo n.º 25
0
 /**
  * Add an object to the pending stack.
  */
 public void PushEvent(PosEvent posEvent1)
 {
     this.PushPending(posEvent1);
 }
Exemplo n.º 26
0
        /// <summary>
        /// </summary>
        public void AddPosKeys(int subMenuID, string menuName)
        {
            //this.txtBlockMenuName.Text = menuName;


            PosKey posKey = new PosKey();

            posKey.Panel_id  = subMenuID;
            posKey.Config_no = PosSettings.Default.Configuration; //PosContext.Instance.Config.ConfigNo;
            DataSet   data   = posKey.LoadBySubMenu();
            DataTable dt     = data.Tables[0];
            int       colNum = 0;
            int       rowNum = 0;

            foreach (DataRow dr in dt.Rows)
            {
                PosButton btn = new PosButton();
                btn.Style = (Style)FindResource("GlassyButtonStyle1");

                btn.Height         = 75;
                btn.KeyValue       = int.Parse(dr["key_val"].ToString());
                btn.KeyCode        = int.Parse(dr["key_code"].ToString());
                btn.AccessKeyValue = int.Parse(dr["attr"].ToString());
                btn.Content        = dr["key_text"].ToString();
                btn.KeyClass       = dr["key_class"].ToString();
                btn.Tag            = "..\\..\\Images\\" + dr["image"].ToString().Trim();
                btn.Margin         = new Thickness(2, 2, 2, 2);
                btn.Focusable      = false;
                Grid.SetRow(btn, rowNum);
                Grid.SetColumn(btn, colNum++);

                this.MyGrid.Children.Add(btn);

                if (colNum > 5)
                {
                    colNum = 0;
                    ++rowNum;
                }


                btn.Click += new RoutedEventHandler(btn_Click);

                //Register key in PosContext;
                //Create events
                string eventClass = dr["key_class"].ToString();
                try
                {
                    Assembly assembly = Assembly.GetExecutingAssembly();
                    PosEvent posEvent = assembly.CreateInstance(eventClass) as PosEvent;
                    if (!PosContext.Instance.KeysById.ContainsKey(dr["key_code"].ToString()))
                    {
                        PosContext.Instance.KeysById.Add(dr["key_code"].ToString(), posEvent);
                    }
                }
                catch (System.NullReferenceException exNull)
                {
                    Logger.Error(this.GetType().ToString(), "Invalid class name " + eventClass);
                }
                catch (Exception ex)
                {
                    Logger.Error(this.GetType().ToString(), ex.ToString());
                }
            }

            this.KeyDisable();
        }
 public void SpecialMessage(int iEmployeeId, int iMessageId, string sMessage)
 {
     new TaskFactory().StartNew(() =>
     {
         var posEvent = new PosEvent("SpecialMessage", TerminalId, _alohaFunctions.GetEmployee(iEmployeeId), sMessage);
         SenderInfoService.SendInfoToTcpSocket(posEvent);
     });
 }
Exemplo n.º 28
0
        //----------------------------------------
        public PosEvent CurrentPosEvent()
        {
            PosEvent event1 = (PosEvent)this.Peek();

            return(event1);
        }
 public void LogOut(int iEmployeeId, string sName)
 {
     try
     {
         Logger.Write("LogIn salir");
         var posEvent = new PosEvent("LogOut", TerminalId, new PosEventEmployee
         {
             FirstName = sName,
             Id = iEmployeeId,
             LastName = String.Empty
         });
         new TaskFactory().StartNew(() => SenderInfoService.SendInfoToTcpSocket(posEvent));
     }
     catch (Exception ex)
     {
         Logger.Exception(ex);
     }
 }
 public void DeletePromo(int iManagerId, int iEmployeeId, int iQueueId, int iTableId, int iCheckId, int iPromotionId, int iPromoId)
 {
     new TaskFactory().StartNew(() =>
     {
         var posEvent = new PosEvent("DeletePromo", TerminalId, _alohaFunctions.GetEmployee(iEmployeeId), _alohaFunctions.GetPromo(iPromotionId, iPromoId));
         SenderInfoService.SendInfoToTcpSocket(posEvent);
     });
 }
 public void ModifyItem(int iEmployeeId, int iQueueId, int iTableId, int iCheckId, int iEntryId)
 {
     new TaskFactory().StartNew(() =>
     {
         var posEvent = new PosEvent("ModifyItem", TerminalId, _alohaFunctions.GetEmployee(iEmployeeId), _alohaFunctions.GetItemInfo(iCheckId, iEntryId));
         SenderInfoService.SendInfoToTcpSocket(posEvent);
     });
 }