GetIDPeloNome() public method

public GetIDPeloNome ( string nome ) : int
nome string
return int
Ejemplo n.º 1
0
        private decimal AdicionarProdutoNoListViewSemComanda(ListView ltv, string codigo, int quantidade)
        {
            try
            {
                InstanciarTipoCadastroRepositorio();
                int IDTipoUnidade = _tipoCadastroRepositorio.GetIDPeloNome("Unidade");

                Produto produto = this.GetProdutoPorCodigoUnidade(codigo);

                IQueryable <dynamic> _venda = null;
                decimal lucroTotal          = 0;
                if (produto != null)
                {
                    if (produto.TipoCadastro == IDTipoUnidade)
                    {
                        _venda = (from prod in _banco.Produto
                                  select new
                        {
                            Nome = prod.Nome
                            ,
                            Codigo = prod.Codigo
                            ,
                            Quantidade = quantidade
                            ,
                            Total = prod.PrecoVenda * quantidade
                            ,
                            LucroTotal = ((prod.PrecoVenda - prod.PrecoCompra) * quantidade)
                        }).Where(c => c.Codigo == codigo);

                        AdicionarItensNoListView(ltv, _venda);
                        foreach (var lucro in _venda)
                        {
                            lucroTotal += lucro.LucroTotal;
                        }
                    }
                }
                else
                {
                    MyErro.MyCustomException("Esse Produto é vendido por peso.");
                }

                return(lucroTotal);
            }
            catch (CustomException erro)
            {
                throw new CustomException(erro.Message);
            }
            catch (Exception erro)
            {
                throw new Exception(erro.Message);
            }
        }
 public int GetIDTipoCategoria(string nome)
 {
     try
     {
         InstanciarTipoCadastroRepositorio();
         return(_tipoCadastroRepositorio.GetIDPeloNome(nome));
     }
     catch (CustomException erro)
     {
         throw new CustomException(erro.Message);
     }
     catch (Exception erro)
     {
         throw new Exception(erro.Message);
     }
 }