Exemplo n.º 1
0
        public void ExcluirOrdemPagamento(OrdemPagamento ordemPagamento)
        {
            DataAccess dao = new DataAccess();
            Dictionary <string, string> lstParametros = new Dictionary <string, string>();

            lstParametros.Add("@idOrdemPagamento", ordemPagamento.idOrdemPagamento.ToString());

            try
            {
                dao.Executar("SP_ORDEMPAGAMENTO_EXCLUIR", lstParametros);
            }
            catch (Exception ex)
            {
                string parametrosSQL = string.Empty;
                parametrosSQL = helper.ConcatenarParametrosSQL(new Dictionary <string, string>());

                LogErro log = new LogErro()
                {
                    procedureSQL  = "SP_ORDEMPAGAMENTO_EXCLUIR",
                    parametrosSQL = parametrosSQL,
                    mensagemErro  = ex.ToString()
                };

                bizLogErro.IncluirLogErro(log);

                throw ex;
            }
        }
Exemplo n.º 2
0
        public OrdemPagamentoManutencao(OrdemPagamento _opSelecionada, bool _origemConsultaOP)
        {
            InitializeComponent();

            opSelecionada    = _opSelecionada;
            origemConsultaOP = _origemConsultaOP;
        }
Exemplo n.º 3
0
        private void CarregarOrdemPagamento(OrdemPagamento opSelecionada)
        {
            tbNumeroOP.Text     = opSelecionada.numeroOP;
            tbDataCriacao.Value = opSelecionada.dataCriacao.Date == DateTime.MinValue ? DateTime.Today : opSelecionada.dataCriacao.Date;

            cbObra.SelectedValue = opSelecionada.idObraEtapa;
            //cbObra.Enabled = opSelecionada.idObraEtapa == 0;

            cbEmpresa.SelectedValue = opSelecionada.idEmpresa;
            cbEmpresa.Enabled       = opSelecionada.idObraEtapa == 0;

            this.CarregarComboUEN();

            cbFavorecido.SelectedValue = opSelecionada.idFavorecido;
            CarregarContasBancarias(opSelecionada.idFavorecido);
            cbDadosBancarios.SelectedValue = opSelecionada.idContaBancaria;

            tbSolicitante.Text         = opSelecionada.nomeSolicitante;
            dtpDataSolicitacao.Value   = opSelecionada.dataSolicitacao;
            cbAutorizado.SelectedValue = opSelecionada.idAutorizado;
            tbObservacao.Text          = opSelecionada.Observacao;

            opSelecionada.Status = this.RetornarStatusOP();
            lbStatus.Text        = opSelecionada.Status != null ? opSelecionada.Status : "GERADA";

            chkCancelada.Checked          = opSelecionada.Cancelada == 1 ? true : false;
            tbObservacaoCancelada.Enabled = chkCancelada.Enabled && chkCancelada.Checked;
            tbObservacaoCancelada.Text    = opSelecionada.observacaoCancelada;

            this.CarregarItens();

            if (btPagamento.Enabled == false)
            {
                // Se houver algum item de UEN, Centro de Custo ou Despesa que o usuário logado não tem permissão, desabilitar os botões Gravar e Excluir
                foreach (OrdemPagamentoItem itemOP in opSelecionada.lstItens)
                {
                    if (UsuarioLogado.lstUEN.Exists(x => x.idUEN == itemOP.idUEN) == false)
                    {
                        btExcluir.Enabled = false;
                        btGravar.Enabled  = false;
                        break;
                    }

                    if (UsuarioLogado.lstCC.Exists(x => x.idCentroCusto == itemOP.idCentroCusto) == false)
                    {
                        btExcluir.Enabled = false;
                        btGravar.Enabled  = false;
                        break;
                    }

                    if (UsuarioLogado.lstDespesas.Exists(x => x.idDespesa == itemOP.idDespesa) == false)
                    {
                        btExcluir.Enabled = false;
                        btGravar.Enabled  = false;
                        break;
                    }
                }
            }
        }
Exemplo n.º 4
0
        private OrdemPagamento PreencherCamposOrigatorios()
        {
            UEN            UEN            = new UEN();
            CentroCusto    centroCusto    = new CentroCusto();
            Despesa        despesa        = new Despesa();
            ObraEtapa      obra           = new ObraEtapa();
            OrdemPagamento ordemPagamento = new OrdemPagamento();

            ordemPagamento.idEmpresa   = new BIZEmpresa().PesquisarEmpresa(new Empresa())[0].idEmpresa;
            ordemPagamento.idObraEtapa = new BIZObra().PesquisarObraEtapa(new ObraEtapa()
            {
                UnitTest = 1
            })[0].idObraEtapa;
            ordemPagamento.idFavorecido = new BIZFornecedor().PesquisarFornecedor(new Fornecedor()
            {
                UnitTest = 1
            })[0].idFornecedor;
            ordemPagamento.idContaBancaria = new BIZFornecedor().PesquisarFornecedorContaBancaria(new FornecedorContaBancaria()
            {
                idFornecedor = ordemPagamento.idFavorecido
            })[0].idContaBancaria;
            ordemPagamento.idSolicitante   = 1;
            ordemPagamento.idAutorizado    = 9;
            ordemPagamento.dataSolicitacao = DateTime.Now;
            ordemPagamento.Status          = string.Empty;

            UEN         = new BIZUEN().PesquisarUEN(new UEN())[0];
            centroCusto = new BIZCentroCusto().PesquisarCentroCusto(new CentroCusto())[0];
            despesa     = new BIZDespesa().PesquisarDespesa(new Despesa())[0];

            ordemPagamento.lstItens = new List <OrdemPagamentoItem>();
            ordemPagamento.lstItens.Add(new OrdemPagamentoItem()
            {
                idUEN              = UEN.idUEN,
                idCentroCusto      = centroCusto.idCentroCusto,
                idDespesa          = despesa.idDespesa,
                idUsuarioPagamento = new BIZUsuario().PesquisarUsuario(new Usuario())[0].idUsuario,
                idAbastecimento    = 9,
                Valor              = Decimal.Parse("999.99"),
                valorPago          = Decimal.Parse("999.99"),
                dataVencimento     = DateTime.Now,
                dataPagamento      = DateTime.Now,
                numeroParcela      = 9,
                totalParcelas      = 999,
                Desconto           = 111,
                Multa              = 222,
                UnitTest           = 1
            });

            ordemPagamento.Observacao          = "Observacão";
            ordemPagamento.Cancelada           = 9;
            ordemPagamento.observacaoCancelada = "teste cancelamento";
            ordemPagamento.UnitTest            = 1;

            return(ordemPagamento);
        }
Exemplo n.º 5
0
        public void OrdemPagamentoAlterar_SemCamposObrigatorios()
        {
            OrdemPagamento opTeste = new OrdemPagamento();
            string         Msg     = string.Empty;

            opTeste.lstItens = new List <OrdemPagamentoItem>();
            Msg = bizOrdemPagamento.AlterarOrdemPagamento(opTeste);

            Assert.AreNotEqual(string.Empty, Msg);
        }
Exemplo n.º 6
0
        private string ValidarCamposObrigatorios(OrdemPagamento ordemPagamento)
        {
            string Msg            = string.Empty;
            string statusForecido = string.Empty;

            if (ordemPagamento.idEmpresa == 0)
            {
                Msg += Environment.NewLine + "Favor selecionar a Empresa";
            }

            if (ordemPagamento.idFavorecido == 0)
            {
                Msg += Environment.NewLine + "Favor selecionar o Favorecido";
            }

            if (ordemPagamento.idContaBancaria == 0)
            {
                Msg += Environment.NewLine + "Favor selecionar a Conta Bancária";
            }

            if (ordemPagamento.idOrdemPagamento == 0 && ordemPagamento.favorecidoInativo == true)
            {
                Msg += Environment.NewLine + "Favor selecionar um Favorecido ATIVO";
            }

            if (ordemPagamento.idAutorizado == 0)
            {
                Msg += Environment.NewLine + "Favor selecionar o Nome de quem autorizou";
            }

            if (ordemPagamento.Cancelada == 1 && ordemPagamento.observacaoCancelada == string.Empty)
            {
                Msg += Environment.NewLine + "Favor justificar o cancelamento dessa Ordem de Pagamento";
            }

            if (ordemPagamento.lstItens == null || ordemPagamento.lstItens.Count == 0)
            {
                Msg += Environment.NewLine + "Favor adicionar pelo menos um item";
            }

            if (ordemPagamento.lstItens != null && ordemPagamento.lstItens.Exists(x => x.idAbastecimento == 0)) // As regras abaixo não se aplicarão para OP's de Abastecimento
            {
                if (ordemPagamento.lstItens != null && ordemPagamento.lstItens.GroupBy(x => x.idUEN).Count() > 1)
                {
                    Msg += Environment.NewLine + "Só podem haver despesas de uma única UEN";
                }

                if (ordemPagamento.lstItens != null && ordemPagamento.lstItens.GroupBy(x => x.idCentroCusto).Count() > 1)
                {
                    Msg += Environment.NewLine + "Só podem haver despesas de um único Centro de Custo";
                }
            }

            return(Msg);
        }
Exemplo n.º 7
0
        public void OrdemPagamentoIncluir_SemCamposObrigatorios()
        {
            OrdemPagamento opTeste = new OrdemPagamento();
            string         Msg     = string.Empty;
            int            idOP    = 0;

            opTeste.lstItens = new List <OrdemPagamentoItem>();
            Msg = bizOrdemPagamento.IncluirOrdemPagamento(opTeste, true, out idOP);

            Assert.AreNotEqual(string.Empty, Msg);
        }
        public void AtualizarOrdemPagamento(OrdemPagamento ordemPagamento)
        {
            var _ordemPagamento = Db.OPagamentos.FirstOrDefault(u => u.Id == ordemPagamento.Id);

            if (ordemPagamento != null)
            {
                _ordemPagamento.NomeCompleto   = ordemPagamento.NomeCompleto;
                _ordemPagamento.CPF            = ordemPagamento.CPF;
                _ordemPagamento.NumeroContrato = ordemPagamento.NumeroContrato;
            }
        }
Exemplo n.º 9
0
        public void OrdemPagamentoIncluir()
        {
            string Msg  = string.Empty;
            int    idOP = 0;

            OrdemPagamento ordemPagamento = new OrdemPagamento();

            ordemPagamento = this.PreencherCamposOrigatorios();
            Msg            = bizOrdemPagamento.IncluirOrdemPagamento(ordemPagamento, true, out idOP);

            Assert.AreEqual(string.Empty, Msg);
        }
Exemplo n.º 10
0
        public string AlterarOrdemPagamento(OrdemPagamento ordemPagamento)
        {
            DataAccess                  dao                = new DataAccess();
            List <_Transacao>           lstComandos        = new List <_Transacao>();
            Dictionary <string, string> lstParametros      = new Dictionary <string, string>();
            Dictionary <string, string> lstParametrosItens = new Dictionary <string, string>();
            string Msg = string.Empty;

            try
            {
                Msg = ValidarCamposObrigatorios(ordemPagamento);

                if (Msg == string.Empty)
                {
                    lstComandos.Add(new _Transacao()
                    {
                        nomeProcedure = "SP_ORDEMPAGAMENTO_ALTERAR",
                        lstParametros = MontarParametrosExecutarOrdemPagamento(ordemPagamento)
                    });

                    lstParametrosItens.Add("@idOrdemPagamento", ordemPagamento.idOrdemPagamento.ToString());
                    lstComandos.Add(new _Transacao()
                    {
                        nomeProcedure = "SP_ORDEMPAGAMENTOITENS_EXCLUIR",
                        lstParametros = lstParametrosItens
                    });

                    lstComandos.AddRange(this.IncluirOrdemPagamentoItens(ordemPagamento.idOrdemPagamento, ordemPagamento.idObraEtapa, ordemPagamento.lstItens));

                    dao.ExecutarTransacao(lstComandos);
                }
            }
            catch (Exception ex)
            {
                string parametrosSQL = string.Empty;
                parametrosSQL = helper.ConcatenarParametrosSQL(lstParametros);

                LogErro log = new LogErro()
                {
                    procedureSQL  = "SP_ORDEMPAGAMENTO_ALTERAR",
                    parametrosSQL = parametrosSQL,
                    mensagemErro  = ex.ToString()
                };

                bizLogErro.IncluirLogErro(log);

                throw ex;
            }

            return(Msg);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Chama a API PagCoin para solicitar a criação de uma Ordem de Pagamento
        /// </summary>
        /// <param name="ordem">Ordem de pagamento com dados preenchidos.</param>
        /// <returns>URL para redirect do usuário, contendo a ordem de pagamento com o respectivo código de carteira.</returns>
        /// <remarks>Leia https://pagcoin.com/Home/Desenvolvedores para verificar os campos obrigatórios, opcionais e ignorados do objeto OrdemPagamento para a criação de uma ordem de pagamento</remarks>
        public string CriarOrdemDePagamento(OrdemPagamento ordem)
        {
            var json       = SerializarOrdemPagamentoParaJSON(ordem);
            var assinatura = GerarAssinaturaString(ApiKey, URL_CRIAR_ORDEM_PAGAMENTO + json);

            var request = HttpWebRequest.Create(URL_CRIAR_ORDEM_PAGAMENTO);

            request.Headers["EnderecoPagCoin"]   = URL_CRIAR_ORDEM_PAGAMENTO;
            request.Headers["AssinaturaPagCoin"] = assinatura;
            request.Method      = "POST";
            request.ContentType = "application/json";

            var erro           = default(string);
            var responseString = default(string);

            var getRequestAsyncResult = request.BeginGetRequestStream(asynchronousResult => {}, request);

            getRequestAsyncResult.AsyncWaitHandle.WaitOne();

            var postStream = request.EndGetRequestStream(getRequestAsyncResult);
            {
                byte[] byteArray = Encoding.UTF8.GetBytes(json);

                postStream.Write(byteArray, 0, json.Length);
                postStream.Flush();
                postStream.Close();
            }

            var getResponseAsyncResult = request.BeginGetResponse(asynchronousResultResponse => {}, request);

            getResponseAsyncResult.AsyncWaitHandle.WaitOne();

            using (var response = (HttpWebResponse)request.EndGetResponse(getResponseAsyncResult))
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    erro = "Erro ao solicitar a criação do Invoice. Código do erro: " + (int)response.StatusCode;
                }
                if (!ValidarAssinatura(response, out responseString))
                {
                    throw new Exception("Assinatura inválida enviada pelo servidor. Por segurança, o código de Invoice recebido não será informado");
                }
            }

            if (!string.IsNullOrEmpty(erro))
            {
                throw new Exception(erro + " \nDescrição:" + responseString ?? "N/A");
            }

            return("https://pagcoin.com" + responseString);
        }
        public void AdicionarOrdemPagamento(OrdemPagamento opagamento)
        {
            var sequence = 1;

            if (Db.OPagamentos.Any())
            {
                var maxId = Db.OPagamentos.Max(u => u.Id); // u => u.Id Expressão Lambda - Ler sobre Expressão Lambda e Função Anônima
                maxId++;
                sequence = maxId;
            }

            opagamento.Id = sequence;
            Db.OPagamentos.Add(opagamento);
        }
Exemplo n.º 13
0
        public DataTable GerarOrdemPagamento(OrdemPagamento opSelecionada, out DataTable dtObras, out DataTable dtTotaisObra)
        {
            DataAccess dao = new DataAccess();
            Dictionary <string, string> lstParametros = new Dictionary <string, string>();
            DataTable dtOP = new DataTable();

            dtObras      = new DataTable();
            dtTotaisObra = new DataTable();

            try
            {
                lstParametros.Add("@idOrdemPagamento", opSelecionada.idOrdemPagamento.ToString());
                using (DataSet ds = dao.Pesquisar("SP_ORDEMPAGAMENTO_EMISSAO", lstParametros))
                {
                    dtOP = ds.Tables[0];
                }

                lstParametros.Add("@idObraEtapa", opSelecionada.idObraEtapa.ToString());
                using (DataSet ds = dao.Pesquisar("SP_ORDEMPAGAMENTO_EMISSAO_SUBRELATORIO_OBRAS", lstParametros))
                {
                    dtObras = ds.Tables[0];
                }

                lstParametros = new Dictionary <string, string>();
                lstParametros.Add("@idObraEtapa", opSelecionada.idObraEtapa.ToString());
                using (DataSet ds = dao.Pesquisar("SP_ORDEMPAGAMENTO_EMISSAO_SUBRELATORIO_TOTAIS", lstParametros))
                {
                    dtTotaisObra = ds.Tables[0];
                }
            }
            catch (Exception ex)
            {
                string parametrosSQL = string.Empty;
                parametrosSQL = helper.ConcatenarParametrosSQL(lstParametros);

                LogErro log = new LogErro()
                {
                    procedureSQL  = "SP_ORDEMPAGAMENTO_EMISSAO",
                    parametrosSQL = parametrosSQL,
                    mensagemErro  = ex.ToString()
                };

                bizLogErro.IncluirLogErro(log);

                throw ex;
            }

            return(dtOP);
        }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            Pagcoin        pc = new Pagcoin(apikeyTeste);
            OrdemPagamento op = new OrdemPagamento();

            op.apiKey               = apikeyTeste;
            op.nomeProduto          = "Teste via API: PagCoin.NET";
            op.valorEmMoedaOriginal = 12.50M;
            op.idInterna            = "T0001";

            var retorno = pc.CriarOrdemDePagamento(op);

            System.Console.WriteLine(retorno);

            System.Console.ReadLine();
        }
Exemplo n.º 15
0
        private void btGerarOP_Click(object sender, EventArgs e)
        {
            OrdemPagamento ordemPagamento = new OrdemPagamento();
            string         msgRetorno     = string.Empty;

            msgRetorno = ValidarCombos();

            if (msgRetorno == string.Empty)
            {
                ordemPagamento.idOrdemPagamento = 0;
                ordemPagamento.idEmpresa        = 0;
                ordemPagamento.idObraEtapa      = 0;
                ordemPagamento.idSolicitante    = UsuarioLogado.idUsuario;
                ordemPagamento.nomeSolicitante  = UsuarioLogado.Nome;
                ordemPagamento.dataSolicitacao  = DateTime.Now;
                ordemPagamento.Autorizado       = string.Empty;
                ordemPagamento.Observacao       = string.Empty;
                ordemPagamento.lstItens         = new List <OrdemPagamentoItem>();
                ordemPagamento.lstItens.Add(new OrdemPagamentoItem()
                {
                    idOcorrenciaMulta    = ocorrenciaSelecionada.idOcorrencia,
                    idManutencao         = 0,
                    idFrete              = 0,
                    idObraGastoRealizado = 0,
                    idAbastecimento      = 0,
                    idUEN                = int.Parse(cbUEN.SelectedValue.ToString()),
                    idCentroCusto        = int.Parse(cbCentroCusto.SelectedValue.ToString()),
                    idDespesa            = int.Parse(cbDespesa.SelectedValue.ToString()),
                    descricaoUEN         = cbUEN.Text,
                    descricaoCentroCusto = cbCentroCusto.Text,
                    descricaoDespesa     = cbDespesa.Text,
                    Valor                = ocorrenciaSelecionada.valorMulta,
                    dataVencimento       = tbData.Value,
                    numeroParcela        = 1,
                    totalParcelas        = 1
                });

                OrdemPagamentoManutencao form = new OrdemPagamentoManutencao(ordemPagamento, false);
                form.ShowDialog();

                this.Close();
            }
            else
            {
                MessageBox.Show("Atenção: " + msgRetorno, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 16
0
        private void CarregarGrid(OrdemPagamento ordemPagamentoFiltro)
        {
            List <OrdemPagamento> lstOrdemPagamento = new List <OrdemPagamento>();

            this.Cursor = Cursors.WaitCursor;

            try
            {
                lstOrdemPagamento = bizOP.PesquisarOrdemPagamento(ordemPagamentoFiltro).OrderBy(op => op.razaoSocial).ToList();

                LimparGrid();

                gvOrdensPagamentos.Columns[8].DefaultCellStyle.Format  = "dd/MM/yyyy";
                gvOrdensPagamentos.Columns[10].DefaultCellStyle.Format = "dd/MM/yyyy";

                foreach (OrdemPagamento itemOrdemPagamento in lstOrdemPagamento)
                {
                    gvOrdensPagamentos.Rows.Add(new object[]
                    {
                        itemOrdemPagamento.idOrdemPagamento,
                        itemOrdemPagamento.numeroOP,
                        itemOrdemPagamento.razaoSocial,
                        itemOrdemPagamento.nomeCliente,
                        itemOrdemPagamento.nomeEvento,
                        itemOrdemPagamento.nomeFavorecido,
                        itemOrdemPagamento.valorTotal,
                        itemOrdemPagamento.Status,
                        itemOrdemPagamento.Status == "PAGA" ? itemOrdemPagamento.dataPagamentoParcela: (DateTime?)null,
                        itemOrdemPagamento.Observacao,
                        itemOrdemPagamento.dataVencimentoParcela
                    });
                }

                helper.VerificarCorLinhaGrid(gvOrdensPagamentos);
            }
            catch (SqlException)
            {
                MessageBox.Show(helper.RetornarMensagemPadraoErroAcessoBD(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MessageBox.Show(helper.RetornarMensagemPadraoErroGenerico(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.Cursor = Cursors.Default;
        }
Exemplo n.º 17
0
        private bool VerificarDuplicidadeOP(OrdemPagamento ordemPagamento)
        {
            DataAccess dao = new DataAccess();
            Dictionary <string, string> lstParametros = new Dictionary <string, string>();
            bool existeOP = false;

            try
            {
                foreach (OrdemPagamentoItem itemOP in ordemPagamento.lstItens)
                {
                    lstParametros = new Dictionary <string, string>();
                    lstParametros.Add("@idFavorecido", ordemPagamento.idFavorecido.ToString());
                    lstParametros.Add("@idDespesa", itemOP.idDespesa.ToString());
                    lstParametros.Add("@DataVencimento", itemOP.dataVencimento.Date.ToShortDateString());

                    using (DataSet ds = dao.Pesquisar("dbo.SP_ORDEMPAGAMENTO_VERIFICARDUPLICIDADE", lstParametros))
                    {
                        existeOP = ds.Tables[0].Rows.Count > 0;
                    }

                    if (existeOP)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                string parametrosSQL = string.Empty;
                parametrosSQL = helper.ConcatenarParametrosSQL(lstParametros);

                LogErro log = new LogErro()
                {
                    procedureSQL  = "SP_NOTASFISCAIS_VERIFICARDUPLICIDADE",
                    parametrosSQL = parametrosSQL,
                    mensagemErro  = ex.ToString()
                };

                bizLogErro.IncluirLogErro(log);

                throw ex;
            }

            return(existeOP);
        }
Exemplo n.º 18
0
        private void SalvarOrdemPagamento()
        {
            if (string.IsNullOrEmpty(txNomeCompleto.Text) ||
                string.IsNullOrEmpty(txCPF.Text) || string.IsNullOrEmpty(txNumContrato.Text))
            {
                lblMessage.Visible = true;
            }
            else
            {
                lblMessage.Visible = false;
                var ordemPagamento = new OrdemPagamento();
                ordemPagamento.NomeCompleto   = txNomeCompleto.Text;
                ordemPagamento.CPF            = txCPF.Text;
                ordemPagamento.NumeroContrato = txNumContrato.Text;

                if (modFormOrdemPagamento.Value.ToLower() == "incluir")
                {
                    OrdemPagamentoController.AdicionarOrdemPagamento(ordemPagamento);
                }
                else
                {
                    ordemPagamento.Id = Convert.ToInt32(hdOrdemPagamentoId.Value);
                    OrdemPagamentoController.AtualizarOrdemPagamento(ordemPagamento);
                }

                grdOrdemPagamento.DataSource = OrdemPagamentoController.ObterOrdens();
                grdOrdemPagamento.DataBind();
            }
            /// Agora é o seguinte
            /// Eu não quero mais este cara aqui.
            /// blz ??
            /// Se eu rodar o codigo dessa forma nao vai dar erro
            /// pq existe um componente que esta apontando para ele
            /// // eu até posso deixar esse "evento" aqui sem um componente vinculado
            /// /// pq olhando para ele, não passa de um método de c# como outro qualquer


            ///  Mas eu não posso ter... um componente com o OnClick apontando para um método (Evento) que não
            ///  existe no codebehind
            ///
            modFormOrdemPagamento.Value = "incluir";
        }
Exemplo n.º 19
0
        private Dictionary <string, string> MontarParametrosExecutarOrdemPagamento(OrdemPagamento ordemPagamento)
        {
            Dictionary <string, string> lstParametros = new Dictionary <string, string>();

            lstParametros.Add("@idOrdemPagamento", ordemPagamento.idOrdemPagamento.ToString());
            lstParametros.Add("@idEmpresa", ordemPagamento.idEmpresa.ToString());
            lstParametros.Add("@idObraEtapa", ordemPagamento.idObraEtapa.ToString());
            lstParametros.Add("@idFavorecido", ordemPagamento.idFavorecido.ToString());
            lstParametros.Add("@idContaBancaria", ordemPagamento.idContaBancaria.ToString());
            lstParametros.Add("@idSolicitante", ordemPagamento.idSolicitante.ToString());
            lstParametros.Add("@NumeroOP", ordemPagamento.numeroOP.ToString());
            lstParametros.Add("@idAutorizado", ordemPagamento.idAutorizado.ToString());
            lstParametros.Add("@DataSolicitacao", ordemPagamento.dataSolicitacao.ToString());
            lstParametros.Add("@Observacao", ordemPagamento.Observacao.ToString());
            lstParametros.Add("@Status", ordemPagamento.Status.ToString());
            lstParametros.Add("@Cancelada", ordemPagamento.Cancelada.ToString());
            lstParametros.Add("@ObservacaoCancelada", ordemPagamento.observacaoCancelada.ToString());
            lstParametros.Add("@UnitTest", ordemPagamento.UnitTest.ToString());

            return(lstParametros);
        }
Exemplo n.º 20
0
        private Dictionary <string, string> MontarParametrosPesquisarOrdemPagamento(OrdemPagamento ordemPagamento)
        {
            Dictionary <string, string> lstParametros = new Dictionary <string, string>();

            lstParametros.Add("@idOrdemPagamento", ordemPagamento.idOrdemPagamento.Equals(0) ? null : ordemPagamento.idOrdemPagamento.ToString());
            lstParametros.Add("@idEmpresa", ordemPagamento.idEmpresa.Equals(0) ? null : ordemPagamento.idEmpresa.ToString());
            lstParametros.Add("@NomeEmpresa", string.IsNullOrEmpty(ordemPagamento.razaoSocial) ? null : ordemPagamento.razaoSocial);
            lstParametros.Add("@NumeroOP", string.IsNullOrEmpty(ordemPagamento.numeroOP) ? null : ordemPagamento.numeroOP);
            lstParametros.Add("@idObraEtapa", ordemPagamento.idObraEtapa.Equals(0) ? null : ordemPagamento.idObraEtapa.ToString());
            lstParametros.Add("@idFavorecido", ordemPagamento.idFavorecido.Equals(0) ? null : ordemPagamento.idFavorecido.ToString());
            lstParametros.Add("@idContaBancaria", ordemPagamento.idContaBancaria.Equals(0) ? null : ordemPagamento.idContaBancaria.ToString());
            lstParametros.Add("@NomeFavorecido", string.IsNullOrEmpty(ordemPagamento.nomeFavorecido) ? null : ordemPagamento.nomeFavorecido);
            lstParametros.Add("@NomeSolicitante", string.IsNullOrEmpty(ordemPagamento.nomeSolicitante) ? null : ordemPagamento.nomeSolicitante);
            lstParametros.Add("@DataVencimento", ordemPagamento.dataVencimentoParcela.Equals(DateTime.MinValue) ? null : ordemPagamento.dataVencimentoParcela.Date.ToString());
            lstParametros.Add("@DataPagamento", ordemPagamento.dataPagamentoParcela.Equals(DateTime.MinValue) ? null : ordemPagamento.dataPagamentoParcela.ToString());
            lstParametros.Add("@Status", string.IsNullOrEmpty(ordemPagamento.Status) ? null : ordemPagamento.Status);
            lstParametros.Add("@Observacao", string.IsNullOrEmpty(ordemPagamento.Observacao) ? null : ordemPagamento.Observacao);
            lstParametros.Add("@UnitTest", ordemPagamento.UnitTest.Equals(0) ? null : ordemPagamento.UnitTest.ToString());

            return(lstParametros);
        }
Exemplo n.º 21
0
        private void btPesquisar_Click(object sender, EventArgs e)
        {
            if (cbPesquisaCampo.FindStringExact(cbPesquisaCampo.Text) != -1)
            {
                OrdemPagamento ordemPagamentoFiltro = new OrdemPagamento();
                ordemPagamentoFiltro = (OrdemPagamento) new ClassProperties().RetornarObjetoFiltro(new OrdemPagamento(), (PropertyInfo)cbPesquisaCampo.SelectedValue, tbPesquisaValor.Text);

                if (ordemPagamentoFiltro != null)
                {
                    CarregarGrid(ordemPagamentoFiltro);
                }
                else
                {
                    MessageBox.Show("Informação inválida para " + cbPesquisaCampo.Text + ". Favor verificar.", "Valor incorreto", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("Campo para o filtro de pesquisa inválido. Favor verificar.", "Opção inválida", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 22
0
        private void VisualizarLancamento()
        {
            OrdemPagamento ordemPagamentoSelecionada = new OrdemPagamento();
            int            linhaGrid = 0;
            int            idOrdemPagamentoSelecionada = 0;

            try
            {
                if (gvOrdensPagamentos.RowCount == 0)
                {
                    return;
                }

                linhaGrid = gvOrdensPagamentos.SelectedCells[0].RowIndex;
                idOrdemPagamentoSelecionada = int.Parse(gvOrdensPagamentos[0, linhaGrid].Value.ToString());

                ordemPagamentoSelecionada = bizOP.PesquisarOrdemPagamento(new OrdemPagamento()
                {
                    idOrdemPagamento = idOrdemPagamentoSelecionada
                })[0];
                ordemPagamentoSelecionada.lstItens = new List <OrdemPagamentoItem>();
                ordemPagamentoSelecionada.lstItens = bizOP.PesquisarOrdemPagamentoItem(new OrdemPagamentoItem()
                {
                    idOrdemPagamento = idOrdemPagamentoSelecionada
                });

                OrdemPagamentoManutencao form = new OrdemPagamentoManutencao(ordemPagamentoSelecionada, true);
                form.ShowDialog();

                btPesquisar_Click(null, null);
            }
            catch (SqlException)
            {
                MessageBox.Show(helper.RetornarMensagemPadraoErroAcessoBD(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MessageBox.Show(helper.RetornarMensagemPadraoErroGenerico(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 23
0
        public void OrdemPagamentoAlterar()
        {
            string Msg = string.Empty;

            OrdemPagamento ordemPagamento = new OrdemPagamento();

            ordemPagamento = bizOrdemPagamento.PesquisarOrdemPagamento(new OrdemPagamento()
            {
                UnitTest = 1
            })[0];
            ordemPagamento.lstItens = bizOrdemPagamento.PesquisarOrdemPagamentoItem(new OrdemPagamentoItem()
            {
                idOrdemPagamento = ordemPagamento.idOrdemPagamento
            });
            ordemPagamento.nomeSolicitante = "Solicitante Alterado";
            ordemPagamento.Status          = "Teste Status";
            ordemPagamento.UnitTest        = 1;

            Msg = bizOrdemPagamento.AlterarOrdemPagamento(ordemPagamento);

            Assert.AreEqual(string.Empty, Msg);
        }
Exemplo n.º 24
0
 public ActionResult PreCadastro(PreCadastroAdesaoVM modelo)
 {
     Log.Info("[POST] Adesao/PreCadastro");
     Log.Warn("[POST] Adesao/PreCadastro");
     Log.Error("[POST] Adesao/PreCadastro");
     if (ModelState.IsValid)
     {
         try
         {
             OrdemPagamento pagamento = Mapper.Map <OrdemPagamento>(modelo);
             return(Redirect(_adesao.CriarNovaAdesao(pagamento)));
         }
         catch (AutoMapperMappingException ex)
         {
             Log.Error(ex);
             //ModelState.AddModelError("Erro ao tentar criar seu plano. Tente novamente mais tarde.", ex.Message);
             //ModelState.AddModelError("Mensagem", "Erro ao tentar criar seu plano. Tente novamente mais tarde.");
             bool envioEmail = _metodosGerais.EnviarEmail("*****@*****.**", "AutoMapperMappingException WFL", string.Format("{0}<br/>{1}", ex.Message, ex));
             ModelState.AddModelError("Mensagem", ex);
         }
         //catch (ServiceWebForLinkException ex)
         //{
         //    Log.Error(ex);
         //    //ModelState.AddModelError("Erro ao tentar criar seu plano. Tente novamente mais tarde.", ex.Message);
         //    //ModelState.AddModelError("Mensagem", "Erro ao tentar criar seu plano. Tente novamente mais tarde.");
         //    bool envioEmail = _metodosGerais.EnviarEmail("*****@*****.**", "WFLBusinessException WFL", string.Format("{0}<br/>{1}", ex.Message, ex));
         //    ModelState.AddModelError("Mensagem", ex);
         //}
         catch (Exception ex)
         {
             Log.Error(ex);
             //ModelState.AddModelError("Mensagem", "Erro ao tentar criar seu plano. Tente novamente mais tarde.");
             bool envioEmail = _metodosGerais.EnviarEmail("*****@*****.**", "Exception WFL", string.Format("{0}<br/>{1}", ex.Message, ex));
             ModelState.AddModelError("Mensagem", ex);
         }
     }
     Log.Error("[POST] Adesao/PreCadastro = !ModelState.IsValid");
     return(View(modelo));
 }
Exemplo n.º 25
0
        public List <OrdemPagamento> PesquisarOrdemPagamento(OrdemPagamento ordemPagamento)
        {
            DataAccess dao = new DataAccess();
            Dictionary <string, string> lstParametros       = new Dictionary <string, string>();
            List <OrdemPagamento>       lstOrdensPagamentos = new List <OrdemPagamento>();
            dynamic lst = new List <OrdemPagamento>();

            try
            {
                lstParametros = this.MontarParametrosPesquisarOrdemPagamento(ordemPagamento);

                using (DataSet ds = dao.Pesquisar("SP_ORDEMPAGAMENTO_CONSULTAR", lstParametros))
                {
                    lst = from f in ds.Tables[0].AsEnumerable <OrdemPagamento>()
                          select f;
                }

                lstOrdensPagamentos.AddRange(lst);
            }
            catch (Exception ex)
            {
                string parametrosSQL = string.Empty;
                parametrosSQL = helper.ConcatenarParametrosSQL(lstParametros);

                LogErro log = new LogErro()
                {
                    procedureSQL  = "SP_ORDEMPAGAMENTO_CONSULTAR",
                    parametrosSQL = parametrosSQL,
                    mensagemErro  = ex.ToString()
                };

                bizLogErro.IncluirLogErro(log);

                throw ex;
            }

            return(lstOrdensPagamentos);
        }
Exemplo n.º 26
0
 /// <summary>
 /// Ao criar uma nova adesão será criado uma string de criação de adesão junto ao PagSeguro
 /// </summary>
 public string CriarNovaAdesao(OrdemPagamento usuario)
 {
     try
     {
         int idSolicitacao = 1;
         usuario.Referencia = string.Format("REFPLANO0{0}{1}", usuario.TipoConta, idSolicitacao.ToString());
         Pagamento pagamento = new Pagamento(usuario);
         try
         {
             pagamento.EfetuarPagamento((TipoPlano)usuario.TipoConta);
             //throw new Exception();
         }
         catch (Exception ex)
         {
             throw new ServiceWebForLinkException("Erro ao tentar criar url", ex);
         }
         return(pagamento.UrlRetorno);
     }
     catch (Exception ex)
     {
         throw new ServiceWebForLinkException("Erro ao tentar processar pagamento", ex);
     }
 }
Exemplo n.º 27
0
        private void btGravar_Click(object sender, EventArgs e)
        {
            string msgRetorno      = string.Empty;
            string acaoSelecionada = string.Empty;
            int    idOP            = 0;

            this.Cursor = Cursors.WaitCursor;

            try
            {
                this.PopularEntidade();

                if (opSelecionada.idOrdemPagamento == 0)
                {
                    msgRetorno      = bizOP.IncluirOrdemPagamento(opSelecionada, origemConsultaOP, out idOP);
                    acaoSelecionada = "Inclusão";
                    opSelecionada.idOrdemPagamento = idOP;
                }
                else
                {
                    msgRetorno      = bizOP.AlterarOrdemPagamento(opSelecionada);
                    acaoSelecionada = "Alteração";
                }

                if (msgRetorno == string.Empty)
                {
                    if (MessageBox.Show(acaoSelecionada + " efetuada com sucesso. Deseja emitir esta Ordem de Pagamento agora?", "Sucesso", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                    {
                        this.EmitirOP();
                    }

                    opSelecionada = bizOP.PesquisarOrdemPagamento(new OrdemPagamento()
                    {
                        idOrdemPagamento = opSelecionada.idOrdemPagamento
                    })[0];
                    opSelecionada.lstItens = new List <OrdemPagamentoItem>();
                    opSelecionada.lstItens = bizOP.PesquisarOrdemPagamentoItem(new OrdemPagamentoItem()
                    {
                        idOrdemPagamento = opSelecionada.idOrdemPagamento
                    });

                    tbNumeroOP.Text = opSelecionada.numeroOP;
                    this.CarregarItens();
                    lbStatus.Text = opSelecionada.Status;
                    this.tabControl1.SelectedIndex = 0;
                }
                else
                {
                    MessageBox.Show("Atenção: " + msgRetorno, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (SqlException)
            {
                MessageBox.Show(helper.RetornarMensagemPadraoErroAcessoBD(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MessageBox.Show(helper.RetornarMensagemPadraoErroGenerico(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.Cursor = Cursors.Default;
        }
Exemplo n.º 28
0
        private void btGerarOP_Click(object sender, EventArgs e)
        {
            BIZOrdemPagamento bizOP           = new BIZOrdemPagamento();
            OrdemPagamento    ordemPagamento  = new OrdemPagamento();
            string            msgRetorno      = string.Empty;
            DateTime          dataVecimentoOP = new DateTime();
            int idOPSelecionada = 0;
            int idFornecedor    = 0;

            try
            {
                msgRetorno = this.ValidarGeracaoOP(out idFornecedor);

                if (msgRetorno == string.Empty)
                {
                    using (AbastecimentoVencimentoOP formVencimentoOP = new AbastecimentoVencimentoOP())
                    {
                        DialogResult dr = formVencimentoOP.ShowDialog();
                        if (dr == DialogResult.OK)
                        {
                            dataVecimentoOP = formVencimentoOP.tbData.Value;
                            if (formVencimentoOP.chkAdicionarOP.Checked)
                            {
                                idOPSelecionada = int.Parse(formVencimentoOP.cbOPAbastecimento.SelectedValue.ToString());
                            }
                        }
                        else
                        {
                            return;
                        }
                    }

                    if (idOPSelecionada == 0)
                    {
                        ordemPagamento.idOrdemPagamento = 0;
                        ordemPagamento.idEmpresa        = 0;
                        ordemPagamento.idFavorecido     = idFornecedor;
                        ordemPagamento.idObraEtapa      = 0;
                        ordemPagamento.idSolicitante    = UsuarioLogado.idUsuario;
                        ordemPagamento.nomeSolicitante  = UsuarioLogado.Nome;
                        ordemPagamento.dataSolicitacao  = DateTime.Now;
                        ordemPagamento.Autorizado       = string.Empty;
                        ordemPagamento.Observacao       = string.Empty;
                        ordemPagamento.lstItens         = new List <OrdemPagamentoItem>();
                        ordemPagamento.lstItens.AddRange(GerarListadeItens(dataVecimentoOP));
                    }
                    else
                    {
                        ordemPagamento = bizOP.PesquisarOrdemPagamento(new OrdemPagamento()
                        {
                            idOrdemPagamento = idOPSelecionada
                        })[0];
                        ordemPagamento.lstItens = bizOP.PesquisarOrdemPagamentoItem(new OrdemPagamentoItem()
                        {
                            idOrdemPagamento = idOPSelecionada
                        });
                        ordemPagamento.lstItens.AddRange(GerarListadeItens(dataVecimentoOP));
                    }

                    OrdemPagamentoManutencao form = new OrdemPagamentoManutencao(ordemPagamento, false);
                    form.ShowDialog();

                    this.CarregarGrid(new Abastecimento());
                }
                else
                {
                    MessageBox.Show("Atenção" + msgRetorno, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (SqlException)
            {
                MessageBox.Show(helper.RetornarMensagemPadraoErroAcessoBD(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MessageBox.Show(helper.RetornarMensagemPadraoErroGenerico(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 29
0
 public virtual DataTable GerarOrdemPagamento(OrdemPagamento opSelecionada, out DataTable dtObras)
 {
     dtObras = new DataTable();
     return(new DataTable());
 }
Exemplo n.º 30
0
 public virtual void Excluir(OrdemPagamento ordemPagamento)
 {
 }