Esempio n. 1
0
        private void lb_items_SelectedIndexChanged(object sender, EventArgs e)
        {
            items_handler item = (items_handler)lb_items.Items[lb_items.SelectedIndex];

            int[] existing_items_recipe = items_handler.RecipeIds(item.id);
            CheckRecipeIds(existing_items_recipe);
        }
Esempio n. 2
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            int[]         r           = GetRecipeIds();
            items_handler item        = (items_handler)lb_items.Items[lb_items.SelectedIndex];
            int           selected_id = item.id;

            items_recipes_handler.AddRecipe(selected_id, r);
        }
Esempio n. 3
0
 //Tick the items with the id's in the array
 private void CheckRecipeIds(int[] ids)
 {
     ClearSelection();
     for (int i = 0; i < ids.Length; i++)
     {
         for (int x = 0; x < clb_recipe_items.Items.Count; x++)
         {
             items_handler item = (items_handler)clb_recipe_items.Items[x];
             if (item.id == ids[i])
             {
                 clb_recipe_items.SetItemChecked(x, true);
             }
         }
     }
 }
Esempio n. 4
0
        //Get Selected ids from the checked list box
        private int[] GetRecipeIds()
        {
            List <int> recipe_list = new List <int>();

            for (int i = 0; i < clb_recipe_items.Items.Count; i++)
            {
                if (clb_recipe_items.GetItemChecked(i) == true)
                {
                    items_handler item = (items_handler)clb_recipe_items.Items[i];
                    recipe_list.Add(item.id);
                }
            }

            return(recipe_list.ToArray());
        }
Esempio n. 5
0
        public static items_handler Read(int id)
        {
            string sql = $"select id, name, description, item_image from items where id = {id}";

            var result = db_handler.instance.query(sql);
            var item   = new items_handler();

            if (result.Rows.Count > 0)
            {
                item.id          = result.Rows[0].Field <int>(0);
                item.name        = result.Rows[0].Field <string>(1);
                item.description = result.Rows[0].Field <string>(2);
                item.image       = result.Rows[0].Field <byte[]>(3);
                item.item_dt     = result;
            }

            return(item);
        }
Esempio n. 6
0
        //Returns all items in a list of objects as to be used in combo boxes
        public static List <items_handler> ReadAllList()
        {
            string sql    = "select * from items";
            var    list   = new List <items_handler>();
            var    item   = new items_handler();
            var    result = db_handler.instance.query(sql);

            foreach (DataRow obj in result.Rows)
            {
                item             = new items_handler();
                item.id          = obj.Field <int>(0);
                item.name        = obj.Field <string>(1);
                item.description = obj.Field <string>(2);
                item.image       = obj.Field <byte[]>(3);
                item.item_dt     = result;
                list.Add(item);
            }

            return(list);
        }
Esempio n. 7
0
        private void btn_give_Click(object sender, EventArgs e)
        {
            int item_count;

            try
            {
                item_count = int.Parse(txt_count.Text);
            }
            catch
            {
                MessageBox.Show("Please enter a valid amount...");
                return;
            }

            players_handler p_handler = (players_handler)cb_players.Items[cb_players.SelectedIndex];
            items_handler   i_handler = (items_handler)cb_item.Items[cb_item.SelectedIndex];

            inventories_handler.Give(p_handler.id, i_handler.id, item_count);
            clear_frm();
        }