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; }
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); }
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(); }
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; }
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); } }