Ejemplo n.º 1
0
        protected override void OnLoad(EventArgs e)
        {
            // Fetch the key field from the query stirng
            string itemId = WebComponents.CleanString.InputText(Request["itemId"], 50);

            // Create an instance of the item business components
            Item item = new Item();

            // Get the item info from the item component
            itemInfo = item.GetItem(itemId);

            // If an item is found then display the results
            if(itemInfo != null){

                lblDescription.Text = itemInfo.ProductDesc;
                lblName.Text = itemInfo.Name;
                lblProductName.Text = itemInfo.ProductName;
                lblPrice.Text = itemInfo.Price.ToString("c");

                // Modify the message if an item is out of stock
                if (itemInfo.Quantity > 0)
                    lblQty.Text = itemInfo.Quantity.ToString();
                else {
                    lblQty.Text = MSG_BACK_ORDERED;
                    lblQty.CssClass = CSS_ALERT;
                }
            }else{
                lblSearchResults.Text = "Item not found";
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get an individual item based on a the unique key
        /// </summary>
        /// <param name="itemId">unique key</param>
        /// <returns></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.Char, 10);
            //Bind the parameter
            parm.Value = itemId;

            //Execute the query
            using (SqlDataReader rdr = SQLHelper.ExecuteReader(SQLHelper.ConnectionString, CommandType.Text, SQL_SELECT_ITEM, parm)) {
                rdr.Read();
                item = new ItemInfo(rdr.GetString(0).Trim(), rdr.GetString(1), rdr.GetInt32(2), rdr.GetDecimal(3), rdr.GetString(4), rdr.GetString(5));

            }
            return item;
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Function to get a list of items within a product group
        /// </summary>
        /// <param name="productId"></param>
        /// <returns></returns>
        public IList GetItemsByProduct(string productId)
        {
            IList itemsByProduct = new ArrayList();

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

            //Execute the query against the database
            using (SqlDataReader rdr = SQLHelper.ExecuteReader(SQLHelper.ConnectionString, CommandType.Text, SQL_SELECT_ITEMS_BY_PRODUCT, parm)) {
                // Scroll through the results
                while (rdr.Read()){
                    ItemInfo item = new ItemInfo(rdr.GetString(0).Trim(), rdr.GetString(1), rdr.GetDecimal(2), rdr.GetString(3), null);
                    //Add each item to the arraylist
                    itemsByProduct.Add(item);
                }
            }

            return itemsByProduct;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Get an individual item based on a the unique key
        /// </summary>
        /// <param name="itemId">unique key</param>
        /// <returns>Details of the Item</returns>
        public ItemInfo GetItem(string itemId)
        {
            //Set up a return value
            ItemInfo item = null;

            //Create a parameter
            OracleParameter parm = new OracleParameter(PARM_ITEM_ID, OracleType.Char, 10);
            //Bind the parameter
            parm.Value = itemId;

            //Execute a query
            using (OracleDataReader rdr = OracleHelper.ExecuteReader(OracleHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_ITEM, parm)) {

                //Query will only return one record
                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;
        }
Ejemplo n.º 7
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)
        {
            // Declare array to return
            IList<ItemInfo> itemsByProduct = new List<ItemInfo>();

            // Create a database parameter
            OracleParameter parm = new OracleParameter(PARM_PRODUCT_ID, OracleType.Char, 10);
            //Set the parameter value
            parm.Value = productId;

            //Execute the query
            using(OracleDataReader rdr = OracleHelper.ExecuteReader(OracleHelper.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;
        }