public void AgregarCategoria() { if (!IsPostBack) { return; } CategoriaNegocio negocio = new CategoriaNegocio(); try { Categoria categoria = new Categoria(); var ItemModificar = Request.QueryString["idModificar"]; if (ItemModificar != null) { categoria.Id = Convert.ToInt32(ItemModificar); } categoria.Descripcion = input.Text; if (categoria.Id != 0) { negocio.Modificar(categoria); } else { negocio.Agregar(categoria); } } catch (Exception ex) { throw ex; } }
protected void btnAceptar_Click(object sender, EventArgs e) { if (ValidarForm()) { CategoriaNegocio categoriaNegocio = new CategoriaNegocio(); try { if (categoria == null) { categoria = new Categoria(); } categoria.Nombre = txtBoxNombre.Text; if (categoria.ID != 0) { categoriaNegocio.Modificar(categoria); } else { categoriaNegocio.Agregar(categoria); } Response.Redirect("ABM_Categorias.aspx"); } catch (Exception ex) { throw ex; } } else { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "modalErrorForm", "$('#modalErrorForm').modal();", true); } }
protected void btnAceptar_Click(object sender, EventArgs e) { if (tbxNombre.Text != "") { negocio.Agregar(categoria); } Response.Redirect("Admin.aspx"); }
protected void btnAgregar_Click(object sender, EventArgs e) { Categoria categoria = new Categoria(); CategoriaNegocio negocio = new CategoriaNegocio(); categoria.Nombre = CategoriaBox.Text; negocio.Agregar(categoria); Response.Redirect("CategoriaAdmin.aspx"); }
protected void Agregar_Click(object sender, EventArgs e) { if (Agregar.Text == "Modificar") { categoria.nombre = categoriaLabel.Text; negocioCategoria.Modificar(categoria); } else { nombreCategoria = categoriaLabel.Text; negocioCategoria.Agregar(nombreCategoria); } Response.Redirect("categorias.aspx"); }
private void btnAceptar_Click(object sender, EventArgs e) { CategoriaNegocio neg = new CategoriaNegocio(); Categoria cat = new Categoria(); try { cat.NombreCategoria = txtNombre.Text; neg.Agregar(cat); Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected void dgvCategorias_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName.Equals("AddNew")) { CategoriaNegocio CategoriaNeg = new CategoriaNegocio(); Categoria Categ = new Categoria(); Categ.nombre = (dgvCategorias.FooterRow.FindControl("txbNombreFooter") as TextBox).Text; CategoriaNeg.Agregar(Categ); lblCorrecto.Text = "Agregado correctamente."; lblIncorrecto.Text = ""; Cargardgv(); } } catch (Exception ex) { lblCorrecto.Text = ""; lblIncorrecto.Text = ex.Message; } }
private void btnAceptar_Click(object sender, EventArgs e) { CategoriaNegocio negocio = new CategoriaNegocio(); Categoria categoria = new Categoria(); bool Anduvo = true; try { categoria.Descripcion = txtNombre.Text; negocio.Agregar(categoria); } catch (SqlException ex) { Anduvo = false; SqlError err = ex.Errors[0]; if (err.Number == 2627) { MessageBox.Show("Esta categorÃa ya existe! Ingrese otra diferente."); } } catch (Exception ex) { Anduvo = false; MessageBox.Show(ex.ToString()); } finally { if (Anduvo == true) { MessageBox.Show("Categoria agregada correctamente!"); } Dispose(); } }