Exemplo n.º 1
0
        public static ArrayList GetStoreCategoryProducts(int store_id, int category_id)
        {
            string query = @"SELECT p.* FROM products p, product2category p2c
                                WHERE p.product_id = p2c.product_id
                                AND p.store_id = {0}
                                AND p2c.category_id = {1}";

            query = string.Format(query, store_id, category_id);
            ArrayList _prods = SBFactory.getDbh().Query(query);

            if (_prods == null)
            {
                return(null);
            }
            ArrayList prods = new ArrayList();

            foreach (Hashtable prod in _prods)
            {
                SBProduct product = new SBProduct();
                product.SetDbData(prod);
                product.GetDbMeta();
                prods.Add(product);
            }

            return(prods);
        }
Exemplo n.º 2
0
        public ArrayList GetProducts(int store_id = 0)
        {
            ArrayList prods = new ArrayList();
            string    query = "";

            if (store_id == 0)
            {
                query = @"SELECT * FROM products p, product2category p2c 
                            WHERE p2c.category_id = {0}
                            AND p.product_id = p2c.product_id";
                query = string.Format(query, this.CategoryID);
            }
            else
            {
                query = @"SELECT * FROM products p, product2category p2c 
                                    WHERE p.store_id = {0}
                                    AND p2c.category_id = {1}
                                    AND p.product_id = p2c.product_id";
                query = string.Format(query, store_id, this.CategoryID);
            }
            ArrayList _prods = SBFactory.getDbh().Query(query);

            if (_prods != null)
            {
                foreach (Hashtable _p in _prods)
                {
                    SBProduct p = new SBProduct();
                    p.SetDbData(_p);
                    prods.Add(p);
                }
            }

            return(prods);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the store product.
        /// </summary>
        /// <returns>
        /// The store product.
        /// A <see cref="SBProduct"/>
        /// </returns>
        /// <param name='store_id'>
        /// Store_id.
        /// </param>
        /// <param name='product_code'>
        /// Product_code.
        /// </param>
        public static SBProduct GetStoreProduct(int store_id, string product_code)
        {
            SBTableProduct tp   = new SBTableProduct();
            Hashtable      prod = tp.getRow(string.Format("store_id = {0} AND product_code = '{1}'", store_id, product_code.Trim()));

            if (prod == null)
            {
                return(null);
            }
            SBProduct product = new SBProduct();

            product.SetDbData(prod);
            product.GetDbMeta();
            return(product);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the category products.
        /// The method returns an SBProduct object array
        /// </summary>
        /// <returns>The category products.</returns>
        /// <param name="category_id">Category identifier.</param>
        public static ArrayList GetCategoryProducts(int category_id)
        {
            string query = "SELECT p.* " +
                           "FROM products p, product2category p2c " +
                           "WHERE p.product_id = p2c.product_id " +
                           "AND p2c.category_id = {0}";

            query = string.Format(query, category_id);
            ArrayList prods     = SBFactory.getDbh().Query(query);
            ArrayList obj_prods = new ArrayList();

            foreach (Hashtable p in prods)
            {
                SBProduct product = new SBProduct();
                product.SetDbData(p);
                obj_prods.Add(product);
            }

            return(obj_prods);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get all Warehouse products and return an ArrayList that contains SMProduct instances
        /// </summary>
        /// <returns>
        /// A <see cref="ArrayList"/>
        /// </returns>
        public static ArrayList getProducts()
        {
            SBTableProduct tp    = new SBTableProduct();
            ArrayList      prods = tp.getRows("(status = 'publish' OR status = 'initial') ORDER BY creation_date ASC");

            if (prods == null)
            {
                return(null);
            }
            ArrayList obj_prods = new ArrayList();

            foreach (Hashtable p in prods)
            {
                SBProduct product = new SBProduct();
                product.SetDbData(p);
                obj_prods.Add(product);
            }

            return(obj_prods);
        }
Exemplo n.º 6
0
        public static ArrayList GetStoreProducts(int store_id)
        {
            SBTableProduct tp     = new SBTableProduct();
            ArrayList      _prods = tp.getRows(string.Format("(status = 'publish' OR status = 'initial') AND store_id = {0}", store_id));

            if (_prods == null)
            {
                return(null);
            }
            ArrayList prods = new ArrayList();

            foreach (Hashtable prod in _prods)
            {
                SBProduct product = new SBProduct();
                product.SetDbData(prod);
                product.GetDbMeta();
                prods.Add(product);
            }

            return(prods);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the product by codebar.
        /// </summary>
        /// <returns>The product by codebar.</returns>
        public static SBProduct GetProductByCodebar(string barcode, int store_id = 0)
        {
            SBFactory.getDbh().Select("*")
            .From("products")
            .Where(string.Format("product_barcode = '{0}'", barcode));
            if (store_id > 0)
            {
                SBFactory.getDbh().And(string.Format("store_id = {0}", store_id));
            }

            Hashtable prod_row = SBFactory.getDbh().QueryRow();

            if (prod_row == null)
            {
                return(null);
            }
            SBProduct product = new SBProduct();

            product.SetDbData(prod_row);

            return(product);
        }