Esempio n. 1
0
 public void AddOrder(ScreenMenuItemData data)
 {
     var ti = AddOrder(data.ScreenMenuItem.MenuItemId, data.Quantity, data.ScreenMenuItem.ItemPortion);
     if (ti != null)
     {
         UpdateOrderTags(SelectedTicket, ti.Model, data.ScreenMenuItem.OrderTags);
         UpdateOrderStates(SelectedTicket, ti.Model, data.ScreenMenuItem.OrderStates);
         ExecuteAutomationCommand(SelectedTicket, ti.Model, data.ScreenMenuItem.AutomationCommand, data.ScreenMenuItem.AutomationCommandValue);
         ti.UpdateItemColor();
         if (data.ScreenMenuItem.AutoSelect)
         {
             ti.ToggleSelection();
             if (!_applicationState.IsLandscape)
             {
                 var so = new SelectedOrdersData { SelectedOrders = new List<Order> { ti.Model }, Ticket = SelectedTicket };
                 OperationRequest<SelectedOrdersData>.Publish(so, EventTopicNames.DisplayTicketOrderDetails, EventTopicNames.RefreshSelectedTicket, "");
             }
         }
     }
 }
        private void OnMenuItemCommandExecute(ScreenMenuItem screenMenuItem)
        {
            decimal selectedMultiplier = 1;
            if (!string.IsNullOrEmpty(NumeratorValue) && !_filtered)
                decimal.TryParse(NumeratorValue, out selectedMultiplier);

            if (IsQuickNumeratorVisible)
                NumeratorValue = QuickNumeratorValues[0];
            if (IsNumeratorVisible)
                NumeratorValue = "";

            if (selectedMultiplier > 0)
            {
                var data = new ScreenMenuItemData { ScreenMenuItem = screenMenuItem, Quantity = selectedMultiplier };
                if (data.Quantity == 1 && screenMenuItem.Quantity > 1)
                    data.Quantity = screenMenuItem.Quantity;
                SelectedMenuItems.Add(data);
                data.PublishEvent(EventTopicNames.ScreenMenuItemDataSelected);
            }
        }
        private void OnFindMenuItemCommand(string obj)
        {
            var insertedData = NumeratorValue;
            decimal quantity = 1;
            if (NumeratorValue.ToLower().Contains("x"))
            {
                insertedData = NumeratorValue.Substring(NumeratorValue.ToLower().IndexOf("x") + 1);
                string q = NumeratorValue.Substring(0, NumeratorValue.ToLower().IndexOf("x"));
                decimal.TryParse(q, out quantity);
            }
            NumeratorValue = "";

            if (quantity > 0)
            {
                var weightBarcodePrefix = _settingService.ProgramSettings.WeightBarcodePrefix;
                if (!string.IsNullOrEmpty(weightBarcodePrefix) && insertedData.StartsWith(weightBarcodePrefix))
                {
                    var itemLength = _settingService.ProgramSettings.WeightBarcodeItemLength;
                    var quantityLength = _settingService.ProgramSettings.WeightBarcodeQuantityLength;
                    if (itemLength > 0 && quantityLength > 0 && insertedData.Length >= itemLength + quantityLength + weightBarcodePrefix.Length)
                    {
                        var bc = insertedData.Substring(weightBarcodePrefix.Length, itemLength);
                        if (!string.IsNullOrEmpty(_settingService.ProgramSettings.WeightBarcodeItemFormat))
                        {
                            int integerValue;
                            int.TryParse(bc, out integerValue);
                            if (integerValue > 0)
                                bc = integerValue.ToString(_settingService.ProgramSettings.WeightBarcodeItemFormat);
                        }
                        var qty = insertedData.Substring(weightBarcodePrefix.Length + itemLength, quantityLength);
                        if (bc.Length > 0 && qty.Length > 0)
                        {
                            insertedData = bc;
                            decimal.TryParse(qty, out quantity);
                        }
                    }
                }
                try
                {
                    var mi = _cacheService.GetMenuItem(x => x.Barcode == insertedData);
                    if (mi != null)
                    {
                        var si = new ScreenMenuItem { MenuItemId = mi.Id, Name = mi.Name };
                        var data = new ScreenMenuItemData { ScreenMenuItem = si, Quantity = quantity };
                        data.PublishEvent(EventTopicNames.ScreenMenuItemDataSelected);
                    }
                }
                catch (Exception) { }
            }
        }
        public void AddOrder(ScreenMenuItemData data)
        {
            var ti = AddOrder(data.ScreenMenuItem.MenuItemId, data.Quantity, data.ScreenMenuItem.ItemPortion, data.ScreenMenuItem.OrderTagTemplate);

            if (data.ScreenMenuItem.AutoSelect && ti != null)
            {
                ti.ItemSelectedCommand.Execute(ti);
            }
        }
        private void FindMenuItem()
        {
            var insertedData = NumeratorValue;
            decimal quantity = 1;
            var separator = _settingService.ProgramSettings.QuantitySeparators.Split(',').FirstOrDefault(x => NumeratorValue.Contains(x));
            if (!string.IsNullOrEmpty(separator))
            {
                insertedData = NumeratorValue.Substring(NumeratorValue.IndexOf(separator, StringComparison.Ordinal) + 1);
                var q = NumeratorValue.Substring(0, NumeratorValue.IndexOf(separator, StringComparison.Ordinal));
                decimal.TryParse(q, out quantity);
            }
            NumeratorValue = "";

            if (quantity <= 0) return;

            var weightBarcodePrefix = _settingService.ProgramSettings.WeightBarcodePrefix;
            if (!string.IsNullOrEmpty(weightBarcodePrefix) && insertedData.StartsWith(weightBarcodePrefix))
            {
                var itemLength = _settingService.ProgramSettings.WeightBarcodeItemLength;
                var quantityLength = _settingService.ProgramSettings.WeightBarcodeQuantityLength;
                if (itemLength > 0 && quantityLength > 0 && insertedData.Length >= itemLength + quantityLength + weightBarcodePrefix.Length)
                {
                    var bc = insertedData.Substring(weightBarcodePrefix.Length, itemLength);
                    if (!string.IsNullOrEmpty(_settingService.ProgramSettings.WeightBarcodeItemFormat))
                    {
                        int integerValue;
                        int.TryParse(bc, out integerValue);
                        if (integerValue > 0)
                            bc = integerValue.ToString(_settingService.ProgramSettings.WeightBarcodeItemFormat);
                    }
                    var qty = insertedData.Substring(weightBarcodePrefix.Length + itemLength, quantityLength);
                    if (bc.Length > 0 && qty.Length > 0)
                    {
                        insertedData = bc;
                        decimal.TryParse(qty, out quantity);
                    }
                }
            }

            var mi = _cacheService.FindMenuItemByBarcode(insertedData);
            if (mi != null)
            {
                var si = new ScreenMenuItem { MenuItemId = mi.Id, Name = mi.Name };
                var data = new ScreenMenuItemData { ScreenMenuItem = si, Quantity = quantity };
                data.PublishEvent(EventTopicNames.ScreenMenuItemDataSelected);
            }
            else
                _applicationState.NotifyEvent(RuleEventNames.NumberpadValueEntered, new { Ticket = SelectedTicket, Value = insertedData });
        }
Esempio n. 6
0
        private void OnAddMenuItemCommandExecute(ScreenMenuItemData obj)
        {
            if (SelectedTicket == null)
            {
                OpenTicket(0);
                RefreshVisuals();
            }

            Debug.Assert(SelectedTicket != null);

            if (SelectedTicket.IsLocked && !_userService.IsUserPermittedFor(PermissionNames.AddItemsToLockedTickets)) return;

            var ti = AddNewItem(obj.ScreenMenuItem.MenuItemId, obj.Quantity, obj.ScreenMenuItem.ItemPortion, obj.ScreenMenuItem.OrderTagTemplate);

            if (obj.ScreenMenuItem.AutoSelect && ti != null)
            {
                ti.ItemSelectedCommand.Execute(ti);
            }

            RefreshSelectedTicket();
        }