public int deleteAlmoxarifado(AlmoxarifadoDTO almoxarifado)
 {
     try
     {
         int resultado = -1;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL<AlmoxarifadoDTO> DAL = new NHibernateDAL<AlmoxarifadoDTO>(session);
             DAL.delete(almoxarifado);
             session.Flush();
             resultado = 0;
         }
         return resultado;
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
Exemple #2
0
 public static int ExcluiR06(R06DTO pR06)
 {
     try
     {
         int Resultado = -1;
         using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession())
         {
             NHibernateDAL <R06DTO> DAL = new NHibernateDAL <R06DTO>(Session);
             DAL.Delete(pR06);
             Session.Flush();
             Resultado = 0;
         }
         return(Resultado);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
 public int deleteTributGrupoTributario(TributGrupoTributarioDTO tributGrupoTributario)
 {
     try
     {
         int resultado = -1;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL <TributGrupoTributarioDTO> DAL = new NHibernateDAL <TributGrupoTributarioDTO>(session);
             DAL.delete(tributGrupoTributario);
             session.Flush();
             resultado = 0;
         }
         return(resultado);
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
        public static IList <EcfTotalTipoPagamentoDTO> ConsultaEcfTotalTipoPagamentoLista(string pFiltro)
        {
            try
            {
                IList <EcfTotalTipoPagamentoDTO> Resultado = null;
                using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession())
                {
                    NHibernateDAL <EcfTotalTipoPagamentoDTO> DAL = new NHibernateDAL <EcfTotalTipoPagamentoDTO>(Session);

                    String ConsultaSql = "from EcfTotalTipoPagamento where " + pFiltro;
                    Resultado = DAL.SelectListaSql <EcfTotalTipoPagamentoDTO>(ConsultaSql);
                }
                return(Resultado);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
            }
        }
Exemple #5
0
 public static void GravaNfeFormaPagamentoLista(List <NfeFormaPagamentoDTO> pListaNfeFormaPagamento)
 {
     try
     {
         using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession())
         {
             NHibernateDAL <NfeFormaPagamentoDTO> DAL = new NHibernateDAL <NfeFormaPagamentoDTO>(Session);
             for (int i = 0; i < pListaNfeFormaPagamento.Count; i++)
             {
                 DAL.SaveOrUpdate(pListaNfeFormaPagamento[i]);
                 Session.Flush();
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
Exemple #6
0
        public static NfceOperadorDTO Usuario(String pLogin, String pSenha)
        {
            try
            {
                NfceOperadorDTO Resultado = null;
                using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession())
                {
                    NHibernateDAL <NfceOperadorDTO> DAL = new NHibernateDAL <NfceOperadorDTO>(Session);

                    String ConsultaSql = "from NfceOperadorDTO where Login="******" and Senha=" + Biblioteca.QuotedStr(pSenha);
                    Resultado = DAL.SelectObjetoSql <NfceOperadorDTO>(ConsultaSql);
                }
                return(Resultado);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
            }
        }
Exemple #7
0
        public static R06DTO ConsultaR06(string pFiltro)
        {
            try
            {
                R06DTO Resultado = null;
                using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession())
                {
                    NHibernateDAL <R06DTO> DAL = new NHibernateDAL <R06DTO>(Session);

                    String ConsultaSql = "from R06DTO where " + pFiltro;
                    Resultado = DAL.SelectObjetoSql <R06DTO>(ConsultaSql);
                }
                return(Resultado);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
            }
        }
        public static R02DTO GravaR02(R02DTO pR02)
        {
            try
            {
                pR02.Logss = "0";
                MemoryStream StreamJson = new MemoryStream();
                DataContractJsonSerializer SerializaJson = new DataContractJsonSerializer(typeof(R02DTO));
                SerializaJson.WriteObject(StreamJson, pR02);
                StreamReader LerStreamJson = new StreamReader(StreamJson);
                StreamJson.Position = 0;
                pR02.Logss          = Biblioteca.MD5String(LerStreamJson.ReadToEnd());

                R02DTO Resultado = null;
                using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession())
                {
                    NHibernateDAL <R02DTO> DAL = new NHibernateDAL <R02DTO>(Session);
                    Resultado = DAL.SaveOrUpdate(pR02);

                    for (int i = 0; i <= pR02.ListaR03.Count; i++)
                    {
                        pR02.ListaR03[i].SerieEcf = Sessao.Instance.Configuracao.EcfImpressora.Serie;
                        pR02.ListaR03[i].Logss    = "0";

                        MemoryStream StreamJsonDetalhe = new MemoryStream();
                        DataContractJsonSerializer SerializaJsonDetalhe = new DataContractJsonSerializer(typeof(R03DTO));
                        SerializaJsonDetalhe.WriteObject(StreamJsonDetalhe, pR02.ListaR03[i]);
                        StreamReader LerStreamJsonDetalhe = new StreamReader(StreamJsonDetalhe);
                        StreamJsonDetalhe.Position = 0;
                        pR02.ListaR03[i].Logss     = Biblioteca.MD5String(LerStreamJsonDetalhe.ReadToEnd());

                        NHibernateDAL <R03DTO> DALDetalhe = new NHibernateDAL <R03DTO>(Session);
                        DALDetalhe.SaveOrUpdate(pR02.ListaR03[i]);
                    }

                    Session.Flush();
                }
                return(pR02);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
            }
        }
Exemple #9
0
 public int deletePontoFechamentoJornada(PontoFechamentoJornadaDTO pontoFechamentoJornada)
 {
     try
     {
         int resultado = -1;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL <PontoFechamentoJornadaDTO> DAL = new NHibernateDAL <PontoFechamentoJornadaDTO>(session);
             DAL.delete(pontoFechamentoJornada);
             session.Flush();
             resultado = 0;
         }
         return(resultado);
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
 public int deleteViewFinChequeNaoCompensado(ViewFinChequeNaoCompensadoDTO viewFinChequeNaoCompensado)
 {
     try
     {
         int resultado = -1;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL <ViewFinChequeNaoCompensadoDTO> DAL = new NHibernateDAL <ViewFinChequeNaoCompensadoDTO>(session);
             DAL.delete(viewFinChequeNaoCompensado);
             session.Flush();
             resultado = 0;
         }
         return(resultado);
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
 public int deleteFinDocumentoOrigem(FinDocumentoOrigemDTO finDocumentoOrigem)
 {
     try
     {
         int resultado = -1;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL <FinDocumentoOrigemDTO> DAL = new NHibernateDAL <FinDocumentoOrigemDTO>(session);
             DAL.delete(finDocumentoOrigem);
             session.Flush();
             resultado = 0;
         }
         return(resultado);
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
Exemple #12
0
 public int deletePatrimIndiceAtualizacao(PatrimIndiceAtualizacaoDTO patrimIndiceAtualizacao)
 {
     try
     {
         int resultado = -1;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL <PatrimIndiceAtualizacaoDTO> DAL = new NHibernateDAL <PatrimIndiceAtualizacaoDTO>(session);
             DAL.delete(patrimIndiceAtualizacao);
             session.Flush();
             resultado = 0;
         }
         return(resultado);
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
 public int deleteNaturezaFinanceira(NaturezaFinanceiraDTO naturezaFinanceira)
 {
     try
     {
         int resultado = -1;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL <NaturezaFinanceiraDTO> DAL = new NHibernateDAL <NaturezaFinanceiraDTO>(session);
             DAL.delete(naturezaFinanceira);
             session.Flush();
             resultado = 0;
         }
         return(resultado);
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
        public static bool ExisteVendaAberta()
        {
            try
            {
                EcfVendaCabecalhoDTO Resultado = null;
                using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession())
                {
                    NHibernateDAL <EcfVendaCabecalhoDTO> DAL = new NHibernateDAL <EcfVendaCabecalhoDTO>(Session);

                    String ConsultaSql = "from EcfVendaCabecalhoDTO where StatusVenda = " + Biblioteca.QuotedStr("A");
                    Resultado = DAL.SelectObjetoSql <EcfVendaCabecalhoDTO>(ConsultaSql);
                }
                return(Resultado != null);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
            }
        }
Exemple #15
0
 public int deleteContratoTipoServico(ContratoTipoServicoDTO contratoTipoServico)
 {
     try
     {
         int resultado = -1;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL <ContratoTipoServicoDTO> DAL = new NHibernateDAL <ContratoTipoServicoDTO>(session);
             DAL.delete(contratoTipoServico);
             session.Flush();
             resultado = 0;
         }
         return(resultado);
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
Exemple #16
0
        public int salvarProduto(ProdutoDTO produto)
        {
            try
            {
                int resultado = -1;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL <ProdutoDTO> prodDAL = new NHibernateDAL <ProdutoDTO>(session);
                    prodDAL.saveOrUpdate(produto);

                    session.Flush();
                    resultado = 0;
                }
                return(resultado);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
        public int deleteAtividadeForCli(AtividadeForCliDTO atividadeforcli)
        {
            try
            {
                int resultado = -1;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<AtividadeForCliDTO> atividadeforcliDAL = new NHibernateDAL<AtividadeForCliDTO>(session);
                    atividadeforcliDAL.delete(atividadeforcli);
                    session.Flush();
                    resultado = 0;
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
        public int deleteBaseCreditoPis(BaseCreditoPisDTO basecreditopis)
        {
            try
            {
                int resultado = -1;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<BaseCreditoPisDTO> basecreditopisDAL = new NHibernateDAL<BaseCreditoPisDTO>(session);
                    basecreditopisDAL.delete(basecreditopis);
                    session.Flush();
                    resultado = 0;
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
Exemple #19
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);
            }
        }
Exemple #20
0
        public void Registrar(Empresa objeto)
        {
            using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession())
            {
                NHibernateDAL <Empresa> DAL = new NHibernateDAL <Empresa>(Session);
                objeto.Logotipo = "";

                string  filtro  = "CNPJ = '" + objeto.Cnpj + "'";
                Empresa empresa = new EmpresaService().ConsultarObjetoFiltro(filtro);
                if (empresa != null)
                {
                    if (empresa.Registrado != "P")
                    {
                        objeto.Id         = empresa.Id;
                        objeto.Registrado = "P";
                        DAL.SaveOrUpdate(objeto);
                        Session.Flush();
                        EnviarEmailConfirmacao(objeto);
                    }
                }
            }
        }
        public static IList <NfeCabecalhoDTO> ConsultaNfceVendaCabecalhoLista(string pFiltro)
        {
            try
            {
                IList <NfeCabecalhoDTO> Resultado = null;
                using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession())
                {
                    NHibernateDAL <NfeCabecalhoDTO> DAL = new NHibernateDAL <NfeCabecalhoDTO>(Session);

                    String ConsultaSql = "from NfeCabecalhoDTO where " + pFiltro;
                    Resultado = DAL.SelectListaSql <NfeCabecalhoDTO>(ConsultaSql);

                    if (Resultado != null)
                    {
                        for (int i = 0; i <= Resultado.Count - 1; i++)
                        {
                            // Consulta lista de detalhes
                            NHibernateDAL <NfeDetalheDTO> DALDetalhe = new NHibernateDAL <NfeDetalheDTO>(Session);
                            Resultado[i].ListaNfeDetalhe = DALDetalhe.Select <NfeDetalheDTO>(
                                new NfeDetalheDTO {
                                IdNfeCabecalho = Resultado[i].Id
                            });

                            // Consulta lista de pagamentos
                            NHibernateDAL <NfeFormaPagamentoDTO> DALPagamento = new NHibernateDAL <NfeFormaPagamentoDTO>(Session);
                            Resultado[i].ListaNfeFormaPagamento = DALPagamento.Select <NfeFormaPagamentoDTO>(
                                new NfeFormaPagamentoDTO {
                                IdNfeCabecalho = Resultado[i].Id
                            });
                        }
                    }
                }
                return(Resultado);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
            }
        }
Exemple #22
0
        public int deleteCotacaoCompra(CompraCotacaoDTO cotacaoCompra)
        {
            try
            {
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    IDAL <CompraCotacaoDTO>           cotacaoCompraDAL    = new NHibernateDAL <CompraCotacaoDTO>(session);
                    IDAL <CompraCotacaoDetalheDTO>    cotacaoCompraDetDAL = new NHibernateDAL <CompraCotacaoDetalheDTO>(session);
                    IDAL <CompraFornecedorCotacaoDTO> fornecedorCompraDAL = new NHibernateDAL <CompraFornecedorCotacaoDTO>(session);

                    IList <CompraFornecedorCotacaoDTO> listaFDelete = fornecedorCompraDAL.select(
                        new CompraFornecedorCotacaoDTO {
                        IdCompraCotacao = cotacaoCompra.Id
                    });

                    foreach (CompraFornecedorCotacaoDTO fornecedor in listaFDelete)
                    {
                        IList <CompraCotacaoDetalheDTO> listaCDelete = cotacaoCompraDetDAL.select(
                            new CompraCotacaoDetalheDTO {
                            IdCompraFornecedorCotacao = fornecedor.Id
                        });

                        foreach (CompraCotacaoDetalheDTO cotacaoDet in listaCDelete)
                        {
                            cotacaoCompraDetDAL.delete(cotacaoDet);
                        }

                        fornecedorCompraDAL.delete(fornecedor);
                    }
                    int resultado = cotacaoCompraDAL.delete(cotacaoCompra);
                    session.Flush();
                    return(resultado);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #23
0
        public RequisicaoInternaCabecalhoDTO salvarAtualizarRequisicaoInternaCabecalho(RequisicaoInternaCabecalhoDTO requisicao)
        {
            try
            {
                int resultado = -1;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL <RequisicaoInternaCabecalhoDTO> reqDAL = new NHibernateDAL <RequisicaoInternaCabecalhoDTO>(session);
                    reqDAL.saveOrUpdate(requisicao);

                    NHibernateDAL <RequisicaoInternaDetalheDTO> reqDetDAL = new NHibernateDAL <RequisicaoInternaDetalheDTO>(session);
                    IList <RequisicaoInternaDetalheDTO>         listaReqDetalheExcluir = reqDetDAL.select <RequisicaoInternaDetalheDTO>(new RequisicaoInternaDetalheDTO {
                        IdRequisicaoInternaCabecalho = requisicao.Id
                    });

                    foreach (RequisicaoInternaDetalheDTO reqExc in listaReqDetalheExcluir)
                    {
                        reqDetDAL.delete(reqExc);
                    }

                    IList <RequisicaoInternaDetalheDTO> listaReqDetalheIncluir = requisicao.ListaRequisicaoInternaDetalhe;

                    foreach (RequisicaoInternaDetalheDTO reqIncluir in listaReqDetalheIncluir)
                    {
                        reqIncluir.IdRequisicaoInternaCabecalho = requisicao.Id;
                        reqDetDAL.saveOrUpdate((RequisicaoInternaDetalheDTO)session.Merge(reqIncluir));
                    }

                    session.Flush();
                    resultado = 0;
                }
                return(requisicao);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
Exemple #24
0
        public PessoaDTO selectPessoa(PessoaDTO pessoa)
        {
            PessoaDTO resultado = null;

            using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
            {
                NHibernateDAL <PessoaDTO> DAL = new NHibernateDAL <PessoaDTO>(session);
                resultado = DAL.selectId <PessoaDTO>(pessoa.Id);

                if (resultado != null)
                {
                    NHibernateDAL <EnderecoDTO> DALEnd   = new NHibernateDAL <EnderecoDTO>(session);
                    IList <EnderecoDTO>         listaEnd = DALEnd.select <EnderecoDTO>(new EnderecoDTO {
                        IdPessoa = resultado.Id
                    });
                    if (listaEnd != null && listaEnd.Count > 0)
                    {
                        resultado.Endereco = listaEnd.First();
                    }
                }
            }
            return(resultado);
        }
Exemple #25
0
 public void ConferirCodigoConfirmacao(Empresa objeto, string codigoConfirmacao)
 {
     using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession())
     {
         NHibernateDAL <Empresa> DAL = new NHibernateDAL <Empresa>(Session);
         objeto.Logotipo = "";
         string codigo = Biblioteca.MD5String(objeto.Cnpj + Constantes.CHAVE);
         if (codigo == codigoConfirmacao)
         {
             string  filtro  = "CNPJ = '" + objeto.Cnpj + "'";
             Empresa empresa = new EmpresaService().ConsultarObjetoFiltro(filtro);
             if (empresa != null)
             {
                 objeto.Id           = empresa.Id;
                 objeto.Registrado   = "S";
                 objeto.DataRegistro = DateTime.Now;
                 objeto.HoraRegistro = Biblioteca.DataParaHora(DateTime.Now);
                 DAL.SaveOrUpdate(objeto);
                 Session.Flush();
             }
         }
     }
 }
Exemple #26
0
        public CompraPedidoDTO updatePedidoCompra(CompraPedidoDTO pedidoCompra)
        {
            try
            {
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    IDAL <CompraPedidoDTO> pedidoCompraDAL = new NHibernateDAL <CompraPedidoDTO>(session);
                    CompraPedidoDTO        resultado       = pedidoCompraDAL.update(pedidoCompra);

                    IDAL <CompraPedidoDetalheDTO> pedidoCompraDetDAL = new NHibernateDAL <CompraPedidoDetalheDTO>(session);

                    IList <CompraPedidoDetalheDTO> listaDetalheExcluir = pedidoCompraDetDAL.select
                                                                             (new CompraPedidoDetalheDTO {
                        IdCompraPedido = pedidoCompra.Id
                    });

                    foreach (CompraPedidoDetalheDTO pDetalhe in listaDetalheExcluir)
                    {
                        pedidoCompraDetDAL.delete(pDetalhe);
                    }

                    foreach (CompraPedidoDetalheDTO pedidoDetalhe in pedidoCompra.listaPedidoCompraDetalhe)
                    {
                        pedidoDetalhe.IdCompraPedido = pedidoCompra.Id;
                        pedidoCompraDetDAL.save(pedidoDetalhe);
                    }
                    session.Flush();

                    return(resultado);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static FinLancamentoReceberDTO GravaFinLancamentoReceber(FinLancamentoReceberDTO pFinLancamentoReceber)
        {
            try
            {
                using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession())
                {
                    NHibernateDAL <FinLancamentoReceberDTO> DAL = new NHibernateDAL <FinLancamentoReceberDTO>(Session);
                    DAL.SaveOrUpdate(pFinLancamentoReceber);

                    for (int i = 0; i <= pFinLancamentoReceber.ListaFinParcelaReceber.Count; i++)
                    {
                        NHibernateDAL <FinParcelaReceberDTO> DALDetalhe = new NHibernateDAL <FinParcelaReceberDTO>(Session);
                        DALDetalhe.SaveOrUpdate(pFinLancamentoReceber.ListaFinParcelaReceber[i]);
                    }

                    Session.Flush();
                }
                return(pFinLancamentoReceber);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
            }
        }
        public static int CancelaItemVenda(int pItem)
        {
            try
            {
                int Resultado = -1;
                using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession())
                {
                    NHibernateDAL <NfeDetalheDTO> DALDetalhe = new NHibernateDAL <NfeDetalheDTO>(Session);
                    NfeDetalheDTO Detalhe = DALDetalhe.SelectObjeto <NfeDetalheDTO>(
                        new NfeDetalheDTO {
                        NumeroItem = pItem, IdNfeCabecalho = Sessao.Instance.VendaAtual.Id
                    }
                        );

                    if (Detalhe != null)
                    {
                        // Se o item existe na base, exclui o imposto e o item
                        NfeDetalheImpostoIcmsDTO Icms = new NfeDetalheImpostoIcmsDTO();
                        Icms.IdNfeDetalhe = Detalhe.Id;

                        NHibernateDAL <NfeDetalheImpostoIcmsDTO> DALIcms = new NHibernateDAL <NfeDetalheImpostoIcmsDTO>(Session);
                        DALIcms.Delete(Icms);

                        DALDetalhe.Delete(Detalhe);

                        Session.Flush();
                        Resultado = 0;
                    }
                }
                return(Resultado);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
            }
        }
        public IList <EmpresaDTO> Select(EmpresaDTO objeto)
        {
            try
            {
                IList <EmpresaDTO> resultado = base.Select <EmpresaDTO>(objeto);

                foreach (EmpresaDTO objP in resultado)
                {
                    NHibernateDAL <EmpresaEnderecoDTO> DAL = new NHibernateDAL <EmpresaEnderecoDTO>(Session);
                    objP.ListaEndereco = DAL.Select <EmpresaEnderecoDTO>(new EmpresaEnderecoDTO {
                        IdEmpresa = objP.Id
                    });

                    if (objP.ListaEndereco == null)
                    {
                        objP.ListaEndereco = new List <EmpresaEnderecoDTO>();
                    }
                    else
                    {
                        for (int i = 0; i <= objP.ListaEndereco.Count - 1; i++)
                        {
                            if (objP.ListaEndereco[i].Principal == "S")
                            {
                                objP.EnderecoPrincipal = objP.ListaEndereco[i];
                            }
                        }
                    }
                }

                return(resultado);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static EcfVendaCabecalhoDTO ConsultaEcfVendaCabecalho(string pFiltro)
        {
            try
            {
                EcfVendaCabecalhoDTO Resultado = null;
                using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession())
                {
                    NHibernateDAL <EcfVendaCabecalhoDTO> DAL = new NHibernateDAL <EcfVendaCabecalhoDTO>(Session);

                    String ConsultaSql = "from EcfVendaCabecalhoDTO where " + pFiltro;
                    Resultado = DAL.SelectObjetoSql <EcfVendaCabecalhoDTO>(ConsultaSql);

                    if (Resultado != null)
                    {
                        // Consulta lista de detalhes
                        NHibernateDAL <EcfVendaDetalheDTO> DALDetalhe = new NHibernateDAL <EcfVendaDetalheDTO>(Session);
                        Resultado.ListaEcfVendaDetalhe = DALDetalhe.Select <EcfVendaDetalheDTO>(
                            new EcfVendaDetalheDTO {
                            IdEcfVendaCabecalho = Resultado.Id
                        });

                        // Consulta lista de pagamentos
                        NHibernateDAL <EcfTotalTipoPagamentoDTO> DALPagamento = new NHibernateDAL <EcfTotalTipoPagamentoDTO>(Session);
                        Resultado.ListaEcfTotalTipoPagamento = DALPagamento.Select <EcfTotalTipoPagamentoDTO>(
                            new EcfTotalTipoPagamentoDTO {
                            IdEcfVendaCabecalho = Resultado.Id
                        });
                    }
                }
                return(Resultado);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
            }
        }
        public static EcfVendaDetalheDTO GravaEcfVendaDetalhe(EcfVendaDetalheDTO pEcfVendaDetalhe)
        {
            try
            {
                using (ISession Session = NHibernateHelper.GetSessionFactory().OpenSession())
                {
                    MemoryStream StreamJsonDetalhe = new MemoryStream();
                    DataContractJsonSerializer SerializaJsonDetalhe = new DataContractJsonSerializer(typeof(EcfVendaDetalheDTO));
                    SerializaJsonDetalhe.WriteObject(StreamJsonDetalhe, pEcfVendaDetalhe);
                    StreamReader LerStreamJsonDetalhe = new StreamReader(StreamJsonDetalhe);
                    StreamJsonDetalhe.Position = 0;
                    pEcfVendaDetalhe.Logss     = Biblioteca.MD5String(LerStreamJsonDetalhe.ReadToEnd());

                    NHibernateDAL <EcfVendaDetalheDTO> DAL = new NHibernateDAL <EcfVendaDetalheDTO>(Session);
                    DAL.SaveOrUpdate(pEcfVendaDetalhe);
                    Session.Flush();
                }
                return(pEcfVendaDetalhe);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
            }
        }
Exemple #32
0
        public CompraPedidoDTO selectPedidoCompraId(CompraPedidoDTO pedidoCompra)
        {
            try
            {
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    IDAL <CompraPedidoDTO> pedidoCompraDAL = new NHibernateDAL <CompraPedidoDTO>(session);
                    CompraPedidoDTO        resultado       = pedidoCompraDAL.selectId <CompraPedidoDTO>((int)pedidoCompra.Id);

                    IDAL <CompraPedidoDetalheDTO> pedidoCompraDetDAL = new NHibernateDAL <CompraPedidoDetalheDTO>(session);

                    resultado.listaPedidoCompraDetalhe = pedidoCompraDetDAL.select(
                        new CompraPedidoDetalheDTO {
                        IdCompraPedido = resultado.Id
                    });

                    return(resultado);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public IList<SituacaoForCliDTO> selectSituacaoForCliPagina(int primeiroResultado, int quantidadeResultados, SituacaoForCliDTO situacaoforcli)
        {
            try
            {
                IList<SituacaoForCliDTO> resultado = null;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<SituacaoForCliDTO> situacaoforcliDAL = new NHibernateDAL<SituacaoForCliDTO>(session);
                    resultado = situacaoforcliDAL.selectPagina(primeiroResultado, quantidadeResultados, situacaoforcli);
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
        public IList<SefipCodigoMovimentacaoDTO> selectSefipCodigoMovimentacaoPagina(int primeiroResultado, int quantidadeResultados, SefipCodigoMovimentacaoDTO sefip_codigo_movimentacao)
        {
            try
            {
                IList<SefipCodigoMovimentacaoDTO> resultado = null;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<SefipCodigoMovimentacaoDTO> sefip_codigo_movimentacaoDAL = new NHibernateDAL<SefipCodigoMovimentacaoDTO>(session);
                    resultado = sefip_codigo_movimentacaoDAL.selectPagina(primeiroResultado, quantidadeResultados, sefip_codigo_movimentacao);
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
        public int salvarAtualizarCep(CepDTO cep)
        {
            try
            {
                int resultado = -1;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<CepDTO> cepDAL = new NHibernateDAL<CepDTO>(session);
                    cepDAL.saveOrUpdate(cep);
                    session.Flush();
                    resultado = 0;
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
 public CargoDTO salvarAtualizarCargo(CargoDTO cargo)
 {
     try
     {
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL<CargoDTO> DAL = new NHibernateDAL<CargoDTO>(session);
             DAL.saveOrUpdate(cargo);
             session.Flush();
         }
         return cargo;
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
 public IList<UnidadeProdutoDTO> selectUnidadeProdutoPagina(int primeiroResultado, int quantidadeResultados, UnidadeProdutoDTO unidadeProduto)
 {
     try
     {
         IList<UnidadeProdutoDTO> resultado = null;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL<UnidadeProdutoDTO> DAL = new NHibernateDAL<UnidadeProdutoDTO>(session);
             resultado = DAL.selectPagina<UnidadeProdutoDTO>(primeiroResultado, quantidadeResultados, unidadeProduto);
         }
         return resultado;
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
        public IList<SituacaoForCliDTO> selectSituacaoForCli(SituacaoForCliDTO situacaoforcli)
        {
            try
            {
                IList<SituacaoForCliDTO> resultado = null;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<SituacaoForCliDTO> situacaoforcliDAL = new NHibernateDAL<SituacaoForCliDTO>(session);
                    resultado = situacaoforcliDAL.select(situacaoforcli);
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
 public IList<TipoRelacionamentoDTO> selectTipoRelacionamento(TipoRelacionamentoDTO tipoRelacionamento)
 {
     try
     {
         IList<TipoRelacionamentoDTO> resultado = null;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL<TipoRelacionamentoDTO> DAL = new NHibernateDAL<TipoRelacionamentoDTO>(session);
             resultado = DAL.select(tipoRelacionamento);
         }
         return resultado;
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
        public IList<SalarioMinimoDTO> selectSalarioMinimoPagina(int primeiroResultado, int quantidadeResultados, SalarioMinimoDTO salario_minimo)
        {
            try
            {
                IList<SalarioMinimoDTO> resultado = null;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<SalarioMinimoDTO> salario_minimoDAL = new NHibernateDAL<SalarioMinimoDTO>(session);
                    resultado = salario_minimoDAL.selectPagina(primeiroResultado, quantidadeResultados, salario_minimo);
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
        public IList<TalonarioChequeDTO> selectTalonarioChequePagina(int primeiroResultado, int quantidadeResultados, TalonarioChequeDTO talonariocheque)
        {
            try
            {
                IList<TalonarioChequeDTO> resultado = null;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<TalonarioChequeDTO> talonariochequeDAL = new NHibernateDAL<TalonarioChequeDTO>(session);
                    resultado = talonariochequeDAL.selectPagina(primeiroResultado, quantidadeResultados, talonariocheque);
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
 public IList<TipoCreditoPisDTO> selectTipoCredioPis(TipoCreditoPisDTO dto)
 {
     try
     {
         IList<TipoCreditoPisDTO> resultado = null;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL<TipoCreditoPisDTO> DAL = new NHibernateDAL<TipoCreditoPisDTO>(session);
             resultado = DAL.select(dto);
         }
         return resultado;
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
 public int deleteOperadoraPlanoSaude(OperadoraPlanoSaudeDTO operadoraplanosaude)
 {
     try
     {
         int resultado = -1;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL<OperadoraPlanoSaudeDTO> operadoraplanosaudeDAL = new NHibernateDAL<OperadoraPlanoSaudeDTO>(session);
             operadoraplanosaudeDAL.delete(operadoraplanosaude);
             session.Flush();
             resultado = 0;
         }
         return resultado;
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
        public int deleteNcm(NcmDTO ncm)
        {
            try
            {
                int resultado = -1;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<NcmDTO> ncmDAL = new NHibernateDAL<NcmDTO>(session);
                    ncmDAL.delete(ncm);
                    session.Flush();
                    resultado = 0;
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
        public int deleteFeriados(FeriadosDTO feriados)
        {
            try
            {
                int resultado = -1;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<FeriadosDTO> feriadosDAL = new NHibernateDAL<FeriadosDTO>(session);
                    feriadosDAL.delete(feriados);
                    session.Flush();
                    resultado = 0;
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
 public IList<TipoCreditoPisDTO> selectTipoCredioPisPagina(int primeiroResultado, int quantidadeResultados, TipoCreditoPisDTO dto)
 {
     try
     {
         IList<TipoCreditoPisDTO> resultado = null;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL<TipoCreditoPisDTO> DAL = new NHibernateDAL<TipoCreditoPisDTO>(session);
             resultado = DAL.selectPagina(primeiroResultado, quantidadeResultados, dto);
         }
         return resultado;
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
 public IList<SituacaoDocumentoDTO> selectSituacaoDocumento(SituacaoDocumentoDTO dto)
 {
     try
     {
         IList<SituacaoDocumentoDTO> resultado = null;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL<SituacaoDocumentoDTO> DAL = new NHibernateDAL<SituacaoDocumentoDTO>(session);
             resultado = DAL.select(dto);
         }
         return resultado;
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
 public IList<TributIcmsCustomCabDTO> selectTributIcmsCustomCab(TributIcmsCustomCabDTO tributIcmsCustomCab)
 {
     try
     {
         IList<TributIcmsCustomCabDTO> resultado = null;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL<TributIcmsCustomCabDTO> DAL = new NHibernateDAL<TributIcmsCustomCabDTO>(session);
             resultado = DAL.select(tributIcmsCustomCab);
         }
         return resultado;
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
        public IList<TalonarioChequeDTO> selectTalonarioCheque(TalonarioChequeDTO talonariocheque)
        {
            try
            {
                IList<TalonarioChequeDTO> resultado = null;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<TalonarioChequeDTO> talonariochequeDAL = new NHibernateDAL<TalonarioChequeDTO>(session);
                    resultado = talonariochequeDAL.select(talonariocheque);
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
        public int deleteTalonarioCheque(TalonarioChequeDTO talonariocheque)
        {
            try
            {
                int resultado = -1;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<TalonarioChequeDTO> talonariochequeDAL = new NHibernateDAL<TalonarioChequeDTO>(session);
                    talonariochequeDAL.delete(talonariocheque);
                    session.Flush();
                    resultado = 0;
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
 public int deleteTipoColaborador(TipoColaboradorDTO tipoColaborador)
 {
     try
     {
         int resultado = -1;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL<TipoColaboradorDTO> DAL = new NHibernateDAL<TipoColaboradorDTO>(session);
             DAL.delete(tipoColaborador);
             session.Flush();
             resultado = 0;
         }
         return resultado;
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
 public int deleteTipoCredioPis(TipoCreditoPisDTO dto)
 {
     try
     {
         int resultado = -1;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL<TipoCreditoPisDTO> DAL = new NHibernateDAL<TipoCreditoPisDTO>(session);
             DAL.delete(dto);
             session.Flush();
             resultado = 0;
         }
         return resultado;
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
        public int deleteSalarioMinimo(SalarioMinimoDTO salario_minimo)
        {
            try
            {
                int resultado = -1;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<SalarioMinimoDTO> salario_minimoDAL = new NHibernateDAL<SalarioMinimoDTO>(session);
                    salario_minimoDAL.delete(salario_minimo);
                    session.Flush();
                    resultado = 0;
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
 public IList<TributOperacaoFiscalDTO> selectTributOperacaoFiscalPagina(int primeiroResultado, int quantidadeResultados, TributOperacaoFiscalDTO tributOperacaoFiscal)
 {
     try
     {
         IList<TributOperacaoFiscalDTO> resultado = null;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL<TributOperacaoFiscalDTO> DAL = new NHibernateDAL<TributOperacaoFiscalDTO>(session);
             resultado = DAL.selectPagina<TributOperacaoFiscalDTO>(primeiroResultado, quantidadeResultados, tributOperacaoFiscal);
         }
         return resultado;
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
        public int deleteSefipCodigoMovimentacao(SefipCodigoMovimentacaoDTO sefip_codigo_movimentacao)
        {
            try
            {
                int resultado = -1;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<SefipCodigoMovimentacaoDTO> sefip_codigo_movimentacaoDAL = new NHibernateDAL<SefipCodigoMovimentacaoDTO>(session);
                    sefip_codigo_movimentacaoDAL.delete(sefip_codigo_movimentacao);
                    session.Flush();
                    resultado = 0;
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
        public int deleteSituacaoForCli(SituacaoForCliDTO situacaoforcli)
        {
            try
            {
                int resultado = -1;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<SituacaoForCliDTO> situacaoforcliDAL = new NHibernateDAL<SituacaoForCliDTO>(session);
                    situacaoforcliDAL.delete(situacaoforcli);
                    session.Flush();
                    resultado = 0;
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
        public int deleteCstPis(CstPisDTO cstpis)
        {
            try
            {
                int resultado = -1;
                using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
                {
                    NHibernateDAL<CstPisDTO> cstpisDAL = new NHibernateDAL<CstPisDTO>(session);
                    cstpisDAL.delete(cstpis);
                    session.Flush();
                    resultado = 0;
                }
                return resultado;
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
 public IList<SituacaoColaboradorDTO> selectSituacaoColaboradorPagina(int primeiroResultado, int quantidadeResultados, SituacaoColaboradorDTO situacaoColaborador)
 {
     try
     {
         IList<SituacaoColaboradorDTO> resultado = null;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL<SituacaoColaboradorDTO> DAL = new NHibernateDAL<SituacaoColaboradorDTO>(session);
             resultado = DAL.selectPagina<SituacaoColaboradorDTO>(primeiroResultado, quantidadeResultados, situacaoColaborador);
         }
         return resultado;
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message + (ex.InnerException != null ? " " + ex.InnerException.Message : ""));
     }
 }
Exemple #59
0
        public void GerarBloco0()
        {
            Empresa = new EmpresaDAL(Session).SelectId(IdEmpresa);
            ContadorDTO Contador = new NHibernateDAL <ContadorDTO>(Session).SelectId <ContadorDTO>(IdContador);

            consultaSql = "from ViewSpedNfeEmitenteDTO emitente where Id in (Select cab.Fornecedor.Id from NfeCabecalhoDTO as cab where cab.DataHoraEmissao BETWEEN " + Biblioteca.QuotedStr(DataInicial) + " and " + Biblioteca.QuotedStr(DataFinal) + ")";
            IList <ViewSpedNfeEmitenteDTO> ListaEmitente = new NHibernateDAL <ViewSpedNfeEmitenteDTO>(Session).SelectListaSql <ViewSpedNfeEmitenteDTO>(consultaSql);

            consultaSql = "from ViewSpedNfeDestinatarioDTO destinatario where Id in (Select cab.Cliente.Id from NfeCabecalhoDTO as cab where cab.DataHoraEmissao BETWEEN " + Biblioteca.QuotedStr(DataInicial) + " and " + Biblioteca.QuotedStr(DataFinal) + ")";
            IList <ViewSpedNfeDestinatarioDTO> ListaDestinatario = new NHibernateDAL <ViewSpedNfeDestinatarioDTO>(Session).SelectListaSql <ViewSpedNfeDestinatarioDTO>(consultaSql);

            consultaSql = "from ViewSpedNfeItemDTO item where Id in (Select det.Produto.Id from NfeDetalheDTO as det inner join det.NfeCabecalho as cab where cab.DataHoraEmissao BETWEEN " + Biblioteca.QuotedStr(DataInicial) + " and " + Biblioteca.QuotedStr(DataFinal) + ")";
            IList <ViewSpedNfeItemDTO> ListaProduto = new NHibernateDAL <ViewSpedNfeItemDTO>(Session).SelectListaSql <ViewSpedNfeItemDTO>(consultaSql);

            IList <TributOperacaoFiscalDTO> ListaOperacaoFiscal = new NHibernateDAL <TributOperacaoFiscalDTO>(Session).Select(new TributOperacaoFiscalDTO());

            var bloco0 = sped.getBloco0();

            // Registro 0000: ABERTURA DO ARQUIVO DIGITAL E IDENTIFICAÇÃO DA ENTIDADE
            sped.getBloco0().getRegistro0000().setDtIni(System.DateTime.Parse(DataInicial));
            sped.getBloco0().getRegistro0000().setDtFin(System.DateTime.Parse(DataFinal));
            sped.getBloco0().getRegistro0000().setCodVer(VersaoLeiaute.ToString());
            //sped.getBloco0().getRegistro0000().setCodFin(FinalidadeArquivo.ToString());
            //sped.getBloco0().getRegistro0000().setIndPerfil(PerfilApresentacao.ToString());
            sped.getBloco0().getRegistro0000().setNome(Empresa.RazaoSocial);
            sped.getBloco0().getRegistro0000().setCnpj(Empresa.Cnpj);
            sped.getBloco0().getRegistro0000().setCpf("");
            sped.getBloco0().getRegistro0000().setIe(Empresa.InscricaoEstadual);
            sped.getBloco0().getRegistro0000().setCodMun(Empresa.CodigoIbgeCidade.Value);
            sped.getBloco0().getRegistro0000().setIm(Empresa.InscricaoMunicipal);
            sped.getBloco0().getRegistro0000().setSuframa(Empresa.Suframa);
            sped.getBloco0().getRegistro0000().setIndAtiv("1");
            sped.getBloco0().getRegistro0000().setUf(Empresa.EnderecoPrincipal.Uf);

            // REGISTRO 0001: ABERTURA DO BLOCO 0
            sped.getBloco0().getRegistro0001().setIndMov(0);

            // REGISTRO 0035: IDENTIFICAÇÃO DE SOCIEDADE EM CONTA DE PARTICIPAÇÃO – SCP
            //{ Não Implementado }

            // REGISTRO 0100: DADOS DO CONTABILISTA
            sped.getBloco0().getRegistro0100().setNome(Contador.Nome);
            sped.getBloco0().getRegistro0100().setCpf(Contador.Cpf);
            sped.getBloco0().getRegistro0100().setCpf(Contador.Cnpj);
            sped.getBloco0().getRegistro0100().setCrc(Contador.InscricaoCrc);
            sped.getBloco0().getRegistro0100().setCep(Contador.Cep);
            sped.getBloco0().getRegistro0100().setEndereco(Contador.Logradouro);
            sped.getBloco0().getRegistro0100().setNum(Contador.Numero);
            sped.getBloco0().getRegistro0100().setCompl(Contador.Complemento);
            sped.getBloco0().getRegistro0100().setBairro(Contador.Bairro);
            sped.getBloco0().getRegistro0100().setFone(Contador.Fone);
            sped.getBloco0().getRegistro0100().setFax(Contador.Fax);
            sped.getBloco0().getRegistro0100().setEmail(Contador.Email);
            sped.getBloco0().getRegistro0100().setCodMun(Contador.MunicipioIbge.Value);

            // REGISTRO  0110:  REGIMES  DE  APURAÇÃO  DA  CONTRIBUIÇÃO  SOCIAL  E  DE APROPRIAÇÃO DE CRÉDITO
            sped.getBloco0().getRegistro0110().setCodIncTrib("1");
            sped.getBloco0().getRegistro0110().setIndAproCred("1");
            sped.getBloco0().getRegistro0110().setCodTipoCont("1");

            // REGISTRO  0111:  TABELA  DE  RECEITA  BRUTA  MENSAL  PARA  FINS  DE  RATEIO  DE CRÉDITOS COMUNS
            // REGISTRO  0120:  IDENTIFICAÇÃO  DE  PERÍODOS  DISPENSADOS  DA  ESCRITURAÇÃO FISCAL DIGITAL DAS CONTRIBUIÇÕES – EFD-CONTRIBUIÇÕES
            // { Não Implementados }

            // REGISTRO 0140: TABELA DE CADASTRO DE ESTABELECIMENTO
            sped.getBloco0().getRegistro0140().setCodEst("MATRIZ");
            sped.getBloco0().getRegistro0140().setNome(Empresa.RazaoSocial);
            sped.getBloco0().getRegistro0140().setCnpj(Empresa.Cnpj);
            sped.getBloco0().getRegistro0140().setUf(Empresa.EnderecoPrincipal.Uf);
            sped.getBloco0().getRegistro0140().setIe(Empresa.InscricaoEstadual);
            sped.getBloco0().getRegistro0140().setCodMun(Empresa.CodigoIbgeCidade.Value);
            sped.getBloco0().getRegistro0140().setIm(Empresa.InscricaoMunicipal);
            sped.getBloco0().getRegistro0140().setSuframa(Empresa.Suframa);

            // REGISTRO 0145: REGIME DE APURAÇÃO DA CONTRIBUIÇÃO PREVIDENCIÁRIA SOBRE A RECEITA BRUTA
            // { Não Implementado }

            // REGISTRO 0150: TABELA DE CADASTRO DO PARTICIPANTE
            Registro0150 registro0150;

            foreach (ViewSpedNfeEmitenteDTO Emitente in ListaEmitente)
            {
                registro0150 = new Registro0150();

                registro0150.setCodPart("F" + Emitente.Id);
                registro0150.setNome(Emitente.RazaoSocial);
                registro0150.setCodPais("01058");
                if (Emitente.CpfCnpj.Length == 11)
                {
                    registro0150.setCpf(Emitente.CpfCnpj);
                }
                else if (Emitente.CpfCnpj.Length == 14)
                {
                    registro0150.setCnpj(Emitente.CpfCnpj);
                }
                registro0150.setIe(Emitente.InscricaoEstadual);
                registro0150.setCodMun(Emitente.CodigoMunicipio);
                registro0150.setSuframa(Emitente.Suframa);
                registro0150.setEndereco(Emitente.Logradouro);
                registro0150.setNum(Emitente.Numero);
                registro0150.setCompl(Emitente.Complemento);
                registro0150.setBairro(Emitente.Bairro);

                sped.getBloco0().getRegistro0140().getRegistro0150List().Add(registro0150);
            }

            foreach (ViewSpedNfeDestinatarioDTO Destinatario in ListaDestinatario)
            {
                registro0150 = new Registro0150();

                registro0150.setCodPart("F" + Destinatario.Id);
                registro0150.setNome(Destinatario.RazaoSocial);
                registro0150.setCodPais("01058");
                if (Destinatario.CpfCnpj.Length == 11)
                {
                    registro0150.setCpf(Destinatario.CpfCnpj);
                }
                else if (Destinatario.CpfCnpj.Length == 14)
                {
                    registro0150.setCnpj(Destinatario.CpfCnpj);
                }
                registro0150.setIe(Destinatario.InscricaoEstadual);
                registro0150.setCodMun(Destinatario.CodigoMunicipio);
                registro0150.setSuframa(Destinatario.Suframa);
                registro0150.setEndereco(Destinatario.Logradouro);
                registro0150.setNum(Destinatario.Numero);
                registro0150.setCompl(Destinatario.Complemento);
                registro0150.setBairro(Destinatario.Bairro);

                sped.getBloco0().getRegistro0140().getRegistro0150List().Add(registro0150);
            }


            //REGISTRO 0200: TABELA DE IDENTIFICAÇÃO DO ITEM (PRODUTO E SERVIÇOS)
            Registro0200             registro0200;
            ArrayList                ListaSiglaUnidade = new ArrayList();
            List <UnidadeProdutoDTO> ListaUnidade      = new List <UnidadeProdutoDTO>();

            foreach (ViewSpedNfeItemDTO Produto in ListaProduto)
            {
                registro0200 = new Registro0200();

                registro0200.setCodItem(Produto.Id.ToString());
                registro0200.setDescrItem(Produto.Nome);
                registro0200.setCodBarra(Produto.Gtin);
                //TEM QUE PREENCHER PARA INFORMAR NO 0205
                registro0200.setCodAntItem("");
                registro0200.setUnidInv(Produto.IdUnidadeProduto.ToString());
                registro0200.setTipoItem(Produto.TipoItemSped);
                registro0200.setCodNcm(Produto.Ncm);
                registro0200.setExIpi(Produto.ExTipi);
                registro0200.setCodGen(Produto.Ncm.Substring(0, 2));
                registro0200.setCodLst(Produto.CodigoLst);
                registro0200.setAliqIcms(Produto.AliquotaIcmsPaf);

                if (ListaSiglaUnidade.IndexOf(Produto.IdUnidadeProduto) == -1)
                {
                    ListaSiglaUnidade.Add(Convert.ToString(Produto.IdUnidadeProduto));
                    UnidadeProdutoDTO Unidade = new UnidadeProdutoDTO();
                    Unidade.Id    = Produto.IdUnidadeProduto;
                    Unidade.Sigla = Produto.Sigla;
                    ListaUnidade.Add(Unidade);
                }

                consultaSql = "from ProdutoAlteracaoItemDTO item where item.DataInicial BETWEEN " + Biblioteca.QuotedStr(DataInicial) + " and " + Biblioteca.QuotedStr(DataFinal);
                IList <ProdutoAlteracaoItemDTO> ListaProdutoAlterado = new NHibernateDAL <ProdutoAlteracaoItemDTO>(Session).SelectListaSql <ProdutoAlteracaoItemDTO>(consultaSql);

                // REGISTRO 0205: ALTERAÇÃO DO ITEM
                Registro0205 registro0205;
                foreach (ProdutoAlteracaoItemDTO ProdutoAlterado in ListaProdutoAlterado)
                {
                    registro0205 = new Registro0205();

                    registro0205.setDescrAntItem(ProdutoAlterado.Nome);
                    registro0205.setDtIni(ProdutoAlterado.DataInicial.Value);
                    registro0205.setDtFin(ProdutoAlterado.DataFinal.Value);
                    registro0205.setCodAntItem(ProdutoAlterado.Codigo);

                    registro0200.getRegistro0205List().Add(registro0205);
                }

                sped.getBloco0().getRegistro0140().getRegistro0200List().Add(registro0200);
            }


            // REGISTRO 0190: IDENTIFICAÇÃO DAS UNIDADES DE MEDIDA
            Registro0190 registro0190;

            foreach (UnidadeProdutoDTO Unidade in ListaUnidade)
            {
                registro0190 = new Registro0190();

                registro0190.setUnid(Unidade.Id.ToString());
                registro0190.setDescr(Unidade.Sigla);

                sped.getBloco0().getRegistro0140().getRegistro0190List().Add(registro0190);
            }


            // REGISTRO 0206: CÓDIGO DE PRODUTO CONFORME TABELA PUBLICADA PELA ANP (COMBUSTÍVEIS)
            // { Não Implementado }

            // REGISTRO 0208: CÓDIGO DE GRUPOS POR MARCA COMERCIAL– REFRI (BEBIDAS FRIAS).
            // { Não Implementado }


            // REGISTRO 0400: TABELA DE NATUREZA DA OPERAÇÃO/PRESTAÇÃO
            Registro0400 registro0400;

            foreach (TributOperacaoFiscalDTO OperacaoFiscal in ListaOperacaoFiscal)
            {
                registro0400 = new Registro0400();

                registro0400.setCodNat(OperacaoFiscal.Id.ToString());
                registro0400.setDescrNat(OperacaoFiscal.DescricaoNaNf);
            }

            // REGISTRO 0450: TABELA DE INFORMAÇÃO COMPLEMENTAR DO DOCUMENTO FISCAL
            //{ Não Implementado }

            // REGISTRO 0500: PLANO DE CONTAS CONTÁBEIS
            //{ Não Implementado }

            // REGISTRO 0600: CENTRO DE CUSTOS
            //{ Não Implementado }
        }
 public int deleteEstadoCivil(EstadoCivilDTO estadoCivil)
 {
     try
     {
         int resultado = -1;
         using (ISession session = NHibernateHelper.getSessionFactory().OpenSession())
         {
             NHibernateDAL<EstadoCivilDTO> DAL = new NHibernateDAL<EstadoCivilDTO>(session);
             DAL.delete(estadoCivil);
             session.Flush();
             resultado = 0;
         }
         return resultado;
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }