Ejemplo n.º 1
0
        private bool CheckItem(ItemWithCategory item)
        {
            if (Global.Database.Select <Stock>("stock", new Dictionary <string, object>()
            {
                { "ItemID", item.ID }
            }).Count > 0)
            {
                return(false);
            }

            if (Global.Database.Select <Shipment>("shipment", new Dictionary <string, object>()
            {
                { "ItemID", item.ID }
            }).Count > 0)
            {
                return(false);
            }

            if (Global.Database.Select <PartnerShipment>("partnershipment", new Dictionary <string, object>()
            {
                { "ItemID", item.ID }
            }).Count > 0)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public ItemEditForm(ItemWithCategory edit)
            : this()
        {
            _edit = edit;

            tbName.Text        = edit.Name;
            tbDescription.Text = edit.Description;
            tbPrice.Text       = edit.Price.ToString();
        }
Ejemplo n.º 3
0
        private void btnNewItem_Click(object sender, System.EventArgs e)
        {
            using (ItemEditForm edit = new ItemEditForm())
            {
                if (edit.ShowDialog(this) == DialogResult.OK)
                {
                    ItemWithCategory newItem = edit.EditedItem;

                    if (Global.Database.InsertInto <Item>("item", newItem))
                    {
                        DataGridManager.AddDataGridEntry <ItemWithCategory>(gridItems, newItem);
                    }
                    else
                    {
                        Error("Hiba a(z) \"" + edit.EditedItem.Name + "\" hozzáadása közben!", "Hiba!");
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void LoadItemsTab()
        {
            int selectedEntryID = -1;

            if (gridItems.SelectedRows.Count > 0)
            {
                selectedEntryID = ((ItemWithCategory)gridItems.SelectedRows[0].Tag).ID;
            }

            DataGridManager.AddDataGridEntries <ItemWithCategory>(gridItems, ComplexQueries.GetItemsWithCategories(), true, new Action <DataGridViewRow>(
                                                                      (DataGridViewRow row) =>
            {
                ItemWithCategory sum = (ItemWithCategory)row.Tag;

                if (selectedEntryID != -1 && sum.ID == selectedEntryID)
                {
                    row.Selected = true;
                }
            }
                                                                      ));
        }
Ejemplo n.º 5
0
        private void btnDeleteItem_Click(object sender, System.EventArgs e)
        {
            DataGridViewRow[] selected = new DataGridViewRow[gridItems.SelectedRows.Count];
            gridItems.SelectedRows.CopyTo(selected, 0);

            foreach (DataGridViewRow row in selected)
            {
                ItemWithCategory item = (ItemWithCategory)row.Tag;

                if (!CheckItem(item))
                {
                    Warning("A \"" + item.Name + "\" nem törölhető mert 1 vagy több helyen is használva van!", "Hiba");
                    continue;
                }

                if (!Global.Database.DeleteFrom <Item>("item", item))
                {
                    Error("Hiba a sor törlése közben! \"" + item.Name + "\"", "Hiba!");
                    return;
                }

                gridItems.Rows.Remove(row);
            }
        }
Ejemplo n.º 6
0
        //GET - INVENTORY
        public IActionResult Inventory(int?id)
        {
            if (id == null || id == 0)
            {
                return(NotFound());
            }
            ItemWithCategory _headItem     = new ItemWithCategory();
            ItemWithCategory _chestItem    = new ItemWithCategory();
            ItemWithCategory _handItem     = new ItemWithCategory();
            ItemWithCategory _feetItem     = new ItemWithCategory();
            ItemWithCategory _ringItem     = new ItemWithCategory();
            ItemWithCategory _necklaceItem = new ItemWithCategory();
            List <Ninja>     ninjas        = _db.Ninjas.Include("itemOfNinjas").ToList();
            Ninja            myNinja       = ninjas.Where(n => n.Id == id).First();

            if (myNinja == null)
            {
                return(NotFound());
            }
            if (myNinja.ownerId != _userManager.GetUserId(HttpContext.User))
            {
                return(NotFound());
            }
            int supInt = 0;
            int supStr = 0;
            int supDex = 0;
            int value  = 0;

            foreach (var item in myNinja.itemOfNinjas)
            {
                var tempItem = _db.Items.Find(item.ItemId);
                switch (tempItem.CategoryId)
                {
                case 1:
                    _headItem.item     = tempItem;
                    _headItem.category = _db.Categories.Find(tempItem.CategoryId);
                    break;

                case 2:
                    _chestItem.item     = tempItem;
                    _chestItem.category = _db.Categories.Find(tempItem.CategoryId);
                    break;

                case 3:
                    _handItem.item     = tempItem;
                    _handItem.category = _db.Categories.Find(tempItem.CategoryId);
                    break;

                case 4:
                    _feetItem.item     = tempItem;
                    _feetItem.category = _db.Categories.Find(tempItem.CategoryId);
                    break;

                case 5:
                    _ringItem.item     = tempItem;
                    _ringItem.category = _db.Categories.Find(tempItem.CategoryId);
                    break;

                case 6:
                    _necklaceItem.item     = tempItem;
                    _necklaceItem.category = _db.Categories.Find(tempItem.CategoryId);
                    break;

                default:
                    break;
                }
                supInt = supInt + tempItem.Intelligence;
                supStr = supStr + tempItem.Strenght;
                supDex = supDex + tempItem.Dexterity;
                value  = value + tempItem.Value;
            }
            NinjaInventory inv = new NinjaInventory();

            inv.Ninja          = myNinja;
            inv.headItem       = _headItem;
            inv.chestItem      = _chestItem;
            inv.handItem       = _handItem;
            inv.feetItem       = _feetItem;
            inv.ringItem       = _ringItem;
            inv.necklaceItem   = _necklaceItem;
            inv.totalInt       = supInt;
            inv.totalStr       = supStr;
            inv.totalDex       = supDex;
            inv.totalItemValue = value;
            return(View(inv));
        }