private void CargarDatos(int almacenId) { Almacen obj = AlmacenBLL.GetAlmacenById(almacenId); if (obj == null) { Response.Redirect("ListaAlmacen.aspx"); } DescripcionTextBox.Text = obj.Descripcion; CapacidadTextBox.Text = obj.CapacidadKG.ToString(); DisponibleTextBox.Text = obj.RestanteKG.ToString(); LastCapacidadKGHD.Value = obj.CapacidadKG.ToString(); ProductosList.DataBind(); ProductosList.SelectedValue = obj.ProductoId.ToString(); }
protected void GridAlmacen_RowCommand(object sender, GridViewCommandEventArgs e) { int almacenId = 0; try { almacenId = Convert.ToInt32(e.CommandArgument); } catch (Exception ex) { } if (almacenId <= 0) { return; } Almacen obj = AlmacenBLL.GetAlmacenById(almacenId); if (obj == null) { return; } if (e.CommandName == "Eliminar") { try { AlmacenBLL.DeleteAlmacen(almacenId); Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "ShowMensaje('success', 'Eliminación Exitosa.')", true); GridAlmacen.DataBind(); } catch (Exception ex) { Console.Write(ex.Message); throw new Exception("Error al eliminar"); } } if (e.CommandName == "Editar") { Session["ALMACEN_ID"] = almacenId.ToString(); Response.Redirect("FormAlmacen.aspx"); } }