private List <ProductBrowse> getProducts()
        {
            SqlConnection        connection = new SqlConnection("server=184.168.47.19;database=anbbvv_sti;user id=jasper;password=wenwen927;");
            SqlCommand           command    = new SqlCommand("select * from anbbvv_sti.jasper.PRODUCT", connection);
            List <ProductBrowse> products   = new List <ProductBrowse>();

            connection.Open();
            using (SqlDataReader dataReader = command.ExecuteReader())
            {
                while (dataReader.Read())
                {
                    ProductBrowse product = new ProductBrowse();
                    product.Id      = Convert.ToString(dataReader.GetValue(0));
                    product.Name    = dataReader.GetString(1).Trim();
                    product.ImgPath = dataReader.GetString(2).Trim();
                    products.Add(product);
                }
            }
            connection.Close();
            return(products);
        }
        private List <ProductBrowse> getProductsWithPage(String page)
        {
            SqlConnection        connection = new SqlConnection("server=184.168.47.19;database=anbbvv_sti;user id=jasper;password=wenwen927;");
            SqlCommand           command    = new SqlCommand("select * from anbbvv_sti.jasper.PRODUCT where id >  " + ((Convert.ToInt32(page) - 1) * 12).ToString() + " and id <= " + (Convert.ToInt32(page) * 12).ToString(), connection);
            List <ProductBrowse> products   = new List <ProductBrowse>();

            connection.Open();
            using (SqlDataReader dataReader = command.ExecuteReader())
            {
                while (dataReader.Read())
                {
                    ProductBrowse product = new ProductBrowse();
                    product.Id      = dataReader.GetString(0).Trim();
                    product.Name    = dataReader.GetString(1).Trim();
                    product.ImgPath = dataReader.GetString(2).Trim();
                    products.Add(product);
                }
            }
            connection.Close();
            return(products);
        }
        private List <ProductBrowse> getProductsBasedOnPage(String page, String numberOfItems)
        {
            String startPoint    = ((Convert.ToInt32(page) - 1) * Convert.ToInt32(numberOfItems)).ToString();
            String subQueryPoint = (Convert.ToInt32(startPoint) + Convert.ToInt32(numberOfItems)).ToString();
            String productsCount = getProductsCount();
            String topItems      = "";

            if (Convert.ToInt32(productsCount) - Convert.ToInt32(startPoint) < Convert.ToInt32(numberOfItems))
            {
                topItems = Convert.ToString(Convert.ToInt32(productsCount) - Convert.ToInt32(startPoint));
            }
            else
            {
                topItems = numberOfItems;
            }

            SqlConnection        connection = new SqlConnection("server=184.168.47.19;database=anbbvv_sti;user id=jasper;password=wenwen927;");
            SqlCommand           command    = new SqlCommand("select * from (select top " + topItems + " * from (select top " + subQueryPoint + " * from anbbvv_sti.jasper.PRODUCT order by ID) as T order by ID desc) as A order by ID", connection);
            List <ProductBrowse> products   = new List <ProductBrowse>();
            int counter = 0;

            connection.Open();
            using (SqlDataReader dataReader = command.ExecuteReader())
            {
                while (dataReader.Read())
                {
                    ProductBrowse productBrowse = new ProductBrowse();
                    productBrowse.Name    = dataReader.GetString(1).Trim();
                    productBrowse.Id      = Convert.ToString(dataReader.GetValue(0));
                    productBrowse.ImgPath = dataReader.GetString(2).Trim();
                    products.Add(productBrowse);
                    counter++;
                }
            }
            connection.Close();
            return(products);
        }