protected void grvListas_SelectedIndexChanged(object sender, EventArgs e) { int IdProducto = Convert.ToInt16(Session["IdProducto"]); int IdLista = Convert.ToInt16(grvListas.SelectedDataKey["IdLista"]); ObjELP.IdProducto = IdProducto; ObjELP.IdLista = IdLista; List <E_ListaProducto> LstLP = new N_ListaProducto().LstUsuarios(); bool flag = false; foreach (E_ListaProducto P in LstLP) { if (P.IdLista == IdLista && P.IdProducto == IdProducto) { //Label flag = true; break; } } if (!flag) { string msn2 = ObjNLP.InsertarListaProductol(ObjELP); } ApagarComponentes(); }
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(); }
protected void Iniciar() { int IdLista = Convert.ToInt16(Session["idlista"]); nombrelista.Text = (new N_ListaUsuario().BuscarListaUsuarioporLista(IdLista)).NombreLista; List <E_ListaProducto> LstLP = new N_ListaProducto().LstUsuarios(); List <E_Producto> LstP = new List <E_Producto>(); foreach (E_ListaProducto LP in LstLP) { if (LP.IdLista == IdLista) { LstP.Add(ObjNP.BuscarProductoPorId(LP.IdProducto)); } } //el id producto siempre es 0, no agarra bien ese parametro //Label1.Text = "id producto "+LstLP[2].IdProducto+" id lista "+ LstLP[2].IdLista; grvProductos.DataSource = LstP; grvProductos.DataBind(); }
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"); }