Exemple #1
0
        protected void grvProductos_SelectedIndexChanged(object sender, EventArgs e)
        {
            int IdProducto = Convert.ToInt16(grvProductos.SelectedDataKey["IdProducto"]);
            int IdLista    = Convert.ToInt16(Session["idlista"]);
            List <E_ListaProducto> LstLP  = new N_ListaProducto().LstUsuarios();
            N_ListaProducto        ObjNLP = new N_ListaProducto();

            foreach (E_ListaProducto LP in LstLP)
            {
                if (LP.IdLista == IdLista && LP.IdProducto == IdProducto)
                {
                    string msn = ObjNLP.BorraListaProducto(LP.IdListaProducto);
                    break;
                }
            }
            grvProductos.DataBind();
        }
Exemple #2
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int    IdUsuario   = Convert.ToInt16(Session["IdUsuario"]);
            string comando     = e.CommandName;
            string str         = e.CommandArgument.ToString();
            string nombrelista = grvListas.Rows[Convert.ToInt16(str)].Cells[0].Text;
            //int lista;
            List <E_ListaUsuario> lstLU = new N_ListaUsuario().LstUsuarios();

            foreach (E_ListaUsuario ls in lstLU)
            {
                if (ls.NombreLista == nombrelista && ls.IdUsuario == IdUsuario)
                {
                    Session["idlista"] = ls.IdLista;
                }
            }
            //int IdLista = (new N_ListaUsuario().BuscarListaUsuarioporNombre(nombrenegocio)).IdLista;
            //int IdLista = (new N_ListaUsuario().BuscarListaUsuarioporLista(lista)).IdLista;
            //Session["IdLista"] = IdLista;
            switch (comando)
            {
            case "colsultar":
            {
                Response.Redirect("consultar_lista.aspx");
                break;
            };

            case "comparar":
            {
                Response.Redirect("comparar.aspx");
                break;
            };

            case "eliminar":
            {
                //string msnB = ObjNLU.BorraListaUsuario(IdLista);

                //eliminando elementos de listaproducto
                N_ListaProducto        NLP   = new N_ListaProducto();
                List <E_ListaProducto> lstLP = new N_ListaProducto().LstUsuarios();
                foreach (E_ListaProducto LP in lstLP)
                {
                    if (LP.IdLista == Convert.ToInt16(Session["idlista"]))
                    {
                        NLP.BorraListaProducto(Convert.ToInt16(Session["idlista"]));
                    }
                }

                // Eliminando lista
                N_ListaUsuario LU = new N_ListaUsuario();
                LU.BorraListaUsuario(Convert.ToInt16(Session["idlista"]));
                //grvListas.DataBind();
                Iniciar();
                break;
            };

            default:
            {
                break;
            };
            }
            // Response.Redirect("productos.aspx");
        }