예제 #1
0
        private void FindProductQuery()
        {
            StringBuilder q = new StringBuilder();

            if (TxtIdCategory.Text.Length > 0)
            {
                string c = String.Empty;
                FillQueryCategories(int.Parse(TxtIdCategory.Text), ref c);
                c = c.Substring(0, c.Length - 3);

                string listquery = string.Empty;
                if (ViewState["ListPrice"] != null && ViewState["ListPrice"].ToString() != "0")
                {
                    listquery = string.Format("(EXCLUDELIST IS NULL OR (EXCLUDELIST NOT LIKE '%|{0}|%')) AND ", ViewState["ListPrice"].ToString());
                }

                q.AppendFormat("SELECT * FROM CATALOGPRODUCTS WHERE {1}({0}) AND (", c, listquery);
                q.AppendFormat("SHORTDESCRIPTION LIKE '{0}%' OR LONGDESCRIPTION LIKE '{0}%' OR CODE LIKE '{0}%') ", DatabaseConnection.FilterInjection(Search.Text));
                q.Append("AND ACTIVE=1 ORDER BY CATEGORY");
            }
            else
            {
                q.Append("SELECT * FROM CATALOGPRODUCTS WHERE (");
                q.AppendFormat("SHORTDESCRIPTION LIKE '{0}%' OR LONGDESCRIPTION LIKE '{0}%' OR CODE LIKE '{0}%') ", DatabaseConnection.FilterInjection(Search.Text));
                q.AppendFormat("AND ACTIVE=1 ORDER BY CATEGORY");
            }

            ProductRepeater.DataSource = DatabaseConnection.CreateDataset(q.ToString());
            ProductRepeater.DataBind();

            ProductRepeater.Visible = (ProductRepeater.Items.Count > 0);
        }
예제 #2
0
        private void PopulatePopularProductsRepeater()
        {
            var           connectionString = ConfigurationManager.ConnectionStrings["AdventureWorksLT2012"].ConnectionString;
            SqlConnection sqlConnection    =
                new SqlConnection(connectionString);

            SqlCommand    sqlCommand    = new SqlCommand("select top 16 * from(select *, row_number() over(partition by ProductCategoryID order by ProductCategoryID) as row_number from AdventureWorksLT2012.dbo.CustomView) as rows where row_number = 1", sqlConnection);
            SqlDataReader sqlDataReader = null;

            try
            {
                sqlConnection.Open();
                sqlDataReader = sqlCommand.ExecuteReader(CommandBehavior.SequentialAccess);
                ProductRepeater.DataSource = sqlDataReader;
                ProductRepeater.DataBind();
            }
            catch (Exception hh)
            {
                //Label1.Text = "Failed to get items from data base";
                //Label1.Visible = true;
                Response.Write(hh);
            }
            finally
            {
                if (sqlDataReader != null)
                {
                    sqlDataReader.Close();
                    sqlDataReader.Dispose();
                }
                sqlCommand.Dispose();
                sqlConnection.Close();
                sqlConnection.Dispose();
            }
        }
예제 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //var productObj = new Product();

        ProductRepeater.DataSource = Product.GetProducts();
        ProductRepeater.DataBind();
    }
예제 #4
0
        private void FindProductQuery()
        {
            StringBuilder q = new StringBuilder();

            if (TxtIdCategory.Text.Length > 0)
            {
                string c = String.Empty;
                FillQueryCategories(int.Parse(TxtIdCategory.Text), ref c);
                c = c.Substring(0, c.Length - 3);
                q.AppendFormat("SELECT * FROM CATALOGPRODUCTS WHERE ({0}) AND (", c);
                q.AppendFormat("SHORTDESCRIPTION LIKE '{0}%' OR LONGDESCRIPTION LIKE '{0}%' OR CODE LIKE '{0}%') ", DatabaseConnection.FilterInjection(Search.Text));
                q.Append("AND ACTIVE=1 ORDER BY CATEGORY");
            }
            else
            {
                q.Append("SELECT * FROM CATALOGPRODUCTS WHERE (");
                q.AppendFormat("SHORTDESCRIPTION LIKE '{0}%' OR LONGDESCRIPTION LIKE '{0}%' OR CODE LIKE '{0}%') ", DatabaseConnection.FilterInjection(Search.Text));
                q.AppendFormat("AND ACTIVE=1 ORDER BY CATEGORY");
            }

            ProductRepeater.DataSource = DatabaseConnection.CreateDataset(q.ToString());
            ProductRepeater.DataBind();

            ProductRepeater.Visible = (ProductRepeater.Items.Count > 0);
        }
예제 #5
0
        public void FillSchema()
        {
            DataTable dtProduct = QuoteProducts();

            ProductRepeater.DataSource = dtProduct;
            ProductRepeater.DataBind();
        }
예제 #6
0
 private void LoadData()
 {
     if (!string.IsNullOrEmpty(Request.QueryString["p"]))
     {
         ProductId = Convert.ToInt32(Request.QueryString["p"]);
         ViewState["ProductId"] = ProductId;
         new ProductAdapter().AddLastViewedProduct(ProductId, DateTime.Now, Request.ServerVariables["REMOTE_ADDR"]);
     }
     ProductRepeater.DataSource = new ProductAdapter().GetDetailedProduct(ProductId);
     ProductRepeater.DataBind();
 }
예제 #7
0
        protected void DataBindProducts()
        {
            ProductRepeater.ItemDataBound += new RepeaterItemEventHandler(ProductRepeater_ItemDataBound);
            string       connectionString = ConfigurationManager.ConnectionStrings["ProductStoreConnectionString"].ConnectionString;
            DbConnection connection       = SqlHelper.Current.GetConnection(connectionString);

            using (ProductStore dataStore = new ProductStore(connection))
            {
                var products = from p in dataStore.Product
                               select p;

                ProductRepeater.DataSource = products;
                ProductRepeater.DataBind();
            }
        }
예제 #8
0
 //Dis Product List
 protected void Page_Load(object sender, EventArgs e)
 {
     requestSeachProduct = Request.QueryString["search"];
     requestQuery        = Request.QueryString["category"];
     if (requestQuery == null)
     {
         ProductRepeater.DataSource = aProductManager.DisplayProductManager();
         ProductRepeater.DataBind();
     }
     else
     {
         ProductRepeater.DataSource = aProductManager.DisplayProductManagerByCategory(requestQuery);
         ProductRepeater.DataBind();
     }
     if (requestQuery == null && requestSeachProduct != null)
     {
         ProductRepeater.DataSource = aProductManager.DisplayProductManagerBySearch(requestSeachProduct);
         ProductRepeater.DataBind();
     }
 }