Ejemplo n.º 1
0
        /// <summary>
        /// Checks if the item has a property in POSSIBLE_OPTIONS and if so adds a checkbox or combo box for that property
        /// Binds that box to the property as well
        /// </summary>
        /// <param name="item"></param>
        public void LoadOptionsForItem(IOrderItem item)
        {
            label.Content = $"Customization Window for {item.DisplayName}";

            this.DataContext = item;
            // if this item is a combo item
            // load choice of entree, side, and drink
            if (item is Combo combo)
            {
                AddComboItemPanel(BleakwindBuffet.Data.Menu.EntreeTypes());
                AddComboItemPanel(BleakwindBuffet.Data.Menu.SideTypes());
                AddComboItemPanel(BleakwindBuffet.Data.Menu.DrinkTypes());
            }
            else
            {
                foreach (var property in item.GetType().GetProperties())
                {
                    if (property == null)
                    {
                        continue;
                    }

                    string option = property.Name;

                    if (property.PropertyType == typeof(Boolean))
                    {
                        AddCheckBox(property, option, (bool)property.GetValue(item));
                    }
                    else if (property.PropertyType == typeof(Size))
                    {
                        AddComboBox(property, Sizes.GetSizes());
                    }
                    else if (property.PropertyType == typeof(SodaFlavor))
                    {
                        AddComboBox(property, SodaFlavors.GetFlavors());
                    }
                }
            }
        }
Ejemplo n.º 2
0
    private void PopulateLookups()
    {
        //categories checkbox
        var _cat = new Categories();

        _cat.GetCategories();

        foreach (Category t in _cat)
        {
            ListItem li = new ListItem(t.CatName, t.Id.ToString());
            this.cbCat.Items.Add(li);
        }


        //Fixed Sizes checkbox
        var _sizes = new Sizes();

        _sizes.GetSizes();

        foreach (Size s in _sizes)
        {
            ListItem li = new ListItem(s.SizeCode, s.SizeId.ToString());
            this.cbSizes.Items.Add(li);
        }


        var _pro = new Products();

        _pro.GetProducts(null);

        this.ddlProducts.Items.Add(new ListItem("New Product", "-1"));
        foreach (Product p in _pro)
        {
            ListItem li = new ListItem(p.ProductName, p.ProductId.ToString());
            this.ddlProducts.Items.Add(li);
        }
    }