コード例 #1
0
        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) { }
            }
        }
コード例 #2
0
 private void OnTypeValueExecute(string obj)
 {
     if (obj == "\r")
     {
         if (_filtered && MenuItems.Count == 1)
         {
             MenuItemCommand.Execute(MenuItems[0].ScreenMenuItem);
         }
         FindMenuItemCommand.Execute("");
     }
     else if (obj == "\b" && !string.IsNullOrEmpty(NumeratorValue))
     {
         NumeratorValue = NumeratorValue.Substring(0, NumeratorValue.Length - 1);
     }
     else if (!string.IsNullOrEmpty(obj) && !Char.IsControl(obj[0]))
     {
         NumeratorValue = obj == "C" ? "" : Helpers.AddTypedValue(NumeratorValue, obj, "#0.");
     }
 }
コード例 #3
0
 public override int GetHashCode()
 {
     return(NumeratorValue.GetHashCode() ^ DenominatorValue.GetHashCode());
 }
コード例 #4
0
        private void FindMenuItem()
        {
            var     insertedData = NumeratorValue;
            decimal quantity     = 1;

            if (NumeratorValue.ToLower().Contains("x"))
            {
                insertedData = NumeratorValue.Substring(NumeratorValue.ToLower().IndexOf("x") + 1);
                var q = NumeratorValue.Substring(0, NumeratorValue.ToLower().IndexOf("x"));
                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 });
            }
        }