protected void dgvFormulas_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName.Equals("AddNew")) { FormulaNegocio FormulaNeg = new FormulaNegocio(); Formula formu = new Formula(); formu.insumo = new Insumo(); formu.insumo.id = Convert.ToInt64((dgvFormulas.FooterRow.FindControl("ddlInsumosFooter") as DropDownList).Text); formu.insumo.nombre = (dgvFormulas.FooterRow.FindControl("ddlInsumosFooter") as DropDownList).SelectedItem.ToString(); formu.producto = new Producto(); formu.producto.id = Convert.ToInt64(Session["idProducto"]); formu.producto.nombre = ((TextBox)dgvFormulas.FooterRow.FindControl("txbProductosFooter")).Text; formu.cantidad = Convert.ToInt32((dgvFormulas.FooterRow.FindControl("txbCantidadFooter") as TextBox).Text); FormulaNeg.Agregar(formu); lblCorrecto.Text = "Agregado correctamente."; lblIncorrecto.Text = ""; cargardgv(); // Response.Redirect("formulas.aspx"); } } catch (Exception ex) { lblCorrecto.Text = ""; lblIncorrecto.Text = ex.Message; } }
protected void btnGuardarFormula_Click(object sender, EventArgs e) { Formula formu = new Formula(); FormulaNegocio formNeg = new FormulaNegocio(); List <Formula> list = new List <Formula>(); list = Session["ListaFormula"] as List <Formula>; foreach (Formula item in list) { formNeg.Agregar(item); } Session["ListaFormula"] = null; Response.Redirect("AltaFormula.aspx"); }