Exemplo n.º 1
0
        public List <thong_tin_dienthoai> getListProductSearch(string tendienthoai)
        {
            List <thong_tin_dienthoai> products = new List <thong_tin_dienthoai>();
            string sqlSearch1 = "select product.product_id, product.product_name, product.price,product.descriptions, product.image,category.category_name,product.category_id " +
                                "from product inner join category on product.category_id = category.category_id " +
                                "where product.product_name like '%" + @tendienthoai + "%'";

            con.Open();
            SqlCommand cmd = new SqlCommand(sqlSearch1, con);

            cmd.Parameters.AddWithValue("tendienthoai", tendienthoai);
            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                thong_tin_dienthoai product = new thong_tin_dienthoai();
                product.product_id    = (int)dr["product_id"];
                product.product_name  = (string)dr["product_name"];
                product.category_id   = (int)dr["category_id"];
                product.price         = (int)dr["price"];
                product.descriptions  = (string)dr["descriptions"];
                product.image         = (string)dr["image"];
                product.category_name = (string)dr["category_name"];
                products.Add(product);
            }
            con.Close();
            return(products);
        }
Exemplo n.º 2
0
        //-----------------------------------------------truy vấn điện thoại----------------------------------
        public List <thong_tin_dienthoai> laydsdt()
        {
            List <thong_tin_dienthoai> products = new List <thong_tin_dienthoai>();
            string sqlDsdt = "select product.product_id, product.product_name, product.price,product.descriptions, product.image,category.category_name,product.category_id from product inner join category on product.category_id = category.category_id";

            con.Open();
            SqlCommand    cmd = new SqlCommand(sqlDsdt, con);
            SqlDataReader dr  = cmd.ExecuteReader();

            while (dr.Read())
            {
                thong_tin_dienthoai product = new thong_tin_dienthoai();
                product.product_id    = (int)dr["product_id"];
                product.product_name  = (string)dr["product_name"];
                product.category_name = (string)dr["category_name"];
                product.price         = (int)dr["price"];
                product.descriptions  = (string)dr["descriptions"];
                product.image         = (string)dr["image"];
                product.category_id   = (int)dr["category_id"];
                products.Add(product);
            }
            con.Close();
            return(products);
        }