public PreVendaCabecalhoDTO SelectObjetoPreVendaCabecalho(string pFiltro) { try { PreVendaCabecalhoDTO Resultado = null; using (ISession Session = NHibernateHelper.getSessionFactory().OpenSession()) { NHibernateDAL <PreVendaCabecalhoDTO> DAL = new NHibernateDAL <PreVendaCabecalhoDTO>(Session); Resultado = DAL.SelectObjetoSql <PreVendaCabecalhoDTO>(pFiltro); if (Resultado != null) { NHibernateDAL <PreVendaDetalheDTO> DALDetalhe = new NHibernateDAL <PreVendaDetalheDTO>(Session); Resultado.ListaPreVendaDetalhe = DAL.Select <PreVendaDetalheDTO>(new PreVendaDetalheDTO { IdPreVendaCabecalho = Resultado.Id }); if (Resultado.ListaPreVendaDetalhe == null) { Resultado.ListaPreVendaDetalhe = new List <PreVendaDetalheDTO>(); } } } return(Resultado); } catch (Exception ex) { throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : "")); } }
public IList <PreVendaCabecalhoDTO> SelectPreVendaCabecalho(PreVendaCabecalhoDTO preVendaCabecalho) { try { IList <PreVendaCabecalhoDTO> Resultado = null; using (ISession Session = NHibernateHelper.getSessionFactory().OpenSession()) { NHibernateDAL <PreVendaCabecalhoDTO> DAL = new NHibernateDAL <PreVendaCabecalhoDTO>(Session); Resultado = DAL.Select(preVendaCabecalho); foreach (PreVendaCabecalhoDTO objP in Resultado) { NHibernateDAL <PreVendaDetalheDTO> DALDetalhe = new NHibernateDAL <PreVendaDetalheDTO>(Session); objP.ListaPreVendaDetalhe = DAL.Select <PreVendaDetalheDTO>(new PreVendaDetalheDTO { IdPreVendaCabecalho = objP.Id }); if (objP.ListaPreVendaDetalhe == null) { objP.ListaPreVendaDetalhe = new List <PreVendaDetalheDTO>(); } } } return(Resultado); } catch (Exception ex) { throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : "")); } }
public void DeletePreVendaCabecalho(PreVendaCabecalhoDTO preVendaCabecalho) { try { using (ISession Session = NHibernateHelper.getSessionFactory().OpenSession()) { NHibernateDAL <PreVendaCabecalhoDTO> DAL = new NHibernateDAL <PreVendaCabecalhoDTO>(Session); DAL.Delete(preVendaCabecalho); Session.Flush(); } } catch (Exception ex) { throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : "")); } }
public PreVendaCabecalhoDTO SalvarAtualizarPreVendaCabecalho(PreVendaCabecalhoDTO preVendaCabecalho) { try { using (ISession Session = NHibernateHelper.getSessionFactory().OpenSession()) { NHibernateDAL <PreVendaCabecalhoDTO> DAL = new NHibernateDAL <PreVendaCabecalhoDTO>(Session); DAL.SaveOrUpdate(preVendaCabecalho); Session.Flush(); } return(preVendaCabecalho); } catch (Exception ex) { throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : "")); } }