Example #1
0
        public IEnumerable <ProductsGet> GetProductByName(string ProductName)
        {
            List <ProductsGet> productsGET = new List <ProductsGet>();
            String             toSearch    = String.Format("SELECT * FROM [ViewProducts] WHERE ProductName LIKE '%{0}%'", ProductName);

            command = new SqlCommand(toSearch, connection);

            connection.Open();

            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    ProductsGet productGET = new ProductsGet((int)Convert.ToInt64(reader["ProductID"]),
                                                             (long)reader["ProductSKU"],
                                                             (String)reader["ProductName"],
                                                             (String)reader["BrandName"],
                                                             (int)Convert.ToInt64(reader["ProductPrice"]),
                                                             (int)Convert.ToInt64(reader["ProductVariableCost"]),
                                                             (int)Convert.ToInt64(reader["ProductStartFactor"]),
                                                             (int)Convert.ToInt64(reader["ProductGrowthFactor"]),
                                                             (int)Convert.ToInt64(reader["ProductQuantity"]));
                    productsGET.Add(productGET);
                }
            }

            connection.Close();
            return(productsGET);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            this.DataBind();

            Repeater1.DataSource = ProductsGet.Skip((CurrentPage - 1) * pageSize).Take(pageSize);
            Repeater1.DataBind();
        }
Example #3
0
        public IEnumerable <ProductsGet> GetProduct(int?ProductID)
        {
            List <ProductsGet> productsGet = new List <ProductsGet>();

            if (ProductID == null)
            {
                command = new SqlCommand("SELECT * FROM [ViewProductsV3]", connection);
            }
            else
            {
                command = new SqlCommand("SELECT * FROM [ViewProductsV3] WHERE ProductID = '" + ProductID + "'", connection);
            }

            connection.Open();

            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    ProductsGet productGet = new ProductsGet((int)Convert.ToInt64(reader["ProductID"]),
                                                             (long)reader["ProductSKU"],
                                                             (String)reader["ProductName"],
                                                             (String)reader["BrandName"],
                                                             (int)Convert.ToInt64(reader["ProductPrice"]),
                                                             (int)Convert.ToInt64(reader["ProductVariableCost"]),
                                                             (int)Convert.ToInt64(reader["ProductStartFactor"]),
                                                             (int)Convert.ToInt64(reader["ProductGrowthFactor"]),
                                                             (int)Convert.ToInt64(reader["ProductQuantity"]));
                    productsGet.Add(productGet);
                }
            }

            connection.Close();

            return(productsGet);
        }