private void Editar() { try { butConsultar.Visible = false; butNuevo.Visible = false; butConfirmar.Visible = true; butCancelar.Visible = true; tblConsulta.Visible = false; rbtAgencia.Enabled = false; rbtCliente.Enabled = false; ICategoria categoria = CategoriaFactory.GetCategoria(); categoria.CategoriaID = Utiles.Validaciones.obtieneEntero(txtCategoriaID.Text); categoria.Consultar(); txtDescripcion.Text = categoria.Descripcion; txtMontoDesde.Text = categoria.MontoDesde.ToString(); txtMontoHasta.Text = categoria.MontoHasta == 0 ? "" : categoria.MontoHasta.ToString(); if (categoria.TipoCategoriaID == 1) { rbtAgencia.Checked = true; rbtCliente.Checked = false; } else { rbtAgencia.Checked = false; rbtCliente.Checked = true; } } catch (Exception ex) { ((ErrorWeb)phErrores.Controls[0]).setMensaje(ex.Message); } }
// <summary> // Obtiene la referencia a la factoría de repositorios de la entidad <see cref="T:Categoria"/>. // </summary> //private CategoriaRepositoryFactory CategoriaRepositoryFactory //{ //get { return this.categoriaRepositoryFactory; } //} #endregion #region Create Method // from template Application\UpdateBase\I2ServiceRegionCreateMethod.tt /// <summary> /// Crea una entidad Categoria. /// </summary> /// <param name="categoriaDto"> /// DTO que contiene la información para crear la entidad. /// </param> /// <returns> /// El identificador de la entidad creada. /// </returns> public int Create(CategoriaDto categoriaDto) { #region Preconditions // Comprobar el DTO de entrada. Guard.ArgumentIsNotNull( categoriaDto, string.Format( FrameworkResource.DataTransferObjectIsNull, SharedResources.CategoriaAlias)); // Comprobar los campos mandatory dentro del DTO. #endregion // el dto debe corresponder a un transient el id debe tener el valor por defecto Guard.Against <ArgumentException>(categoriaDto.Id != default(Int32), string.Format( FrameworkResource.IsNotTransient, SharedResources.CategoriaAlias ) ); Categoria categoria = CategoriaFactory.Create(); categoria.Name = categoriaDto.Name; ICategoriaRepository repo = ApplicationLayer.IocContainer.Resolve <ICategoriaRepository>(); repo.Add(categoria); this.Commit(); return(categoria.Id); }
private void dtgCategoria_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { try { ICategoria categoria = CategoriaFactory.GetCategoria(); categoria.CategoriaID = Utiles.Validaciones.obtieneEntero(e.Item.Cells[0].Text); categoria.Eliminar(); BindGrid(); } catch (Exception ex) { ((ErrorWeb)phErrores.Controls[0]).setMensaje(ex.Message); } }
private void butConfirmar_Click(object sender, System.EventArgs e) { try { BaseValidator bv; bv = (BaseValidator)phDescripcion.FindControl("descripReq"); bv.Enabled = true; bv.Validate(); if (!bv.IsValid) { return; } /* * bv = (BaseValidator)phMontoHasta.FindControl("hastaReq"); * bv.Enabled = true; * bv.Validate(); * if(!bv.IsValid) * return; */ CustomValidator validatorRango = (CustomValidator)GenerarValidadores.Custom(); validatorRango.ServerValidate += new System.Web.UI.WebControls.ServerValidateEventHandler(ValidateRango); phMontoHasta.Controls.Add(validatorRango); validatorRango.Validate(); if (!validatorRango.IsValid) { return; } bv = (BaseValidator)phMontoDesde.FindControl("desdeReq"); bv.Enabled = true; bv.Validate(); if (!bv.IsValid) { return; } ICategoria categoria = CategoriaFactory.GetCategoria(); categoria.CategoriaID = Utiles.Validaciones.obtieneEntero(txtCategoriaID.Text); categoria.Descripcion = txtDescripcion.Text; categoria.TipoCategoriaID = rbtAgencia.Checked ? 1 : 2; categoria.MontoDesde = Utiles.Validaciones.obtieneDouble(txtMontoDesde.Text); categoria.MontoHasta = Utiles.Validaciones.obtieneDouble(txtMontoHasta.Text); categoria.Guardar(); Response.Redirect("CategoriaConsul.aspx"); } catch (Exception ex) { ((ErrorWeb)phErrores.Controls[0]).setMensaje(ex.Message); } }
private void ComboCategoriaC() { try { ICategoria categoria = CategoriaFactory.GetCategoria(); categoria.TipoCategoriaID = 2; ddlCategoriaC.Items.Clear(); ddlCategoriaC.DataTextField = "Descripcion"; ddlCategoriaC.DataValueField = "CategoriaID"; ddlCategoriaC.DataSource = categoria.GetCategorias().Datos; ddlCategoriaC.DataBind(); ddlCategoriaC.Items.Insert(0, "Todas"); } catch (Exception ex) { ((ErrorWeb)phErrores.Controls[0]).setMensaje(ex.Message); } }
public async Task <CategoriaCommandResponse> Handle(CategoriaCommand request, CancellationToken cancellationToken) { _cancellationToken = cancellationToken; try { var categoria = CategoriaFactory.Incluir(request.Descricao, request.ImagemUrl); await _categoriaRepository.AddAsync(categoria); _uow.Commit(); } catch { return(new CategoriaCommandResponse(false, "Ocorreu um erro intero!")); } return(new CategoriaCommandResponse(true, string.Empty)); }
private void BindGrid() { try { ICategoria categoria = CategoriaFactory.GetCategoria(); categoria.Descripcion = txtDescripcion.Text; categoria.MontoDesde = Utiles.Validaciones.obtieneDouble(txtMontoDesde.Text); categoria.MontoHasta = Utiles.Validaciones.obtieneDouble(txtMontoHasta.Text); categoria.TipoCategoriaID = rbtAgencia.Checked ? 1 : 2; AdministrarGrillas.Configurar(dtgCategoria, "CategoriaID", CantidadOpciones, true, false); dtgCategoria.CurrentPageIndex = Utiles.Validaciones.obtieneEntero(txtPagina.Text); dtgCategoria.DataSource = categoria.GetCategorias().Datos; dtgCategoria.DataBind(); } catch (Exception ex) { ((ErrorWeb)phErrores.Controls[0]).setMensaje(ex.Message); } }
protected async Task abrirCategoria(CategoriaInfo categoria) { var regraLoja = LojaFactory.create(); var loja = regraLoja.pegarAtual(); if (loja == null) { await DisplayAlert("Aviso", "Nenhuma loja selecionada.", "Fechar"); return; } var regraCategoria = CategoriaFactory.create(); var categoriasFilho = await regraCategoria.listarPorCategoria(loja.Id, categoria.Id); if (categoriasFilho.Count > 0) { var categoriaPage = CategoriaPageFactory.create(); categoriaPage.Title = categoria.Nome; categoriaPage.IdCategoria = categoria.Id; if (AoAbrirProdutoLista != null) { categoriaPage.AoAbrirProdutoLista += AoAbrirProdutoLista; } await Navigation.PushAsync(categoriaPage); } else { var produtoPage = ProdutoUtils.gerarProdutoListaPorCategoria(categoria); if (AoAbrirProdutoLista != null) { AoAbrirProdutoLista(this, produtoPage); } else { await Navigation.PushAsync(produtoPage); } } }
protected async Task atualizarCategoria() { var regraLoja = LojaFactory.create(); var loja = regraLoja.pegarAtual(); if (loja != null) { _empresaLabel.Text = loja.Nome; var regraCategoria = CategoriaFactory.create(); UserDialogs.Instance.ShowLoading("Carregando..."); try { var regraBanner = BannerPecaFactory.create(); _bannerView.ItemsSource = await regraBanner.gerar(new BannerFiltroInfo { SlugBanner = BannerUtils.CATEGORIA, IdLoja = loja.Id, Ordem = BannerOrdemEnum.PorOrdem }); if (IdCategoria.HasValue) { executarAtualizarCategoria(await regraCategoria.listarPorCategoria(loja.Id, IdCategoria.Value)); } else { executarAtualizarCategoria(await regraCategoria.listarPai(loja.Id)); } UserDialogs.Instance.HideLoading(); } catch (Exception erro) { UserDialogs.Instance.HideLoading(); UserDialogs.Instance.Alert(erro.Message, "Erro", "Entendi"); } } else { await DisplayAlert("Aviso", "Nenhuma loja selecionada.", "Fechar"); } }
public ProdutoController(IProdutoRepository produtoRepository) { _produtoRepository = produtoRepository; _categoriaFactory = new CategoriaFactory(); }