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