Beispiel #1
0
        /// <summary>
        /// Get an individual item based on a unique key
        /// </summary>
        /// <param name="itemId">unique key</param>
        /// <returns>Details about the Item</returns>
        public ItemInfo GetItem(string itemId)
        {
            //Set up a return value
            ItemInfo item = null;

            //Create a parameter
            SqlParameter parm = new SqlParameter(PARM_ITEM_ID, SqlDbType.VarChar, 10);
            //Bind the parameter
            parm.Value = itemId;

            //Execute the query
            using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_ITEM, parm))
            {
                if (rdr.Read())
                    item = new ItemInfo(rdr.GetString(0), rdr.GetString(1), 0, rdr.GetDecimal(2), rdr.GetString(3), rdr.GetString(4), rdr.GetString(5), rdr.GetString(6));
                else
                    item = new ItemInfo();
            }
            return item;
        }
Beispiel #2
0
        /// <summary>
        /// Function to get a list of items within a product group
        /// </summary>
        /// <param name="productId">Product Id</param>	   	 
        /// <returns>A Generic List of ItemInfo</returns>
        public IList<ItemInfo> GetItemsByProduct(string productId)
        {
            IList<ItemInfo> itemsByProduct = new List<ItemInfo>();

            SqlParameter parm = new SqlParameter(PARM_PRODUCT_ID, SqlDbType.VarChar, 10);
            parm.Value = productId;

            //Execute the query against the database
            using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_ITEMS_BY_PRODUCT, parm))
            {
                // Scroll through the results
                while (rdr.Read())
                {
                    ItemInfo item = new ItemInfo(rdr.GetString(0), rdr.GetString(1), rdr.GetInt32(2), rdr.GetDecimal(3), rdr.GetString(4), rdr.GetString(5), rdr.GetString(6), rdr.GetString(7));
                    //Add each item to the arraylist
                    itemsByProduct.Add(item);
                }
            }
            return itemsByProduct;
        }