Exemplo n.º 1
0
        private void GetByBaseCategoryId()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["bc"]))
            {
                int baseCatId = Convert.ToInt32(Business.Encryption.Encryption64.Decrypt(Request.QueryString["bc"], "!#$a54?3"));
                if (baseCatId != 0)
                {
                    CategoryEntity category = new CategoryAdapter().GetCategoryById(baseCatId);
                    BaseCategoryNameLabel.Text = category.Name;
                    CategoryNameLabel.Text     = category.Name;

                    SubCategoriesRepeater.DataSource = new CategoryAdapter().GetSubCategories(baseCatId);
                    SubCategoriesRepeater.DataBind();

                    ProductListRepeater.DataSource = new ProductAdapter().GetProductsByMainCategoryId(baseCatId);
                    ProductCollection productList = (ProductCollection)ProductListRepeater.DataSource;
                    Session["ProductList"] = productList;
                    ProductListRepeater.DataBind();
                }
                else
                {
                    Response.Redirect("~/Default.aspx");
                }
            }
        }
Exemplo n.º 2
0
        protected void SortBy_Click(object sender, EventArgs e)
        {
            LinkButton        lnkButton   = (LinkButton)sender;
            ProductCollection productList = (ProductCollection)Session["ProductList"];

            switch (lnkButton.ID)
            {
            case "SortByTitleAscending":
                ProductListRepeater.DataSource = new ProductAdapter().SortProductsByTitle(productList, true);
                break;

            case "SortByTitleDescending":
                ProductListRepeater.DataSource = new ProductAdapter().SortProductsByTitle(productList, false);
                break;

            case "SortByPriceAscending":
                ProductListRepeater.DataSource = new ProductAdapter().SortProductsByPrice(productList, true);
                break;

            case "SortByPriceDescending":
                ProductListRepeater.DataSource = new ProductAdapter().SortProductsByPrice(productList, false);
                break;

            case "SortByRateDescending":
                ProductListRepeater.DataSource = productList;
                break;

            case "SortByRateAscending":
                ProductListRepeater.DataSource = productList;
                break;

            default:
                ProductListRepeater.DataSource = productList;
                break;
            }

            ProductListRepeater.DataBind();
            DataPager1.DataBind();
            //ScriptManager.RegisterStartupScript(this, this.GetType(), "shoppica.js", "  <script type='text/javascript' src='/Assets/js/shoppica.js'></script>", true);



            //ScriptManager.RegisterStartupScript(this, this.GetType(), "shoppica.js", "alert('aasd')", false);
        }
Exemplo n.º 3
0
        private void GetByBrandId()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["b"]))
            {
                int brandId = Convert.ToInt32(Business.Encryption.Encryption64.Decrypt(Request.QueryString["b"], "!#$a54?3"));
                BaseCategoryNameLabel.Text = new BrandAdapter().GetBrandById(brandId).Name;
                CategoryNameLabel.Text     = new BrandAdapter().GetBrandById(brandId).Name;

                //Disable CategorySlider
                SubCategoriesRepeater.Visible = false;

                ProductListRepeater.DataSource = new ProductAdapter().GetProductsByBrandId(brandId);
                ProductCollection productList = (ProductCollection)ProductListRepeater.DataSource;
                Session["ProductList"] = productList;
                ProductListRepeater.DataBind();
            }
            else
            {
                Response.Redirect("~/Default.aspx");
            }
        }
Exemplo n.º 4
0
        private void GetByKeyword()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["k"]))
            {
                string keyword = Business.Encryption.Encryption64.Decrypt(Request.QueryString["k"], "12345678").Replace("+", " ");
                BaseCategoryNameLabel.Text = keyword;
                CategoryNameLabel.Text     = keyword;

                //Disable CategorySlider
                SubCategoriesRepeater.Visible = false;

                ProductListRepeater.DataSource = new ProductAdapter().GetProductsByKeyword(keyword);
                ProductCollection productList = (ProductCollection)ProductListRepeater.DataSource;
                Session["ProductList"] = productList;
                ProductListRepeater.DataBind();
            }
            else
            {
                Response.Redirect("~/Default.aspx");
            }
        }
Exemplo n.º 5
0
        private void GetByKeywordAndBaseCategory()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["k"]) && !string.IsNullOrEmpty(Request.QueryString["bc"]))
            {
                string keyword   = Business.Encryption.Encryption64.Decrypt(Request.QueryString["k"], "12345678").Replace("+", " ");
                int    baseCatId = Convert.ToInt32(Business.Encryption.Encryption64.Decrypt(Request.QueryString["bc"], "!#$a54?3"));
                if (baseCatId != 0)
                {
                    CategoryEntity category = new CategoryAdapter().GetCategoryById(baseCatId);
                    BaseCategoryNameLabel.Text = category.Name;
                    CategoryNameLabel.Text     = keyword;

                    SubCategoriesRepeater.DataSource = new CategoryAdapter().GetSubCategories(baseCatId);
                    SubCategoriesRepeater.DataBind();

                    ProductListRepeater.DataSource = new ProductAdapter().GetProductsByKeywordAndBaseCatId(keyword, baseCatId);
                    ProductCollection productList = (ProductCollection)ProductListRepeater.DataSource;
                    Session["ProductList"] = productList;
                    ProductListRepeater.DataBind();
                }
                else
                {
                    BaseCategoryNameLabel.Text = keyword;
                    CategoryNameLabel.Text     = keyword;
                    ProductCollection products = new ProductAdapter().GetProductsByKeyword(keyword);
                    Session["ProductList"] = products;
                    //Disable CategorySlider
                    SubCategoriesRepeater.Visible = false;

                    ProductListRepeater.DataSource = products;
                    ProductListRepeater.DataBind();
                }
            }
            else
            {
                Response.Redirect("~/Default.aspx");
            }
        }
 private void GetData(int storeId)
 {
     ProductListRepeater.DataSource = new ProductSearchEngine.Business.Adapters.ProductAdapter().GetProductsByStoreId(storeId);
     ProductListRepeater.DataBind();
 }
 private void GetData()
 {
     ProductListRepeater.DataSource = new ProductSearchEngine.Business.Adapters.ProductAdapter().GetAllProducts();
     ProductListRepeater.DataBind();
 }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // We check to see that this page loads without any postback on the page because it is unnessary to
            // to run this code if there only is a postback on the page like a click on a button.
            if (!Page.IsPostBack)
            {
                // We select all products from the "Products" table and sort the list by "ProductName" in ascending order.
                // The data for the products are supplied to the "ProductListRepeater" repeater control and we split up the
                // product list in pages with next and previous links for navigation.

                // Declare variables for a connection string and a SELECT statement.
                string ConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
                string sql        = "SELECT ProductID, ProductName, Description, PriceExSaleTax, CAST(PriceExSaleTax * "
                                    + "SaleTaxPercent as decimal(18,2)) As SaleTaxMoney, SaleTaxPercent, CAST(PriceExSaleTax * "
                                    + "(1 + SaleTaxPercent) as decimal(18,2)) As TotalPrice FROM Products ORDER BY ProductName ASC";

                // Create a SqlConnection. The using block is used to call dispose (close) automatically even
                // if there are an exception.
                using (SqlConnection cn = new SqlConnection(ConnString))
                {
                    // Create a SqlDataAdapter.
                    SqlDataAdapter sad = new SqlDataAdapter();

                    // Create a SqlCommand.
                    SqlCommand cmd = new SqlCommand(sql, cn);

                    // Create a DataTable.
                    DataTable dt = new DataTable();

                    // Create a PagedDataSource.
                    PagedDataSource objPds = new PagedDataSource();

                    // The Try/Catch/Finally block is used to handle exceptions.
                    try
                    {
                        // Open the SqlConnection.
                        cn.Open();

                        // Assign the select command to the SqlDataAdapter.
                        sad.SelectCommand = cmd;

                        // Fill the data table "dt" with data from the SqlDataAdapter
                        sad.Fill(dt);

                        // Populate the repeater control with the datatable
                        objPds.DataSource = dt.DefaultView;

                        // Indicate that the data should be paged
                        objPds.AllowPaging = true;

                        // Set the pagesize
                        objPds.PageSize = 10;

                        // The current page (curpage) is declared as an integer
                        Int32 curpage;

                        // We set the page number for the current page from the page parameter in the url
                        // or to 1 if there are no page parameter in the url
                        if (Request.QueryString["page"] != null)
                        {
                            curpage = Convert.ToInt32(Request.QueryString["page"]);
                        }
                        else
                        {
                            curpage = 1;
                        }

                        // The current page index is equal to the current page minus 1 and we need to know this
                        // to show the right page to the user.
                        objPds.CurrentPageIndex = curpage - 1;

                        // We set the text in the middle to show the current pagenumber and the last pagenumber
                        lblCurrentPage.Text = "| Page: " + curpage.ToString() + " of " + objPds.PageCount.ToString() + " |";

                        // This is code for the link to the previous page, we don't show this link on the first page
                        if (!objPds.IsFirstPage)
                        {
                            lnkPrev.Visible     = true;
                            lnkPrev.NavigateUrl = "~/Default1.aspx?" + "page=" + Convert.ToString(curpage - 1);
                        }

                        // This is code for the link to the next page, we don't show this link on the last page
                        if (!objPds.IsLastPage)
                        {
                            lnkNext.Visible     = true;
                            lnkNext.NavigateUrl = "~/Default1.aspx?" + "page=" + Convert.ToString(curpage + 1);
                        }

                        // This code is used to bind data to the repeater control.
                        ProductListRepeater.DataSource = objPds;
                        ProductListRepeater.DataBind();
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex.Message);
                    }
                    finally
                    {
                        // Dispose of objects to avoid memory leakage.
                        sad.Dispose();
                        cmd.Dispose();
                        dt.Dispose();
                    }
                }
            }
        }