Beispiel #1
0
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            if (TxtCodigo.Text != string.Empty)
            {
                AtualizarCategoria();
            }
            else
            {
                if (txtCategoria == null || txtCategoria.Text.Length < 3)
                {
                    Util.showMessage(Page, "O Campo Categoria não pode estar vazio ou conter menos de 3 caracteres, favor digite o nome corretamente");
                }
                else
                {
                    categoria.NOME = txtCategoria.Text;
                    categoriaBLL.Add(categoria);
                    categoriaBLL.SaveChanges();

                    ListarCategorias();

                    Util.showMessage(Page, "Categoria salva com sucesso!");

                    categoria    = null;
                    categoriaBLL = null;
                    LimparCampos();
                }
            }
        }