protected void btnBorrar_Click(object sender, EventArgs e) { CheckBox checkBorrado; IProductos bdd = new BusinessLogic(); List<PRODUCTO> products = Session["products"] as List<PRODUCTO>; PRODUCTO selectedProduct = null; GridProducts.Rows.ToList().ForEach(row => { checkBorrado = row.FindControl("chkBorrar") as CheckBox; if (checkBorrado.Checked) { selectedProduct = products.FirstOrDefault(product => product.NOMBREPRODUCTO == row.Cells[4].Text); selectedProduct.ESBORRADOPRODUCTO = true; bdd.SaveProducto(selectedProduct); } }); }
protected void btnSave_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtNombreProducto.Text)) throw new Exception("Escriba el nombre"); IProductos bdd = new BusinessLogic(); if (Session["selectedProduct"] == null) { producto = new PRODUCTO(); producto.IDPRODUCTO = Guid.NewGuid(); } else producto = Session["selectedProduct"] as PRODUCTO; producto.NOMBREPRODUCTO = txtNombreProducto.Text; bdd.SaveProducto(producto); Session.Remove("selectedProduct"); Response.Redirect("~/ui/MantenimientoProducto.aspx"); } catch (Exception ex) { ShowError(ex.Message); } }