protected void btnOk_Click(object sender, EventArgs e)
    {
        try
        {
            string login     = txtLogin.Text.ToUpper().Trim();
            string nome      = txtNome.Text.ToUpper().Trim();
            string sobrenome = txtSobrenome.Text.ToUpper().Trim();
            string senha     = FuncoesGerais.RetornaSHA512Base64(txtSenha.Text.ToUpper().Trim());

            if (MySql.ExecuteNonQuery("INSERT INTO UsuariosAdmin ( login, nome, sobrenome, senha ) VALUES ('" + login + "','" + nome + "','" + sobrenome + "','" + senha + "') ") != 1)
            {
                throw new Exception("Erro ao inserir.");
            }
            lblMsg.Visible = false;
        }
        catch (Exception ex)
        {
            lblMsg.Visible = true;
            lblMsg.Text    = ex.Message;
        }
        finally
        {
            LimpaCampos();
        }
    }
示例#2
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        DataTable dt;
        string    Senha_Crip;

        dt = MySql.FillDataTable("SELECT LOGIN, SENHA FROM UsuariosAdmin WHERE LOGIN = '******'");
        if (dt.Rows.Count == 1)
        {
            Senha_Crip = FuncoesGerais.RetornaSHA512Base64(txtSenha.Text);
            if (Senha_Crip == dt.Rows[0]["SENHA"].ToString())
            {
                System.Web.Security.FormsAuthentication.RedirectFromLoginPage(txtUsuario.Text.ToUpper(), false);
            }
            else
            {
                lblErro.Visible = true;
                lblErro.Text    = "Senha incorreta.";
            }
        }
        else
        {
            lblErro.Visible = true;
            lblErro.Text    = "Login incorreto.";
        }
    }
示例#3
0
        private void TmCancelamento_Tick(object sender, EventArgs e)
        {
            EnviarCancelamentoSefaz envCancelamento;

            mCancelamento = new Model_Cancelamento();
            eCancelamento = new Entidade_Cancelamento();


            TmCancelamento.Enabled = false;

            var dtCancelamento = mCancelamento.ConsultarCancelementosSolicitados();

            for (int i = 0; i < dtCancelamento.Rows.Count; i++)
            {
                envCancelamento = new EnviarCancelamentoSefaz();

                eCancelamento.id   = Convert.ToInt32(dtCancelamento.Rows[i]["idoperacao"]);
                eCancelamento.Loja = Convert.ToInt32(dtCancelamento.Rows[i]["id_loja"]);
                //eCancelamento.CdFornec = dtCancelamento.Rows[i]["CdFornec"] != null ? Convert.ToInt32(dtCancelamento.Rows[i]["CdFornec"]) : 0;
                eCancelamento.NmSerie          = dtCancelamento.Rows[i]["serienf"].ToString();
                eCancelamento.NrNf             = Convert.ToInt32(dtCancelamento.Rows[i]["NrNF"].ToString());
                eCancelamento.CnpjCpf          = dtCancelamento.Rows[i]["cnpj"].ToString();
                eCancelamento.ChaveAcessoNfe   = dtCancelamento.Rows[i]["TxChAcessoNfe"].ToString();
                eCancelamento.TpNf             = dtCancelamento.Rows[i]["TpNFe"].ToString();
                eCancelamento.ProtocoloAutoriz = dtCancelamento.Rows[i]["NrProtocoloAutorizNfe"].ToString().Trim();
                eCancelamento.cUf = Convert.ToInt32(dtCancelamento.Rows[i]["cdUfCidadeIbge_Empresa"].ToString().Substring(0, dtCancelamento.Rows[i]["cdUfCidadeIbge_Empresa"].ToString().Length - 5));
                eCancelamento.CodigoIbgeEmpresa = dtCancelamento.Rows[i]["cdUfCidadeIbge_Empresa"].ToString();
                eCancelamento.DataHora          = dtCancelamento.Rows[i]["DtOperacao"].ToString();
                eCancelamento.TpAmb             = FuncoesGerais.TipoAmbiente();;
                eCancelamento.Justificatica     = "CANCELAMENTO DE NOTA FISCAL POR PROBLEMAS LANCAMENTO";
                envCancelamento.Enviar(eCancelamento, out eCancelamento);
            }

            TmCancelamento.Enabled = true;
        }
示例#4
0
        public JsonResult RecuperarDadosRecebimento(int codigoRecebimento)
        {
            var recebimento = _recebimentoService
                              .List()
                              .Where(y => y.Id.Equals(codigoRecebimento))
                              .Select(x => new RecebimentoClienteDto
            {
                IdRecebimento       = x.Id,
                CodigoCliente       = x.CodigoCliente,
                CodigoServico       = x.CodigoServico,
                CodigoEspecialidade = x.CodigoEspecialidade,
                CodigoProfissional  = x.CodigoProfissional,
                DataAquisicao       = x.DataAquisicao,
                DataPagamento       = x.DataPagamento,
                DataVencimento      = x.DataVencimento,
                DescricaoServico    = x.Servico.Descricao,
                SituacaoPagamento   = FuncoesGerais.GetEnumDescription(x.SituacaoPagamento),
                TipoPagamento       = FuncoesGerais.GetEnumDescription(x.TipoPagamento),
                CodTipoPagamento    = Convert.ToInt32(x.TipoPagamento),
                UsuarioRecebimento  = x.UsuarioRecebimento,
                ValorDevido         = x.ValorDevido,
                ValorRecebido       = x.ValorRecebido
            })
                              .FirstOrDefault();

            return(Json(recebimento, JsonRequestBehavior.AllowGet));
        }
示例#5
0
        private void TmInutilizacao_Tick(object sender, EventArgs e)
        {
            Model_InutilizacaoNfe mInut    = new Model_InutilizacaoNfe();
            EnviarInutilizacao    nEnvInut = new EnviarInutilizacao();

            TmInutilizacao.Enabled = false;

            var dtInut = mInut.Pesquisar();

            for (int i = 0; i < dtInut.Rows.Count; i++)
            {
                eInut = new Entidade_Inutilizacao();

                eInut.Loja       = int.Parse(dtInut.Rows[i]["id_loja"].ToString());
                eInut.cUf        = Convert.ToInt32(dtInut.Rows[i]["cdUfCidadeIbge_Empresa"].ToString().Substring(0, dtInut.Rows[i]["cdUfCidadeIbge_Empresa"].ToString().Length - 5));
                eInut.Cnpj       = dtInut.Rows[i]["cnpj"].ToString();
                eInut.sSerieNf   = dtInut.Rows[i]["serienf"].ToString().Trim();
                eInut.NrIni      = int.Parse(dtInut.Rows[i]["numero_ini"].ToString());
                eInut.NrFim      = int.Parse(dtInut.Rows[i]["numero_fim"].ToString());
                eInut.ModNfe     = int.Parse(dtInut.Rows[i]["ModNfe"].ToString());
                eInut.TpAmbiente = FuncoesGerais.TipoAmbiente();
                nEnvInut.Enviar(eInut, out eInut);
            }

            TmInutilizacao.Enabled = true;
        }
示例#6
0
        /// <summary>
        /// Procura o elemento pelo conteúdo do atributo "Description"
        /// </summary>
        /// <param name="value">Valor a verificar</param>
        public static T?FindByEnumDescription <T>(this string value) where T : struct
        {
            int iResultado;
            var dicEnum = FuncoesGerais.ObterChaveValorEnum <T>();

            return(dicEnum.TryGetValue(value, out iResultado) ? iResultado.ToEnumValue <T>() : new T?());
        }
示例#7
0
    protected void gvUsuarios_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            string      login     = gvUsuarios.DataKeys[e.RowIndex].Value.ToString();
            GridViewRow row       = gvUsuarios.Rows[e.RowIndex];
            string      nome      = ((TextBox)row.Cells[1].FindControl("txtNome")).Text;
            string      sobrenome = ((TextBox)row.Cells[1].FindControl("txtSobrenome")).Text;
            string      senha     = FuncoesGerais.RetornaSHA512Base64(((TextBox)row.Cells[3].FindControl("txtSenha")).Text);

            if (MySql.ExecuteNonQuery("UPDATE UsuariosAdmin SET NOME = '" + nome + "', SOBRENOME = '" + sobrenome + "', SENHA = '" + senha + "' WHERE LOGIN = '******' ") != 0)
            {
                gvUsuarios.EditIndex = -1;
                BindGrid();
                lblMsg.Visible = false;
            }
            else
            {
                throw new Exception("Erro ao atualizar.");
            }
        }
        catch (Exception ex)
        {
            lblMsg.Visible = true;
            lblMsg.Text    = ex.Message;
        }
    }
示例#8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Ajax.Utility.RegisterTypeForAjax(typeof(Utils.ExportarImportarPedido));

            if (!IsPostBack)
            {
                lblTamanhoMaximo.Text += FuncoesGerais.GetTamanhoMaximoUpload() + " MB";
            }
        }
示例#9
0
        protected override void AddedControl(Control control, int index)
        {
            if (FuncoesGerais.IsChrome(Page))
            {
                this.Page.ClientTarget = "uplevel";
            }

            base.AddedControl(control, index);
        }
示例#10
0
        public Entidade_CCe PesquisarCartaEletronica()
        {
            Entidade_CCe            ObjEntCarta       = new Entidade_CCe();
            Entidade_ItemCCe        ObjEntItemCCe     = new Entidade_ItemCCe();
            List <Entidade_ItemCCe> ObjListEntItemCCe = new List <Entidade_ItemCCe>();

            mCartaEletronica = new Model_CCe();
            int seqItem = 0;
            var DtCarta = mCartaEletronica.ConsultaCartas();

            for (int i = 0; i < DtCarta.Rows.Count; i++)
            {
                ObjEntCarta = new Entidade_CCe();

                ObjEntCarta.id_loja      = Convert.ToInt32(DtCarta.Rows[i]["id_loja"]);
                ObjEntCarta.Id_CCe_Lote  = Convert.ToInt32(DtCarta.Rows[i]["Id_cce_lote"]);
                ObjEntCarta.TipoAmbiente = FuncoesGerais.TipoAmbiente();
                ObjEntCarta.cUF          = Convert.ToInt32(DtCarta.Rows[i]["cdUfCidadeIbge_Empresa"].ToString().Substring(0, 2));
                CodUfEmpresa             = Convert.ToInt32(DtCarta.Rows[i]["cdUfCidadeIbge_Empresa"].ToString().Substring(0, 2));

                seqItem = 0;

                for (int j = 0; j < DtCarta.Rows.Count; j++)
                {
                    ObjEntItemCCe = new Entidade_ItemCCe();

                    if (ObjEntCarta.Id_CCe_Lote == Convert.ToInt32(DtCarta.Rows[j]["Id_CCe_Lote"]))
                    {
                        ObjEntItemCCe.id_loja                = Convert.ToInt32(DtCarta.Rows[j]["id_loja"]);
                        ObjEntItemCCe.Dt_Prot_Nfe            = Convert.ToDateTime(DtCarta.Rows[j]["Dt_Prot_Nfe"]);
                        ObjEntItemCCe.CdUfCidadeIbge_Empresa = Convert.ToInt32(DtCarta.Rows[i]["cdUfCidadeIbge_Empresa"].ToString().Substring(0, 2));
                        ObjEntItemCCe.TxChAcessoNfe          = DtCarta.Rows[j]["TxChAcessoNfe"].ToString();
                        ObjEntItemCCe.NrNf          = Convert.ToInt32(DtCarta.Rows[j]["NrNf"]);
                        ObjEntItemCCe.serienf       = DtCarta.Rows[j]["serienf"].ToString();
                        ObjEntItemCCe.CdCpfCgc      = DtCarta.Rows[j]["CdCpfCgc"].ToString();
                        ObjEntItemCCe.Ambiente      = DtCarta.Rows[j]["TipoEmissao"].ToString();
                        ObjEntItemCCe.Desc_Correcao = DtCarta.Rows[j]["Desc_Correcao"].ToString();
                        //ObjEntItemCCe.NrSeqEnvio = Convert.ToInt32(DtCarta.Rows[j]["NrSeqEnvio"]);
                        ObjEntItemCCe.NrSeqEnvio = seqItem += 1;
                        ObjListEntItemCCe.Add(ObjEntItemCCe);
                    }
                    else
                    {
                        break;
                    }
                }

                ObjEntCarta.ItemCCe = ObjListEntItemCCe;
                break;
            }

            return(ObjEntCarta);
        }
示例#11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Ajax.Utility.RegisterTypeForAjax(typeof(Glass.UI.Web.Cadastros.Projeto.ExportarImportar));

            if (!IsPostBack)
            {
                lblTamanhoMaximo.Text += FuncoesGerais.GetTamanhoMaximoUpload() + " MB";
                if (Request["exportar"] != null)
                {
                    Page.ClientScript.RegisterStartupScript(GetType(),
                                                            "exportar", "exportar('" + Request["exportar"] + "'" + "," + Request["semFolgas"] + ");", true);
                }
            }
        }
        protected void btnRetificarEncontroContas_Click(object sender, EventArgs e)
        {
            try
            {
                int    idEncontroContas = Glass.Conversoes.StrParaInt(hdfIdEncontroContas.Value);
                string dtVenc           = ((TextBox)ctrlDataVenc.FindControl("txtData")).Text;
                string msg = WebGlass.Business.EncontroContas.Fluxo.EncontroContas.Instance.Retificar(idEncontroContas, hdfIdsContasPg.Value, hdfIdsContasR.Value, dtVenc);

                Glass.MensagemAlerta.ShowMsg(msg, Page);
                FuncoesGerais.RedirecionaPagina("../Listas/lstEncontroContas.aspx", Page);
            }
            catch (Exception ex)
            {
                Glass.MensagemAlerta.ErrorMsg("Falha ao retificar sinal.", ex, Page);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Ajax.Utility.RegisterTypeForAjax(typeof(ExportarImportarFerragem));

            if (!IsPostBack)
            {
                lblTamanhoMaximo.Text += string.Format("{0} MB", FuncoesGerais.GetTamanhoMaximoUpload());

                // Verifica se existem ids de ferragem na URL atual.
                if (Request["exportar"] != null)
                {
                    // Registra um script que irá chamar o método de exportação de ferragens, para todos os ids de ferragem informados na URL atual.
                    Page.ClientScript.RegisterStartupScript(GetType(), "exportar", string.Format("exportar('{0}');", Request["exportar"]), true);
                }
            }
        }
示例#14
0
        protected void btnFinalizar_Click(object sender, EventArgs e)
        {
            try
            {
                uint   idEncontroContas = Glass.Conversoes.StrParaUint(Request["idEncontroContas"]);
                string dtVenc           = ((TextBox)dtvEncontroContas.FindControl("ctrlDataVenc").FindControl("txtData")).Text;

                string msg = WebGlass.Business.EncontroContas.Fluxo.EncontroContas.Instance.Finalizar(idEncontroContas, dtVenc);

                Glass.MensagemAlerta.ShowMsg(msg, Page);
                FuncoesGerais.RedirecionaPagina("../Listas/LstEncontroContas.aspx", Page);
            }
            catch (Exception ex)
            {
                Glass.MensagemAlerta.ErrorMsg("Falha ao finalizar encontro de contas a pagar/receber.", ex, Page);
            }
        }
示例#15
0
        public TDownloadNFe(Entidade_DownloadNFe ObjEntDownload)
        {
            var DtLoja = FuncoesGerais.Loja(ObjEntDownload.id_loja);

            if (FuncoesGerais.TipoAmbiente() == "HOM")
            {
                this.tpAmb = TAmb.Item2;
            }
            else
            {
                this.tpAmb = TAmb.Item1;
            }
            this.chNFe  = ObjEntDownload.ChaveNFe.ToArray();
            this.CNPJ   = DtLoja.Rows[0]["cnpj"].ToString();
            this.versao = TVerDownloadNFe.Item100;
            this.xServ  = TDownloadNFeXServ.DOWNLOADNFE;
        }
示例#16
0
        public TEventoInfEvento(int loja, DateTime DtEvento, Entidade_ItemManifestacao objitem)
        {
            var DtEmpresa = FuncoesGerais.Loja(loja);

            this.Id       = "ID" + objitem.codmanifestacao + objitem.chaveacesso + objitem.idseq.ToString().PadLeft(2, '0');
            this.chNFe    = objitem.chaveacesso;
            this.dhEvento = string.Format("{0:s}", Convert.ToDateTime(DtEvento)) + "-03:00";
            this.cOrgao   = TCOrgaoIBGE.Item91; //(TCOrgaoIBGE)NegocioFuncoesGerais.RetornoCodigoIbge(Convert.ToInt32(FuncoesGerais.UfIbgeEmpresa(loja)));
            if (FuncoesGerais.TipoAmbiente() == "PROD")
            {
                this.tpAmb = TAmb.Item1;                        // 1- Produção | 2 - Homologação
            }
            else
            {
                this.tpAmb = TAmb.Item2;
            }
            this.ItemElementName = ItemChoiceType.CNPJ;     // DA EMPRESA EMITENTE
            this.Item            = DtEmpresa.Rows[0]["cnpj"].ToString();

            switch (objitem.codmanifestacao)
            {
            case 210200:
                this.tpEvento = TEventoInfEventoTpEvento.Item210200;
                break;

            case 210210:
                this.tpEvento = TEventoInfEventoTpEvento.Item210210;
                break;

            case 210220:
                this.tpEvento = TEventoInfEventoTpEvento.Item210220;
                break;

            case 210240:
                this.tpEvento = TEventoInfEventoTpEvento.Item210240;
                break;
            }

            this.nSeqEvento = objitem.idseq.ToString();
            this.verEvento  = "1.00";
            this.detEvento  = new TEventoInfEventoDetEvento(objitem);
        }
示例#17
0
        public TConsNFeDest(int loja)
        {
            var DtLoja = FuncoesGerais.Loja(loja);

            this.versao = TVeConsNFeDest.Item101;
            if (FuncoesGerais.TipoAmbiente() == "HOM")
            {
                this.tpAmb = TAmb.Item2;
            }
            else
            {
                this.tpAmb = TAmb.Item1;
            }

            this.xServ  = TConsNFeDestXServ.CONSULTARNFEDEST;
            this.CNPJ   = DtLoja.Rows[0]["cnpj"].ToString();
            this.indNFe = TConsNFeDestIndNFe.Item0;
            this.indEmi = TConsNFeDestIndEmi.Item1;
            this.ultNSU = "0";
        }
示例#18
0
        private void TmStatus_Tick(object sender, EventArgs e)
        {
            EnviarStatus status = new EnviarStatus();

            TmStatus.Enabled = false;
            try
            {
                var dtRet = FuncoesGerais.LojasEmitentes();

                for (int i = 0; i < dtRet.Rows.Count; i++)
                {
                    eRet            = new Entidade_Status();
                    eRet.Loja       = int.Parse(dtRet.Rows[i]["idloja"].ToString());
                    eRet.tpAmbiente = FuncoesGerais.TipoAmbiente();
                    eRet.cUf        = FuncoesGerais.UfIbgeEmpresa(int.Parse(dtRet.Rows[i]["idloja"].ToString()));
                    eRet.Uf         = dtRet.Rows[i]["uf"].ToString();
                    eRet.versao     = dtRet.Rows[i]["VersaoNfe"].ToString();
                    status.Enviar(eRet, out eRet);

                    if (eRet != null)
                    {
                        txtStatus.Text      = eRet.cStatus;
                        txtAmb.Text         = eRet.AmbienteFormatado;
                        txtMsg.Text         = eRet.sMotivo;
                        TxtVersao.Text      = eRet.versao;
                        txtUltConsulta.Text = eRet.dhRet;
                    }
                }
                TmStatus.Enabled = true;
            }
            catch (XmlException exm)
            {
                TmStatus.Enabled = true;
                throw new Exception(exm.Message.ToString());
            }
            catch (Exception ex)
            {
                TmStatus.Enabled = true;
                throw new Exception(ex.Message.ToString());
            }
        }
        public void EnviarXml(XmlDocument doc, X509Certificate2 cert, ref Entidade_ConsNFDest obj)
        {
            object retObj = new object();

            UrlEstados = new UrlNfesEstados();
            NFeConsultaDest.NFeConsultaDest wNfeConsDest = new NFeConsultaDest.NFeConsultaDest();
            NFeConsultaDest.nfeCabecMsg     wCabMsg      = new NFeConsultaDest.nfeCabecMsg();

            wCabMsg.cUF         = FuncoesGerais.UfIbgeEmpresa(obj.id_loja);
            wCabMsg.versaoDados = "1.01";

            wNfeConsDest.SoapVersion     = System.Web.Services.Protocols.SoapProtocolVersion.Soap12;
            wNfeConsDest.PreAuthenticate = true;
            wNfeConsDest.ClientCertificates.Add(cert);
            wNfeConsDest.nfeCabecMsgValue = wCabMsg;

            nodeList   = doc.GetElementsByTagName("consNFeDest");
            nodeStatus = nodeList.Item(0);
            //wNfeConsDest.Url = UrlEstados.SetarUrlEstado(UrlEstados.Uf(Convert.ToInt32(FuncoesGerais.UfIbgeEmpresa(obj.id_loja))), FuncoesGerais.TipoAmbiente() == "HOM" ? UrlNfesEstados.tbAmbiente.HOM : UrlNfesEstados.tbAmbiente.PROD, UrlNfesEstados.TipoUrlEnvio.RecepcaoEvento);
            retObj = wNfeConsDest.nfeConsultaNFDest(nodeStatus);

            DeserilizarEvento(retObj, ref obj);
        }
示例#20
0
        private void TmConsultaLote_Tick(object sender, EventArgs e)
        {
            TmConsultaLote.Enabled = false;

            ConRecibo  nRec  = new ConRecibo();
            Model_Lote mLote = new Model_Lote();

            eRec = new Entidade_Recibo();

            var retDt = mLote.LotesNaoProcessados();

            for (int i = 0; i < retDt.Rows.Count; i++)
            {
                eRec.TpNf   = retDt.Rows[i]["TpNFe"].ToString();
                eRec.Recibo = retDt.Rows[i]["NrRecibo"].ToString();
                eRec.Loja   = int.Parse(retDt.Rows[i]["id"].ToString());
                eRec.cUf    = int.Parse(FuncoesGerais.UfIbgeEmpresa(int.Parse(retDt.Rows[i]["id"].ToString())));
                eRec.TpAmb  = FuncoesGerais.TipoAmbiente();
                nRec.Enviar(eRec, out eRec);
            }

            TmConsultaLote.Enabled = true;
        }
        public JsonResult RecuperarPresencasPorCliente(int codigoCliente)
        {
            List <DadosPresencaDto> presencas = _agendaService
                                                .List()
                                                .Where(x => x.CodigoCliente == codigoCliente)
                                                .Select(y => new DadosPresencaDto()
            {
                CodigoCliente          = y.CodigoCliente,
                CodigoEspecialidade    = y.CodigoEspecialidade,
                CodigoProfissional     = y.CodigoProfissional,
                CodSituacaoPresenca    = (Int32)y.SituacaoPresenca,
                DataFimEvento          = y.DataFim,
                DataInicioEvento       = y.DataInicio,
                DescricaoEspecialidade = y.Especialidade.Descricao,
                IdAgenda         = y.Id,
                Justificativa    = y.ObservacaoPresenca,
                NomeCliente      = y.Cliente.Nome,
                NomeProfissional = y.Profissional.Nome,
                SituacaoPresenca = FuncoesGerais.GetEnumDescription(y.SituacaoPresenca)
            }).ToList();

            return(Json(presencas, JsonRequestBehavior.AllowGet));
        }
示例#22
0
        private void TmSemRetorno_Tick(object sender, EventArgs e)
        {
            EnviarConsultaNfe ConsultaNfe = new EnviarConsultaNfe();
            Model_NotaFiscal  mNotaFisca  = new Model_NotaFiscal();

            NFuncoes = new NegocioFuncoesGerais();

            mLog = new Model_LogNfe();

            try
            {
                TmSemRetorno.Enabled = false;
                var DtRet = mNotaFisca.ConsultarNotasFiscalSemRetornoOuDuplicadas();

                for (int i = 0; i < DtRet.Rows.Count; i++)
                {
                    eNf                = new Entidade_NotaFiscal();
                    eNf.Loja           = int.Parse(DtRet.Rows[i]["id_loja"].ToString());
                    eNf.TpNfe          = DtRet.Rows[i]["TpNfe"].ToString();
                    eNf.NotaFiscal     = int.Parse(DtRet.Rows[i]["NrNf"].ToString());
                    eNf.sSerieNf       = DtRet.Rows[i]["serienf"].ToString();
                    eNf.CdFornecedor   = Convert.ToInt32(DtRet.Rows[i]["CdFornec"].ToString());
                    eNf.ChaveAcessoNfe = DtRet.Rows[i]["TxChAcessoNfe"].ToString();
                    eNf.TpNfe          = DtRet.Rows[i]["TpNFe"].ToString();
                    eNf.cUf            = int.Parse(FuncoesGerais.UfIbgeEmpresa(int.Parse(DtRet.Rows[i]["id_loja"].ToString())));
                    eNf.TpAmbiente     = FuncoesGerais.TipoAmbiente();
                    ConsultaNfe.Enviar(eNf, out eNf);
                }
                TmSemRetorno.Enabled = true;
            }
            catch (Exception Ex)
            {
                TmSemRetorno.Enabled = true;
                mLog.InsertErroLog("Erro em consulta de nota fiscal. \nErro encontrado:" + NFuncoes.TiraCampos(Ex.Message.ToString()));
            }
        }
示例#23
0
        public JsonResult RecuperarDadosRecebimentoCliente(int codigoCliente)
        {
            var recebimentos = _clienteService.GetById(codigoCliente)
                               .Recebimentos
                               .Select(x => new RecebimentoClienteDto
            {
                IdRecebimento      = x.Id,
                CodigoCliente      = x.CodigoCliente,
                CodigoServico      = x.CodigoServico,
                DataAquisicao      = x.DataAquisicao,
                DataPagamento      = x.DataPagamento,
                DataVencimento     = x.DataVencimento,
                DescricaoServico   = x.Servico.Descricao,
                SituacaoPagamento  = FuncoesGerais.GetEnumDescription(x.SituacaoPagamento),
                TipoPagamento      = FuncoesGerais.GetEnumDescription(x.TipoPagamento),
                UsuarioRecebimento = x.UsuarioRecebimento,
                ValorDevido        = x.ValorDevido,
                ValorRecebido      = x.ValorRecebido
            })
                               .OrderByDescending(y => y.DataVencimento)
                               .ToList();

            return(Json(recebimentos, JsonRequestBehavior.AllowGet));
        }
示例#24
0
 /// <summary>
 /// Obtem o conteúdo do atributo "Description" do item da enum. Ver também Trans.<seealso cref="Trans.GetEnumDescription"/>
 /// </summary>
 /// <param name="element">Elemento da Enum a verificar</param>
 public static string GetDescription(this Enum element)
 {
     return(FuncoesGerais.GetEnumDescription(element));
 }
示例#25
0
 /// <summary>
 /// <para>Converte os elementos da enum informada para um Dicionário com os itens, onde: Key->Atributo Description, Value->int do valor da enum.</para>
 /// <para>Ver também Trans.<seealso cref="Trans.ObterChaveValorEnum{T}"/></para>
 /// </summary>
 /// <param name="origem">tem da enum para obter os itens e converter</param>
 public static Dictionary <string, int> ToDictionary <T>(this Enum origem)
 {
     return(FuncoesGerais.ObterChaveValorEnum <T>());
 }
示例#26
0
 /// <summary>
 /// Converte os elementos da enum informada para uma Lista
 /// </summary>
 /// <param name="origem">Item da enum para obter os itens e converter</param>
 public static List <T> ToList <T>(this Enum origem) where T : struct
 {
     return(FuncoesGerais.ObterChaveValorEnum <T>().Values.Select(i => i.ToEnumValue <T>()).ToList());
 }
示例#27
0
        public void DeserilizarEvento(object obj, ref Entidade_NotaFiscal objDes)
        {
            fGeral      = new FuncoesGerais();
            mNotaFiscal = new Model_NotaFiscal();

            mCartaEletronica = new Model_CCe();

            object objRet = new object();

            retXmlNodeReader = new XmlNodeReader((XmlNode)obj);
            xmlDesSerializar = new XmlSerializer(typeof(retConsSitNFe.TRetConsSitNFe));

            objRet = xmlDesSerializar.Deserialize(retXmlNodeReader);

            var Ret = (retConsSitNFe.TRetConsSitNFe)objRet;

            if (Ret.protNFe != null)
            {
                if (Ret.protNFe.infProt.cStat == "100")
                {
                    if (objDes.TpNfe == "E")
                    {
                        mNotaFiscal.UpdateNfRetornoAutorizado(Convert.ToInt32(Ret.protNFe.infProt.cStat), Ret.protNFe.infProt.nProt, objDes.Loja, objDes.ChaveAcessoNfe, Model_NotaFiscal.NotaFiscal.Entrada);
                    }
                    else
                    {
                        mNotaFiscal.UpdateNfRetornoAutorizado(Convert.ToInt32(Ret.protNFe.infProt.cStat), Ret.protNFe.infProt.nProt, objDes.Loja, objDes.ChaveAcessoNfe, Model_NotaFiscal.NotaFiscal.Saida);
                    }

                    fGeral.TramitacaoNfe(FuncoesGerais.TipoTramitacao.AutorizacaoNFe, eNotaFiscal.Loja, eNotaFiscal.NotaFiscal, eNotaFiscal.sSerieNf, eNotaFiscal.CdFornecedor);
                }
                else if (Ret.protNFe.infProt.cStat == "101" || Ret.protNFe.infProt.cStat == "102")
                {
                    if (objDes.TpNfe == "E")
                    {
                        mNotaFiscal.UpdateNfInutilizacaoCancelamento(Convert.ToInt32(Ret.protNFe.infProt.cStat), Ret.protNFe.infProt.nProt, objDes.Loja, objDes.ChaveAcessoNfe, Model_NotaFiscal.NotaFiscal.Entrada);
                    }
                    else
                    {
                        mNotaFiscal.UpdateNfInutilizacaoCancelamento(Convert.ToInt32(Ret.protNFe.infProt.cStat), Ret.protNFe.infProt.nProt, objDes.Loja, objDes.ChaveAcessoNfe, Model_NotaFiscal.NotaFiscal.Saida);
                    }

                    fGeral.TramitacaoNfe(FuncoesGerais.TipoTramitacao.Inutilizacao, eNotaFiscal.Loja, eNotaFiscal.NotaFiscal, eNotaFiscal.sSerieNf, eNotaFiscal.CdFornecedor);
                }
                else
                {
                    if (objDes.TpNfe == "E")
                    {
                        mNotaFiscal.UpdateNfRetorno(Convert.ToInt32(Ret.protNFe.infProt.cStat), Ret.protNFe.infProt.nProt, objDes.Loja, objDes.ChaveAcessoNfe, Model_NotaFiscal.NotaFiscal.Entrada);
                    }
                    else
                    {
                        mNotaFiscal.UpdateNfRetorno(Convert.ToInt32(Ret.protNFe.infProt.cStat), Ret.protNFe.infProt.nProt, objDes.Loja, objDes.ChaveAcessoNfe, Model_NotaFiscal.NotaFiscal.Saida);
                    }

                    fGeral.TramitacaoNfe(FuncoesGerais.TipoTramitacao.Indefinido, eNotaFiscal.Loja, eNotaFiscal.NotaFiscal, eNotaFiscal.sSerieNf, eNotaFiscal.CdFornecedor);
                }

                int ddd = Ret.procEventoNFe.Count();
                if (Ret.procEventoNFe.Count() > 0)
                {
                    foreach (var EventoNfe in Ret.procEventoNFe)
                    {
                        mCartaEletronica.UpdateRetornoCCeConsSit(Convert.ToInt32(EventoNfe.evento.infEvento.nSeqEvento), Convert.ToInt32(EventoNfe.retEvento.infEvento.cStat), EventoNfe.retEvento.infEvento.chNFe);
                    }
                }
            }

            string cdret = Ret.cStat;
        }
示例#28
0
        public void EnviarXml(XmlDocument doc, X509Certificate2 cert, ref Entidade_Manifestacao obj)
        {
            try
            {
                object retObj = new object();
                UrlEstados = new UrlNfesEstados();

                RecepcaoEvento.RecepcaoEvento RecepEvCanc = new RecepcaoEvento.RecepcaoEvento();
                RecepcaoEvento.nfeCabecMsg    wCabMsg     = new RecepcaoEvento.nfeCabecMsg();

                wCabMsg.cUF         = "91";//FuncoesGerais.UfIbgeEmpresa(obj.id_loja);
                wCabMsg.versaoDados = "1.00";

                RecepEvCanc.SoapVersion     = System.Web.Services.Protocols.SoapProtocolVersion.Soap12;
                RecepEvCanc.PreAuthenticate = true;
                RecepEvCanc.ClientCertificates.Add(cert);
                RecepEvCanc.nfeCabecMsgValue = wCabMsg;

                nodeList        = doc.GetElementsByTagName("envEvento");
                nodeStatus      = nodeList.Item(0);
                RecepEvCanc.Url = UrlEstados.SetarUrlEstado(UrlNfesEstados.Estado.AN, FuncoesGerais.TipoAmbiente() == "HOM" ? UrlNfesEstados.tbAmbiente.HOM : UrlNfesEstados.tbAmbiente.PROD, UrlNfesEstados.TipoUrlEnvio.RecepcaoEvento);
                retObj          = RecepEvCanc.nfeRecepcaoEvento(nodeStatus);
                DeserilizarEvento(retObj, ref obj);
            }
            catch (Exception Ex)
            {
                Mensagem.MensagemErro(Mensagem.TipoMensagem.Manifestacao, "Saida", Ex.Message.ToString());
            }
        }
示例#29
0
        public string GerarHistoricoCliente(int codigoCliente)
        {
            string dirArquivo      = Server.MapPath("~/Relatorios");
            string nomeArquivo     = "RelHistoricoCliente_" + DateTime.Now.ToString("ddMMyyyyhhmss");
            string caminhoCompleto = dirArquivo + "\\" + nomeArquivo + ".pdf";

            var normalFont   = FontFactory.GetFont(FontFactory.HELVETICA, 11, BaseColor.GRAY);
            var detailsFont  = FontFactory.GetFont(FontFactory.HELVETICA, 9, BaseColor.GRAY);
            var cellFont     = FontFactory.GetFont(FontFactory.HELVETICA, 10, BaseColor.GRAY);
            var boldFont     = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 11, BaseColor.GRAY);
            var boldTextFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 11, BaseColor.MAGENTA);
            var tituloFont   = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 14, BaseColor.MAGENTA);

            Document doc = InicializarDocumento(caminhoCompleto);

            doc.Open();

            doc = EscreverCabeçalho(doc);

            Cliente dadosCliente = _clienteService.GetById(codigoCliente);

            // Informações do Cliente
            Paragraph paragrafo = new Paragraph();

            paragrafo.Alignment = Element.ALIGN_CENTER;
            paragrafo.Add(new Phrase("HISTÓRICO DO CLIENTE\n", tituloFont));
            paragrafo.Add("\n");
            paragrafo.Add("\n");
            doc.Add(paragrafo);

            paragrafo           = new Paragraph();
            paragrafo.Alignment = Element.ALIGN_LEFT;
            paragrafo.Add(new Phrase("DADOS PESSOAIS \n", boldTextFont));
            paragrafo.Add("\n");
            doc.Add(paragrafo);

            paragrafo = new Paragraph();
            paragrafo.Add(new Phrase("Cliente: ", boldFont));
            paragrafo.Add(new Phrase(dadosCliente.Nome, normalFont));
            paragrafo.Add("\n");

            if (dadosCliente.DataNascimento != null)
            {
                paragrafo.Add(new Phrase("Aniversário: ", boldFont));
                paragrafo.Add(new Phrase(dadosCliente.DataNascimento.Value.ToString("dd/MM"), normalFont));
                paragrafo.Add("\n");
            }

            if (dadosCliente.Endereco != null)
            {
                paragrafo.Add(new Phrase("Endereço: ", boldFont));
                paragrafo.Add(new Phrase(dadosCliente.Endereco + ", " + dadosCliente.Bairro, normalFont));
                paragrafo.Add("\n");
            }

            if (dadosCliente.Cidade != null)
            {
                paragrafo.Add(new Phrase("Cidade: ", boldFont));
                paragrafo.Add(new Phrase(dadosCliente.Cidade + "/" + dadosCliente.Uf.ToUpper(), normalFont));
                paragrafo.Add("\n");
            }

            paragrafo.Add(new Phrase("Telefone: ", boldFont));
            paragrafo.Add(new Phrase((dadosCliente.TelefoneFixo != null ? dadosCliente.TelefoneFixo + "/" : "") + (dadosCliente.TelefoneCelular ?? ""), normalFont));
            paragrafo.Add("\n");

            paragrafo.Add(new Phrase("Email: ", boldFont));
            paragrafo.Add(new Phrase((dadosCliente.Email ?? "-"), normalFont));
            paragrafo.Add("\n");

            doc.Add(paragrafo);

            paragrafo = new Paragraph();
            paragrafo.Add("\n");
            paragrafo.Alignment = Element.ALIGN_LEFT;
            paragrafo.Add(new Phrase("CONSULTAS REALIZADAS \n", boldTextFont));
            paragrafo.Add("\n");
            doc.Add(paragrafo);

            PdfPCell pcell = new PdfPCell();

            PdfPTable table = new PdfPTable(4);

            table.DefaultCell.Border = Rectangle.BOTTOM_BORDER;
            table.WidthPercentage    = 100;
            float[] widths = new float[] { 15, 55, 20, 20 };
            table.SetWidths(widths);

            pcell = new PdfPCell();

            pcell = new PdfPCell(new Phrase("Data", boldFont));
            pcell.HorizontalAlignment = Element.ALIGN_CENTER;
            pcell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            pcell.Border      = PdfPCell.BOTTOM_BORDER;
            pcell.BorderColor = BaseColor.GRAY;
            table.AddCell(pcell);

            pcell = new PdfPCell(new Phrase("Serviço", boldFont));
            pcell.HorizontalAlignment = Element.ALIGN_LEFT;
            pcell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            pcell.Border      = PdfPCell.BOTTOM_BORDER;
            pcell.BorderColor = BaseColor.GRAY;
            table.AddCell(pcell);

            pcell = new PdfPCell(new Phrase("Profissional", boldFont));
            pcell.HorizontalAlignment = Element.ALIGN_LEFT;
            pcell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            pcell.Border      = PdfPCell.BOTTOM_BORDER;
            pcell.BorderColor = BaseColor.GRAY;
            table.AddCell(pcell);

            pcell = new PdfPCell(new Phrase("Presença", boldFont));
            pcell.HorizontalAlignment = Element.ALIGN_LEFT;
            pcell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            pcell.Border      = PdfPCell.BOTTOM_BORDER;
            pcell.BorderColor = BaseColor.GRAY;
            table.AddCell(pcell);

            foreach (var item in dadosCliente.Compromissos.OrderBy(x => x.DataInicio).OrderBy(y => y.DataInicio).ToList())
            {
                pcell = new PdfPCell(new Phrase(item.DataInicio.ToString("dd/MM/yyyy"), normalFont));
                pcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                pcell.Border      = PdfPCell.BOTTOM_BORDER;
                pcell.BorderColor = BaseColor.LIGHT_GRAY;
                table.AddCell(pcell);

                pcell = new PdfPCell(new Phrase(item.Servico == null ? "" : item.Servico.Descricao, normalFont));
                pcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                pcell.Border      = PdfPCell.BOTTOM_BORDER;
                pcell.BorderColor = BaseColor.LIGHT_GRAY;
                table.AddCell(pcell);

                pcell = new PdfPCell(new Phrase(item.Profissional.Nome, normalFont));
                pcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                pcell.Border      = PdfPCell.BOTTOM_BORDER;
                pcell.BorderColor = BaseColor.LIGHT_GRAY;
                table.AddCell(pcell);

                pcell = new PdfPCell(new Phrase(FuncoesGerais.GetEnumDescription(item.SituacaoPresenca), normalFont));
                pcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                pcell.Border      = PdfPCell.BOTTOM_BORDER;
                pcell.BorderColor = BaseColor.LIGHT_GRAY;
                table.AddCell(pcell);
            }

            doc.Add(table);

            paragrafo = new Paragraph();
            paragrafo.Add("\n");
            paragrafo.Alignment = Element.ALIGN_LEFT;
            paragrafo.Add(new Phrase("PAGAMENTOS REALIZADOS \n", boldTextFont));
            paragrafo.Add("\n");
            doc.Add(paragrafo);

            table = new PdfPTable(4);
            table.DefaultCell.Border = Rectangle.BOTTOM_BORDER;
            table.WidthPercentage    = 100;
            widths = new float[] { 15, 55, 20, 20 };
            table.SetWidths(widths);

            pcell = new PdfPCell();

            pcell = new PdfPCell(new Phrase("Data", boldFont));
            pcell.HorizontalAlignment = Element.ALIGN_CENTER;
            pcell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            pcell.Border      = PdfPCell.BOTTOM_BORDER;
            pcell.BorderColor = BaseColor.GRAY;
            table.AddCell(pcell);

            pcell = new PdfPCell(new Phrase("Serviço", boldFont));
            pcell.HorizontalAlignment = Element.ALIGN_LEFT;
            pcell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            pcell.Border      = PdfPCell.BOTTOM_BORDER;
            pcell.BorderColor = BaseColor.GRAY;
            table.AddCell(pcell);

            pcell = new PdfPCell(new Phrase("Profissional", boldFont));
            pcell.HorizontalAlignment = Element.ALIGN_LEFT;
            pcell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            pcell.Border      = PdfPCell.BOTTOM_BORDER;
            pcell.BorderColor = BaseColor.GRAY;
            table.AddCell(pcell);

            pcell = new PdfPCell(new Phrase("Vlr Pago", boldFont));
            pcell.HorizontalAlignment = Element.ALIGN_CENTER;
            pcell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            pcell.Border      = PdfPCell.BOTTOM_BORDER;
            pcell.BorderColor = BaseColor.GRAY;
            table.AddCell(pcell);

            foreach (var item in dadosCliente.Recebimentos.Where(x => x.SituacaoPagamento.Equals(SituacaoPagamento.Recebido)).OrderBy(x => x.DataPagamento).OrderBy(y => y.DataPagamento).ToList())
            {
                pcell = new PdfPCell(new Phrase(item.DataPagamento.Value.ToString("dd/MM/yyyy"), normalFont));
                pcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                pcell.Border      = PdfPCell.BOTTOM_BORDER;
                pcell.BorderColor = BaseColor.LIGHT_GRAY;
                table.AddCell(pcell);

                pcell = new PdfPCell(new Phrase(item.Servico == null ? "" : item.Servico.Descricao, normalFont));
                pcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                pcell.Border      = PdfPCell.BOTTOM_BORDER;
                pcell.BorderColor = BaseColor.LIGHT_GRAY;
                table.AddCell(pcell);

                pcell = new PdfPCell(new Phrase(item.Profissional.Nome, normalFont));
                pcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                pcell.Border      = PdfPCell.BOTTOM_BORDER;
                pcell.BorderColor = BaseColor.LIGHT_GRAY;
                table.AddCell(pcell);

                pcell = new PdfPCell(new Phrase("R$ " + item.ValorRecebido.ToString(), normalFont));
                pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                pcell.Border      = PdfPCell.BOTTOM_BORDER;
                pcell.BorderColor = BaseColor.LIGHT_GRAY;
                table.AddCell(pcell);
            }

            doc.Add(table);
            doc.Close();

            return(nomeArquivo);
        }
示例#30
0
        public string GerarFechamentoFinanceiro(DateTime dtInicio, DateTime dtFim)
        {
            PdfPTable tabela = new PdfPTable(3);

            var normalFont   = FontFactory.GetFont(FontFactory.HELVETICA, 11, BaseColor.GRAY);
            var detailsFont  = FontFactory.GetFont(FontFactory.HELVETICA, 9, BaseColor.GRAY);
            var cellFont     = FontFactory.GetFont(FontFactory.HELVETICA, 10, BaseColor.GRAY);
            var boldFont     = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 11, BaseColor.GRAY);
            var boldTextFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 11, BaseColor.MAGENTA);
            var tituloFont   = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 14, BaseColor.MAGENTA);

            string dirArquivo      = Server.MapPath("~/Relatorios");
            string nomeArquivo     = "RelFechamentoFinanceiro_" + DateTime.Now.ToString("ddMMyyyyhhmss");
            string caminhoCompleto = dirArquivo + "\\" + nomeArquivo + ".pdf";

            Document doc = InicializarDocumento(caminhoCompleto);

            doc.Open();

            doc = EscreverCabeçalho(doc);

            Paragraph paragrafo = new Paragraph();

            paragrafo.Alignment = Element.ALIGN_CENTER;
            paragrafo.Add(new Phrase("FECHAMENTO FINANCEIRO\n", tituloFont));
            paragrafo.Add(new Phrase(dtInicio.ToString("dd/MM/yyyy") + " a " + dtFim.ToString("dd/MM/yyyy"), boldFont));
            paragrafo.Add("\n");
            paragrafo.Add("\n");
            doc.Add(paragrafo);

            PdfPTable table = new PdfPTable(4);
            PdfPCell  pcell = new PdfPCell();

            float[]   widths = new float[] { 20, 20, 50, 20 };
            Paragraph lineP  = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.LIGHT_GRAY, Element.ALIGN_LEFT, 1)));

            var recebimentos = _recebimento.List().Where(x => x.DataPagamento >= dtInicio && x.DataPagamento <= dtFim).ToList();

            foreach (var tipoPagto in Enum.GetValues(typeof(TipoPagamento)))
            {
                TipoPagamento tipoPagamentoEnum = (TipoPagamento)tipoPagto;

                var recebimentoPorPagamento = recebimentos.Where(y => y.TipoPagamento.Equals(tipoPagto)).OrderBy(x => x.DataPagamento).ToList();

                if (recebimentoPorPagamento.Count > 0)
                {
                    paragrafo = new Paragraph();

                    paragrafo.Alignment = Element.ALIGN_LEFT;
                    paragrafo.Add(new Phrase("FORMA DE PAGAMENTO: " + FuncoesGerais.GetEnumDescription(tipoPagamentoEnum) + "\n \n", boldTextFont));
                    doc.Add(paragrafo);

                    table = new PdfPTable(4);
                    table.DefaultCell.Border  = Rectangle.BOTTOM_BORDER;
                    table.WidthPercentage     = 100;
                    table.HorizontalAlignment = Element.ALIGN_MIDDLE;
                    table.SetWidths(widths);

                    pcell = new PdfPCell();

                    pcell = new PdfPCell(new Phrase("Dt Pagamento", boldFont));
                    pcell.HorizontalAlignment = Element.ALIGN_CENTER;
                    pcell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                    pcell.Border      = PdfPCell.BOTTOM_BORDER;
                    pcell.BorderColor = BaseColor.GRAY;
                    table.AddCell(pcell);

                    pcell = new PdfPCell(new Phrase("Dt Vencimento", boldFont));
                    pcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                    pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                    pcell.Border      = PdfPCell.BOTTOM_BORDER;
                    pcell.BorderColor = BaseColor.GRAY;
                    table.AddCell(pcell);

                    pcell = new PdfPCell(new Phrase("Descrição", boldFont));
                    pcell.HorizontalAlignment = Element.ALIGN_CENTER;
                    pcell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                    pcell.Border      = PdfPCell.BOTTOM_BORDER;
                    pcell.BorderColor = BaseColor.GRAY;
                    table.AddCell(pcell);

                    pcell = new PdfPCell(new Phrase("Valor Recebido", boldFont));
                    pcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                    pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                    pcell.Border      = PdfPCell.BOTTOM_BORDER;
                    pcell.BorderColor = BaseColor.GRAY;
                    table.AddCell(pcell);

                    foreach (var item in recebimentoPorPagamento)
                    {
                        pcell = new PdfPCell(new Phrase(item.DataPagamento.Value.ToString("dd/MM/yyyy"), cellFont));
                        pcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                        pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                        pcell.Border      = PdfPCell.BOTTOM_BORDER;
                        pcell.BorderColor = BaseColor.LIGHT_GRAY;
                        table.AddCell(pcell);

                        pcell = new PdfPCell(new Phrase(item.DataVencimento.ToString("dd/MM/yyyy"), cellFont));
                        pcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                        pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                        pcell.Border      = PdfPCell.BOTTOM_BORDER;
                        pcell.BorderColor = BaseColor.LIGHT_GRAY;
                        table.AddCell(pcell);

                        pcell = new PdfPCell();
                        pcell.AddElement(new Phrase("Serviço: " + item.Servico.Descricao, cellFont));
                        pcell.AddElement(new Phrase(new Phrase("Cliente: " + item.Cliente.Nome, cellFont)));
                        pcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                        pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                        pcell.Border      = PdfPCell.BOTTOM_BORDER;
                        pcell.BorderColor = BaseColor.LIGHT_GRAY;
                        table.AddCell(pcell);

                        pcell = new PdfPCell(new Phrase("R$ " + item.ValorRecebido.ToString(), cellFont));
                        pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                        pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                        pcell.Border      = PdfPCell.BOTTOM_BORDER;
                        pcell.BorderColor = BaseColor.LIGHT_GRAY;
                        table.AddCell(pcell);
                    }

                    pcell = new PdfPCell(new Phrase("", normalFont));
                    pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                    pcell.Border            = PdfPCell.NO_BORDER;
                    pcell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
                    table.AddCell(pcell);

                    pcell = new PdfPCell(new Phrase("Total", boldFont));
                    pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                    pcell.Border            = PdfPCell.NO_BORDER;
                    pcell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
                    table.AddCell(pcell);

                    pcell = new PdfPCell(new Phrase("", normalFont));
                    pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                    pcell.Border            = PdfPCell.NO_BORDER;
                    pcell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
                    table.AddCell(pcell);

                    pcell = new PdfPCell(new Phrase("R$ " + recebimentoPorPagamento.Sum(x => x.ValorRecebido).ToString(), boldFont));
                    pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                    pcell.Border = PdfPCell.NO_BORDER;
                    table.AddCell(pcell);

                    doc.Add(table);

                    paragrafo = new Paragraph();
                    paragrafo.Add("\n");
                    paragrafo.Add("\n");
                    doc.Add(paragrafo);
                }
            }

            paragrafo = new Paragraph();
            paragrafo.Add("\n");
            paragrafo.Alignment = Element.ALIGN_LEFT;
            paragrafo.Add(new Phrase("DESPESAS \n", boldTextFont));
            paragrafo.Add("\n");
            doc.Add(paragrafo);

            table  = new PdfPTable(4);
            pcell  = new PdfPCell();
            widths = new float[] { 20, 50, 20, 20 };
            lineP  = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.LIGHT_GRAY, Element.ALIGN_LEFT, 1)));
            table.SetWidths(widths);
            table.WidthPercentage = 100;

            var despesas = _despesaService.List().Where(x => x.DataPagamento >= dtInicio && x.DataPagamento <= dtFim && x.Situacao.Equals(SituacaoDespesa.Liquidado)).ToList();

            pcell = new PdfPCell();

            pcell = new PdfPCell(new Phrase("Dt Vencimento", boldFont));
            pcell.HorizontalAlignment = Element.ALIGN_CENTER;
            pcell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            pcell.Border      = PdfPCell.BOTTOM_BORDER;
            pcell.BorderColor = BaseColor.GRAY;
            table.AddCell(pcell);

            pcell = new PdfPCell(new Phrase("Descrição", boldFont));
            pcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            pcell.Border      = PdfPCell.BOTTOM_BORDER;
            pcell.BorderColor = BaseColor.GRAY;
            table.AddCell(pcell);

            pcell = new PdfPCell(new Phrase("Dt Pagamento", boldFont));
            pcell.HorizontalAlignment = Element.ALIGN_CENTER;
            pcell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            pcell.Border      = PdfPCell.BOTTOM_BORDER;
            pcell.BorderColor = BaseColor.GRAY;
            table.AddCell(pcell);

            pcell = new PdfPCell(new Phrase("Valor Pago", boldFont));
            pcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            pcell.Border      = PdfPCell.BOTTOM_BORDER;
            pcell.BorderColor = BaseColor.GRAY;
            table.AddCell(pcell);

            foreach (var item in despesas)
            {
                pcell = new PdfPCell(new Phrase(item.DataVencimento.ToString("dd/MM/yyyy"), cellFont));
                pcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                pcell.Border      = PdfPCell.BOTTOM_BORDER;
                pcell.BorderColor = BaseColor.LIGHT_GRAY;
                table.AddCell(pcell);

                pcell = new PdfPCell();
                pcell.AddElement(new Phrase(item.Descricao, cellFont));
                pcell.AddElement(new Phrase(new Phrase("Fornecedor: " + item.Fornecedor, cellFont)));
                pcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                pcell.Border      = PdfPCell.BOTTOM_BORDER;
                pcell.BorderColor = BaseColor.LIGHT_GRAY;
                table.AddCell(pcell);

                pcell = new PdfPCell(new Phrase(item.DataPagamento == null ? "-" : item.DataPagamento.Value.ToString("dd/MM/yyyy"), cellFont));
                pcell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                pcell.Border      = PdfPCell.BOTTOM_BORDER;
                pcell.BorderColor = BaseColor.LIGHT_GRAY;
                table.AddCell(pcell);

                pcell = new PdfPCell(new Phrase(item.ValorPagamento == null ? "-" : "R$ " + item.ValorPagamento.ToString(), cellFont));
                pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                pcell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                pcell.Border      = PdfPCell.BOTTOM_BORDER;
                pcell.BorderColor = BaseColor.LIGHT_GRAY;
                table.AddCell(pcell);
            }

            doc.Add(table);

            table  = new PdfPTable(4);
            widths = new float[] { 20, 20, 50, 20 };
            table.WidthPercentage = 100;
            table.SetWidths(widths);

            pcell = new PdfPCell(new Phrase("", normalFont));
            pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            pcell.Border            = PdfPCell.NO_BORDER;
            pcell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(pcell);

            pcell = new PdfPCell(new Phrase("Total", boldFont));
            pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            pcell.Border            = PdfPCell.NO_BORDER;
            pcell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(pcell);

            pcell = new PdfPCell(new Phrase("", normalFont));
            pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            pcell.Border            = PdfPCell.NO_BORDER;
            pcell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(pcell);

            pcell = new PdfPCell(new Phrase("R$ " + despesas.Sum(x => x.ValorPagamento).ToString(), boldFont));
            pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            pcell.Border = PdfPCell.NO_BORDER;
            table.AddCell(pcell);

            doc.Add(table);

            widths = new float[] { 30, 40, 20, 20 };

            paragrafo = new Paragraph();
            paragrafo.Add("\n");
            paragrafo.Add("\n");
            doc.Add(paragrafo);

            // TOTAL RECEITA
            table = new PdfPTable(4);
            table.DefaultCell.Border  = Rectangle.BOTTOM_BORDER;
            table.WidthPercentage     = 100;
            table.HorizontalAlignment = Element.ALIGN_MIDDLE;
            table.SetWidths(widths);

            pcell = new PdfPCell(new Phrase("TOTAL RECEITAS (+)", boldFont));
            pcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
            pcell.Border            = PdfPCell.NO_BORDER;
            pcell.VerticalAlignment = PdfPCell.ALIGN_CENTER;
            table.AddCell(pcell);

            pcell = new PdfPCell();
            pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            pcell.Border = PdfPCell.NO_BORDER;
            pcell.AddElement(new Phrase("", normalFont));
            pcell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(pcell);

            pcell = new PdfPCell();
            pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            pcell.Border = PdfPCell.NO_BORDER;
            pcell.AddElement(new Phrase("", normalFont));
            pcell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(pcell);

            pcell = new PdfPCell(new Phrase("R$ " + recebimentos.Sum(x => x.ValorRecebido).ToString(), boldFont));
            pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            pcell.Border = PdfPCell.NO_BORDER;
            table.AddCell(pcell);

            doc.Add(table);

            // TOTAL DESPESA
            table = new PdfPTable(4);
            table.DefaultCell.Border  = Rectangle.BOTTOM_BORDER;
            table.WidthPercentage     = 100;
            table.HorizontalAlignment = Element.ALIGN_MIDDLE;
            table.SetWidths(widths);

            pcell = new PdfPCell(new Phrase("TOTAL DESPESAS (-)", boldFont));
            pcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
            pcell.Border            = PdfPCell.NO_BORDER;
            pcell.VerticalAlignment = PdfPCell.ALIGN_CENTER;
            table.AddCell(pcell);

            pcell = new PdfPCell();
            pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            pcell.Border = PdfPCell.NO_BORDER;
            pcell.AddElement(new Phrase("", normalFont));
            pcell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(pcell);

            pcell = new PdfPCell();
            pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            pcell.Border = PdfPCell.NO_BORDER;
            pcell.AddElement(new Phrase("", normalFont));
            pcell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(pcell);

            pcell = new PdfPCell(new Phrase("R$ " + despesas.Sum(x => x.ValorPagamento).ToString(), boldFont));
            pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            pcell.Border = PdfPCell.NO_BORDER;
            table.AddCell(pcell);

            doc.Add(table);

            // TOTAL GERAL
            table = new PdfPTable(4);
            table.DefaultCell.Border  = Rectangle.BOTTOM_BORDER;
            table.WidthPercentage     = 100;
            table.HorizontalAlignment = Element.ALIGN_MIDDLE;
            table.SetWidths(widths);

            pcell = new PdfPCell(new Phrase("TOTAL GERAL", boldFont));
            pcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
            pcell.Border            = PdfPCell.NO_BORDER;
            pcell.VerticalAlignment = PdfPCell.ALIGN_CENTER;
            table.AddCell(pcell);

            pcell = new PdfPCell();
            pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            pcell.Border = PdfPCell.NO_BORDER;
            pcell.AddElement(new Phrase("", normalFont));
            pcell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(pcell);

            pcell = new PdfPCell();
            pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            pcell.Border = PdfPCell.NO_BORDER;
            pcell.AddElement(new Phrase("", normalFont));
            pcell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
            table.AddCell(pcell);

            decimal totalGeral = recebimentos.Sum(x => x.ValorRecebido).Value - despesas.Sum(x => x.ValorPagamento).Value;

            pcell = new PdfPCell(new Phrase("R$ " + totalGeral.ToString(), boldFont));
            pcell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            pcell.Border = PdfPCell.NO_BORDER;
            table.AddCell(pcell);

            doc.Add(table);

            doc.Close();

            return(nomeArquivo);
        }