Example #1
0
        public static List<Inventory> GetAll()
        {
            List<Inventory> allInventory = new List<Inventory>{};

              SqlConnection conn = DB.Connection();
              conn.Open();

              SqlCommand cmd = new SqlCommand("SELECT * FROM items;", conn);
              SqlDataReader rdr = cmd.ExecuteReader();

              while(rdr.Read())
              {
            int inventoryId = rdr.GetInt32(0);
            string inventoryDescription = rdr.GetString(1);
            Inventory newInventory = new Inventory(inventoryDescription, inventoryId);
            allInventory.Add(newInventory);
              }
              if (rdr != null)
              {
            rdr.Close();
              }
              if (conn != null)
              {
            conn.Close();
              }
              return allInventory;
        }
Example #2
0
 public void T2_Equal_ReturnsTrueIfDescriptionsAreTheSame()
 {
     //Arrange, Act
       Inventory firstItem = new Inventory("Of Mice and Men");
       Inventory secondItem = new Inventory ("Of Mice and Men");
       //Assert
       Assert.Equal(firstItem, secondItem);
 }
Example #3
0
 public Character(string name)
 {
     this.name = name;
     health    = new Attribute(100);
     stamina   = new Attribute(100);
     strength  = new Attribute(1);
     speed     = new Attribute(1);
     inventory = new Inventory.Inventory();
 }
Example #4
0
 public void T3_Save_SavesToDatabase()
 {
     //Arrange
       Inventory testInventory = new Inventory("Of Mice and Men");
       //Action
       testInventory.Save();
       List<Inventory> result = Inventory.GetAll();
       List<Inventory> testList = new List<Inventory>{testInventory};
       //Assert
       Assert.Equal(testList, result);
 }
Example #5
0
        public void TestAddItems()
        {
            Inventory.Inventory inventory = new Inventory.Inventory(10);
            Item sword  = new Item("Sword", 3, ItemType.equipment);
            Item potion = new Item("Potion", 2, ItemType.consumable);
            Item map    = new Item("Map", 0, ItemType.key);

            inventory.Add(sword);
            inventory.Add(potion);
            inventory.Add(map);

            Assert.IsNotNull(inventory);
        }
Example #6
0
        public void TestAddItems()
        {
            Inventory.Inventory inventory = new Inventory.Inventory(10);
            Item sword  = new Item("Sword", 3, ItemType.equipment);
            Item potion = new Item("Potion", 2, ItemType.consumable);
            Item map    = new Item("Map", 0, ItemType.key);

            inventory.Add(sword);
            inventory.Add(potion);
            inventory.Add(map);
            Assert.IsTrue(inventory.GetSize() == 3);

            inventory.Remove(potion);
            Assert.IsTrue(inventory.GetSize() == 2);
        }
Example #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Initializing Systems...");
            // TODO: create inventory system
            Inventory.Inventory mInv = new Inventory.Inventory(10);
            mInv.Add(new Item("Dai-Ryumyaku Jufuku of Fending", 1, ItemType.equipment));
            mInv.Add(new Item("Max Potion", 1, ItemType.consumable));
            mInv.Add(new Item("Max Ether", 1, ItemType.consumable));
            mInv.Add(new Item("Diamond Sword", 1, ItemType.equipment));
            mInv.Add(new Item("Diamond Shield", 1, ItemType.equipment));
            mInv.Add(new Item("Silvergrace Earrings of Fending", 1, ItemType.equipment));
            mInv.Add(new Item("Aether Compass", 1, ItemType.key));
            mInv.Add(new Item("Empty Dalmascan Wine Bottle", 1, ItemType.key));
            mInv.Add(new Item("Pazuzu Feather", 1, ItemType.key));

            mInv.PrintInventory();

            Console.WriteLine("Initializing Character Manager");
            Character.Character player;

            // load the character
            player = PersistentData.PersistentData.Deserialize <Character.Character>("player.xml");
            if (player == null)
            {
                Console.WriteLine("No player found, creating new default character");
                player = new Character.Character(100, Race.Elf, Alignment.Neutral);
            }


            CharacterManager characterManager = CharacterManager.Instance;

            characterManager.Player = player;
            Character.Character enemyOne = new Character.Character(50, Race.Orc, Alignment.ChaoticEvil);
            Character.Character enemyTwo = new Character.Character(50, Race.Orc, Alignment.NeutralEvil);
            characterManager.AddEnemy(enemyOne);
            characterManager.AddEnemy(enemyTwo);


            // TODO: create persistent data system

            // save the player
            Console.WriteLine("Saving players and Enemys");
            PersistentData.PersistentData.Serialize <CharacterManager>(characterManager, "character.xml");


            Console.WriteLine("Press return to exit...");
            Console.ReadKey();
        }
Example #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("Initializing Systems...");

            // Creates an inventory and items
            Console.WriteLine("Initializing Inventory...");
            Inventory.Inventory inventory = new Inventory.Inventory(10);
            Item sword  = new Item("Sword", 3, ItemType.equipment);
            Item potion = new Item("Potion", 2, ItemType.consumable);
            Item map    = new Item("Map", 0, ItemType.key);

            // adds items into inventory
            Console.WriteLine("Filling Inventory...");
            inventory.Add(sword);
            inventory.Add(potion);
            inventory.Add(map);

            Console.WriteLine("Initializing Character Manager");
            Character.Character player;

            // load the character
            player = PersistentData.PersistentData.Deserialize <Character.Character>("player.xml");
            if (player == null)
            {
                Console.WriteLine("No player found, creating new default character");
                player = new Character.Character(100, Races.Elf, Alignments.Neutral);
            }

            CharacterManager characterManager = CharacterManager.Instance;

            characterManager.Player = player;
            Character.Character enemyOne = new Character.Character(50, Races.Orc, Alignments.ChaoticEvil);
            Character.Character enemyTwo = new Character.Character(50, Races.Orc, Alignments.NeutralEvil);
            characterManager.AddEnemy(enemyOne);
            characterManager.AddEnemy(enemyTwo);

            // TODO: create persistent data system

            // save the player
            Console.WriteLine("Saving player");
            PersistentData.PersistentData.Serialize <Character.Character>(player, "character.xml");

            Console.WriteLine("Press return to exit...");
            Console.ReadKey();
        }
Example #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Initializing Systems...");
            // TODO: create inventory system
            Inventory.Inventory inventory = new Inventory.Inventory(5);

            Item item  = new Item("A", 1, ItemType.consumable);
            Item item2 = new Item("B", 2, ItemType.consumable);
            Item item3 = new Item("C", 3, ItemType.consumable);
            Item item4 = new Item("D", 4, ItemType.consumable);

            inventory.Add(item);
            inventory.Add(item2);
            inventory.Add(item3);
            inventory.Add(item4);

            Console.WriteLine("Initializing Character Manager");
            Character.Character player;

            // load the character
            player = PersistentData.PersistentData.Deserialize <Character.Character>("player.xml");
            if (player == null)
            {
                Console.WriteLine("No player found, creating new default character");
                player = new Character.Character(100, Races.Elf, Alignments.Neutral);
            }

            CharacterManager characterManager = CharacterManager.Instance;

            characterManager.Player = player;
            Character.Character enemyOne = new Character.Character(50, Races.Orc, Alignments.ChaoticEvil, "1", "masculine");
            Character.Character enemyTwo = new Character.Character(50, Races.Orc, Alignments.NeutralEvil, "2", "masculine");
            characterManager.AddEnemy(enemyOne);
            characterManager.AddEnemy(enemyTwo);

            // TODO: create persistent data system

            // save the player
            Console.WriteLine("Saving player");
            PersistentData.PersistentData.Serialize <Character.Character>(player, "character.xml");

            Console.WriteLine("Press return to exit...");
            Console.ReadKey();
        }
Example #10
0
 public void CreateInventory()
 {
     Inventory.Inventory inventory = new Inventory.Inventory(10);
     Assert.NotNull(inventory);
 }
Example #11
0
 private void button1_Click_1(object sender, EventArgs e)
 {
     Inventory_Controller item_clv = new Inventory_Controller();
     Inventory it = new Inventory();
     it.InvtID = txtInvtID.Text.Trim();
     it.Descr = txtDescr.Text;
     it.ShortDescr = txtShort.Text;
     it.DfltSite = textSiteID.Text;
     it.User1 = textUser1.Text;
     it.DfltWhseLoc = textPriceClassID.Text;
     it.Style = textStyle.Text;
     it.StkBasePrc = textSalesPrice.Text;
     it.ListPrice = textPurchasePrice.Text;
     it.UOM1 = txtuom.Text;
     it.StkUnit = txtuom.Text;
     it.CnvFact2 = txtCnvFact2.Text;
     it.PriceClassID = textpriceclass.Text;
     it.SalesTeam = cbsalesteam.Text;
     it.Division = cbDivision.Text;
     it.Category = cbCategory.Text;
     it.Brand = cbBrand.Text;
     it.Brandy = cbBrandy.Text;
     it.Variant = cbVariant.Text;
     it.Status = cbstatus.Text;
     item_clv.insertProduct(it);
     dataGridView1.DataSource = item_clv.Getdata();
 }
 public void insertProduct(Inventory it)
 {
     string strSQL = "p_Product";
     DBAccess data = new DBAccess();
     data.Store_RnSQL(strSQL, it);
 }
Example #13
0
 public DataTable Store_RnSQL(string strproSQL, Inventory it)
 {
     DataTable dt = new DataTable();
     try
     {
         Openconn();
         SqlCommand cmd = new SqlCommand(strproSQL, con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@InvtID", it.InvtID);
         cmd.Parameters.AddWithValue("@Descr", it.Descr);
         cmd.Parameters.AddWithValue("@ShortDescr", it.ShortDescr);
         cmd.Parameters.AddWithValue("@DfltSite", it.DfltSite);
         cmd.Parameters.AddWithValue("@StkBasePrc", it.StkBasePrc);
         cmd.Parameters.AddWithValue("@User1", it.User1);
         cmd.Parameters.AddWithValue("@ListPrice", it.ListPrice);
         cmd.Parameters.AddWithValue("@DfltWhseLoc", it.DfltWhseLoc);
         cmd.Parameters.AddWithValue("@UOM1", it.UOM1);
         cmd.Parameters.AddWithValue("@StkUnit", it.StkUnit);
         cmd.Parameters.AddWithValue("@Style", it.Style);
         cmd.Parameters.AddWithValue("@CnvFact2", it.CnvFact2);
         cmd.Parameters.AddWithValue("@PriceClassID", it.PriceClassID);
         cmd.Parameters.AddWithValue("@SalesTeam", it.SalesTeam);
         cmd.Parameters.AddWithValue("@Division", it.Division);
         cmd.Parameters.AddWithValue("@CAT", it.Category);
         cmd.Parameters.AddWithValue("@Brand", it.Brand);
         cmd.Parameters.AddWithValue("@Brandy", it.Brandy);
         cmd.Parameters.AddWithValue("@Variant", it.Variant);
         cmd.Parameters.AddWithValue("@Status", it.Status);
         SqlDataAdapter da = new SqlDataAdapter(cmd);
         da.Fill(dt);
         Closeconn();
         return dt;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }