Esempio n. 1
0
    public void CheckItem()
    {
        string held = coco.held;

        if (string.IsNullOrEmpty(held) && !string.IsNullOrEmpty(pickup))
        {
            coco.AddItem(pickup);
            TextManager.DisplayText(success);
            Destroy(gameObject);
        }
        else if (!string.IsNullOrEmpty(held) && !string.IsNullOrEmpty(use) && held == use)
        {
            coco.RemoveItem(held);
            if (door != null)
            {
                Destroy(door);
                updateRoom.UpdateRoom(true);
            }
            if (!string.IsNullOrEmpty(usePickup))
            {
                coco.AddItem(usePickup);
            }
            TextManager.DisplayText(success);
            Destroy(gameObject);
        }
        else
        {
            TextManager.DisplayText(fail);
            coco.unequip();
        }
    }
Esempio n. 2
0
    public void BuyBoot()
    {
        if (!playerMoney.CheckEnoughMoney(bootPrice))
        {
            return;
        }

        if (itemManager.AddItem(new SpeedBoost(speedBoostSprite)))
        {
            playerMoney.UseMoney(bootPrice);
        }
    }
Esempio n. 3
0
 public ActionResult AdminItemCreate(ItemCreateViewModel newItem)
 {
     try
     {
         itemManager.AddItem(newItem.Name, newItem.Type, newItem.SelectedOrganizationId, newItem.StringKeywords, newItem.TwitterUrl);
         return(RedirectToAction("AdminItemIndex"));
     }
     catch
     {
         return(View(newItem));
     }
 }
Esempio n. 4
0
        public void InsertOperation()
        {
            var itMan = new ItemManager(mockRepository.Object);

            var resultNorm = itMan.AddItem(testItem);
            var resultNull = itMan.AddItem(null);

            testItem = new Item(1, DateTime.Now, "", "King");
            var resultNotValidManufacturer = itMan.AddItem(testItem);

            Assert.True(resultNorm);
            Assert.False(resultNull);
            Assert.False(resultNotValidManufacturer);
        }
Esempio n. 5
0
 private void AddButton_Click(object sender, EventArgs e)
 {
     try
     {
         _item.Name       = textBoxItem.Text;
         _item.Price      = Convert.ToInt32(textBoxPrice.Text);
         _item.SearchName = textBoxSearch.Text;
         DataTable isSearch = _itemManager.SearchItem(_item);
         if (isSearch.Rows.Count > 0)
         {
             MessageBox.Show("Item Name Exists");
         }
         else
         {
             bool isAdded = _itemManager.AddItem(_item);
             if (isAdded)
             {
                 MessageBox.Show("Saved");
             }
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
        public ActionResult Create(Item item)
        {
            HttpPostedFileBase file = Request.Files["myFile"];

            ViewBag.ItemTypes = _itemTypes;

            if (ModelState.IsValid)
            {
                try
                {
                    if (file != null)
                    {
                        string path = Path.Combine(Server.MapPath("/Content/Photos/"), Path.GetFileName(file.FileName));
                        file.SaveAs(path);
                        item.Picture = file.FileName;
                    }

                    if (_itemManager.AddItem(item))
                    {
                        return(RedirectToAction("Index"));
                    }
                }
                catch
                {
                    return(View());
                }
            }
            return(View(item));
        }
    public GameObject GetItemFromContainer()
    {
        GameObject itemToReturn;

        //If the player is not carrying things
        if (itemCount > 0)
        {
            itemToReturn = Instantiate(emptyItemPrefab, FindObjectOfType <ItemManager>().transform);
            itemToReturn.GetComponent <ItemObject>().SetItemData(itemType);
            if (itemToReturn.GetComponent <ItemObject>().GetItemData().GetName() != "")
            {
                itemToReturn.name = itemToReturn.GetComponent <ItemObject>().GetItemData().GetName() + itemToReturn.name;
            }
            if (itemToReturn.GetComponent <ItemObject>().GetItemData().GetSprite() != null)
            {
                itemToReturn.GetComponent <SpriteRenderer>().sprite = itemToReturn.GetComponent <ItemObject>().GetItemData().GetSprite();
            }
            im.AddItem(itemToReturn.GetComponent <ItemObject>());
            itemCount--;
            EmptyCheck();
            return(itemToReturn);
        }
        else
        {
            return(null);
        }
    }
Esempio n. 8
0
        public ActionResult SaveItem(Item item)
        {
            if (Request.IsAuthenticated)
            {
                if (ModelState.IsValid)
                {
                    item.ActionDate = DateTime.Now.ToString();
                    item.ActionType = ActionType.Insert;
                    item.ActionBy   = ActionType.User;

                    ViewBag.Response = itemManager.AddItem(item);
                }
                else
                {
                    ViewBag.Response = 3;
                }

                ViewBag.Companies  = companyManager.GetCompaniesForDropDown();
                ViewBag.Categories = categoryManager.GetCategoriesForDropDown();

                ModelState.Clear();
                return(View());
            }
            else
            {
                return(HttpNotFound());
            }
        }
Esempio n. 9
0
 public void Initialize(Material Gunmaterial, ItemManager itemManager)
 {
     this.Gunmaterial = Gunmaterial;
     foreach (var gun in _gun)
     {
         itemManager.AddItem(gun);
     }
 }
Esempio n. 10
0
    public void Initialize(TrailRenderer[] trailRenderer, ItemManager itemManager)
    {
        this.trailRenderers = trailRenderer;

        foreach (var trail in _trail)
        {
            itemManager.AddItem(trail);
        }
    }
Esempio n. 11
0
    // Use this for initialization
    void Start()
    {
        Manager <Player> .Add("Player", new Player());

        ContentParser.InsertReplace("%class%", "warrior");
        ContentParser.InsertReplace("%Class%", "Warrior");
        ItemManager.AddItem(new Item(0, new ItemDataStack("test", ItemType.A, new Stats(), ContentParser.ReplaceFromList("hello, %class%"), Resources.LoadAll <Sprite> ("Images/Items/items-3")[0], 100)));
        ItemManager.AddItem(new Item(1, new ItemDataVisual("test2", ItemType.A, new Stats(), "description2", Resources.LoadAll <Sprite> ("Images/Items/items-3")[1])));
    }
Esempio n. 12
0
        static void Main(string[] args)
        {
            MenuActionService actionService = new MenuActionService();
            IService <Item>   itemService   = new ItemService();
            ItemManager       itemManager   = new ItemManager(actionService, itemService);

            //Welcome User
            Console.WriteLine("Welcome to the Collection Manager!");
            while (true)
            {
                //Giving user a choice what to do next
                Console.WriteLine("\r\nPlease, choose your next action:");
                var mainMenu = actionService.GetMenuActionsByMenuName("Main");
                for (int i = 0; i < mainMenu.Count; i++)
                {
                    Console.WriteLine($"{mainMenu[i].Id}. {mainMenu[i].Name}");
                }

                var operation = Console.ReadKey();

                //Proccessing users decision
                switch (operation.KeyChar)
                {
                case '1':
                    var item = itemManager.CreateItem();
                    itemManager.AddItem(item);
                    break;

                case '2':
                    var itemToRemove = itemManager.ChooseRemoveItem();
                    itemManager.RemoveItem(itemToRemove);
                    break;

                case '3':
                    itemManager.EditExistingItem();
                    break;

                case '4':
                    var typeId = itemManager.GetItemsTypeId();
                    var toShow = itemManager.GetItemsOfTheSameType(typeId);
                    if (toShow.Any())
                    {
                        itemManager.ShowItemsOfSameType(toShow);
                    }
                    else
                    {
                        Console.WriteLine("\r\nCollection is empty");
                    }
                    break;

                default:
                    Console.WriteLine("\r\nAction you entered does not exist");
                    break;
                }
            }
        }
Esempio n. 13
0
        /// <summary>
        ///AddItem 的测试
        ///</summary>
        public void AddItemTestHelper <T>()
            where T : BaseItem
        {
            ItemManager <T> target = new ItemManager <T>(); // TODO: 初始化为适当的值
            long            itemId = 0;                     // TODO: 初始化为适当的值
            T itemT = default(T);                           // TODO: 初始化为适当的值

            target.AddItem(itemId, itemT);
            Assert.Inconclusive("无法验证不返回值的方法。");
        }
Esempio n. 14
0
 public ActionResult Create(ItemModel itemCreate)
 {
     try
     {
         Item newItem = Utility.convertSrcToTarget <ItemModel, Item>(itemCreate);
         ItemManager.AddItem(newItem, "nirshan");
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 15
0
        protected void saveItemButton_Click(object sender, EventArgs e)
        {
            if (categoryDropDownList.SelectedIndex > 0 && companyDropDownList.SelectedIndex > 0 &&
                itemNameTextBox.Text != "")
            {
                if (System.Text.RegularExpressions.Regex.IsMatch(itemNameTextBox.Text, "^[a-zA-Z]"))
                {
                    if (System.Text.RegularExpressions.Regex.IsMatch(reorderLevelTextBox.Text, "^[0-9]+$") ||
                        reorderLevelTextBox.Text == "")
                    {
                        int Quantity     = 0;
                        int reorderLevel = 0;

                        ItemModel aAddItem = new ItemModel();
                        aAddItem.CategoryId = Convert.ToInt32(categoryDropDownList.SelectedValue);
                        aAddItem.CompanyId  = Convert.ToInt32(companyDropDownList.SelectedValue);
                        aAddItem.ItemName   = itemNameTextBox.Text;

                        if (reorderLevelTextBox.Text != "")
                        {
                            reorderLevel = Convert.ToInt32(reorderLevelTextBox.Text);
                        }
                        aAddItem.ReorderLevel = reorderLevel.ToString();
                        aAddItem.Quantity     = Quantity;

                        string message = itemManager.AddItem(aAddItem);
                        outputLabel.Text      = aAddItem.ItemName + " " + message;
                        outputLabel.ForeColor = Color.Red;

                        if (message == "Item Added Successfully")
                        {
                            ClearTextBox();
                        }
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Oops!", "VaidationMsg()", true);
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Oops!", "VaidationMsg1()", true);
                }
            }
            else
            {
                outputLabel.Text      = "Please Select Category Name, Company Name and Enter an Item Name";
                outputLabel.ForeColor = Color.Red;
            }
        }
        public string AddItem(string itemName = "", string image = "", string description = "", double price     = 0, int categoryId = 0,
                              int clickCount  = 0, int stock     = 0, DateTime dateAdd    = default, double cost = 0, int sold       = 0, int discount = 0)
        {
            Response response = new Response();

            response.status = false;
            //判断用户权限
            int  nowUserId  = Convert.ToInt32(HttpContext.Session.GetInt32("id"));
            bool nowIsadmin = Convert.ToBoolean(HttpContext.Session.GetString("admin"));

            if (nowUserId != 0 && nowIsadmin)
            {
                if (!Tool.IsNullOrEmpty(itemName, image, description))
                {
                    Item item = new Item();
                    item.Item_Name    = itemName;
                    item.Image_Url    = image;
                    item.Description  = description;
                    item.Item_Price   = price;
                    item.Category_ID  = categoryId;
                    item.Click_Counts = clickCount;
                    item.Stock        = stock;
                    item.Date_added   = dateAdd;
                    item.Cost         = cost;
                    item.Sold         = sold;
                    item.Discount     = discount;

                    bool result = ItemManager.AddItem(item);
                    if (result)
                    {
                        response.status  = true;
                        response.message = "添加成功";
                    }
                    else
                    {
                        response.message = "添加失败,请联系管理员";
                    }
                }
                else
                {
                    response.message = "添加失败,请检查资料是否填写完整";
                }
            }
            else
            {
                response.message = "没有权限";
            }
            return(JsonConvert.SerializeObject(response));
        }
Esempio n. 17
0
        /// <summary>
        /// remove if blockstate is broken
        /// </summary>
        /// <param name="ball"></param>
        private void RemoveDisabledBlocks(Block block)
        {
            //remove disabled blocks

            TeamColor team        = block.ScoredTeam;
            IItem     spawnedItem = block.SpawnItem();

            if (spawnedItem != null)
            {
                itemManager.AddItem(spawnedItem);
            }
            Blocks.Remove(block);
            ScoreManager.Score[(int)team]++;
            currentScore++;
        }
Esempio n. 18
0
        public void CanAddItem()
        {
            //Arrange
            Item item = new Item(1, "Gold coin", 1);
            var  mock = new Mock <IService <Item> >();

            var manager = new ItemManager(new MenuActionService(), mock.Object);

            //Act
            var itemId = manager.AddItem(item);

            //Assert
            itemId.Should().NotBe(null);
            itemId.Should().Equals(item.Id);
        }
Esempio n. 19
0
    private void DropItem()
    {
        Vector2 offset = new Vector2(Random.Range(-0.5f, 0.5f), 0);
        var     theOne = Instantiate(emptyItemPrefab, (Vector2)transform.position + offset, Quaternion.identity, FindObjectOfType <ItemManager>().transform);

        theOne.GetComponent <ItemObject>().SetItemData(itemData[Random.Range(0, itemData.Count - 1)]);
        if (theOne.GetComponent <ItemObject>().GetItemData().GetName() != "")
        {
            theOne.name = theOne.GetComponent <ItemObject>().GetItemData().GetName() + theOne.name;
        }
        if (theOne.GetComponent <ItemObject>().GetItemData().GetSprite() != null)
        {
            theOne.GetComponent <SpriteRenderer>().sprite = theOne.GetComponent <ItemObject>().GetItemData().GetSprite();
        }
        im.AddItem(theOne.GetComponent <ItemObject>());
    }
Esempio n. 20
0
        public void CanRemoveItem()
        {
            //Arrange
            Item item = new Item(1, "Gold coin", 1);
            var  mock = new Mock <IService <Item> >();

            var manager = new ItemManager(new MenuActionService(), mock.Object);
            var itemId  = manager.AddItem(item);

            //Act
            var removedId = manager.RemoveItem(item);

            //Assert
            removedId.Should().Equals(itemId);
            mock.Object.Items.Should().BeNull();
        }
Esempio n. 21
0
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     createNewItem();
     try
     {
         var result = _itemManager.AddItem(_newItem);
         if (result == true)
         {
             MessageBox.Show("Item Added successfully");
             this.DialogResult = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Add Failed.");
     }
 }
Esempio n. 22
0
        protected void addBtn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(nameTxtBox.Text))
            {
                lblerrormsg.Text = "Name cannot be empty.";
                nameTxtBox.Focus();
                return;
            }

            if (string.IsNullOrEmpty(ppriceTxtBox.Text))
            {
                lblerrormsg.Text = "Purchase price cannot be empty.";
                ppriceTxtBox.Focus();
                return;
            }

            if (string.IsNullOrEmpty(spriceTxtBox.Text))
            {
                lblerrormsg.Text = "Sales price cannot be empty.";
                spriceTxtBox.Focus();
                return;
            }

            if (string.IsNullOrEmpty(qtyTxtBox.Text))
            {
                lblerrormsg.Text = "Quantity cannot be empty.";
                qtyTxtBox.Focus();
                return;
            }

            ItemOrProduct obj = new ItemOrProduct();

            obj.ItemID        = Guid.NewGuid();
            obj.Name          = nameTxtBox.Text;
            obj.PurchasePrice = decimal.Parse(ppriceTxtBox.Text);
            obj.SalesPrice    = decimal.Parse(spriceTxtBox.Text);
            obj.OpeningQty    = double.Parse(qtyTxtBox.Text);

            bool status = ItemManager.AddItem(obj);

            if (status)
            {
                bool message = true;
                Response.Redirect("~/Web/Item/ItemList.aspx?status=" + message);
            }
        }
        private void addButton_Click(object sender, EventArgs e)
        {
            searchNameTextBox.Clear();


            _item.Name = nameTextBox.Text;

            if (String.IsNullOrEmpty(_item.Name))
            {
                MessageBox.Show(@"Enter item name");
                nameTextBox.Focus();
                return;
            }

            if (String.IsNullOrEmpty(priceTextBox.Text))
            {
                MessageBox.Show(@"Enter item price");
                priceTextBox.Focus();
                return;
            }


            if (_itemManager.UniqueItemName(_item))
            {
                MessageBox.Show(@"Item name already exits");
                return;
            }


            _item.Price = Convert.ToDouble(priceTextBox.Text);

            //call method
            bool isAdded = _itemManager.AddItem(_item);

            if (isAdded)
            {
                showDataGridView.DataSource = _itemManager.Display();
                MessageBox.Show(@"Saved Successfully");
            }
            else
            {
                MessageBox.Show(@"Save failed");
            }
            ClearAllInputField();
        }
        public void Process()
        {
            //Create Templates
            //Create Layouts
            //Create Items
            //Any other configuration data
            var           textTemplate            = TemplateManager.AddTemplate("Text Only", IDs.Types.BaseModule, Ids.TemplateBase, IDs.Types.OnlyText.Type);
            var           fieldSectionDataSection = ItemManager.AddItem("Data", Ids.Editor.Type.System.Types.FieldSectionTemplate, IDs.Types.OnlyText.Type, CreekWorm.Kernel.Items.ItemType.Item | CreekWorm.Kernel.Items.ItemType.System, IDs.Types.OnlyText.DataSection);
            TemplateField nameField = TemplateField.New("Name", Ids.Editor.Type.System.Fields.TextField, IDs.Types.OnlyText.NameField);

            TemplateManager.AddTemplateField(nameField, fieldSectionDataSection.Id);

            var           listTemplate = TemplateManager.AddTemplate("SimpleList", IDs.Types.BaseModule, Ids.TemplateBase, IDs.Types.OnlyText.Type);
            var           dataSection  = ItemManager.AddItem("Data", Ids.Editor.Type.System.Types.FieldSectionTemplate, IDs.Types.OnlyText.Type, CreekWorm.Kernel.Items.ItemType.Item | CreekWorm.Kernel.Items.ItemType.System, IDs.Types.OnlyText.DataSection);
            TemplateField titleField   = TemplateField.New("Title", Ids.Editor.Type.System.Fields.TextField, IDs.Types.OnlyText.NameField);

            TemplateManager.AddTemplateField(nameField, dataSection.Id);
        }
Esempio n. 25
0
        internal void SpawnItems()
        {
            int x, y;

            do
            {
                x = Randomizer.Between(0, Width - 1);
                y = Randomizer.Between(0, Height - 1);

                if (!Tiles[x, y].IsObstacle)
                {
                    var weapon = new Weapon("Test Gun", WeaponType.Handgun, 10, 12);
                    ItemManager.AddItem(weapon);

                    Tiles[x, y] = Tiles[x, y].UpdateItem(weapon);
                    break;
                }
            }while (Tiles[x, y].IsObstacle);
        }
Esempio n. 26
0
        private void addButton_Click(object sender, EventArgs e)
        {
            _item.Name  = addItemNameTextBox.Text;
            _item.Price = addItemPriceTextBox.Text;

            if (String.IsNullOrEmpty(_item.Name) || String.IsNullOrEmpty(_item.Price))
            {
                MessageBox.Show("Both name and price must be inserted!");
                return;
            }
            if (_itemManager.IsItemExist(_item))
            {
                MessageBox.Show("Item " + _item.Name + " already exists in your database!");
                return;
            }

            if (_itemManager.AddItem(_item))
            {
                MessageBox.Show("Item " + addItemNameTextBox.Text + " added Successfully!");
            }
        }
Esempio n. 27
0
        /// <summary>
        /// 初始化玩家
        /// </summary>
        static void IniPlayer()
        {
            player = player.IniPlayer(name, 500, 200, 10, 10, 1);
            player.AddSkill(Skill.SkillCreateNormalAttack("蓄力一击", 5));
            player.AddSkill(Skill.CreateDamageSkill("光速次元斩", 20, 10));
            player.AddSkill(Skill.CreateHealSkill("吃血瓶", 50, 100));
            player.AddSkill(Skill.CreateDeBuffSkill("灼烧", 10, 10, 3));
            player.AddSkill(Skill.CreateInvincibleSkill("无敌", 100, 3));

            Bag.AddItem(Item.CreateConsumable(1, "大血瓶", 100, 0, 100, "里面存放了不知名的红色液体,甚至有点发霉,喝下却能恢复100点生命值", 10));
            Bag.AddItem(Item.CreateConsumable(2, "大蓝瓶", 0, 100, 100, "里面存放了不知名的蓝色液体,甚至有点发霉,喝下却能恢复100点魔法值", 10));
            Bag.AddItem(Item.CreateEquip(3, "木剑", 0, 0, 10, 0, 100, EquipType.Hand, "一把木剑,装备后提高10点攻击力,感觉除了鸡什么也杀不死"));
            Bag.AddItem(Item.CreateEquip(4, "草帽", 10, 0, 0, 5, 100, EquipType.Head, "一顶草帽,装备后提高10点生命,5点防御力,也就挡挡叶子"));
            Bag.AddItem(Item.CreateEquip(5, "布衣", 50, 50, 0, 20, 100, EquipType.Body, "一件布衣,装备后提高50点生命值,50点魔法值,20点防御力,非常轻,感觉奸商肯定偷工减料了"));
            Bag.AddItem(Item.CreateEquip(6, "布鞋", 10, 0, 0, 5, 100, EquipType.Shoes, "一双布鞋,装备后提高10点生命值,5点防御力,感觉还不如光脚实在"));
        }
Esempio n. 28
0
    /// <summary>
    /// handles when a player is next to it
    /// </summary>
    /// <param name="collision"></param>
    private void OnTriggerStay2D(Collider2D collision)
    {
        ItemManager player = collision.GetComponent <ItemManager>();   //grab Movement data from collision

        if (collision.tag == "Player" && filled && (player.grab == 1)) //if collision is with a player & grab is held down
        {
            if (player.AddItem(stocked_item))
            {
                filled = false;
                Debug.Log("grabbed");

                //if the ShelfManager is attached to a floor item, delete it
                if (emptyimage == null)
                {
                    Destroy(gameObject);
                }
                else //else, show the empty sprite
                {
                    obj.sprite = emptyimage;
                }
            }
        }
    }
Esempio n. 29
0
    void Start()
    {
        //Initializing the player's items
        itemManager = gameObject.AddComponent<ItemManager>();
        GameObject soap = Resources.Load("soap") as GameObject;
        GameObject chlorine = Resources.Load("chlorineDrop") as GameObject;
        itemManager.AddItem(soap.GetComponent<Item>(), 10);
        itemManager.AddItem(chlorine.GetComponent<Item>(), 10);

        itemManager.DisplayCurrentItem(); //showing the first item on screen

        isWearingSandals = false; //telling the game that the player doesn't have sandals yet

        health = originalHealth; //setting current health to the base health

        //if we are in the main game, show the player on screen
        if (Application.loadedLevelName == "mainGame")
        {
            playerInstance =
                Instantiate
                    (
                        Resources.Load("Player") as GameObject,
                        Vector2.zero,
                        Quaternion.identity
                    ) as GameObject;
            playerInstanceSpriteRenderer = playerInstance.GetComponent<SpriteRenderer>();
        }

        //show the initial score and health
        GameController.UpdateScoreText();
        GameController.UpdateHealthText();
    }
 public void ClickMethodAdd()
 {
     player.PlayList.Add(ItemManager.AddItem());
 }
        private void NewItem()
        {
            view.Clear();
            view.ShowMessage("Enter the product name:");
            string prodname = Console.ReadLine();

            while (prodname.Length < 2)
            {
                view.ShowError("Please enter a suitable length name");
                prodname = Console.ReadLine();
            }
            view.ShowMessage("Please enter the product description");
            string proddesc = Console.ReadLine();

            while (proddesc.Length < 5)
            {
                view.ShowError("Please enter a suitable length description");
            }
            view.ShowMessage("Please enter the product price");
            string prodprice = Console.ReadLine();
            float  price;

            while (!float.TryParse(prodprice, out (price)))
            {
                view.ShowError("Please enter a valid price.");
                prodprice = Console.ReadLine();
            }
            view.ShowMessage("Please enter 0 for food (kitchen) item, or 1 for drink (bar) item:");
            string prodtype = Console.ReadLine();
            int    itemType;
            bool   status = int.TryParse(prodtype, out (itemType));

            while (status == false || !(itemType == 1 || itemType == 0))
            {
                view.ShowError("Please enter a valid option.");
                prodtype = Console.ReadLine();
                status   = int.TryParse(prodtype, out (itemType));
            }
            // should have valid product specs. Lets create (and write):
            // get next valid item ID from the DB:
            int itemId = DBManager.GetNextProductId();

            if (itemType == 1)
            {
                // drink item

                DrinkItem createdDrink = new DrinkItem(itemId, prodname, proddesc, price);
                itemManager.AddItem(createdDrink);
                DBManager.AddProduct(createdDrink);
            }
            else if (itemType == 0)
            {
                // food item
                FoodItem createdFood = new FoodItem(itemId, prodname, proddesc, price);
                itemManager.AddItem(createdFood);
                DBManager.AddProduct(createdFood);
            }
            else
            {
                // shouldn't get here.
                throw new ArgumentOutOfRangeException();
            }
            Show();
        }