Beispiel #1
0
        public IList <EstoqueContagemCabecalhoDTO> selectEstoqueContagemCabecalho(EstoqueContagemCabecalhoDTO contagem)
        {
            try
            {
                IList <EstoqueContagemCabecalhoDTO> resultado = null;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL <EstoqueContagemCabecalhoDTO> contDAL = new NHibernateDAL <EstoqueContagemCabecalhoDTO>(session);
                    resultado = contDAL.select(contagem);

                    foreach (EstoqueContagemCabecalhoDTO objP in resultado)
                    {
                        NHibernateDAL <EstoqueContagemDetalheDTO> contDetDAL = new NHibernateDAL <EstoqueContagemDetalheDTO>(session);
                        objP.listaContagemDetalhe = contDetDAL.select <EstoqueContagemDetalheDTO>(new EstoqueContagemDetalheDTO {
                            IdEstoqueContagemCabecalho = objP.Id
                        });
                    }
                }

                return(resultado);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
Beispiel #2
0
        public int deleteEstoqueContagemCabecalho(EstoqueContagemCabecalhoDTO estoqueContagemCabecalho)
        {
            try
            {
                int resultado = -1;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL <EstoqueContagemDetalheDTO> contDetDAL           = new NHibernateDAL <EstoqueContagemDetalheDTO>(session);
                    IList <EstoqueContagemDetalheDTO>         listaContagemDetalhe = contDetDAL.select <EstoqueContagemDetalheDTO>(new EstoqueContagemDetalheDTO {
                        IdEstoqueContagemCabecalho = estoqueContagemCabecalho.Id
                    });

                    foreach (EstoqueContagemDetalheDTO req in listaContagemDetalhe)
                    {
                        contDetDAL.delete(req);
                    }

                    NHibernateDAL <EstoqueContagemCabecalhoDTO> contDAL = new NHibernateDAL <EstoqueContagemCabecalhoDTO>(session);
                    contDAL.delete(estoqueContagemCabecalho);

                    session.Flush();
                    resultado = 0;
                }
                return(resultado);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
Beispiel #3
0
        public EstoqueContagemCabecalhoDTO salvarAtualizarEstoqueContagemCabecalho(EstoqueContagemCabecalhoDTO contagem)
        {
            try
            {
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL <EstoqueContagemCabecalhoDTO> contDAL = new NHibernateDAL <EstoqueContagemCabecalhoDTO>(session);
                    contDAL.saveOrUpdate(contagem);

                    if (contagem.listaContagemDetalhe != null)
                    {
                        NHibernateDAL <EstoqueContagemDetalheDTO> contDetDAL = new NHibernateDAL <EstoqueContagemDetalheDTO>(session);
                        IList <EstoqueContagemDetalheDTO>         listaContagemDetalheExcluir = contDetDAL.select <EstoqueContagemDetalheDTO>(new EstoqueContagemDetalheDTO {
                            IdEstoqueContagemCabecalho = contagem.Id
                        });

                        foreach (EstoqueContagemDetalheDTO contExc in listaContagemDetalheExcluir)
                        {
                            contDetDAL.delete(contExc);
                        }

                        IList <EstoqueContagemDetalheDTO> listaContagemDetalheIncluir = contagem.listaContagemDetalhe;

                        foreach (EstoqueContagemDetalheDTO contIncluir in listaContagemDetalheIncluir)
                        {
                            contIncluir.IdEstoqueContagemCabecalho = contagem.Id;
                            contDetDAL.saveOrUpdate((EstoqueContagemDetalheDTO)session.Merge(contIncluir));
                        }
                    }

                    session.Flush();
                }
                return(contagem);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
Beispiel #4
0
        public IList <EstoqueContagemCabecalhoDTO> selectEstoqueContagemCabecalhoPagina(int primeiroResultado, int quantidadeResultados, EstoqueContagemCabecalhoDTO estoqueContagemCabecalho)
        {
            try
            {
                IList <EstoqueContagemCabecalhoDTO> resultado = null;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL <EstoqueContagemCabecalhoDTO> DAL = new NHibernateDAL <EstoqueContagemCabecalhoDTO>(session);
                    resultado = DAL.selectPagina <EstoqueContagemCabecalhoDTO>(primeiroResultado, quantidadeResultados, estoqueContagemCabecalho);

                    foreach (EstoqueContagemCabecalhoDTO objP in resultado)
                    {
                        NHibernateDAL <EstoqueContagemDetalheDTO> contDetDAL = new NHibernateDAL <EstoqueContagemDetalheDTO>(session);
                        objP.listaContagemDetalhe = contDetDAL.select <EstoqueContagemDetalheDTO>(new EstoqueContagemDetalheDTO {
                            IdEstoqueContagemCabecalho = objP.Id
                        });
                    }
                }
                return(resultado);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
            }
        }