public void Incluir(ModeloProduto obj) { if (obj.ProNome.Trim().Length == 0) { throw new Exception("O nome do Produto é obrigatório"); } if (obj.ProDescricao.Trim().Length == 0) { throw new Exception("A descrição do Produto é obrigatório"); } if (obj.ProValorVenda <= 0) { throw new Exception("O valor de venda do Produto é obrigatório"); } if (obj.ProQtde < 0) { throw new Exception("A quantidade do Produto deve ser maior que 0"); } if (obj.ScatCod <= 0) { throw new Exception("O código da Subcategoria é obrigatório"); } if (obj.CatCod <= 0) { throw new Exception("O código da Categoria é obrigatório"); } if (obj.UmedCod <= 0) { throw new Exception("O código da Unidade de Medida é obrigatório"); } DALProduto DALobj = new DALProduto(conexao); DALobj.Incluir(obj); }
public void Incluir(ModeloProduto p) { if (p.DescricaoProduto.Trim().Length == 0) { throw new Exception("A descrição do Produto é obrigatoria."); } if (p.NomeProduto.Trim().Length == 0) { throw new Exception("O nome do produto é obrigatório."); } if (p.ValorVenda <= 0) { throw new Exception("O valor da venda deve ser maior que zero."); } if (p.Quantidade <= 0) { throw new Exception("A quantidade deve ser maior que zero."); } if (p.Quantidade > 1000) { throw new Exception("Valor maximo da quantidade alcaçado para esta operação, o valor deve ser menor ou igual a mil."); } if (p.UnidadeMedida <= 0) { throw new Exception("Unidade de medida deve ser informada."); } if (p.Categoria <= 0) { throw new Exception("A Categoria deve ser informada."); } if (p.SubCategoria <= 0) { throw new Exception("A SubCategoria deve ser informada."); } DALProduto da = new DALProduto(CONEXAO); da.Incluir(p); }