Esempio n. 1
0
        public StaticDataStore()
        {
            var baseDefence = new DefenceDice(new GreyDie());

            Hero     = new Hero("Leoric", 4, 8, 5, baseDefence, 1, 5, 3, 2, 0);
            MainHand = GetWeoponItems();
            OffHand  = new List <ShieldItem> {
                new ShieldItem("Standard Shield", new Ability[0])
            };
            Armor = new List <ArmorItem> {
                new ArmorItem("Brown Armor", new DefenceDice(new BrownDie()),
                              ItemCatagory.LightArmor, new Ability[0]),
                new ArmorItem("Grey Armor", new DefenceDice(new GreyDie()),
                              ItemCatagory.MediumArmor, new Ability[0]),
                new ArmorItem("Black Armor", new DefenceDice(new BlackDie()),
                              ItemCatagory.HeavyArmor, new Ability[0])
            };
            var c = new ItemCatagory[] { ItemCatagory.Ring };

            Trinket = new List <TrinketItem> {
                new TrinketItem("Pretty Ring", c, new Ability[0]),
                new TrinketItem("Ugly Ring", c, new Ability[0])
            };
        }
Esempio n. 2
0
        void AddItemToDB(string barcode, string description, decimal rrp, int stockLevel, ItemCatagory itemCatagory)
        {
            var item = UIObjectCreator.CreateNewItem(barcode, description, rrp, stockLevel, itemCatagory);

            if (item == null)
            {
                //Item wasn't added, set all input fields to default
                MessageBox.Show("Something went wrong.\nThat item was not added.\nTry again.");
                SetToDefault();
            }
            else
            {
                MessageBox.Show("Item was succesfully added to the database.");
                SetToDefault();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Will return a new Item
        /// Which has been commited to database
        /// Assumes weaklyQuantitySaleRate
        /// Is 0
        /// </summary>
        /// <param name="_Barcode"></param>
        /// <param name="_Description"></param>
        /// <param name="_RRP"></param>
        /// <param name=""></param>
        /// <returns></returns>
        public static Item CreateNewItem(string _Barcode, string _Description, decimal _RRP, int _QuantityStockLevel, ItemCatagory _Catagory)
        {
            using (var dbContext = new InventoryContext())
            {
                //makes sure description "AllRevenue" cannot be used for an item
                //this is a special case for combobox on analyticsgraph page
                if (_Description != "AllRevenue")
                {
                    var newItem = new Item()
                    {
                        Barcode                = _Barcode,
                        Description            = _Description,
                        RRP                    = _RRP,
                        QuantityStockLevel     = _QuantityStockLevel,
                        QuantityWeaklySaleRate = 0,
                        Catagory               = _Catagory
                    };

                    dbContext.Items.Add(newItem);
                    dbContext.SaveChanges();

                    return(newItem);
                }
                else
                {
                    return(null);
                }
            }
        }