Example #1
0
        private void CarregarComboOP()
        {
            List <OrdemPagamento> lstOP = new List <OrdemPagamento>();
            BIZOrdemPagamento     bizOP = new BIZOrdemPagamento();

            this.Cursor = Cursors.WaitCursor;

            try
            {
                lstOP.Add(new OrdemPagamento()
                {
                    idOrdemPagamento = 0, numeroOP = "--Selecione--"
                });
                lstOP.AddRange(bizOP.PesquisarOPAbastecimento().OrderBy(x => x.idOrdemPagamento));

                cbOPAbastecimento.DataSource    = lstOP;
                cbOPAbastecimento.DisplayMember = "numeroOP";
                cbOPAbastecimento.ValueMember   = "idOrdemPagamento";
            }
            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;
        }
Example #2
0
        private void btContaRemover_Click(object sender, EventArgs e)
        {
            BIZOrdemPagamento bizOP = new BIZOrdemPagamento();
            int linhaGrid           = 0;
            int idConta             = 0;

            if (gvContasBancarias.RowCount == 0)
            {
                return;
            }

            lbIdContaBancaria.Text = string.Empty;

            linhaGrid = gvContasBancarias.SelectedCells[0].RowIndex;

            idConta = int.Parse(gvContasBancarias[0, linhaGrid].Value.ToString());

            // Verificar se a conta bancária está sendo utilizada em alguma OP
            if (idConta != 0 && bizOP.PesquisarOrdemPagamento(new OrdemPagamento()
            {
                idContaBancaria = idConta
            }).Count > 0)
            {
                MessageBox.Show("Esta Conta Bancária está sendo utilizada em alguma Ordem de Pagamento", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            FornecedorContaBancaria itemSelecionado = new FornecedorContaBancaria()
            {
                Banco     = gvContasBancarias[1, linhaGrid].Value.ToString(),
                Agencia   = gvContasBancarias[2, linhaGrid].Value.ToString(),
                TipoConta = gvContasBancarias[3, linhaGrid].Value.ToString(),
                Conta     = gvContasBancarias[4, linhaGrid].Value.ToString(),
            };

            fornecedorSelecionado.lstContasBancarias.Where
                (item =>
                item.Banco == itemSelecionado.Banco &&
                item.Agencia == itemSelecionado.Agencia &&
                item.TipoConta == itemSelecionado.TipoConta &&
                item.Conta == itemSelecionado.Conta).ToList()[0].Excluir = true;

            tbBanco.Text     = string.Empty;
            tbAgencia.Text   = string.Empty;
            cbTipoConta.Text = string.Empty;
            tbConta.Text     = string.Empty;

            this.CarregarContasBancarias();
        }
Example #3
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);
            }
        }