public RetornoEstoque getEstoque() { RetornoEstoque ret = new RetornoEstoque(); try { EstoqueDAO DAO = new EstoqueDAO(); DataTable dt = DAO.getEstoque(); if (dt.Rows.Count.Equals(0)) { ret.erro = "0 entradas de mercadoria cadastradas."; ret.sucesso = false; ret.listEstoque = new List <Estoque>(); return(ret); } List <Estoque> listEstoque = new List <Estoque>(); foreach (DataRow row in dt.Rows) { listEstoque.Add(montaEstoque(row)); } ret.erro = string.Empty; ret.sucesso = true; ret.listEstoque = listEstoque; return(ret); }catch (Exception ex) { throw ex; } }
public RetornoEstoque getEstoqueByProduto(int idProduto) { RetornoEstoque ret = new RetornoEstoque(); try { EstoqueDAO DAO = new EstoqueDAO(); DataTable dt = DAO.getEstoqueByIdProduto(idProduto); if (dt.Rows.Count.Equals(0)) { ret.erro = "Ainda não foi cadastrado entradas dessa mercadoria para essa empresa."; ret.sucesso = false; ret.listEstoque = new List <Estoque>(); } List <Estoque> listEstoque = new List <Estoque>(); foreach (DataRow row in dt.Rows) { listEstoque.Add(montaEstoque(row)); } ret.erro = string.Empty; ret.sucesso = true; ret.listEstoque = listEstoque; return(ret); } catch (Exception ex) { throw ex; } }
public RetornoEstoque getRetornoEstoqueException(Exception ex) { RetornoEstoque ret = new RetornoEstoque(); ret.sucesso = false; ret.erro = ex.Message; ret.listEstoque = new List <Estoque>(); return(ret); }
public Retorno getEstoqueByEmpresa(int idEmpresa) { UtilBLL util = new UtilBLL(); String metodo = ConfigurationManager.AppSettings.Get("getEstoqueByEmpresa"); RetornoString rs = util.realizaRequisicaoComPmt(idEmpresa, metodo, TipoRequisicao.POST); RetornoEstoque re = new RetornoEstoque(); if (rs.sucesso.Equals(true)) { re = JsonConvert.DeserializeObject <RetornoEstoque>(rs.resposta); } else { re.sucesso = false; re.erro = "Não foi possível conectar ao banco de dados."; re.listEstoque = new List <Estoque>(); } return(re); }