Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.IsPostBack)
     {
         ProductsListView.DataBind();
     }
 }
Exemplo n.º 2
0
        private void cargarListViewProductos()
        {
            try
            {
                wsProducto.producto[] productos = productoClient.obtenerProducto();
                ProductsListView.DataSource = productos;
                ProductsListView.DataBind();

                //var listadto = productoClient.obtenerProducto();
                //var nuevolistadto = (from o in listadto
                //                     orderby o.productoId
                //                     where o.categoriaProductoId == 1 //Puedes comprobar los id cambiando este valor
                //                     select new
                //                     {
                //                         Id = o.productoId,
                //                         Nombre = o.nombreProducto,
                //                         Imagen = o.imagenProdcuto,
                //                         Porciones = o.porcionesProdcuto,
                //                         Precio = o.precioProducto,
                //                         Descripción = o.descripcionProducto,
                //                         Disponibilidad = o.disponibilidadProducto
                //                     }).ToList();
                //ProductsListView.DataSource = nuevolistadto;
                //ProductsListView.DataBind();
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 3
0
        private void BindProducts(int subcategoryId, bool isSub, string orderBy, string searchValue)
        {
            try
            {
                lblProductMsg.Text = "No Products Found";
                DataSet products = null;
                if (searchValue == string.Empty)
                {
                    products = (new ProductsDAL()).GetProducts(subcategoryId, isSub, orderBy);
                }
                else
                {
                    products = (new ProductsDAL()).GetProductSearch(subcategoryId, searchValue, orderBy);
                }

                if (products != null && products.Tables[0].Rows.Count > 0)
                {
                    lblProductMsg.Text          = "";
                    ProductsListView.DataSource = products;
                    ProductsListView.DataBind();
                    dpProducts.Visible = true;
                }
                else
                {
                    ProductsListView.DataSource = null;
                    ProductsListView.DataBind();
                    dpProducts.Visible = false;
                }
                lblNavBar.Text = "All Categories";
                if (ViewState["Category"] != null && ViewState["Category"].ToString() != string.Empty)
                {
                    lblNavBar.Text += "   >>   " + ViewState["Category"].ToString();
                }
                if (ViewState["SubCat"] != null && ViewState["SubCat"].ToString() != string.Empty)
                {
                    lblNavBar.Text += "   >>   " + ViewState["SubCat"].ToString();
                }
            }
            catch (Exception ex)
            {
                string strErrCode = ERROR_DISPLAY_MESSAGE + "," + (new Error_Log()).LogErrorIntoDB(ex, "BindProducts", subcategoryId.ToString(),
                                                                                                   isSub.ToString(), orderBy, searchValue);
                lblErr.Text = strErrCode;
            }
        }
Exemplo n.º 4
0
        private void GetAndBindProducts(string category)
        {
            if (!string.IsNullOrEmpty(SearchTextBox.Text.Trim()))
            {
                this.search = SearchTextBox.Text.Trim();
            }

            if (string.IsNullOrEmpty(this.search))
            {
                l1 = ProductsDAO.GetPRODUCTsByCategory(category);
                ProductsListView.DataSource = l1;
                ProductsListView.DataBind();
            }
            else
            {
                l1 = ProductsDAO.GetPRODUCTsByCategorySearch(category, this.search.Trim());
                ProductsListView.DataSource = l1;
                ProductsListView.DataBind();
            }
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session == null || HttpContext.Current.Session["admin"] == null)
            {
                Response.Redirect("~/LoginP.aspx");
            }

            Page.Header.Title = "Fast food - Menu";


            if (IsPostBack == false)
            {
                SearchTextBox.Text   = "";
                this.category        = "Beverages";
                CategoryTextBox.Text = this.category;
                l1 = ProductsDAO.GetPRODUCTsByCategory(this.category);
                ProductsListView.DataSource = l1;
                ProductsListView.DataBind();
            }
        }
Exemplo n.º 6
0
        private void GetAndBindUnavailableProducts()
        {
            if (!string.IsNullOrEmpty(SearchTextBox.Text.Trim()))
            {
                this.search = SearchTextBox.Text.Trim();
            }

            if (string.IsNullOrEmpty(this.search))
            {
                l1 = ProductsDAO.GetUnavailablePRODUCTs();
                ProductsListView.DataSource = l1;
                ProductsListView.DataBind();
            }
            else
            {
                l1 = ProductsDAO.GetUnavailablePRODUCTsBySearch(this.search.Trim());
                ProductsListView.DataSource = l1;
                ProductsListView.DataBind();
            }
        }
Exemplo n.º 7
0
        protected void ProductsListView_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "ShowInsertView":
                ProductsListView.InsertItemPosition = InsertItemPosition.LastItem;
                ProductsListView.DataBind();
                ProductsListView.InsertItem.DataBind();
                break;

            case "HideInsertView":
                ProductsListView.InsertItemPosition = InsertItemPosition.None;
                break;

            case "AddToCart":
                var cart = new ShoppingCart();
                cart.AddProduct(Convert.ToInt32(e.CommandArgument));
                break;

            case "Delete":
                ProductsDataSource.DeleteParameters.Add("ID", e.CommandArgument.ToString());
                break;
            }
        }
Exemplo n.º 8
0
 protected void ProductsDataSource_Deleted(object sender, ObjectDataSourceStatusEventArgs e)
 {
     ProductsListView.DataBind();
 }
Exemplo n.º 9
0
 protected void ProductsDataSource_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
 {
     ProductsListView.InsertItemPosition = InsertItemPosition.None;
     ProductsListView.DataBind();
 }